示例#1
0
def _async_migrate_entity_config(
    hass: HomeAssistant, entry: ConfigEntry, mylink_status: dict
):
    if CONF_ENTITY_CONFIG not in entry.options:
        return

    options = dict(entry.options)

    reversed_target_ids = options[CONF_REVERSED_TARGET_IDS] = {}
    legacy_entry_config = options[CONF_ENTITY_CONFIG]
    default_reverse = options.get(CONF_DEFAULT_REVERSE)

    for cover in mylink_status["result"]:
        legacy_entity_id = ENTITY_ID_FORMAT.format(slugify(cover["name"]))
        target_id = cover["targetID"]

        entity_config = legacy_entry_config.get(legacy_entity_id, {})
        if entity_config.get(CONF_REVERSE, default_reverse):
            reversed_target_ids[target_id] = True

    for legacy_key in (CONF_DEFAULT_REVERSE, CONF_ENTITY_CONFIG):
        if legacy_key in options:
            del options[legacy_key]

    hass.config_entries.async_update_entry(entry, data=entry.data, options=options)
示例#2
0
 def __init__(self, homee_node, homee_attribute, cube):
     """Initialize the cover."""
     self.attribute_id = homee_attribute.id
     self.position = homee_attribute.value
     HomeeDevice.__init__(self, hass, homee_node, cube)
     self.entity_id = ENTITY_ID_FORMAT.format(self.homee_id)
     self.update_state(homee_attribute)
示例#3
0
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
    """Discover and configure Somfy covers."""
    if discovery_info is None:
        return
    somfy_mylink = hass.data[DATA_SOMFY_MYLINK]
    cover_list = []
    try:
        mylink_status = await somfy_mylink.status_info()
    except TimeoutError:
        _LOGGER.error(
            "Unable to connect to the Somfy MyLink device, "
            "please check your settings"
        )
        return
    for cover in mylink_status["result"]:
        entity_id = ENTITY_ID_FORMAT.format(slugify(cover["name"]))
        entity_config = discovery_info.get(entity_id, {})
        default_reverse = discovery_info[CONF_DEFAULT_REVERSE]
        cover_config = {}
        cover_config["target_id"] = cover["targetID"]
        cover_config["name"] = cover["name"]
        cover_config["reverse"] = entity_config.get("reverse", default_reverse)
        cover_list.append(SomfyShade(somfy_mylink, **cover_config))
        _LOGGER.info(
            "Adding Somfy Cover: %s with targetID %s",
            cover_config["name"],
            cover_config["target_id"],
        )
    async_add_entities(cover_list)
示例#4
0
    def __init__(self, fibaro_device):
        """Initialize the Vera device."""
        super().__init__(fibaro_device)
        self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)

        if self._is_open_close_only():
            self._attr_supported_features = (CoverEntityFeature.OPEN
                                             | CoverEntityFeature.CLOSE)
示例#5
0
 def __init__(self, dev, idx, val, param):
     """Init LifeSmart cover device."""
     super().__init__(dev, idx, val, param)
     self._name = dev['name']
     self.entity_id = ENTITY_ID_FORMAT.format(
         (dev['devtype'] + "_" + dev['me']).lower())
     self._pos = val['val']
     self._device_class = "curtain"
示例#6
0
 def __init__(self, device, endpoint):
     """Initialize the cover."""
     self._device = device
     self._endpoint = endpoint
     ieee = device.ieee or device.addr  # compatibility
     entity_id = 'zigate_{}_{}'.format(ieee,
                                       endpoint)
     self.entity_id = ENTITY_ID_FORMAT.format(entity_id)
示例#7
0
 def __init__(self, hass, device, endpoint):
     """Initialize the cover."""
     self._device = device
     self._endpoint = endpoint
     ieee = device.ieee or device.addr  # compatibility
     entity_id = 'zigate_{}_{}'.format(ieee, endpoint)
     self.entity_id = ENTITY_ID_FORMAT.format(entity_id)
     self._pos = 100
     self._available = True
     hass.bus.listen('zigate.attribute_updated', self._handle_event)
示例#8
0
 def __init__(self, hass, args, object_id):
     """Initialize the cover."""
     self.hass = hass
     self.entity_id = ENTITY_ID_FORMAT.format(object_id)
     self._name = args[CONF_FRIENDLY_NAME]
     self._device = args[CONF_DEVICE]
     self._available = True
     self._state = None
     self._command_open = b64decode(args[CONF_COMMAND_OPEN]) if args[CONF_COMMAND_OPEN] else None
     self._command_close = b64decode(args[CONF_COMMAND_CLOSE]) if args[CONF_COMMAND_CLOSE] else None
     self._command_stop = b64decode(args[CONF_COMMAND_STOP]) if args[CONF_COMMAND_STOP] else None
     self._trigger_time = args[CONF_TRIGGER_TIME]
 def __init__(self, device, name, friendly_name, icon, switchid):
     self._device = device
     self.entity_id = ENTITY_ID_FORMAT.format(name)
     self._name = friendly_name
     self._friendly_name = friendly_name
     self._icon = icon
     self._switch_id = switchid
     self._status = self._device.status()
     self._state = self._status['dps'][self._switch_id]
     print(
         'Initialized tuya cover [{}] with switch status [{}] and state [{}]'
         .format(self._name, self._status, self._state))
示例#10
0
    def __init__(self, hass, args, object_id):
        """Initialize the cover."""
        self.hass = hass
        self.entity_id = ENTITY_ID_FORMAT.format(object_id)
        self._name = args[CONF_FRIENDLY_NAME]
        self._available = True
        self._state = None
        self.battery_level = 100
        self._mac = args[CONF_MAC]
        self._device_state_attributes = {}

        self._device = args[CONF_DEVICE]
        self._blindsControlService = self._device.getServiceByUUID("fe50")
        self._blindCharacteristics = self._blindsControlService.getCharacteristics("fe51")[0]
        self.update()
示例#11
0
 def __init__(self, tuya):
     """Init tuya cover device."""
     super().__init__(tuya)
     self.entity_id = ENTITY_ID_FORMAT.format(tuya.object_id())
示例#12
0
 def __init__(self, tuya, platform):
     """Init tuya cover device."""
     super().__init__(tuya, platform)
     self.entity_id = ENTITY_ID_FORMAT.format(tuya.object_id())
     self._was_closing = False
     self._was_opening = False
示例#13
0
 def __init__(self, coordinator, api, door_id):
     """Initialize our door."""
     super().__init__(coordinator)
     self.entity_id = ENTITY_ID_FORMAT.format(door_id)
     self._door_id = door_id
     self._api = api
示例#14
0
 def __init__(self, tahoma_device, controller):
     """Initialize the Tahoma device."""
     super().__init__(tahoma_device, controller)
     self.entity_id = ENTITY_ID_FORMAT.format(self.unique_id)
示例#15
0
 def __init__(self, fibaro_device):
     """Initialize the Vera device."""
     super().__init__(fibaro_device)
     self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
示例#16
0
 def __init__(self, vera_device, controller):
     """Initialize the Vera device."""
     VeraDevice.__init__(self, vera_device, controller)
     self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
示例#17
0
 def __init__(self, tahoma_device, controller):
     """Initialize the Tahoma device."""
     super().__init__(tahoma_device, controller)
     self.entity_id = ENTITY_ID_FORMAT.format(self.unique_id)
示例#18
0
 def __init__(self, vera_device: veraApi.VeraCurtain,
              controller_data: ControllerData) -> None:
     """Initialize the Vera device."""
     VeraDevice.__init__(self, vera_device, controller_data)
     self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
示例#19
0
 def __init__(self, fibaro_device):
     """Initialize the Vera device."""
     super().__init__(fibaro_device)
     self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
示例#20
0
 def __init__(self, tuya):
     """Init tuya cover device."""
     super().__init__(tuya)
     self.entity_id = ENTITY_ID_FORMAT.format(tuya.object_id())
示例#21
0
 def __init__(self, vera_device, controller):
     """Initialize the Vera device."""
     VeraDevice.__init__(self, vera_device, controller)
     self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)