In some scenarios, such as switching lights on and off, we need to do something extra to synchronize the state with the device after updating the properties, but webthing-python doesn't seem to implement this feature, I add this in aiowebthing, property:
async def property_action(self, property_):
"""
Additional action when a property change.
property_ -- the property that changed
"""
pass
usage example:
class Z2mThing(Thing):
async def property_action(self, property_):
if property_.name == "state":
value = "ON" if await property_.get_value() else "OFF"
else:
value = await property_.get_value()
await mqtt.publish(f"zigbee2mqtt/{self.id}/set", {property_.name: value})
In some scenarios, such as switching lights on and off, we need to do something extra to synchronize the state with the device after updating the properties, but webthing-python doesn't seem to implement this feature, I add this in aiowebthing, property:
usage example: