def __init__(self, mac, name) -> None: """Initialize the Switchbot.""" import switchbot self._state = False self._name = name self._mac = mac self._device = switchbot.Switchbot(mac=mac)
def _send_command( mqtt_client: paho.mqtt.client.Client, switchbot_mac_address: str, action: _SwitchbotAction, ) -> None: switchbot_device = switchbot.Switchbot(mac=switchbot_mac_address) if action == _SwitchbotAction.ON: if not switchbot_device.turn_on(): _LOGGER.error("failed to turn on switchbot %s", switchbot_mac_address) else: _LOGGER.info("switchbot %s turned on", switchbot_mac_address) _report_state( mqtt_client=mqtt_client, switchbot_mac_address=switchbot_mac_address, switchbot_state=_SwitchbotState.ON, ) else: assert action == _SwitchbotAction.OFF, action if not switchbot_device.turn_off(): _LOGGER.error("failed to turn off switchbot %s", switchbot_mac_address) else: _LOGGER.info("switchbot %s turned off", switchbot_mac_address) _report_state( mqtt_client=mqtt_client, switchbot_mac_address=switchbot_mac_address, switchbot_state=_SwitchbotState.OFF, )
def __init__(self, mac, name, password) -> None: """Initialize the Switchbot.""" self._state = None self._last_run_success = None self._name = name self._mac = mac self._device = switchbot.Switchbot(mac=mac, password=password)
def __init__(self, mac, name) -> None: """Initialize the Switchbot.""" # pylint: disable=import-error, no-member import switchbot self._state = False self._name = name self._mac = mac self._device = switchbot.Switchbot(mac=mac)
def __init__(self, mac_address: str, retry_count: int, password: typing.Optional[None]) -> None: self._device = switchbot.Switchbot(mac=mac_address, password=password, retry_count=retry_count) super().__init__(mac_address=mac_address, retry_count=retry_count, password=password)