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 '{} Status'.format(self._monitor_name)
|
'Return the state of the sensor.'
| @property
def state(self):
| return self._state
|
'Update the sensor.'
| def update(self):
| monitor = zoneminder.get_state(('api/monitors/%i.json' % self._monitor_id))
if (monitor['monitor']['Monitor']['Function'] is None):
self._state = STATE_UNKNOWN
else:
self._state = monitor['monitor']['Monitor']['Function']
|
'Initialize event sensor.'
| def __init__(self, monitor_id, monitor_name, include_archived):
| self._monitor_id = monitor_id
self._monitor_name = monitor_name
self._include_archived = include_archived
self._state = None
|
'Return the name of the sensor.'
| @property
def name(self):
| return '{} Events'.format(self._monitor_name)
|
'Return the unit of measurement of this entity, if any.'
| @property
def unit_of_measurement(self):
| return 'Events'
|
'Return the state of the sensor.'
| @property
def state(self):
| return self._state
|
'Update the sensor.'
| def update(self):
| archived_filter = '/Archived:0'
if self._include_archived:
archived_filter = ''
event = zoneminder.get_state(('api/events/index/MonitorId:%i%s.json' % (self._monitor_id, archived_filter)))
self._state = event['pagination']['count']
|
'Initialize a Torque view.'
| def __init__(self, email, vehicle, sensors, add_devices):
| self.email = email
self.vehicle = vehicle
self.sensors = sensors
self.add_devices = add_devices
|
'Handle Torque data request.'
| @callback
def get(self, request):
| hass = request.app['hass']
data = request.query
if ((self.email is not None) and (self.email != data[SENSOR_EMAIL_FIELD])):
return
names = {}
units = {}
for key in data:
is_name = NAME_KEY.match(key)
is_unit = UNIT_KEY.match(key)
is_value = VALUE_KEY.match(key)
... |
'Initialize the sensor.'
| def __init__(self, name, unit):
| self._name = name
self._unit = unit
self._state = None
|
'Return the name of the sensor.'
| @property
def name(self):
| return self._name
|
'Return the unit of measurement.'
| @property
def unit_of_measurement(self):
| return self._unit
|
'Return the state of the sensor.'
| @property
def state(self):
| return self._state
|
'Return the default icon of the sensor.'
| @property
def icon(self):
| return 'mdi:car'
|
'Receive an update.'
| @callback
def async_on_update(self, value):
| self._state = value
self.hass.async_add_job(self.async_update_ha_state())
|
'Initialize the sensor.'
| def __init__(self, hass, name, latitude, longitude, radius):
| self._session = requests.Session()
self._latitude = latitude
self._longitude = longitude
self._radius = util_distance.convert(radius, LENGTH_KILOMETERS, LENGTH_METERS)
self._state = 0
self._hass = hass
self._name = name
self._previously_tracked = 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
|
'Handle flights crossing region boundary.'
| def _handle_boundary(self, callsigns, event):
| for callsign in callsigns:
data = {ATTR_CALLSIGN: callsign, ATTR_SENSOR: self._name}
self._hass.bus.fire(event, data)
|
'Update device state.'
| def update(self):
| currently_tracked = set()
states = self._session.get(OPENSKY_API_URL).json().get(ATTR_STATES)
for state in states:
data = dict(zip(OPENSKY_API_FIELDS, state))
missing_location = ((data.get(ATTR_LONGITUDE) is None) or (data.get(ATTR_LATITUDE) is None))
if missing_location:
... |
'Return the state attributes.'
| @property
def device_state_attributes(self):
| return {ATTR_ATTRIBUTION: OPENSKY_ATTRIBUTION}
|
'Return the unit of measurement.'
| @property
def unit_of_measurement(self):
| return 'flights'
|
'Return the icon.'
| @property
def icon(self):
| return 'mdi:airplane'
|
'Initialize the sensor.'
| def __init__(self, sensor_name, sensor_type, sensor_index):
| self._name = '{} {}'.format(sensor_name, SENSOR_TYPES[sensor_type][0])
self.sensor_name = sensor_name
self.type = sensor_type
self.index = sensor_index
self._state = None
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
|
'Return the name of the Ecobee sensor.'
| @property
def name(self):
| return self._name.rstrip()
|
'Return the state of the sensor.'
| @property
def state(self):
| return self._state
|
'Return the unique ID of this sensor.'
| @property
def unique_id(self):
| return 'sensor_ecobee_{}_{}'.format(self._name, self.index)
|
'Return the unit of measurement this sensor expresses itself in.'
| @property
def unit_of_measurement(self):
| return self._unit_of_measurement
|
'Get the latest state of the sensor.'
| def update(self):
| data = ecobee.NETWORK
data.update()
for sensor in data.ecobee.get_remote_sensors(self.index):
for item in sensor['capability']:
if ((item['type'] == self.type) and (self.sensor_name == sensor['name'])):
if ((self.type == 'temperature') and (item['value'] != 'unknown')):
... |
'Return id of the device.'
| @property
def device_id(self):
| return self._id[0]
|
'Return the type of the sensor.'
| @property
def _type(self):
| return self._id[1]
|
'Return value of the sensor.'
| @property
def _value(self):
| return self.device.value(*self._id[1:])
|
'Return the value as temperature.'
| @property
def _value_as_temperature(self):
| return round(float(self._value), 1)
|
'Return the value as luminance.'
| @property
def _value_as_luminance(self):
| return round(float(self._value), 1)
|
'Return the value as humidity.'
| @property
def _value_as_humidity(self):
| return int(round(float(self._value)))
|
'Return the name of the sensor.'
| @property
def name(self):
| return '{} {}'.format(super().name, (self.quantity_name or ''))
|
'Return the state of the sensor.'
| @property
def state(self):
| if (not self.available):
return None
elif (self._type == SENSOR_TYPE_TEMP):
return self._value_as_temperature
elif (self._type == SENSOR_TYPE_HUMIDITY):
return self._value_as_humidity
elif (self._type == SENSOR_TYPE_LUMINANCE):
return self._value_as_luminance
return s... |
'Name of quantity.'
| @property
def quantity_name(self):
| return (SENSOR_TYPES[self._type][0] if (self._type in SENSOR_TYPES) else None)
|
'Return the unit of measurement.'
| @property
def unit_of_measurement(self):
| return (SENSOR_TYPES[self._type][1] if (self._type in SENSOR_TYPES) else None)
|
'Return the icon.'
| @property
def icon(self):
| return (SENSOR_TYPES[self._type][2] if (self._type in SENSOR_TYPES) else None)
|
'Initialize a new NZBGet sensor.'
| def __init__(self, api, sensor_type, client_name):
| self._name = '{} {}'.format(client_name, sensor_type[1])
self.type = sensor_type[0]
self.client_name = client_name
self.api = api
self._state = None
self._unit_of_measurement = sensor_type[2]
self.update()
_LOGGER.debug('Created NZBGet sensor: %s', self.type)
|
'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 entity, if any.'
| @property
def unit_of_measurement(self):
| return self._unit_of_measurement
|
'Update state of sensor.'
| def update(self):
| try:
self.api.update()
except requests.exceptions.ConnectionError:
return
if (self.api.status is None):
_LOGGER.debug('Update of %s requested, but no status is available', self._name)
return
value = self.api.status.get(self.type)
if (value is N... |
'Initialize NZBGet API and set headers needed later.'
| def __init__(self, api_url, username=None, password=None):
| self.api_url = api_url
self.status = None
self.headers = {'content-type': CONTENT_TYPE_JSON}
if ((username is not None) and (password is not None)):
self.auth = (username, password)
else:
self.auth = None
self.update()
|
'Send a POST request and return the response as a dict.'
| def post(self, method, params=None):
| payload = {'method': method}
if params:
payload['params'] = params
try:
response = requests.post(self.api_url, json=payload, auth=self.auth, headers=self.headers, timeout=5)
response.raise_for_status()
return response.json()
except requests.exceptions.ConnectionError as c... |
'Update cached response.'
| @Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
| try:
self.status = self.post('status')['result']
except requests.exceptions.ConnectionError:
raise
|
'Return the state of the sensor.'
| @property
def state(self):
| name = self._hmdevice.__class__.__name__
if (name in HM_STATE_HA_CAST):
return HM_STATE_HA_CAST[name].get(self._hm_get_state(), None)
return self._hm_get_state()
|
'Return the unit of measurement of this entity, if any.'
| @property
def unit_of_measurement(self):
| return HM_UNIT_HA_CAST.get(self._state, None)
|
'Return the icon to use in the frontend, if any.'
| @property
def icon(self):
| return HM_ICON_HA_CAST.get(self._state, None)
|
'Generate a data dictionary (self._data) from metadata.'
| def _init_data_struct(self):
| if self._state:
self._data.update({self._state: STATE_UNKNOWN})
else:
_LOGGER.critical("Can't initialize sensor %s", self._name)
|
'Initialize the sensor.'
| def __init__(self, name, token):
| import pyotp
self._name = name
self._otp = pyotp.TOTP(token)
self._state = None
self._next_expiration = None
|
'Handle when an entity is about to be added to Home Assistant.'
| @asyncio.coroutine
def async_added_to_hass(self):
| self._call_loop()
|
'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
|
'No polling needed.'
| @property
def should_poll(self):
| return False
|
'Return the icon to use in the frontend.'
| @property
def icon(self):
| return ICON
|
'Initialize the sensor.'
| def __init__(self, hass, config):
| self._config = config
self._temp = None
|
'Return the name of the sensor.'
| @property
def name(self):
| return self._config.name
|
'Return the state of the sensor.'
| @property
def state(self):
| return self._temp
|
'Return the unit of measurement the value is expressed in.'
| @property
def unit_of_measurement(self):
| return TEMP_CELSIUS
|
'Get the latest data.'
| def update(self, *args):
| try:
self._temp = zigbee.DEVICE.get_temperature(self._config.address)
except zigbee.ZIGBEE_TX_FAILURE:
_LOGGER.warning('Transmission failure when attempting to get sample from ZigBee device at address: %s', hexlify(self._config.address))
except zigbee.ZIGB... |
'Initialize the sensor.'
| def __init__(self, name, ohmid):
| self._name = name
self._ohmid = ohmid
self._data = {}
|
'Return the name of the sensor.'
| @property
def name(self):
| return self._name
|
'Return the state of the sensor.'
| @property
def state(self):
| if (self._data.get('active') == 'True'):
return 'Active'
return 'Inactive'
|
'Return the state attributes.'
| @property
def device_state_attributes(self):
| return {'Address': self._data.get('address'), 'ID': self._ohmid}
|
'Get the latest data from OhmConnect.'
| @Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
| try:
url = 'https://login.ohmconnect.com/verify-ohm-hour/{}'.format(self._ohmid)
response = requests.get(url, timeout=10)
root = ET.fromstring(response.text)
for child in root:
self._data[child.tag] = child.text
except requests.exceptions.ConnectionError:
_LOG... |
'Initialize the sensor.'
| def __init__(self, dht_client, sensor_type, temp_unit, name, temperature_offset, humidity_offset):
| self.client_name = name
self._name = SENSOR_TYPES[sensor_type][0]
self.dht_client = dht_client
self.temp_unit = temp_unit
self.type = sensor_type
self.temperature_offset = temperature_offset
self.humidity_offset = humidity_offset
self._state = None
self._unit_of_measurement = SENSOR_... |
'Return the name of the sensor.'
| @property
def name(self):
| return '{} {}'.format(self.client_name, 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
|
'Get the latest data from the DHT and updates the states.'
| def update(self):
| self.dht_client.update()
temperature_offset = self.temperature_offset
humidity_offset = self.humidity_offset
data = self.dht_client.data
if (self.type == SENSOR_TEMPERATURE):
temperature = data[SENSOR_TEMPERATURE]
_LOGGER.debug('Temperature %.1f \\u00b0C + offset %.1f'... |
'Initialize the sensor.'
| def __init__(self, adafruit_dht, sensor, pin):
| self.adafruit_dht = adafruit_dht
self.sensor = sensor
self.pin = pin
self.data = dict()
|
'Get the latest data the DHT sensor.'
| @Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
| (humidity, temperature) = self.adafruit_dht.read_retry(self.sensor, self.pin)
if temperature:
self.data[SENSOR_TEMPERATURE] = temperature
if humidity:
self.data[SENSOR_HUMIDITY] = humidity
|
'Initialize the sensor.'
| def __init__(self, forecast_data, sensor_type, name, forecast_day=0):
| self.client_name = name
self._name = SENSOR_TYPES[sensor_type][0]
self.forecast_data = forecast_data
self.type = sensor_type
self.forecast_day = forecast_day
self._state = None
self._icon = None
self._unit_of_measurement = None
|
'Return the name of the sensor.'
| @property
def name(self):
| if (self.forecast_day == 0):
return '{} {}'.format(self.client_name, self._name)
return '{} {} {}'.format(self.client_name, self._name, self.forecast_day)
|
'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 unit system of this entity.'
| @property
def unit_system(self):
| return self.forecast_data.unit_system
|
'Return the entity picture to use in the frontend, if any.'
| @property
def entity_picture(self):
| if ((self._icon is None) or ('summary' not in self.type)):
return None
if (self._icon in CONDITION_PICTURES):
return CONDITION_PICTURES[self._icon]
return None
|
'Update units based on unit system.'
| def update_unit_of_measurement(self):
| unit_index = {'si': 1, 'us': 2, 'ca': 3, 'uk': 4, 'uk2': 5}.get(self.unit_system, 1)
self._unit_of_measurement = SENSOR_TYPES[self.type][unit_index]
|
'Icon to use in the frontend, if any.'
| @property
def icon(self):
| return SENSOR_TYPES[self.type][6]
|
'Return the state attributes.'
| @property
def device_state_attributes(self):
| return {ATTR_ATTRIBUTION: CONF_ATTRIBUTION}
|
'Get the latest data from Dark Sky and updates the states.'
| def update(self):
| self.forecast_data.update()
self.update_unit_of_measurement()
if (self.type == 'minutely_summary'):
self.forecast_data.update_minutely()
minutely = self.forecast_data.data_minutely
self._state = getattr(minutely, 'summary', '')
self._icon = getattr(minutely, 'icon', '')
e... |
'Return a new state based on the type.
If the sensor type is unknown, the current state is returned.'
| def get_state(self, data):
| lookup_type = convert_to_camel(self.type)
state = getattr(data, lookup_type, None)
if (state is None):
return state
if ('summary' in self.type):
self._icon = getattr(data, 'icon', '')
if (self.type in ['precip_probability', 'cloud_cover', 'humidity']):
return round((state * 1... |
'Initialize the data object.'
| def __init__(self, api_key, latitude, longitude, units, interval):
| self._api_key = api_key
self.latitude = latitude
self.longitude = longitude
self.units = units
self.data = None
self.unit_system = None
self.data_currently = None
self.data_minutely = None
self.data_hourly = None
self.data_daily = None
self.update = Throttle(interval)(self._u... |
'Get the latest data from Dark Sky.'
| def _update(self):
| import forecastio
try:
self.data = forecastio.load_forecast(self._api_key, self.latitude, self.longitude, units=self.units)
except (ConnectError, HTTPError, Timeout, ValueError) as error:
_LOGGER.error('Unable to connect to Dark Sky. %s', error)
self.data = None
... |
'Update currently data.'
| def _update_currently(self):
| self.data_currently = (self.data and self.data.currently())
|
'Update minutely data.'
| def _update_minutely(self):
| self.data_minutely = (self.data and self.data.minutely())
|
'Update hourly data.'
| def _update_hourly(self):
| self.data_hourly = (self.data and self.data.hourly())
|
'Update daily data.'
| def _update_daily(self):
| self.data_daily = (self.data and self.data.daily())
|
'Initialize the sensor.'
| def __init__(self, hydroquebec_data, sensor_type, name):
| self.client_name = name
self.type = sensor_type
self._name = SENSOR_TYPES[sensor_type][0]
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
self._icon = SENSOR_TYPES[sensor_type][2]
self.hydroquebec_data = hydroquebec_data
self._state = None
|
'Return the name of the sensor.'
| @property
def name(self):
| return '{} {}'.format(self.client_name, 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
|
'Icon to use in the frontend, if any.'
| @property
def icon(self):
| return self._icon
|
'Get the latest data from Hydroquebec and update the state.'
| def update(self):
| self.hydroquebec_data.update()
if (self.type in self.hydroquebec_data.data):
self._state = round(self.hydroquebec_data.data[self.type], 2)
|
'Initialize the data object.'
| def __init__(self, username, password, contract=None):
| from pyhydroquebec import HydroQuebecClient
self.client = HydroQuebecClient(username, password, REQUESTS_TIMEOUT)
self._contract = contract
self.data = {}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.