Skip to content

add property_action? #74

Description

@hidaris

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})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions