def __init__(self, hass, name, friendly_name, device): """Initialize the switch.""" self.entity_id = ENTITY_ID_FORMAT.format(slugify(name)) self._name = friendly_name self._state = False self._device = device self.hass = hass
def __init__( self, object_id: str, resource: str, port: int, friendly_name: str, command_on: str, command_off: str, command_state: str | None, value_template: Template | None, timeout: float, ) -> None: """Initialize the switch.""" self.entity_id = ENTITY_ID_FORMAT.format(object_id) self._resource = resource self._port = port self._attr_name = friendly_name self._attr_is_on = False self._command_on = command_on self._command_off = command_off self._command_state = command_state self._value_template = value_template self._timeout = timeout self._attr_should_poll = bool(command_state) self._attr_assumed_state = bool(command_state is None)
def __init__(self, alarm_id: str, speaker: SonosSpeaker) -> None: """Initialize the switch.""" super().__init__(speaker) self._attr_unique_id = f"alarm-{speaker.household_id}:{alarm_id}" self.alarm_id = alarm_id self.household_id = speaker.household_id self.entity_id = ENTITY_ID_FORMAT.format(f"sonos_alarm_{self.alarm_id}")
def __init__( self, hass, object_id, resource, port, friendly_name, command_on, command_off, command_state, value_template, timeout, ): """Initialize the switch.""" self._hass = hass self.entity_id = ENTITY_ID_FORMAT.format(object_id) self._resource = resource self._port = port self._name = friendly_name self._state = False self._command_on = command_on self._command_off = command_off self._command_state = command_state self._value_template = value_template self._timeout = timeout
def __init__(self, hass, object_id, gateway, unit, friendly_name): """Initialize the switch.""" self._hass = hass self.entity_id = ENTITY_ID_FORMAT.format(object_id) self._name = friendly_name self._gateway = gateway self._unit = unit
def __init__( self, hass, object_id, friendly_name, command_on, command_off, command_state, icon_template, value_template, timeout, unique_id, ): """Initialize the switch.""" self._hass = hass self.entity_id = ENTITY_ID_FORMAT.format(object_id) self._name = friendly_name self._state = False self._command_on = command_on self._command_off = command_off self._command_state = command_state self._icon_template = icon_template self._value_template = value_template self._timeout = timeout self._attr_unique_id = unique_id
def __init__(self, soco, alarm): """Init Sonos alarms switch.""" self._icon = "mdi:alarm" self._soco = soco self._id = alarm._alarm_id self._is_available = True speaker_info = self._soco.get_speaker_info(True) self._unique_id = "{}-{}".format(soco.uid, self._id) self._name = "Sonos {} Alarm (id: {})".format( speaker_info["zone_name"], self._id) _entity_id = slugify("sonos_alarm_{}".format(self._id)) self.entity_id = ENTITY_ID_FORMAT.format(_entity_id) self._model = speaker_info["model_name"] self.alarm = None for one_alarm in alarms.get_alarms(self._soco): # pylint: disable=protected-access if one_alarm._alarm_id == self._id: self.alarm = one_alarm self._is_on = self.alarm.enabled self._attributes = { ATTR_TIME: str(self.alarm.start_time), ATTR_VOLUME: self.alarm.volume / 100, ATTR_DURATION: str(self.alarm.duration), ATTR_INCLUDE_LINKED_ZONES: self.alarm.include_linked_zones, ATTR_RECURRENCE: str(self.alarm.recurrence), ATTR_PLAY_MODE: str(self.alarm.play_mode), } super().__init__()
def __init__(self, alarm_id: str, speaker: SonosSpeaker) -> None: """Initialize the switch.""" super().__init__(speaker) self._alarm_id = alarm_id self.entity_id = ENTITY_ID_FORMAT.format( f"sonos_alarm_{self.alarm_id}")
def __init__( self, vera_device: veraApi.VeraSwitch, controller_data: ControllerData ) -> None: """Initialize the Vera device.""" self._state = False VeraDevice.__init__(self, vera_device, controller_data) self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
def __init__(self, hass, meross_device_uuid, meross_device_name, meross_switch_channel, suffix): # attributes self._is_on = False self._meross_switch_channel = meross_switch_channel self._meross_plug = hass.data[DOMAIN].meross_plugs_by_uuid[ meross_device_uuid] # add entity to the meross_plug meross_device = self._meross_plug.device meross_device_online = meross_device.online self._meross_plug.switch_states[meross_switch_channel] = { 'available': meross_device_online, 'is_on': self._is_on, } # naming meross_switch_name = str(meross_switch_channel) meross_switch_id = "{}_{}{}".format(DOMAIN, meross_device_uuid, suffix) meross_entity_id = ENTITY_ID_FORMAT.format(meross_switch_id) _LOGGER.debug(meross_device_name + ' >>> ' + meross_switch_name + ' >>> __init__()') # init MerossEntity super().__init__(hass, meross_device_uuid, meross_device_name, meross_entity_id, meross_switch_name, meross_device_online)
def __init__(self, hass, shelly_cloud_device_id, shelly_cloud_device_name, shelly_cloud_switch_channel, suffix): # attributes self._is_on = hass.data[DOMAIN].get_device_switch_status( shelly_cloud_device_id, shelly_cloud_switch_channel) self._shelly_cloud_switch_channel = shelly_cloud_switch_channel self._shelly_cloud_device_id = shelly_cloud_device_id # naming shelly_cloud_switch_name = str(shelly_cloud_switch_channel) shelly_cloud_switch_id = "{}_{}{}".format(DOMAIN, shelly_cloud_device_id, suffix) shelly_cloud_entity_id = ENTITY_ID_FORMAT.format( shelly_cloud_switch_id) _LOGGER.debug(shelly_cloud_device_name + ' >>> ' + shelly_cloud_switch_name + ' >>> __init__()') # init shelly_cloudEntity shelly_cloud_device_online = hass.data[DOMAIN].get_device_availability( shelly_cloud_device_id) super().__init__(hass, shelly_cloud_device_id, shelly_cloud_device_name, shelly_cloud_entity_id, shelly_cloud_switch_name, shelly_cloud_device_online)
def __init__(self, name, friendly_name, device, command_on, command_off): """Initialize the switch.""" self.entity_id = ENTITY_ID_FORMAT.format(slugify(name)) self._name = friendly_name self._state = False self._command_on = b64decode(command_on) if command_on else None self._command_off = b64decode(command_off) if command_off else None self._device = device
def __init__(self, homee_node, homee_attribute, cube): """Initialize the switch.""" self._state = homee_attribute.value self.attribute_id = homee_attribute.id self._temperature_units = None HomeeDevice.__init__(self, homee_node, homee_attribute, cube) self.entity_id = ENTITY_ID_FORMAT.format(self.homee_id) self.update_state(homee_attribute)
def __init__(self, hass, name, devType): """Initialize the switch.""" self._hass = hass self.entity_id = ENTITY_ID_FORMAT.format(slugify(devType)) self._name = name self._type = devType self._state = False self._attributes = {} hass.bus.listen(CONF_EVENT_ZINGUO_STATE_CHANGE, self._handle_event)
def __init__(self, name, friendly_name, device, command_on, command_off): """Initialize the switch.""" self.entity_id = ENTITY_ID_FORMAT.format(slugify(name)) self._name = friendly_name self._state = False self._command_on = 1 self._command_off = 0 self._device = device self._load_power = None
def __init__(self, container, prefix, cname, alias, name_format): self._loop = asyncio.get_running_loop() self._container = container self._prefix = prefix self._cname = cname self._state = False self._entity_id = ENTITY_ID_FORMAT.format( slugify(self._prefix + "_" + self._cname)) self._name = name_format.format(name=alias)
def __init__(self, dev, idx, val, param): """Initialize the switch.""" super().__init__(dev, idx, val, param) self.entity_id = ENTITY_ID_FORMAT.format( (dev['devtype'] + "_" + dev['me'] + "_" + idx).lower()) if val['val'] == 1: self._state = True else: self._state = False
def __init__(self, name, friendly_name, device, command_on, command_off): """Initialize the switch.""" self.entity_id = ENTITY_ID_FORMAT.format(slugify(name)) self._name = friendly_name self._state = False self._command_on = command_on self._command_off = command_off self._device = device self._is_available = False
def __init__(self, instance, object_id, friendly_name, address, address_type, icon): """Initialize the switch.""" self._name = friendly_name self._address = address self._address_type = address_type self._state = False self._icon = icon self.entity_id = ENTITY_ID_FORMAT.format(object_id) self._instance = instance
def __init__(self, tracker_id, get_token_callback, get_tracker_callback, data): """Set up Georide entity.""" self._tracker_id = tracker_id self._data = data or {} self._get_token_callback = get_token_callback self._get_tracker_callback = get_tracker_callback self._name = data.tracker_name self._is_on = data.is_locked self.entity_id = ENTITY_ID_FORMAT.format("lock") +"." + str(tracker_id) self._state = {}
def __init__(self, tracker_id, get_token_callback, get_tracker_callback, data): """Set up Georide entity.""" self._tracker_id = tracker_id self._data = data or {} self._get_token_callback = get_token_callback self._get_tracker_callback = get_tracker_callback self._name = data.tracker_name self._unit_of_measurement = "m" self.entity_id = ENTITY_ID_FORMAT.format("odometer") + "." + str(tracker_id) self._state = 0
def __init__(self, name, friendly_name, device, command_on, command_off): """Initialize the switch.""" self.entity_id = ENTITY_ID_FORMAT.format(slugify(name)) self._name = friendly_name self._state = False self._command_on = command_on self._command_off = command_off self._device = device self._available = False self._last_update_time = datetime.now() self._update_force = True # force update()
def __init__(self, hass, object_id, friendly_name, command_on, command_off, command_state, value_template): """Initialize the switch.""" self._hass = hass self.entity_id = ENTITY_ID_FORMAT.format(object_id) self._name = friendly_name self._state = False self._command_on = command_on self._command_off = command_off self._command_state = command_state self._value_template = value_template
def __init__(self, name, state, stats, host, port, dm, prefix): _slow_reported = True if prefix == 'None': self.entity_id = ENTITY_ID_FORMAT.format(slugify(name)) else: self.entity_id = ENTITY_ID_FORMAT.format( slugify(prefix + '_' + name)) self._dm = dm self._state = False self._name = name self._stats = stats self._network_stats = None self._status = None self._image = None self._memory_usage = None self._network_rx_total = None self._network_tx_total = None self._host = host self._port = port self._component = COMPONENT_NAME self._componentversion = __version__
def __init__(self, hass, visonic_device, queue): """Initialise a Visonic X10 Device.""" _LOGGER.info("In setup_platform in switch for X10") self.queue = queue self.visonic_device = visonic_device self.x10id = self.visonic_device.id self._name = "Visonic " + self.visonic_device.name # Append device id to prevent name clashes in HA. self.visonic_id = slugify(self._name) # VISONIC_ID_FORMAT.format( slugify(self._name), visonic_device.getDeviceID()) self.entity_id = ENTITY_ID_FORMAT.format(self.visonic_id) self.current_value = self.visonic_device.state self.visonic_device.install_change_handler(self.onChange)
def __init__(self, fritzbox_tools, network_num, network_name): self._fritzbox_tools = fritzbox_tools self._network_num = network_num id = network_name.lower().replace(' ', '_').replace('(', '').replace(')', '') self.entity_id = ENTITY_ID_FORMAT.format(f"fritzbox_{self._fritzbox_tools.fritzbox_model}_{id}") self._name = f"FRITZ!Box {network_name}" self._is_on = None self._last_toggle_timestamp = None self._is_available = ( True # set to False if an error happend during toggling the switch ) super().__init__()
def __init__(self, hass, device, endpoint): """Initialize the ZiGate switch.""" self._device = device self._endpoint = endpoint self._is_on = False a = self._device.get_attribute(endpoint, 6, 0) if a: self._is_on = a.get('value', False) ieee = device.ieee or device.addr # compatibility entity_id = 'zigate_{}_{}'.format(ieee, endpoint) self.entity_id = ENTITY_ID_FORMAT.format(entity_id) hass.bus.listen('zigate.attribute_updated', self._handle_event)
def __init__(self, fritzbox_tools, profile): self.fritzbox_tools = fritzbox_tools self.profile = profile self.profile_switch = self.fritzbox_tools.profile_switch[self.profile] self._name = f"Access profile {self.profile}" id = f"fritzbox_{self.fritzbox_tools.fritzbox_model}_profile_{self.profile}" self.entity_id = ENTITY_ID_FORMAT.format(slugify(id)) self._is_available = True self._is_on = None super().__init__()
def __init__(self, uplink, system_id, parameter_id, name=None, object_id=None, data=None): super(NibeSwitch, self).__init__(uplink, system_id, parameter_id) self._name = name self.parse_data(data) if object_id: # Forced id on discovery self.entity_id = ENTITY_ID_FORMAT.format(object_id)
def __init__(self, name, stats, host, port, username, password, dm, prefix): _slow_reported = True if prefix == 'None': self.entity_id = ENTITY_ID_FORMAT.format(slugify(name)) else: self.entity_id = ENTITY_ID_FORMAT.format( slugify(prefix + '_' + name)) self._dm = dm self._state = False self._name = name self._stats = stats self._network_stats = None self._status = None self._image = None self._memory_usage = None self._network_rx_total = None self._network_tx_total = None self._host = host self._port = port self._username = username self._password = password
def __init__(self, device, name, friendly_name, icon, switchid, attr_current, attr_consumption, attr_voltage): """Initialize the Tuya switch.""" self._device = device self.entity_id = ENTITY_ID_FORMAT.format(name) self._name = friendly_name self._icon = icon self._switch_id = switchid self._attr_current = attr_current self._attr_consumption = attr_consumption self._attr_voltage = attr_voltage self._status = self._device.status() self._state = self._status['dps'][self._switch_id] print('Initialized tuya switch [{}] with switch status [{}] and state [{}]'.format(self._name, self._status, self._state))
def __init__(self, tuya): """Init Tuya switch device.""" super().__init__(tuya) self.entity_id = ENTITY_ID_FORMAT.format(tuya.object_id())
def __init__(self, vera_device, controller): """Initialize the Vera device.""" self._state = False VeraDevice.__init__(self, vera_device, controller) self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
def __init__(self, fibaro_device): """Initialize the Fibaro device.""" self._state = False super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
def __init__(self, tesla_device, controller): """Initialisation of the switch.""" self._state = None super().__init__(tesla_device, controller) self.entity_id = ENTITY_ID_FORMAT.format(self.tesla_id)