desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Retrieve the latest details from the host.'
def update(self):
self.data = self.ping() self.available = bool(self.data)
'Return True if the binary sensor is on.'
@property def is_on(self):
val = getattr(self.vehicle, self._attribute) if (self._attribute == 'bulb_failures'): return bool(val) elif (self._attribute in ['doors', 'windows']): return any([val[key] for key in val if ('Open' in key)]) return (val != 'Normal')
'Return the class of this sensor, from DEVICE_CLASSES.'
@property def device_class(self):
return 'safety'
'Initialize the Workday sensor.'
def __init__(self, obj_holidays, workdays, excludes, name):
self._name = name self._obj_holidays = obj_holidays self._workdays = workdays self._excludes = excludes self._state = None
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return the state of the device.'
@property def is_on(self):
return self._state
'Check if given day is in the includes list.'
def is_include(self, day, now):
if (day in self._workdays): return True elif (('holiday' in self._workdays) and (now in self._obj_holidays)): return True return False
'Check if given day is in the excludes list.'
def is_exclude(self, day, now):
if (day in self._excludes): return True elif (('holiday' in self._excludes) and (now in self._obj_holidays)): return True return False
'Get date and look whether it is a holiday.'
@asyncio.coroutine def async_update(self):
self._state = False day = (datetime.datetime.today().isoweekday() - 1) day_of_week = day_to_string(day) if self.is_include(day_of_week, dt_util.now()): self._state = True if self.is_exclude(day_of_week, dt_util.now()): self._state = False
'Initialize the sensor.'
def __init__(self, hass, device_id, friendly_name, target_entity, attribute, device_class, invert):
self._hass = hass self.entity_id = generate_entity_id(ENTITY_ID_FORMAT, device_id, hass=hass) self._name = friendly_name self._target_entity = target_entity self._attribute = attribute self._device_class = device_class self._invert = invert self._state = None self.from_state = None ...
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return true if sensor is on.'
@property def is_on(self):
return self._state
'Return the sensor class of the sensor.'
@property def device_class(self):
return self._device_class
'No polling needed.'
@property def should_poll(self):
return False
'Get the latest data and update the states.'
@asyncio.coroutine def async_update(self):
if ((self.from_state is None) or (self.to_state is None)): return if ((self.from_state.state == STATE_UNKNOWN) or (self.to_state.state == STATE_UNKNOWN)): return try: if self._attribute: from_value = float(self.from_state.attributes.get(self._attribute)) to_va...
'Initialize the binarysensor.'
def __init__(self, hass, plm, address, name):
self._hass = hass self._plm = plm.protocol self._address = address self._name = name self._plm.add_update_callback(self.async_binarysensor_update, {'address': self._address})
'No polling needed.'
@property def should_poll(self):
return False
'Return the the address of the node.'
@property def address(self):
return self._address
'Return the the name of the node.'
@property def name(self):
return self._name
'Return the boolean response if the node is on.'
@property def is_on(self):
sensorstate = self._plm.get_device_attr(self._address, 'sensorstate') _LOGGER.info('Sensor state for %s is %s', self._address, sensorstate) return bool(sensorstate)
'Provide attributes for display on device card.'
@property def device_state_attributes(self):
insteon_plm = get_component('insteon_plm') return insteon_plm.common_attributes(self)
'Return specified attribute for this device.'
def get_attr(self, key):
return self._plm.get_device_attr(self.address, key)
'Receive notification from transport that new data exists.'
@callback def async_binarysensor_update(self, message):
_LOGGER.info('Received update calback from PLM for %s', self._address) self._hass.async_add_job(self.async_update_ha_state())
'Initialize the Command line binary sensor.'
def __init__(self, hass, data, name, device_class, payload_on, payload_off, value_template):
self._hass = hass self.data = data self._name = name self._device_class = device_class self._state = False self._payload_on = payload_on self._payload_off = payload_off self._value_template = value_template
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return true if the binary sensor is on.'
@property def is_on(self):
return self._state
'Return the class of the binary sensor.'
@property def device_class(self):
return self._device_class
'Get the latest data and updates the state.'
def update(self):
self.data.update() value = self.data.value if (self._value_template is not None): value = self._value_template.render_with_possible_json_value(value, False) if (value == self._payload_on): self._state = True elif (value == self._payload_off): self._state = False
'Initialize the binary_sensor.'
def __init__(self, hass, zone_number, zone_name, zone_type, info, controller):
self._zone_type = zone_type self._zone_number = zone_number _LOGGER.debug(('Setting up zone: ' + zone_name)) super().__init__(zone_name, info, controller)
'Register callbacks.'
@asyncio.coroutine def async_added_to_hass(self):
async_dispatcher_connect(self.hass, SIGNAL_ZONE_UPDATE, self._update_callback)
'Return the state attributes.'
@property def device_state_attributes(self):
attr = {} attr[ATTR_LAST_TRIP_TIME] = self._info['last_fault'] return attr
'Return true if sensor is on.'
@property def is_on(self):
return self._info['status']['open']
'Return the class of this sensor, from DEVICE_CLASSES.'
@property def device_class(self):
return self._zone_type
'Update the zone\'s state, if needed.'
@callback def _update_callback(self, zone):
if ((zone is None) or (int(zone) == self._zone_number)): self.hass.async_add_job(self.async_update_ha_state())
'Initialize the modbus coil sensor.'
def __init__(self, device_label):
self._device_label = device_label
'Return the name of the binary sensor.'
@property def name(self):
return hub.get_first("$.doorWindow.doorWindowDevice[?(@.deviceLabel=='%s')].area", self._device_label)
'Return the state of the sensor.'
@property def is_on(self):
return (hub.get_first("$.doorWindow.doorWindowDevice[?(@.deviceLabel=='%s')].state", self._device_label) == 'OPEN')
'Return True if entity is available.'
@property def available(self):
return (hub.get_first("$.doorWindow.doorWindowDevice[?(@.deviceLabel=='%s')]", self._device_label) is not None)
'Update the state of the sensor.'
def update(self):
hub.update_overview()
'Initialize the sensor.'
def __init__(self, name, eight, sensor):
super().__init__(eight) self._sensor = sensor self._mapped_name = NAME_MAP.get(self._sensor, self._sensor) self._name = '{} {}'.format(name, self._mapped_name) self._state = None self._side = self._sensor.split('_')[0] self._userid = self._eight.fetch_userid(self._side) self._usrobj =...
'Return the name of the sensor, if any.'
@property def name(self):
return self._name
'Return true if the binary sensor is on.'
@property def is_on(self):
return self._state
'Retrieve latest state.'
@asyncio.coroutine def async_update(self):
self._state = self._usrobj.bed_presence
'Set up for access to the Netatmo camera events.'
def __init__(self, data, camera_name, module_name, home, timeout, offset, camera_type, sensor):
self._data = data self._camera_name = camera_name self._module_name = module_name self._home = home self._timeout = timeout self._offset = offset if home: self._name = '{} / {}'.format(home, camera_name) else: self._name = camera_name if module_name: sel...
'Return the name of the Netatmo device and this sensor.'
@property def name(self):
return self._name
'Return the unique ID for this sensor.'
@property def unique_id(self):
return self._unique_id
'Return the class of this sensor, from DEVICE_CLASSES.'
@property def device_class(self):
if (self._cameratype == 'NACamera'): return WELCOME_SENSOR_TYPES.get(self._sensor_name) elif (self._cameratype == 'NOC'): return PRESENCE_SENSOR_TYPES.get(self._sensor_name) return TAG_SENSOR_TYPES.get(self._sensor_name)
'Return true if binary sensor is on.'
@property def is_on(self):
return self._state
'Request an update from the Netatmo API.'
def update(self):
self._data.update() self._data.update_event() if (self._cameratype == 'NACamera'): if (self._sensor_name == 'Someone known'): self._state = self._data.camera_data.someoneKnownSeen(self._home, self._camera_name, (self._timeout * 60)) elif (self._sensor_name == 'Someone unkno...
'Initialize the Concord232 binary sensor.'
def __init__(self, hass, client, zone, zone_type):
self._hass = hass self._client = client self._zone = zone self._number = zone['number'] self._zone_type = zone_type
'Return the class of this sensor, from DEVICE_CLASSES.'
@property def device_class(self):
return self._zone_type
'No polling needed.'
@property def should_poll(self):
return True
'Return the name of the binary sensor.'
@property def name(self):
return self._zone['name']
'Return true if the binary sensor is on.'
@property def is_on(self):
return bool((self._zone['state'] == 'Normal'))
'Get updated stats from API.'
def update(self):
last_update = (datetime.datetime.now() - self._client.last_zone_update) _LOGGER.debug('Zone: %s ', self._zone) if (last_update > datetime.timedelta(seconds=1)): self._client.zones = self._client.list_zones() self._client.last_zone_update = datetime.datetime.now() _LOGGER.debug(...
'Initialize the sensor.'
def __init__(self, name, data):
self._name = (('blink_' + name) + '_motion_enabled') self._camera_name = name self.data = data self._state = self.data.cameras[self._camera_name].armed
'Return the name of the blink sensor.'
@property def name(self):
return self._name
'Return the status of the sensor.'
@property def is_on(self):
return self._state
'Update sensor state.'
def update(self):
self.data.refresh() self._state = self.data.cameras[self._camera_name].armed
'Initialize the sensor.'
def __init__(self, data):
self._name = 'blink armed status' self.data = data self._state = self.data.arm
'Return the name of the blink sensor.'
@property def name(self):
return self._name.replace(' ', '_')
'Return the status of the sensor.'
@property def is_on(self):
return self._state
'Update sensor state.'
def update(self):
self.data.refresh() self._state = self.data.arm
'Initialize sensor.'
def __init__(self, address, channel, name, invert_logic, device_class):
self._address = address self._channel = channel self._name = (name or DEVICE_DEFAULT_NAME) self._invert_logic = invert_logic self._device_class = device_class self._state = self.I2C_HATS_MANAGER.read_di(self._address, self._channel) def online_callback(): 'Callback fired when ...
'Return the class of this sensor.'
@property def device_class(self):
return self._device_class
'Return the name of this sensor.'
@property def name(self):
return self._name
'Polling not needed for this sensor.'
@property def should_poll(self):
return False
'Return the state of this sensor.'
@property def is_on(self):
return (self._state != self._invert_logic)
'Initialize the Threshold sensor.'
def __init__(self, hass, entity_id, name, threshold, limit_type, device_class):
self._hass = hass self._entity_id = entity_id self.is_upper = (limit_type == 'upper') self._name = name self._threshold = threshold self._device_class = device_class self._deviation = False self.sensor_value = 0 @callback def async_threshold_sensor_state_listener(entity, old_stat...
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return true if sensor is on.'
@property def is_on(self):
return self._deviation
'No polling needed.'
@property def should_poll(self):
return False
'Return the sensor class of the sensor.'
@property def device_class(self):
return self._device_class
'Return the state attributes of the sensor.'
@property def device_state_attributes(self):
return {ATTR_ENTITY_ID: self._entity_id, ATTR_SENSOR_VALUE: self.sensor_value, ATTR_THRESHOLD: self._threshold, ATTR_TYPE: (CONF_UPPER if self.is_upper else CONF_LOWER)}
'Get the latest data and updates the states.'
@asyncio.coroutine def async_update(self):
if self.is_upper: self._deviation = bool((self.sensor_value > self._threshold)) else: self._deviation = bool((self.sensor_value < self._threshold))
'Initialize the sensor.'
def __init__(self, hass, name, variable, payload, on_value, off_value):
self._state = False self._hass = hass self._name = name self._variable = variable self._payload = payload self._on_value = on_value self._off_value = off_value hass.bus.listen(pilight.EVENT, self._handle_code)
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return True if the binary sensor is on.'
@property def is_on(self):
return self._state
'Handle received code by the pilight-daemon. If the code matches the defined playload of this sensor the sensor state is changed accordingly.'
def _handle_code(self, call):
payload_ok = True for key in self._payload: if (key not in call.data): payload_ok = False continue if (self._payload[key] != call.data[key]): payload_ok = False if payload_ok: if (self._variable not in call.data): return value =...
'Initialize the sensor.'
def __init__(self, hass, name, variable, payload, on_value, off_value, rst_dly_sec=30):
self._state = False self._hass = hass self._name = name self._variable = variable self._payload = payload self._on_value = on_value self._off_value = off_value self._reset_delay_sec = rst_dly_sec self._delay_after = None self._hass = hass hass.bus.listen(pilight.EVENT, self._...
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return True if the binary sensor is on.'
@property def is_on(self):
return self._state
'Handle received code by the pilight-daemon. If the code matches the defined playload of this sensor the sensor state is changed accordingly.'
def _handle_code(self, call):
payload_ok = True for key in self._payload: if (key not in call.data): payload_ok = False continue if (self._payload[key] != call.data[key]): payload_ok = False if payload_ok: if (self._variable not in call.data): return value =...
'Initialize the Wink binary sensor.'
def __init__(self, wink, hass):
super().__init__(wink, hass) if hasattr(self.wink, 'unit'): self._unit_of_measurement = self.wink.unit() else: self._unit_of_measurement = None if hasattr(self.wink, 'capability'): self.capability = self.wink.capability() else: self.capability = None
'Callback when entity is added to hass.'
@asyncio.coroutine def async_added_to_hass(self):
self.hass.data[DOMAIN]['entities']['binary_sensor'].append(self)
'Return true if the binary sensor is on.'
@property def is_on(self):
return self.wink.state()
'Return the class of this sensor, from DEVICE_CLASSES.'
@property def device_class(self):
return SENSOR_TYPES.get(self.capability)
'Return the state attributes.'
@property def device_state_attributes(self):
return {'test_activated': self.wink.test_activated()}
'Return the state attributes.'
@property def device_state_attributes(self):
return {'update needed': self.wink.update_needed(), 'firmware version': self.wink.firmware_version()}
'Return the state attributes.'
@property def device_state_attributes(self):
return {'button_on_pressed': self.wink.button_on_pressed(), 'button_off_pressed': self.wink.button_off_pressed(), 'button_up_pressed': self.wink.button_up_pressed(), 'button_down_pressed': self.wink.button_down_pressed()}
'Return the class of this sensor, from DEVICE_CLASSES.'
@property def device_class(self):
return None
'Return the state attributes.'
@property def device_state_attributes(self):
return {'pressed': self.wink.pressed(), 'long_pressed': self.wink.long_pressed()}
'Return true if the gang is connected.'
@property def is_on(self):
return self.wink.state()
'Initialize the WeMo sensor.'
def __init__(self, device):
self.wemo = device self._state = None wemo = get_component('wemo') wemo.SUBSCRIPTION_REGISTRY.register(self.wemo) wemo.SUBSCRIPTION_REGISTRY.on(self.wemo, None, self._update_callback)
'Handle state changes.'
def _update_callback(self, _device, _type, _params):
_LOGGER.info('Subscription update for %s', _device) updated = self.wemo.subscription_update(_type, _params) self._update(force_update=(not updated)) if (not hasattr(self, 'hass')): return self.schedule_update_ha_state()
'No polling needed with subscriptions.'
@property def should_poll(self):
return False
'Return the id of this WeMo device.'
@property def unique_id(self):
return '{}.{}'.format(self.__class__, self.wemo.serialnumber)
'Return the name of the sevice if any.'
@property def name(self):
return self.wemo.name
'Return true if sensor is on.'
@property def is_on(self):
return self._state
'Update WeMo state.'
def update(self):
self._update(force_update=True)