-
Notifications
You must be signed in to change notification settings - Fork 475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Ankuoo NEO devices #413
Comments
Hi @tottka! Thanks for the contribution! I want to add this code to the library, but first I need to understand something: energy = round(float(payload[0x04]/100.0 + payload[0x05])/4.1, 2) Why |
Hey Felipe thanks for the reply, This week, I updated to HA 0.117.3 & python 3.8.6 and noticed the formula is wrong. Famous last words, it was working when I posted this request. I'm gonna look into it today to see if I can figure out what changed Wish I could take credit for the code but originally I found it here #200 I'll let you know when I get it working again. Thanks |
Hi @felipediel, sometimes I wonder what I was thinking. I tested this morning using a 60 watt light bulb and it worked perfectly but I moved my NEO Pro switch to a water kettle and it was totally wrong. Went back and looked at the original code and copied that in as coded from post #200 and bingo! Worked perfectly, of course! Here's the formula that should be used. Let me know when I can test it for you. |
Thanks for the response. energy = int((payload[0x06] + payload[0x05] / 100) * 100) + payload[0x04] / 100 How does it work for you? (I don't have the device to test) |
Works Perfectly, thank you so much. |
Thank you! |
I've been using the Ankuoo NEO wall switches & plugs in Home Assistant for a couple years and they have worked well. Thank you for your efforts. Recently I wanted to use an Ankuoo NEO Pro plug which monitors electricity usage and found that the current_power_w attribute isn't returned to Home Assistant for these devices. Funny because the original NEO's have the attribute returned but aren't capable of doing the usage. The attribute is always 0 which I just ignore.
After looking thru the code I realized the the NEO's aren't defined in your devtype table and fall thru to the exception logic to work. I have solved the usage calculation for the NEO Pro and would like to understand if it's possible to include the code in the master broadlink. My experience with github has been limited to cloning so not sure how to move forward or if you would consider this change.
Here's what I have working in my environment:
The original NEO's are 0x2717 and the NEO Pro is a 0x2716.
Here's the code needed to calculate the enery usage (change in SP2)
def get_energy(self):
if self.devtype == 10006:
packet = bytearray(16)
packet[0] = 4
response = self.send_packet(0x6a, packet)
err = response[0x22] | (response[0x23] << 8)
if err == 0:
payload = self.decrypt(bytes(response[0x38:]))
energy = round(float(payload[0x04]/100.0 + payload[0x05])/4.1, 2)
return energy
else:
packet = bytearray([8, 0, 254, 1, 5, 1, 0, 0, 0, 45])
response = self.send_packet(0x6a, packet)
check_error(response[0x22:0x24])
payload = self.decrypt(bytes(response[0x38:]))
if isinstance(payload[0x7], int):
energy = int(hex(payload[0x07] * 256 + payload[0x06])[2:]) + int(hex(payload[0x05])[2:]) / 100.0
else:
energy = int(hex(ord(payload[0x07]) * 256 + ord(payload[0x06]))[2:]) + int(
hex(ord(payload[0x05]))[2:]) / 100.0
return energy
The text was updated successfully, but these errors were encountered: