Closed jdeath closed 2 years ago
@jdeath
I'm not 100% sure that this is going to work as you intend. When you tested it, it actually toggled the light on and off (not just indicating to Home Assistant that it toggled)?
The reason that I ask is that it looks like you may be mixing up what the PropertyIDs enum is doing vice what the object properties are doing. The PropertyIDs enum is just to get the ID code for the JSON field in Wyze's API response for things like on/off. Which looks like you're using correctly in lines 61-63. However, in the two functions lines 112-116... you're just toggling the object's property. This shouldn't cause anything to be transmitted back to Wyze to actually toggle the light. This occurs in the _run_action function of the base service.
Given the commits attached here... it looks like these should be more like:
async def floodlight_on(self, camera: Camera):
await self._run_action(camera, "flood_light", "1")
async def floodlight_off(self, camera: Camera):
await self._run_action(camera, "flood_light", "2")
admittedly, the way you're getting the value from the propertyID may work as well and be cleaner than hardcoding the string. But, I'm pretty sure that you'll need to call "_run_action" vice "_set_property" regardless of how you obtain the propertyID code.
Sorry for the close... touchpad craziness.
Sorry for the close... touchpad craziness.
I 100% confirm this actually works. The app is making the call this way when I toggle the light, as per the mitm I posted in the homeassistant app. I am controlling the light via homeassistant as we speak. I can try the other method if you think it is cleaner, but I thought best to do it like the app. I couldn't tell where you got the strings in the _run_action commands, as the app was not using that api call.
@jdeath no worries. If it works, it works. The string is just the enum item's name. Basically, it's just for the run action function to grab the property id from the enum.
I'm not entirely sure where the hook that would cause the base service to call anything when the properties change off the top of my head. But, if it's working it must somewhere.
I just wanted to verify the device followed and not just the HA entity. Glad to hear it is :)
On/Off tested and worked. Property not tested, but should work. I was wrong 1 is on, 2 is off for P1056