Comments (7)
This is very useful when the smart plug is in DHCP environment only.
from pyhs100.
In what format you would like to have it? The sys_info returned by the discovery already contains the mac, but the one from the wire (which is what you probably want?) is not exposed.
from pyhs100.
I have a nice little code piece that can obtain a devices true mac based on IP and without using subprocess to run ping and capture the output either :) funny thing is I just keyed it up about a week ago to send a WOL packet based on IP alone. So this can be done if it is something that the maintainers feel should be added or not. Or if it should be something the user should do themselves. But if you want the code for it drop a line. It's actually very small maybe 8 - 10 lines of code.
from pyhs100.
Thank you @rytilahti for your quick response! I found that both CLI and the static method of 'discover' have the mac data there already. The json format is pretty good. I think no code change/enhancement needed.
from pyhs100.
@kdschlosser
If you can post your code snippets somewhere or here that would be helpful.
Thanks,
Gene
from pyhs100.
here is the code for getting the mac address, it's a little longer then 10 lines but it is still very small
usage: print get_mac_address('192.168.1.1')
import struct
import ctypes
def get_mac_address(ip_address):
arp = ctypes.windll.Iphlpapi.SendARP
addr = ctypes.windll.wsock32.inet_addr(ip_address)
hw_address = ctypes.c_buffer(6)
add_long = ctypes.c_ulong(ctypes.sizeof(hw_address))
arp(addr, 0, ctypes.byref(hw_address), ctypes.byref(add_long))
res = []
for val in struct.unpack('BBBBBB', hw_address):
if val > 15:
replace_str = '0x'
else:
replace_str = 'x'
res.append(hex(val).replace(replace_str, '').upper())
return ':'.join(res)
from pyhs100.
Closing this as MAC is available in the payload.
from pyhs100.
Related Issues (20)
- alias, state, and is_on not functional in SmartPlug for SmartStrip.plug[] devices HOT 2
- HS300 not listed in Discover.discover() HOT 4
- HS200 weird communication error HOT 6
- Security HOT 2
- New protocol HOT 5
- Add support for the KP200 HOT 23
- bug displaying plug status if off.
- New release? HOT 2
- LED config not working HOT 4
- view and update a schedule
- import failure HOT 5
- TP-link KP200 not working proper NOT A DUPLICATE OF ADD SUPPORT FOR THE KP200 HOT 1
- Smart Bulb KL50 HOT 3
- HS220 Set Brightness HOT 1
- Get rid of click-datetime dep HOT 2
- Archive this repository HOT 3
- Failed to run "$ pyhs100" after install HOT 2
- KP105 support HOT 1
- Run
- Kasa discovery HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyhs100.