1 """Support for Switchmate."""
3 from __future__
import annotations
5 from datetime
import timedelta
8 from switchmate
import Switchmate
9 import voluptuous
as vol
12 PLATFORM_SCHEMA
as SWITCH_PLATFORM_SCHEMA,
21 CONF_FLIP_ON_OFF =
"flip_on_off"
22 DEFAULT_NAME =
"Switchmate"
26 PLATFORM_SCHEMA = SWITCH_PLATFORM_SCHEMA.extend(
28 vol.Required(CONF_MAC): cv.string,
29 vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
30 vol.Optional(CONF_FLIP_ON_OFF, default=
False): cv.boolean,
38 add_entities: AddEntitiesCallback,
39 discovery_info: DiscoveryInfoType |
None =
None,
41 """Perform the setup for Switchmate devices."""
42 name = config.get(CONF_NAME)
43 mac_addr = config[CONF_MAC]
44 flip_on_off = config[CONF_FLIP_ON_OFF]
49 """Representation of a Switchmate."""
51 def __init__(self, mac, name, flip_on_off) -> None:
52 """Initialize the Switchmate."""
56 self.
_device_device = Switchmate(mac=mac, flip_on_off=flip_on_off)
60 """Return a unique, Home Assistant friendly identifier for this entity."""
61 return self.
_mac_mac.replace(
":",
"")
65 """Return True if entity is available."""
66 return self.
_device_device.available
70 """Return the name of the switch."""
71 return self.
_name_name
74 """Synchronize state with switch."""
79 """Return true if it is on."""
80 return self.
_device_device.state
83 """Turn the switch on."""
87 """Turn the switch off."""
None async_turn_on(self, **Any kwargs)
None __init__(self, mac, name, flip_on_off)
None async_turn_off(self, **Any kwargs)
None turn_off(self, **Any kwargs)
None turn_on(self, **Any kwargs)
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
IssData update(pyiss.ISS iss)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)