Esempio n. 1
0
 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)
Esempio n. 2
0
 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}")
Esempio n. 3
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 = b64decode(command_on) if command_on else None
     self._command_off = b64decode(command_off) if command_off else None
     self._device = device
Esempio n. 4
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 = b64decode(command_on) if command_on else None
     self._command_off = b64decode(command_off) if command_off else None
     self._device = device
Esempio n. 5
0
 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
     self._available = False
 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)
Esempio n. 7
0
 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
Esempio n. 8
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._is_available = False
Esempio n. 9
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 = 1
     self._command_off = 0
     self._device = device
     self._load_power = None
Esempio n. 10
0
 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, 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
Esempio n. 12
0
 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 = {}
Esempio n. 13
0
 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
Esempio n. 14
0
 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
Esempio n. 15
0
    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
Esempio n. 16
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()
Esempio n. 17
0
 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__
Esempio n. 18
0
 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__()
Esempio n. 19
0
 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)
Esempio n. 20
0
 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)
Esempio n. 21
0
    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__()
Esempio n. 22
0
 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
Esempio n. 23
0
    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)
Esempio n. 24
0
 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))
Esempio n. 25
0
 def __init__(self, hass: HomeAssistant, client, visonic_device):
     """Initialise a Visonic X10 Device."""
     #_LOGGER.info("Creating X10 Switch {0}".format(visonic_device.name))
     self.client = client
     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)
Esempio n. 26
0
    def __init__(self, feature_type: str, speaker: SonosSpeaker) -> None:
        """Initialize the switch."""
        super().__init__(speaker)
        self.feature_type = feature_type
        self.entity_id = ENTITY_ID_FORMAT.format(
            f"sonos_{speaker.zone_name}_{FRIENDLY_NAMES[feature_type]}")
        self.needs_coordinator = feature_type in COORDINATOR_FEATURES
        self._attr_entity_category = EntityCategory.CONFIG
        self._attr_name = f"{speaker.zone_name} {FRIENDLY_NAMES[feature_type]}"
        self._attr_unique_id = f"{speaker.soco.uid}-{feature_type}"
        self._attr_icon = FEATURE_ICONS.get(feature_type)

        if feature_type in POLL_REQUIRED:
            self._attr_entity_registry_enabled_default = False
            self._attr_should_poll = True
Esempio n. 27
0
 def __init__(self, hass, homee_node, cube, idx=0, state_attr=None):
     """Initialize the switch."""
     HomeeDevice.__init__(self, hass, homee_node, cube)
     if state_attr is not None:
         self._state_attr = state_attr
         # make sure OnOff attribute is the selected
         self.homee_id = "{}_{}_{}".format(slugify(self._name),
                                           self._homee_node.id,
                                           state_attr.id)
         self._name = "{} {}".format(self._name, idx + 1)
     else:
         self._state_attr = self.get_attr("OnOff")
     self.entity_id = ENTITY_ID_FORMAT.format(self.homee_id)
     _LOGGER.info(self.entity_id)
     self._state = False
     self.update_state(self._state_attr)
Esempio n. 28
0
    def __init__(self, fritzbox_tools, dict_of_deflection):
        self.fritzbox_tools = fritzbox_tools
        self.dict_of_deflection = dict_of_deflection
        self.id = int(self.dict_of_deflection["DeflectionId"])
        self._name = f"Deflection {self.id}"
        id = f"fritzbox_{self.fritzbox_tools.fritzbox_model}_deflection_{self.id}"
        self.entity_id = ENTITY_ID_FORMAT.format(id)

        self._attributes = defaultdict(str)
        self._is_available = (
            True  # set to False if an error happend during toggling the switch
        )
        self._is_on = self.dict_of_deflection["Enable"] is True

        self._last_toggle_timestamp = None
        super().__init__()
Esempio n. 29
0
 def __init__(self, hass, object_id, friendly_name, command_on, command_off,
              command_state, value_template, brightness_scale):
     """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
     self._brightness_scale = brightness_scale
     self._supported_features = 0
     self._supported_features |= (topic[CONF_RGB_STATE] is not None
                                  and SUPPORT_RGB_COLOR)
     self._supported_features |= (topic[CONF_BRIGHTNESS_STATE] is not None
                                  and SUPPORT_BRIGHTNESS)
     self._color = WHITE
Esempio n. 30
0
    def __init__(self, alarm):
        _LOGGER.debug("Init Sonos alarms switch.")
        """Init Sonos alarms switch."""

        self._subscriptions: list[SubscriptionBase] = []
        self._poll_timer = None
        self._seen_timer = None

        self._icon = "mdi:alarm"
        self.alarm = alarm
        self.alarm_id = self.alarm._alarm_id
        self._unique_id = "{}-{}".format(SONOS_DOMAIN,self.alarm_id)
        _entity_id = slugify("sonos_alarm_{}".format(self.alarm_id))
        self.entity_id = ENTITY_ID_FORMAT.format(_entity_id)

        speaker_info = self.alarm.zone.get_speaker_info(True)
        self._speaker_name: str = speaker_info["zone_name"]
        self._model: str = speaker_info["model_name"]
        self._sw_version: str = speaker_info["software_version"]
        self._mac_address: str = speaker_info["mac_address"]
        self._unique_player_id: str = self.alarm.zone.uid

        self._get_current_alarm_instance()

        self._is_on = self.alarm.enabled
        self._attributes = {
            ATTR_ID: str(self.alarm_id),
            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),
            ATTR_SCHEDULED_TODAY: self._is_today
        }

        self._name = "Sonos Alarm {} {} {}".format(
            self._speaker_name,
            self.alarm.recurrence.title(),
            str(self.alarm.start_time)[0:5]
        )

        super().__init__()
        _LOGGER.debug("reached end of init")
Esempio n. 31
0
    def __init__(self, fritzbox_tools, port_mapping, idx, connection_type):
        self.fritzbox_tools = fritzbox_tools
        self.connection_type = connection_type
        self.port_mapping: dict = port_mapping  # dict in the format as it comes from fritzconnection. eg: {'NewRemoteHost': '0.0.0.0', 'NewExternalPort': 22, 'NewProtocol': 'TCP', 'NewInternalPort': 22, 'NewInternalClient': '192.168.178.31', 'NewEnabled': True, 'NewPortMappingDescription': 'Beast SSH ', 'NewLeaseDuration': 0}  # noqa

        description = port_mapping["NewPortMappingDescription"]
        self._name = f"Port forward {description}"
        id = f"fritzbox_{self.fritzbox_tools.fritzbox_model}_portforward_{slugify(description)}"
        self.entity_id = ENTITY_ID_FORMAT.format(id)

        self._attributes = defaultdict(str)
        self._is_available = (
            True  # set to False if an error happend during toggling the switch
        )
        self._is_on = self.port_mapping["NewEnabled"] is True

        self._idx = idx  # needed for update routine
        self._last_toggle_timestamp = None
        super().__init__()
    def __init__(self, name, device, haskey=0):
        """Initialize the switch."""
        self._haskey = haskey

        self.entity_id = ENTITY_ID_FORMAT.format(name)
        self._name = name
        self._dev = device
        self._unique_id = 'sp4' + self._dev.mac.hex()
        #set to true if we failed to set state
        self._update_state = 0
        self._safe_state = {
            'pwr': 0,
            'ntlight': 0,
            'indicator': 0,
            'ntlbrightness': 60
        }
        self._state = self._safe_state
        self._is_available = True
        _LOGGER.info("Init done")
Esempio n. 33
0
 def __init__(self, tuya):
     """Init Tuya switch device."""
     super().__init__(tuya)
     self.entity_id = ENTITY_ID_FORMAT.format(tuya.object_id())
Esempio n. 34
0
 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)
Esempio n. 35
0
 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)
Esempio n. 36
0
 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)