def __init__(self, tesla_device, controller, sensor_type): """Initialisation of binary sensor.""" super().__init__(tesla_device, controller) self._name = self.tesla_device.name self._state = False self.entity_id = ENTITY_ID_FORMAT.format(self.tesla_id) self._sensor_type = sensor_type
def __init__(self, connection, config, car_vid): """Initialize sensor with car connection.""" self._conn = connection self._name = config.name self._attr = config.attr self._type = config.device_class self._is_on = None self._car_vid = car_vid self.entity_id = ENTITY_ID_FORMAT.format('{}_{}_{}'.format( MYCHEVY_DOMAIN, slugify(self._car.name), slugify(self._name)))
def __init__(self, client, heater) -> None: """Initialize the binary sensor.""" super().__init__() self._unique_id = f"{heater.serial_no}_failed" self.entity_id = ENTITY_ID_FORMAT.format(f"{DOMAIN}_failed") self._name = "Boiler Fault" self._client = client self._heater = heater
def __init__(self, connection, config): """Initialize sensor with car connection.""" self._conn = connection self._name = config.name self._attr = config.attr self._type = config.device_class self._is_on = None self.entity_id = ENTITY_ID_FORMAT.format( '{}_{}'.format(MYCHEVY_DOMAIN, slugify(self._name)))
def __init__(self, fritzbox_tools): self.fritzbox_tools = fritzbox_tools self.entity_id = ENTITY_ID_FORMAT.format( f"fritzbox_{self.fritzbox_tools.fritzbox_model}_connectivity") self._is_on = True # We assume the fritzbox to be online initially self._is_available = ( True # set to False if an error happend during toggling the switch ) self._attributes = defaultdict(str) super().__init__()
def __init__(self, fibaro_device: Any) -> None: """Initialize the binary_sensor.""" super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id) stype = None if fibaro_device.type in SENSOR_TYPES: stype = fibaro_device.type elif fibaro_device.baseType in SENSOR_TYPES: stype = fibaro_device.baseType if stype: self._attr_device_class = SENSOR_TYPES[stype][2] self._attr_icon = SENSOR_TYPES[stype][1]
def __init__(self, uplink, system_id, parameter_id, name=None, object_id=None, data=None): super().__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 add_new_device(sensor): name, device_class, _, _ = get_sensor_details(sensor) _LOGGER.debug("adding binary sensor %s with id %s", name, sensor["id"]) kubemotionsensor = KubeMotionDevice( hass=hass, name=name, state_topic="/sensor/" + sensor["id"] + "/" + sensor["data_type"], device_class=device_class, qos=0, force_update=False, timeout=DEFAULT_TIMEOUT, unique_id=ENTITY_ID_FORMAT.format(sensor["id"])) # Add device entity async_add_devices([kubemotionsensor])
def __init__(self, dev, idx, val, param): super().__init__(dev, idx, val, param) self.entity_id = ENTITY_ID_FORMAT.format( (dev['devtype'] + "_" + dev['me'] + "_" + idx).lower()) devtype = dev['devtype'] if devtype in GUARD_SENSOR: self._device_class = "door" elif devtype in MOTION_SENSOR: self._device_class = "motion" else: self._device_class = "smoke" if val['val'] == 1: self._state = True else: self._state = False
def __init__(self, fibaro_device, controller): """Initialize the binary_sensor.""" self._state = None super().__init__(fibaro_device, controller) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id) stype = None if fibaro_device.type in SENSOR_TYPES: stype = fibaro_device.type elif fibaro_device.baseType in SENSOR_TYPES: stype = fibaro_device.baseType if stype: self._device_class = SENSOR_TYPES[stype][2] self._icon = SENSOR_TYPES[stype][1] else: self._device_class = None self._icon = None
def __init__(self, fibaro_device, controller): """Initialize the binary_sensor.""" self._state = None super().__init__(fibaro_device, controller) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id) stype = None if fibaro_device.type in SENSOR_TYPES: stype = fibaro_device.type elif fibaro_device.baseType in SENSOR_TYPES: stype = fibaro_device.baseType if stype: self._device_class = SENSOR_TYPES[stype][2] self._icon = SENSOR_TYPES[stype][1] else: self._device_class = None self._icon = None
def __init__(self, device, attribute): """Initialize the sensor.""" self._device = device self._attribute = attribute self._device_class = None name = attribute.get('name') entity_id = 'zigate_{}_{}'.format(device.addr, name) self.entity_id = ENTITY_ID_FORMAT.format(entity_id) typ = self._device.get_value('type', '').lower() if name == 'presence': self._device_class = 'motion' elif 'magnet' in typ: self._device_class = 'door' elif 'smok' in typ: self._device_class = 'smoke' elif 'zone_status' in name: self._device_class = 'safety'
def __init__(self, fibaro_device): """Initialize the binary_sensor.""" self._state = None super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id) stype = None devconf = fibaro_device.device_config if fibaro_device.type in SENSOR_TYPES: stype = fibaro_device.type elif fibaro_device.baseType in SENSOR_TYPES: stype = fibaro_device.baseType if stype: self._device_class = SENSOR_TYPES[stype][2] self._icon = SENSOR_TYPES[stype][1] else: self._device_class = None self._icon = None # device_config overrides: self._device_class = devconf.get(CONF_DEVICE_CLASS, self._device_class) self._icon = devconf.get(CONF_ICON, self._icon)
def __init__(self, fibaro_device): """Initialize the binary_sensor.""" self._state = None super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id) stype = None devconf = fibaro_device.device_config if fibaro_device.type in SENSOR_TYPES: stype = fibaro_device.type elif fibaro_device.baseType in SENSOR_TYPES: stype = fibaro_device.baseType if stype: self._device_class = SENSOR_TYPES[stype][2] self._icon = SENSOR_TYPES[stype][1] else: self._device_class = None self._icon = None # device_config overrides: self._device_class = devconf.get(CONF_DEVICE_CLASS, self._device_class) self._icon = devconf.get(CONF_ICON, self._icon)
async def add_new_device(sensor): name, device_class, _, _ = get_sensor_details(sensor) _LOGGER.debug("adding binary sensor %s with id %s", name, sensor["id"]) mqttsensorconfig = {} mqttsensorconfig["platform"] = "mqtt" mqttsensorconfig["name"] = name mqttsensorconfig["state_topic"] = "/sensor/" + sensor[ "id"] + "/" + sensor["data_type"] if device_class: mqttsensorconfig["device_class"] = device_class if device_class and (device_class == "problem"): mqttsensorconfig["value_template"] = """ {% if (value.split(",")[1]|int) > 0 %} ON {% else %} OFF {% endif %}""" else: mqttsensorconfig["off_delay"] = DEFAULT_TIMEOUT mqttsensorconfig["value_template"] = """ {% if value %} ON {% else %} OFF {% endif %}""" mqttsensorconfig["unique_id"] = ENTITY_ID_FORMAT.format(sensor["id"]) mqttsensorconfig["qos"] = "0" mqttsensorconfig["force_update"] = "false" config = MQTT_BINARY_SENSOR_PLATFORM_SCHEMA(mqttsensorconfig) # Add device entity async_add_devices([MqttBinarySensor(config, None, None)])
def __init__(self, hass, device, attribute): """Initialize the sensor.""" self._device = device self._attribute = attribute self._device_class = None if self._is_zone_status(): self._is_on = attribute.get('value', {}).get('alarm1', False) else: self._is_on = attribute.get('value', False) name = attribute.get('name') ieee = device.ieee or device.addr # compatibility entity_id = 'zigate_{}_{}'.format(ieee, name) self.entity_id = ENTITY_ID_FORMAT.format(entity_id) typ = self._device.get_value('type', '').lower() if name == 'presence': self._device_class = 'motion' elif 'magnet' in typ: self._device_class = 'door' elif 'smok' in typ: self._device_class = 'smoke' elif 'zone_status' in name: self._device_class = 'safety' hass.bus.listen('zigate.attribute_updated', self._handle_event)
def __init__(self, tesla_device, controller, sensor_type): """Initialise of a Tesla binary sensor.""" super().__init__(tesla_device, controller) self._state = False self.entity_id = ENTITY_ID_FORMAT.format(self.tesla_id) self._sensor_type = sensor_type
def __init__(self, hubitat_device): self._state = False super().__init__(hubitat_device) self.entity_id = ENTITY_ID_FORMAT.format(self.entity_id)
def __init__(self, vera_device: veraApi.VeraBinarySensor, controller_data: ControllerData): """Initialize the binary_sensor.""" self._state = False VeraDevice.__init__(self, vera_device, controller_data) self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
def __init__(self, vera_device, controller): """Initialize the binary_sensor.""" self._state = False VeraDevice.__init__(self, vera_device, controller) self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
def __init__(self, vera_device, controller): """Initialize the binary_sensor.""" self._state = False VeraDevice.__init__(self, vera_device, controller) self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)