Skip to content

add property_action? #74

@hidaris

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:

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

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