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:
asyncdefproperty_action(self, property_):
""" Additional action when a property change. property_ -- the property that changed """pass
usage example:
classZ2mThing(Thing):
asyncdefproperty_action(self, property_):
ifproperty_.name=="state":
value="ON"ifawaitproperty_.get_value() else"OFF"else:
value=awaitproperty_.get_value()
awaitmqtt.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: