示例#1
0
 def listen_changes(self, controller_id: str) -> None:
     Mqtt.listen_event(
         self.controller,
         self.event_callback,
         topic=controller_id,
         namespace="mqtt",
     )
示例#2
0
 def listen_changes(self, controller_id: str) -> None:
     listens_to = self.kwargs.get("listen_to", LISTENS_TO_HA)
     if listens_to == LISTENS_TO_HA:
         Hass.listen_state(self.controller, self.state_callback,
                           controller_id)
     elif listens_to == LISTENS_TO_MQTT:
         Mqtt.listen_event(
             self.controller,
             self.event_callback,
             topic=f"zigbee2mqtt/{controller_id}",
             namespace="mqtt",
         )
     else:
         raise ValueError(
             "`listen_to` has to be either `ha` or `mqtt`. Default is `ha`."
         )