desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return the state of the sensor.'
@property def state(self):
return self._state
'Return the unit of measurement of this sensor.'
@property def unit_of_measurement(self):
return self._unit_of_measurement
'Get the monitored data from the charger.'
def update(self):
try: if (self.type == 'status'): self._state = self.charger.getStatus() elif (self.type == 'charge_time'): self._state = (self.charger.getChargeTimeElapsed() / 60) elif (self.type == 'ambient_temp'): self._state = self.charger.getAmbientTemperature() ...
'Initialize the sensor.'
def __init__(self, name, access_code):
self._data = {} self._access_code = access_code self._name = name self._state = None
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return the state of the sensor.'
@property def state(self):
return self._state
'Icon to use in the frontend, if any.'
@property def icon(self):
return self.ICON
'Construct a travel time sensor.'
def __init__(self, name, access_code, travel_time_id):
self._travel_time_id = travel_time_id WashingtonStateTransportSensor.__init__(self, name, access_code)
'Get the latest data from WSDOT.'
def update(self):
params = {ATTR_ACCESS_CODE: self._access_code, ATTR_TRAVEL_TIME_ID: self._travel_time_id} response = requests.get(self.RESOURCE, params, timeout=10) if (response.status_code != 200): _LOGGER.warning('Invalid response from WSDOT API') else: self._data = response.json() sel...
'Return other details about the sensor state.'
@property def device_state_attributes(self):
if (self._data is not None): attrs = {ATTR_ATTRIBUTION: ATTRIBUTION} for key in [ATTR_AVG_TIME, ATTR_NAME, ATTR_DESCRIPTION, ATTR_TRAVEL_TIME_ID]: attrs[key] = self._data.get(key) attrs[ATTR_TIME_UPDATED] = _parse_wsdot_timestamp(self._data.get(ATTR_TIME_UPDATED)) return ...
'Return the unit this state is expressed in.'
@property def unit_of_measurement(self):
return 'min'
'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 the state of the sensor.'
@property def state(self):
return self._state
'Return the unit the value is expressed in.'
@property def unit_of_measurement(self):
return '%'
'Retrieve latest state.'
@asyncio.coroutine def async_update(self):
_LOGGER.debug('Updating Heat sensor: %s', self._sensor) self._state = self._usrobj.heating_level
'Return device state attributes.'
@property def device_state_attributes(self):
state_attr = {ATTR_TARGET_HEAT: self._usrobj.target_heating_level} state_attr[ATTR_ACTIVE_HEAT] = self._usrobj.now_heating state_attr[ATTR_DURATION_HEAT] = self._usrobj.heating_remaining state_attr[ATTR_LAST_SEEN] = self._usrobj.last_seen return state_attr
'Initialize the sensor.'
def __init__(self, name, eight, sensor, units):
super().__init__(eight) self._sensor = sensor self._sensor_root = self._sensor.split('_', 1)[1] self._mapped_name = NAME_MAP.get(self._sensor, self._sensor) self._name = '{} {}'.format(name, self._mapped_name) self._state = None self._attr = None self._units = units self._side = s...
'Return the name of the sensor, if any.'
@property def name(self):
return self._name
'Return the state of the sensor.'
@property def state(self):
return self._state
'Return the unit the value is expressed in.'
@property def unit_of_measurement(self):
if (('current_sleep' in self._sensor) or ('last_sleep' in self._sensor)): return 'Score' elif ('bed_temp' in self._sensor): if (self._units == 'si'): return '\xc2\xb0C' return '\xc2\xb0F' return None
'Icon to use in the frontend, if any.'
@property def icon(self):
if ('bed_temp' in self._sensor): return 'mdi:thermometer'
'Retrieve latest state.'
@asyncio.coroutine def async_update(self):
_LOGGER.debug('Updating User sensor: %s', self._sensor) if ('current' in self._sensor): self._state = self._usrobj.current_sleep_score self._attr = self._usrobj.current_values elif ('last' in self._sensor): self._state = self._usrobj.last_sleep_score self._attr = sel...
'Return device state attributes.'
@property def device_state_attributes(self):
if (self._attr is None): return None state_attr = {ATTR_SESSION_START: self._attr['date']} state_attr[ATTR_TNT] = self._attr['tnt'] state_attr[ATTR_PROCESSING] = self._attr['processing'] sleep_time = (sum(self._attr['breakdown'].values()) - self._attr['breakdown']['awake']) state_attr[AT...
'Initialize the sensor.'
def __init__(self, name, eight, sensor, units):
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._attr = None self._units = units
'Return the name of the sensor, if any.'
@property def name(self):
return self._name
'Return the state of the sensor.'
@property def state(self):
return self._state
'Retrieve latest state.'
@asyncio.coroutine def async_update(self):
_LOGGER.debug('Updating Room sensor: %s', self._sensor) temp = self._eight.room_temperature() if (self._units == 'si'): self._state = round(temp, 2) else: self._state = round(((temp * 1.8) + 32), 2)
'Return the unit the value is expressed in.'
@property def unit_of_measurement(self):
if (self._units == 'si'): return '\xc2\xb0C' return '\xc2\xb0F'
'Icon to use in the frontend, if any.'
@property def icon(self):
return 'mdi:thermometer'
'Initialize the IGD sensor.'
def __init__(self, upnp, sensor_type, unit=''):
self._upnp = upnp self.type = sensor_type self.unit = unit self.unit_factor = (UNITS[unit] if (unit is not None) else 1) self._name = 'IGD {}'.format(SENSOR_TYPES[sensor_type][0]) self._state = None
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return the state of the device.'
@property def state(self):
if (self._state is None): return None return format((self._state / self.unit_factor), '.1f')
'Icon to use in the frontend, if any.'
@property def icon(self):
return SENSOR_TYPES[self.type][2]
'Return the unit of measurement of this entity, if any.'
@property def unit_of_measurement(self):
return self.unit
'Get the latest information from the IGD.'
def update(self):
if (self.type == 'byte_received'): self._state = self._upnp.totalbytereceived() elif (self.type == 'byte_sent'): self._state = self._upnp.totalbytesent() elif (self.type == 'packets_in'): self._state = self._upnp.totalpacketreceived() elif (self.type == 'packets_out'): se...
'Initialize the Uber sensor.'
def __init__(self, sensorType, products, product_id, product):
self.data = products self._product_id = product_id self._product = product self._sensortype = sensorType self._name = '{} {}'.format(self._product['display_name'], self._sensortype) if (self._sensortype == 'time'): self._unit_of_measurement = 'min' time_estimate = self._produc...
'Return the name of the sensor.'
@property def name(self):
if ('uber' not in self._name.lower()): self._name = 'Uber{}'.format(self._name) return self._name
'Return the state of the sensor.'
@property def state(self):
return self._state
'Return the unit of measurement of this entity, if any.'
@property def unit_of_measurement(self):
return self._unit_of_measurement
'Return the state attributes.'
@property def device_state_attributes(self):
time_estimate = self._product.get('time_estimate_seconds') params = {'Product ID': self._product['product_id'], 'Product short description': self._product['short_description'], 'Product display name': self._product['display_name'], 'Product description': self._product['description'], 'Pickup ...
'Icon to use in the frontend, if any.'
@property def icon(self):
return ICON
'Get the latest data from the Uber API and update the states.'
def update(self):
self.data.update() self._product = self.data.products[self._product_id] if (self._sensortype == 'time'): time_estimate = self._product.get('time_estimate_seconds', 0) self._state = int((time_estimate / 60)) elif (self._sensortype == 'price'): price_details = self._product.get('pr...
'Initialize the UberEstimate object.'
def __init__(self, session, start_latitude, start_longitude, end_latitude=None, end_longitude=None):
self._session = session self.start_latitude = start_latitude self.start_longitude = start_longitude self.end_latitude = end_latitude self.end_longitude = end_longitude self.products = None self.update()
'Get the latest product info and estimates from the Uber API.'
@Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self):
from uber_rides.client import UberRidesClient client = UberRidesClient(self._session) self.products = {} products_response = client.get_products(self.start_latitude, self.start_longitude) products = products_response.json.get('products') for product in products: self.products[product['pr...
'Initialize the sensor.'
def __init__(self, info, server):
self._info = info self._server = server self._available = True
'Return the name of the sensor.'
@property def name(self):
return self._info.get('name')
'Return the state of the sensor.'
@property def state(self):
return self._info.get('statename')
'Could the device be accessed during the last update call.'
@property def available(self):
return self._available
'Return the state attributes.'
@property def device_state_attributes(self):
return {ATTR_DESCRIPTION: self._info.get('description'), ATTR_GROUP: self._info.get('group')}
'Update device state.'
def update(self):
try: self._info = self._server.supervisor.getProcessInfo(self._info.get('name')) self._available = True except ConnectionRefusedError: _LOGGER.warning('Supervisord not available') self._available = False
'Initialize the sensor.'
def __init__(self, data, journey, name):
self.data = data self._name = name self._state = None self._times = None self._from = journey[2] self._to = journey[3]
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return the state of the sensor.'
@property def state(self):
return self._state
'Return the state attributes.'
@property def device_state_attributes(self):
if (self._times is not None): return {ATTR_DEPARTURE_TIME1: self._times[0], ATTR_DEPARTURE_TIME2: self._times[1], ATTR_START: self._from, ATTR_TARGET: self._to, ATTR_REMAINING_TIME: '{}'.format(':'.join(str(self._times[2]).split(':')[:2])), ATTR_ATTRIBUTION: CONF_ATTRIBUTION}
'Icon to use in the frontend, if any.'
@property def icon(self):
return ICON
'Get the latest data from opendata.ch and update the states.'
def update(self):
self.data.update() self._times = self.data.times try: self._state = self._times[0] except TypeError: pass
'Initialize the data object.'
def __init__(self, journey):
self.start = journey[0] self.destination = journey[1] self.times = {}
'Get the latest data from opendata.ch.'
def update(self):
response = requests.get((((((((((_RESOURCE + 'connections?') + 'from=') + self.start) + '&') + 'to=') + self.destination) + '&') + 'fields[]=connections/from/departureTimestamp/&') + 'fields[]=connections/'), timeout=10) connections = response.json()['connections'][:2] try: self.times = [dt_util.as_...
'Initialize the sensor.'
def __init__(self, session, name):
self._session = session self._name = name self._attributes = None self._state = None
'Return the name of the sensor.'
@property def name(self):
return '{} packages'.format((self._name or DOMAIN))
'Return the state of the sensor.'
@property def state(self):
return self._state
'Update device state.'
def update(self):
import myusps status_counts = defaultdict(int) for package in myusps.get_packages(self._session): status = slugify(package['primary_status']) if ((status == STATUS_DELIVERED) and (parse_datetime(package['date']).date() < now().date())): continue status_counts[status] += 1...
'Return the state attributes.'
@property def device_state_attributes(self):
return self._attributes
'Icon to use in the frontend.'
@property def icon(self):
return 'mdi:package-variant-closed'
'Initialize the sensor.'
def __init__(self, session, name):
self._session = session self._name = name self._attributes = None self._state = None
'Return the name of the sensor.'
@property def name(self):
return '{} mail'.format((self._name or DOMAIN))
'Return the state of the sensor.'
@property def state(self):
return self._state
'Update device state.'
def update(self):
import myusps self._state = len(myusps.get_mail(self._session))
'Return the state attributes.'
@property def device_state_attributes(self):
import myusps return {ATTR_ATTRIBUTION: myusps.ATTRIBUTION}
'Icon to use in the frontend.'
@property def icon(self):
return 'mdi:mailbox'
'Initialize the sensor.'
def __init__(self, sensor_name, server_name, server_port):
self.server_name = server_name self.server_port = server_port self._name = sensor_name self._state = None
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return the unit this state is expressed in.'
@property def unit_of_measurement(self):
return 'days'
'Return the state of the sensor.'
@property def state(self):
return self._state
'Icon to use in the frontend, if any.'
@property def icon(self):
return 'mdi:certificate'
'Fetch the certificate information.'
def update(self):
try: ctx = ssl.create_default_context() sock = ctx.wrap_socket(socket.socket(), server_hostname=self.server_name) sock.settimeout(TIMEOUT) sock.connect((self.server_name, self.server_port)) except socket.gaierror: _LOGGER.error('Cannot resolve hostname: %s', self...
'Initialize the sensor.'
def __init__(self, data, name, target):
self.data = data self._target = target self._name = name self._state = None
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return the unit of measurement of this entity, if any.'
@property def unit_of_measurement(self):
return self._target
'Return the state of the sensor.'
@property def state(self):
return self._state
'Return the state attributes.'
@property def device_state_attributes(self):
if (self.data.rate is not None): return {ATTR_BASE: self.data.rate['base'], ATTR_TARGET: self._target, ATTR_EXCHANGE_RATE: self.data.rate['rates'][self._target], ATTR_ATTRIBUTION: CONF_ATTRIBUTION}
'Return the icon to use in the frontend, if any.'
@property def icon(self):
return ICON
'Get the latest data and updates the states.'
def update(self):
self.data.update() self._state = round(self.data.rate['rates'][self._target], 3)
'Initialize the data object.'
def __init__(self, base_currency, target_currency):
from fixerio import Fixerio self.rate = None self.base_currency = base_currency self.target_currency = target_currency self.exchange = Fixerio(base=self.base_currency, symbols=[self.target_currency], secure=True)
'Get the latest data from Fixer.io.'
def update(self):
self.rate = self.exchange.latest()
'Initialize the Neato Connected sensor.'
def __init__(self, hass, robot, sensor_type):
self.type = sensor_type self.robot = robot self.neato = hass.data[NEATO_LOGIN] self._robot_name = ((self.robot.name + ' ') + SENSOR_TYPES[self.type][0]) self._status_state = None try: self._state = self.robot.state except (requests.exceptions.ConnectionError, requests.exceptions.H...
'Update the properties of sensor.'
def update(self):
_LOGGER.debug('Update of sensor') self.neato.update_robots() self._mapdata = self.hass.data[NEATO_MAP_DATA] try: self._state = self.robot.state except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError) as ex: self._state = None self._status_state = 'Of...
'Return unit for the sensor.'
@property def unit_of_measurement(self):
if (self.type == SENSOR_TYPE_BATTERY): return '%'
'Return True if sensor data is available.'
@property def available(self):
return self._state
'Return the sensor state.'
@property def state(self):
if (self.type == SENSOR_TYPE_STATUS): return self._status_state if (self.type == SENSOR_TYPE_BATTERY): return self._battery_state
'Return the name of the sensor.'
@property def name(self):
return self._robot_name
'Return the device specific attributes.'
@property def device_state_attributes(self):
data = {} if (self.type is SENSOR_TYPE_STATUS): if self.clean_time_start: data[ATTR_CLEAN_START] = self.clean_time_start if self.clean_time_stop: data[ATTR_CLEAN_STOP] = self.clean_time_stop if self.clean_area: data[ATTR_CLEAN_AREA] = self.clean_area ...
'Initialize the sensor.'
def __init__(self, netatmo_data, module_name, sensor_type):
self._name = 'Netatmo {} {}'.format(module_name, SENSOR_TYPES[sensor_type][0]) self.netatmo_data = netatmo_data self.module_name = module_name self.type = sensor_type self._state = None self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] module_id = self.netatmo_data.station_data....
'Return the name of the sensor.'
@property def name(self):
return self._name
'Return the unique ID for this sensor.'
@property def unique_id(self):
return self._unique_id
'Icon to use in the frontend, if any.'
@property def icon(self):
return SENSOR_TYPES[self.type][2]
'Return the state of the device.'
@property def state(self):
return self._state
'Return the unit of measurement of this entity, if any.'
@property def unit_of_measurement(self):
return self._unit_of_measurement