1 """Support for myStrom switches/plugs."""
3 from __future__
import annotations
8 from pymystrom.exceptions
import MyStromConnectionError
16 from .const
import DOMAIN, MANUFACTURER
18 DEFAULT_NAME =
"myStrom Switch"
20 _LOGGER = logging.getLogger(__name__)
24 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
26 """Set up the myStrom entities."""
27 device = hass.data[DOMAIN][entry.entry_id].device
32 """Representation of a myStrom switch/plug."""
34 _attr_has_entity_name =
True
38 """Initialize the myStrom switch/plug."""
42 identifiers={(DOMAIN, self.
plugplug.mac)},
44 manufacturer=MANUFACTURER,
45 sw_version=self.
plugplug.firmware,
47 configuration_url=self.
plugplug.uri,
51 """Turn the switch on."""
54 except MyStromConnectionError:
55 _LOGGER.error(
"No route to myStrom plug")
58 """Turn the switch off."""
61 except MyStromConnectionError:
62 _LOGGER.error(
"No route to myStrom plug")
65 """Get the latest data from the device and update the data."""
70 except MyStromConnectionError:
73 _LOGGER.error(
"No route to myStrom plug")
None async_turn_on(self, **Any kwargs)
def __init__(self, plug, name)
None async_turn_off(self, **Any kwargs)
None turn_off(self, **Any kwargs)
None turn_on(self, **Any kwargs)
str|float get_state(dict[str, float] data, str key)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)