desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Return the attribution.'
| @property
def attribution(self):
| return ATTRIBUTION
|
'Return the forecast array.'
| @property
def forecast(self):
| try:
return [{ATTR_FORECAST_TIME: v['date'], ATTR_FORECAST_TEMP: int(v['high']), ATTR_FORECAST_TEMP_LOW: int(v['low']), ATTR_FORECAST_CONDITION: self.hass.data[DATA_CONDITION][int(v['code'])]} for v in self._data.yahoo.Forecast]
except (ValueError, IndexError):
return STATE_UNKNOWN
|
'Get the latest data from Yahoo! and updates the states.'
| def update(self):
| self._data.update()
if (not self._data.yahoo.RawData):
_LOGGER.info("Don't receive weather data from Yahoo!")
return
|
'Initialize the data object.'
| def __init__(self, woeid, temp_unit):
| from yahooweather import YahooWeather
self._yahoo = YahooWeather(woeid, temp_unit)
|
'Return Yahoo! API object.'
| @property
def yahoo(self):
| return self._yahoo
|
'Get the latest data from Yahoo!.'
| def update(self):
| return self._yahoo.updateWeather()
|
'Initialise the platform with a data instance and site.'
| def __init__(self, site, data, config):
| self.data = data
self.site = site
|
'Update current conditions.'
| def update(self):
| self.data.update()
|
'Return the name of the sensor.'
| @property
def name(self):
| return 'Met Office ({})'.format(self.site.name)
|
'Return the current condition.'
| @property
def condition(self):
| return [k for (k, v) in CONDITION_CLASSES.items() if (self.data.data.weather.value in v)][0]
|
'Return the platform temperature.'
| @property
def temperature(self):
| return self.data.data.temperature.value
|
'Return the unit of measurement.'
| @property
def temperature_unit(self):
| return TEMP_CELSIUS
|
'Return the mean sea-level pressure.'
| @property
def pressure(self):
| return None
|
'Return the relative humidity.'
| @property
def humidity(self):
| return self.data.data.humidity.value
|
'Return the wind speed.'
| @property
def wind_speed(self):
| return self.data.data.wind_speed.value
|
'Return the wind bearing.'
| @property
def wind_bearing(self):
| return self.data.data.wind_direction.value
|
'Return the attribution.'
| @property
def attribution(self):
| return CONF_ATTRIBUTION
|
'Initialise the platform with a data instance and station name.'
| def __init__(self, bom_data, stationname=None):
| self.bom_data = bom_data
self.stationname = (stationname or self.bom_data.data.get('name'))
|
'Update current conditions.'
| def update(self):
| self.bom_data.update()
|
'Return the name of the sensor.'
| @property
def name(self):
| return 'BOM {}'.format((self.stationname or '(unknown station)'))
|
'Return the current condition.'
| @property
def condition(self):
| return self.bom_data.data.get('weather')
|
'Return the platform temperature.'
| @property
def temperature(self):
| return self.bom_data.data.get('air_temp')
|
'Return the unit of measurement.'
| @property
def temperature_unit(self):
| return TEMP_CELSIUS
|
'Return the mean sea-level pressure.'
| @property
def pressure(self):
| return self.bom_data.data.get('press_msl')
|
'Return the relative humidity.'
| @property
def humidity(self):
| return self.bom_data.data.get('rel_hum')
|
'Return the wind speed.'
| @property
def wind_speed(self):
| return self.bom_data.data.get('wind_spd_kmh')
|
'Return the wind bearing.'
| @property
def wind_bearing(self):
| directions = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']
wind = {name: ((idx * 360) / 16) for (idx, name) in enumerate(directions)}
return wind.get(self.bom_data.data.get('wind_dir'))
|
'Return the attribution.'
| @property
def attribution(self):
| return 'Data provided by the Australian Bureau of Meteorology'
|
'Initialize the sensor.'
| def __init__(self, name, owm, temperature_unit):
| self._name = name
self._owm = owm
self._temperature_unit = temperature_unit
self.data = None
self.forecast_data = None
|
'Return the name of the sensor.'
| @property
def name(self):
| return self._name
|
'Return the current condition.'
| @property
def condition(self):
| try:
return [k for (k, v) in CONDITION_CLASSES.items() if (self.data.get_weather_code() in v)][0]
except IndexError:
return STATE_UNKNOWN
|
'Return the temperature.'
| @property
def temperature(self):
| return self.data.get_temperature('celsius').get('temp')
|
'Return the unit of measurement.'
| @property
def temperature_unit(self):
| return TEMP_CELSIUS
|
'Return the pressure.'
| @property
def pressure(self):
| return self.data.get_pressure().get('press')
|
'Return the humidity.'
| @property
def humidity(self):
| return self.data.get_humidity()
|
'Return the wind speed.'
| @property
def wind_speed(self):
| return self.data.get_wind().get('speed')
|
'Return the wind bearing.'
| @property
def wind_bearing(self):
| return self.data.get_wind().get('deg')
|
'Return the attribution.'
| @property
def attribution(self):
| return ATTRIBUTION
|
'Return the forecast array.'
| @property
def forecast(self):
| return [{ATTR_FORECAST_TIME: entry.get_reference_time('iso'), ATTR_FORECAST_TEMP: entry.get_temperature('celsius').get('temp')} for entry in self.forecast_data.get_weathers()]
|
'Get the latest data from OWM and updates the states.'
| def update(self):
| self._owm.update()
self._owm.update_forecast()
self.data = self._owm.data
self.forecast_data = self._owm.forecast_data
|
'Initialize the data object.'
| def __init__(self, owm, latitude, longitude):
| self.owm = owm
self.latitude = latitude
self.longitude = longitude
self.data = None
self.forecast_data = None
|
'Get the latest data from OpenWeatherMap.'
| @Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
| obs = self.owm.weather_at_coords(self.latitude, self.longitude)
if (obs is None):
_LOGGER.warning('Failed to fetch data from OWM')
return
self.data = obs.get_weather()
|
'Get the lastest forecast from OpenWeatherMap.'
| @Throttle(MIN_TIME_BETWEEN_FORECAST_UPDATES)
def update_forecast(self):
| fcd = self.owm.three_hours_forecast_at_coords(self.latitude, self.longitude)
if (fcd is None):
_LOGGER.warning('Failed to fetch forecast data from OWM')
return
self.forecast_data = fcd.get_forecast()
|
'Initialise the platform with a data instance and station name.'
| def __init__(self, zamg_data, stationname=None):
| self.zamg_data = zamg_data
self.stationname = stationname
|
'Return the name of the sensor.'
| @property
def name(self):
| return (self.stationname or 'ZAMG {}'.format((self.zamg_data.data.get('Name') or '(unknown station)')))
|
'Return the current condition.'
| @property
def condition(self):
| return None
|
'Return the attribution.'
| @property
def attribution(self):
| return ATTRIBUTION
|
'Return the platform temperature.'
| @property
def temperature(self):
| return self.zamg_data.get_data(ATTR_WEATHER_TEMPERATURE)
|
'Return the unit of measurement.'
| @property
def temperature_unit(self):
| return TEMP_CELSIUS
|
'Return the pressure.'
| @property
def pressure(self):
| return self.zamg_data.get_data(ATTR_WEATHER_PRESSURE)
|
'Return the humidity.'
| @property
def humidity(self):
| return self.zamg_data.get_data(ATTR_WEATHER_HUMIDITY)
|
'Return the wind speed.'
| @property
def wind_speed(self):
| return self.zamg_data.get_data(ATTR_WEATHER_WIND_SPEED)
|
'Return the wind bearing.'
| @property
def wind_bearing(self):
| return self.zamg_data.get_data(ATTR_WEATHER_WIND_BEARING)
|
'Update current conditions.'
| def update(self):
| self.zamg_data.update()
|
'Initialize the Demo weather.'
| def __init__(self, name, condition, temperature, humidity, pressure, wind_speed, temperature_unit, forecast):
| self._name = name
self._condition = condition
self._temperature = temperature
self._temperature_unit = temperature_unit
self._humidity = humidity
self._pressure = pressure
self._wind_speed = wind_speed
self._forecast = forecast
|
'Return the name of the sensor.'
| @property
def name(self):
| return '{} {}'.format('Demo Weather', self._name)
|
'No polling needed for a demo weather condition.'
| @property
def should_poll(self):
| return False
|
'Return the temperature.'
| @property
def temperature(self):
| return self._temperature
|
'Return the unit of measurement.'
| @property
def temperature_unit(self):
| return self._temperature_unit
|
'Return the humidity.'
| @property
def humidity(self):
| return self._humidity
|
'Return the wind speed.'
| @property
def wind_speed(self):
| return self._wind_speed
|
'Return the pressure.'
| @property
def pressure(self):
| return self._pressure
|
'Return the weather condition.'
| @property
def condition(self):
| return [k for (k, v) in CONDITION_CLASSES.items() if (self._condition.lower() in v)][0]
|
'Return the attribution.'
| @property
def attribution(self):
| return 'Powered by Home Assistant'
|
'Return the forecast.'
| @property
def forecast(self):
| reftime = datetime.now().replace(hour=16, minute=0)
forecast_data = []
for entry in self._forecast:
data_dict = {ATTR_FORECAST_TIME: reftime.isoformat(), ATTR_FORECAST_TEMP: entry}
reftime = (reftime + timedelta(hours=4))
forecast_data.append(data_dict)
return forecast_data
|
'Initialize the xiaomi device.'
| def __init__(self, device, name, xiaomi_hub):
| self._state = None
self._sid = device['sid']
self._name = '{}_{}'.format(name, self._sid)
self._write_to_hub = xiaomi_hub.write_to_hub
self._get_from_hub = xiaomi_hub.get_from_hub
xiaomi_hub.callbacks[self._sid].append(self.push_data)
self._device_state_attributes = {}
self.parse_data(de... |
'Return the name of the device.'
| @property
def name(self):
| return self._name
|
'Poll update device status.'
| @property
def should_poll(self):
| return False
|
'Return the state attributes.'
| @property
def device_state_attributes(self):
| return self._device_state_attributes
|
'Push from Hub.'
| def push_data(self, data):
| _LOGGER.debug('PUSH >> %s: %s', self, data)
if (self.parse_data(data) or self.parse_voltage(data)):
self.schedule_update_ha_state()
|
'Parse battery level data sent by gateway.'
| def parse_voltage(self, data):
| if ('voltage' not in data):
return False
max_volt = 3300
min_volt = 2800
voltage = data['voltage']
voltage = min(voltage, max_volt)
voltage = max(voltage, min_volt)
percent = (((voltage - min_volt) / (max_volt - min_volt)) * 100)
self._device_state_attributes[ATTR_BATTERY_LEVEL] ... |
'Parse data sent by gateway.'
| def parse_data(self, data):
| raise NotImplementedError()
|
'Return true if the binary sensor is on.'
| @property
def is_on(self):
| return self._state
|
'Retrieve latest state.'
| def update(self):
| self._state = bool(getattr(self.device, self.variable))
|
'Initialize the sensor.'
| def __init__(self, structure, device, zone):
| super(NestActivityZoneSensor, self).__init__(structure, device, '')
self.zone = zone
self._name = '{} {} activity'.format(self._name, self.zone.name)
|
'Return the name of the nest, if any.'
| @property
def name(self):
| return self._name
|
'Retrieve latest state.'
| def update(self):
| self._state = self.device.has_ongoing_motion_in_zone(self.zone.zone_id)
|
'Initialize the binary_sensor.'
| def __init__(self, hass, zone_number, zone_name, zone_type):
| self._zone_number = zone_number
self._zone_type = zone_type
self._state = 0
self._name = zone_name
self._type = zone_type
_LOGGER.debug('Setup up zone: %s', self._name)
|
'Register callbacks.'
| @asyncio.coroutine
def async_added_to_hass(self):
| async_dispatcher_connect(self.hass, SIGNAL_ZONE_FAULT, self._fault_callback)
async_dispatcher_connect(self.hass, SIGNAL_ZONE_RESTORE, self._restore_callback)
|
'Return the name of the entity.'
| @property
def name(self):
| return self._name
|
'Icon for device by its type.'
| @property
def icon(self):
| if ('window' in self._name.lower()):
return ('mdi:window-open' if self.is_on else 'mdi:window-closed')
if (self._type == 'smoke'):
return 'mdi:fire'
return None
|
'No polling needed.'
| @property
def should_poll(self):
| return False
|
'Return true if sensor is on.'
| @property
def is_on(self):
| return (self._state == 1)
|
'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 _fault_callback(self, zone):
| if ((zone is None) or (int(zone) == self._zone_number)):
self._state = 1
self.hass.async_add_job(self.async_update_ha_state())
|
'Update the zone\'s state, if needed.'
| @callback
def _restore_callback(self, zone):
| if ((zone is None) or (int(zone) == self._zone_number)):
self._state = 0
self.hass.async_add_job(self.async_update_ha_state())
|
'Initialize the aREST device.'
| def __init__(self, arest, resource, name, device_class, pin):
| self.arest = arest
self._resource = resource
self._name = name
self._device_class = device_class
self._pin = pin
if (self._pin is not None):
request = requests.get('{}/mode/{}/i'.format(self._resource, self._pin), timeout=10)
if (request.status_code != 200):
_LOGGER.e... |
'Return the name of the binary sensor.'
| @property
def name(self):
| return self._name
|
'Return true if the binary sensor is on.'
| @property
def is_on(self):
| return bool(self.arest.data.get('state'))
|
'Return the class of this sensor.'
| @property
def device_class(self):
| return self._device_class
|
'Get the latest data from aREST API.'
| def update(self):
| self.arest.update()
|
'Initialize the aREST data object.'
| def __init__(self, resource, pin):
| self._resource = resource
self._pin = pin
self.data = {}
|
'Get the latest data from aREST device.'
| @Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
| try:
response = requests.get('{}/digital/{}'.format(self._resource, self._pin), timeout=10)
self.data = {'state': response.json()['return_value']}
except requests.exceptions.ConnectionError:
_LOGGER.error("No route to device '%s'", self._resource)
|
'Initialize the APCUPSd binary device.'
| def __init__(self, config, data):
| self._config = config
self._data = data
self._state = None
|
'Return the name of the UPS online status sensor.'
| @property
def name(self):
| return self._config.get(CONF_NAME)
|
'Return true if the UPS is online, else false.'
| @property
def is_on(self):
| return (self._state == apcupsd.VALUE_ONLINE)
|
'Get the status report from APCUPSd and set this entity\'s state.'
| def update(self):
| self._state = self._data.status[apcupsd.KEY_STATUS]
|
'Initialize the sensor.'
| def __init__(self, event, name, device_class=None, should_fire=False, off_delay=None, data_bits=None, cmd_on=None, cmd_off=None):
| self.event = event
self._name = name
self._should_fire_event = should_fire
self._device_class = device_class
self._off_delay = off_delay
self._state = False
self.is_lighting4 = False
self.delay_listener = None
self._data_bits = data_bits
self._cmd_on = cmd_on
self._cmd_off = ... |
'Return the name of the sensor.'
| def __str__(self):
| return self._name
|
'Return the device name.'
| @property
def name(self):
| return self._name
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.