desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Initialize the data object.'
| def __init__(self, latitude, longitude, threshold):
| self.latitude = latitude
self.longitude = longitude
self.number_of_latitude_intervals = 513
self.number_of_longitude_intervals = 1024
self.api_url = 'http://services.swpc.noaa.gov/text/aurora-nowcast-map.txt'
self.headers = {'User-Agent': 'Home Assistant Aurora Tracker v.0.1.0'}
... |
'Get the latest data from the Aurora service.'
| @Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
| try:
self.visibility_level = self.get_aurora_forecast()
if (int(self.visibility_level) > self.threshold):
self.is_visible = True
self.is_visible_text = 'visible!'
else:
self.is_visible = False
self.is_visible_text = "nothing's out"
excep... |
'Get forecast data and parse for given long/lat.'
| def get_aurora_forecast(self):
| raw_data = requests.get(self.api_url, headers=self.headers).text
forecast_table = [row.strip(' ').split(' ') for row in raw_data.split('\n') if (not row.startswith('#'))]
converted_latitude = round(((self.latitude / 180) * self.number_of_latitude_intervals))
converted_longitude = round(((s... |
'Init the Google Calendar service.'
| def __init__(self, token_file):
| self.token_file = token_file
|
'Get the calendar service from the storage file token.'
| def get(self):
| import httplib2
from oauth2client.file import Storage
from googleapiclient import discovery as google_discovery
credentials = Storage(self.token_file).get()
http = credentials.authorize(httplib2.Http())
service = google_discovery.build('calendar', 'v3', http=http, cache_discovery=False)
retu... |
'Initialize the thermostat.'
| def __init__(self, structure, device, temp_unit):
| self._unit = temp_unit
self.structure = structure
self.device = device
self._fan_list = [STATE_ON, STATE_AUTO]
self._operation_list = [STATE_OFF]
if self.device.can_heat:
self._operation_list.append(STATE_HEAT)
if self.device.can_cool:
self._operation_list.append(STATE_COOL)
... |
'Return the name of the nest, if any.'
| @property
def name(self):
| return self._name
|
'Return the unit of measurement.'
| @property
def temperature_unit(self):
| return self._temperature_scale
|
'Return the current temperature.'
| @property
def current_temperature(self):
| return self._temperature
|
'Return current operation ie. heat, cool, idle.'
| @property
def current_operation(self):
| if (self._mode in [STATE_HEAT, STATE_COOL, STATE_OFF, STATE_ECO]):
return self._mode
elif (self._mode == STATE_HEAT_COOL):
return STATE_AUTO
return STATE_UNKNOWN
|
'Return the temperature we try to reach.'
| @property
def target_temperature(self):
| if ((self._mode != STATE_HEAT_COOL) and (not self.is_away_mode_on)):
return self._target_temperature
return None
|
'Return the lower bound temperature we try to reach.'
| @property
def target_temperature_low(self):
| if ((self.is_away_mode_on or (self._mode == STATE_ECO)) and self._eco_temperature[0]):
return self._eco_temperature[0]
if (self._mode == STATE_HEAT_COOL):
return self._target_temperature[0]
return None
|
'Return the upper bound temperature we try to reach.'
| @property
def target_temperature_high(self):
| if ((self.is_away_mode_on or (self._mode == STATE_ECO)) and self._eco_temperature[1]):
return self._eco_temperature[1]
if (self._mode == STATE_HEAT_COOL):
return self._target_temperature[1]
return None
|
'Return if away mode is on.'
| @property
def is_away_mode_on(self):
| return self._away
|
'Set new target temperature.'
| def set_temperature(self, **kwargs):
| target_temp_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
target_temp_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
if (self._mode == STATE_HEAT_COOL):
if ((target_temp_low is not None) and (target_temp_high is not None)):
temp = (target_temp_low, target_temp_high)
else:
temp = kwargs.ge... |
'Set operation mode.'
| def set_operation_mode(self, operation_mode):
| if (operation_mode in [STATE_HEAT, STATE_COOL, STATE_OFF, STATE_ECO]):
device_mode = operation_mode
elif (operation_mode == STATE_AUTO):
device_mode = STATE_HEAT_COOL
self.device.mode = device_mode
|
'List of available operation modes.'
| @property
def operation_list(self):
| return self._operation_list
|
'Turn away on.'
| def turn_away_mode_on(self):
| self.structure.away = True
|
'Turn away off.'
| def turn_away_mode_off(self):
| self.structure.away = False
|
'Return whether the fan is on.'
| @property
def current_fan_mode(self):
| if self._has_fan:
return (STATE_ON if self._fan else STATE_AUTO)
return None
|
'List of available fan modes.'
| @property
def fan_list(self):
| return self._fan_list
|
'Turn fan on/off.'
| def set_fan_mode(self, fan):
| self.device.fan = fan.lower()
|
'Identify min_temp in Nest API or defaults if not available.'
| @property
def min_temp(self):
| return self._min_temperature
|
'Identify max_temp in Nest API or defaults if not available.'
| @property
def max_temp(self):
| return self._max_temperature
|
'Cache value from Python-nest.'
| def update(self):
| self._location = self.device.where
self._name = self.device.name
self._humidity = (self.device.humidity,)
self._temperature = self.device.temperature
self._mode = self.device.mode
self._target_temperature = self.device.target
self._fan = self.device.fan
self._away = (self.structure.away ... |
'Initialize the thermostat.'
| def __init__(self, heatmiser, device, name, serport):
| self.heatmiser = heatmiser
self.device = device
self.serport = serport
self._current_temperature = None
self._name = name
self._id = device
self.dcb = None
self.update()
self._target_temperature = int(self.dcb.get('roomset'))
|
'Return the name of the thermostat, if any.'
| @property
def name(self):
| return self._name
|
'Return the unit of measurement which this thermostat uses.'
| @property
def temperature_unit(self):
| return TEMP_CELSIUS
|
'Return the current temperature.'
| @property
def current_temperature(self):
| if (self.dcb is not None):
low = self.dcb.get('floortemplow ')
high = self.dcb.get('floortemphigh')
temp = (((high * 256) + low) / 10.0)
self._current_temperature = temp
else:
self._current_temperature = None
return self._current_temperature
|
'Return the temperature we try to reach.'
| @property
def target_temperature(self):
| return self._target_temperature
|
'Set new target temperature.'
| def set_temperature(self, **kwargs):
| temperature = kwargs.get(ATTR_TEMPERATURE)
if (temperature is None):
return
self.heatmiser.hmSendAddress(self._id, 18, temperature, 1, self.serport)
self._target_temperature = temperature
|
'Get the latest data.'
| def update(self):
| self.dcb = self.heatmiser.hmReadAddress(self._id, 'prt', self.serport)
|
'Initialize the thermostat.'
| def __init__(self, data, thermostat_index, hold_temp):
| self.data = data
self.thermostat_index = thermostat_index
self.thermostat = self.data.ecobee.get_thermostat(self.thermostat_index)
self._name = self.thermostat['name']
self.hold_temp = hold_temp
self.vacation = None
self._climate_list = self.climate_list
self._operation_list = ['auto', '... |
'Get the latest state from the thermostat.'
| def update(self):
| if self.update_without_throttle:
self.data.update(no_throttle=True)
self.update_without_throttle = False
else:
self.data.update()
self.thermostat = self.data.ecobee.get_thermostat(self.thermostat_index)
|
'Return the name of the Ecobee Thermostat.'
| @property
def name(self):
| return self.thermostat['name']
|
'Return the unit of measurement.'
| @property
def temperature_unit(self):
| return TEMP_FAHRENHEIT
|
'Return the current temperature.'
| @property
def current_temperature(self):
| return (self.thermostat['runtime']['actualTemperature'] / 10)
|
'Return the lower bound temperature we try to reach.'
| @property
def target_temperature_low(self):
| if (self.current_operation == STATE_AUTO):
return int((self.thermostat['runtime']['desiredHeat'] / 10))
return None
|
'Return the upper bound temperature we try to reach.'
| @property
def target_temperature_high(self):
| if (self.current_operation == STATE_AUTO):
return int((self.thermostat['runtime']['desiredCool'] / 10))
return None
|
'Return the temperature we try to reach.'
| @property
def target_temperature(self):
| if (self.current_operation == STATE_AUTO):
return None
if (self.current_operation == STATE_HEAT):
return int((self.thermostat['runtime']['desiredHeat'] / 10))
elif (self.current_operation == STATE_COOL):
return int((self.thermostat['runtime']['desiredCool'] / 10))
return None
|
'Return the desired fan mode of operation.'
| @property
def desired_fan_mode(self):
| return self.thermostat['runtime']['desiredFanMode']
|
'Return the current fan state.'
| @property
def fan(self):
| if ('fan' in self.thermostat['equipmentStatus']):
return STATE_ON
return STATE_OFF
|
'Return current hold mode.'
| @property
def current_hold_mode(self):
| events = self.thermostat['events']
for event in events:
if event['running']:
if (event['type'] == 'hold'):
if (event['holdClimateRef'] == 'away'):
if ((int(event['endDate'][0:4]) - int(event['startDate'][0:4])) <= 1):
return 'away'
... |
'Return current operation.'
| @property
def current_operation(self):
| if ((self.operation_mode == 'auxHeatOnly') or (self.operation_mode == 'heatPump')):
return STATE_HEAT
return self.operation_mode
|
'Return the operation modes list.'
| @property
def operation_list(self):
| return self._operation_list
|
'Return current operation ie. heat, cool, idle.'
| @property
def operation_mode(self):
| return self.thermostat['settings']['hvacMode']
|
'Return current mode, as the user-visible name.'
| @property
def mode(self):
| cur = self.thermostat['program']['currentClimateRef']
climates = self.thermostat['program']['climates']
current = list(filter((lambda x: (x['climateRef'] == cur)), climates))
return current[0]['name']
|
'Return current fan minimum on time.'
| @property
def fan_min_on_time(self):
| return self.thermostat['settings']['fanMinOnTime']
|
'Return device specific state attributes.'
| @property
def device_state_attributes(self):
| status = self.thermostat['equipmentStatus']
operation = None
if (status == ''):
operation = STATE_IDLE
elif ('Cool' in status):
operation = STATE_COOL
elif ('auxHeat' in status):
operation = STATE_HEAT
elif ('heatPump' in status):
operation = STATE_HEAT
else:
... |
'Return true if away mode is on.'
| @property
def is_away_mode_on(self):
| return (self.current_hold_mode == 'away')
|
'Return true if aux heater.'
| @property
def is_aux_heat_on(self):
| return ('auxHeat' in self.thermostat['equipmentStatus'])
|
'Turn away on.'
| def turn_away_mode_on(self):
| self.set_hold_mode('away')
|
'Turn away off.'
| def turn_away_mode_off(self):
| self.set_hold_mode(None)
|
'Set hold mode (away, home, temp, sleep, etc.).'
| def set_hold_mode(self, hold_mode):
| hold = self.current_hold_mode
if (hold == hold_mode):
return
elif ((hold_mode == 'None') or (hold_mode is None)):
if (hold == VACATION_HOLD):
self.data.ecobee.delete_vacation(self.thermostat_index, self.vacation)
else:
self.data.ecobee.resume_program(self.ther... |
'Set temperature hold in auto mode.'
| def set_auto_temp_hold(self, heat_temp, cool_temp):
| self.data.ecobee.set_hold_temp(self.thermostat_index, cool_temp, heat_temp, self.hold_preference())
_LOGGER.debug('Setting ecobee hold_temp to: heat=%s, is=%s, cool=%s, is=%s', heat_temp, isinstance(heat_temp, (int, float)), cool_temp, isinstance(cool_temp, (int, float)))
self.update_wi... |
'Set temperature hold in modes other than auto.'
| def set_temp_hold(self, temp):
| if (self.current_operation == STATE_HEAT):
heat_temp = temp
cool_temp = (temp + 20)
elif (self.current_operation == STATE_COOL):
heat_temp = (temp - 20)
cool_temp = temp
self.data.ecobee.set_hold_temp(self.thermostat_index, cool_temp, heat_temp, self.hold_preference())
_L... |
'Set new target temperature.'
| def set_temperature(self, **kwargs):
| low_temp = kwargs.get(ATTR_TARGET_TEMP_LOW)
high_temp = kwargs.get(ATTR_TARGET_TEMP_HIGH)
temp = kwargs.get(ATTR_TEMPERATURE)
if ((self.current_operation == STATE_AUTO) and (low_temp is not None) and (high_temp is not None)):
self.set_auto_temp_hold(int(low_temp), int(high_temp))
elif (temp ... |
'Set HVAC mode (auto, auxHeatOnly, cool, heat, off).'
| def set_operation_mode(self, operation_mode):
| self.data.ecobee.set_hvac_mode(self.thermostat_index, operation_mode)
self.update_without_throttle = True
|
'Set the minimum fan on time.'
| def set_fan_min_on_time(self, fan_min_on_time):
| self.data.ecobee.set_fan_min_on_time(self.thermostat_index, fan_min_on_time)
self.update_without_throttle = True
|
'Resume the thermostat schedule program.'
| def resume_program(self, resume_all):
| self.data.ecobee.resume_program(self.thermostat_index, str(resume_all).lower())
self.update_without_throttle = True
|
'Return user preference setting for hold time.'
| def hold_preference(self):
| default = self.thermostat['settings']['holdAction']
if (default == 'nextTransition'):
return default
return 'nextTransition'
|
'Return the list of climates currently available.'
| @property
def climate_list(self):
| climates = self.thermostat['program']['climates']
return list(map((lambda x: x['name']), climates))
|
'Return the unit of measurement that is used.'
| @property
def temperature_unit(self):
| return TEMP_CELSIUS
|
'Return current operation ie. heat, cool, idle.'
| @property
def current_operation(self):
| if (HM_CONTROL_MODE not in self._data):
return None
for (mode, state) in HM_STATE_MAP.items():
code = getattr(self._hmdevice, mode, 0)
if (self._data.get('CONTROL_MODE') == code):
return state
|
'Return the list of available operation modes.'
| @property
def operation_list(self):
| op_list = []
for mode in self._hmdevice.ACTIONNODE:
if (mode in HM_STATE_MAP):
op_list.append(HM_STATE_MAP.get(mode))
return op_list
|
'Return the current humidity.'
| @property
def current_humidity(self):
| for node in HM_HUMI_MAP:
if (node in self._data):
return self._data[node]
|
'Return the current temperature.'
| @property
def current_temperature(self):
| for node in HM_TEMP_MAP:
if (node in self._data):
return self._data[node]
|
'Return the target temperature.'
| @property
def target_temperature(self):
| return self._data.get(self._state)
|
'Set new target temperature.'
| def set_temperature(self, **kwargs):
| temperature = kwargs.get(ATTR_TEMPERATURE)
if (temperature is None):
return None
self._hmdevice.writeNodeData(self._state, float(temperature))
|
'Set new target operation mode.'
| def set_operation_mode(self, operation_mode):
| for (mode, state) in HM_STATE_MAP.items():
if (state == operation_mode):
code = getattr(self._hmdevice, mode, 0)
self._hmdevice.MODE = code
|
'Return the minimum temperature - 4.5 means off.'
| @property
def min_temp(self):
| return convert(4.5, TEMP_CELSIUS, self.unit_of_measurement)
|
'Return the maximum temperature - 30.5 means on.'
| @property
def max_temp(self):
| return convert(30.5, TEMP_CELSIUS, self.unit_of_measurement)
|
'Generate a data dict (self._data) from the Homematic metadata.'
| def _init_data_struct(self):
| self._state = next(iter(self._hmdevice.WRITENODE.keys()))
self._data[self._state] = STATE_UNKNOWN
if (HM_CONTROL_MODE in self._hmdevice.ATTRIBUTENODE):
self._data[HM_CONTROL_MODE] = STATE_UNKNOWN
for node in self._hmdevice.SENSORNODE.keys():
self._data[node] = STATE_UNKNOWN
|
'Initialize the thermostat.'
| def __init__(self, pdp):
| self._pdp = pdp
self._pdp.update()
self._name = self._pdp.name
|
'Set up polling needed for thermostat.'
| @property
def should_poll(self):
| return True
|
'Update the data from the thermostat.'
| def update(self):
| self._pdp.update()
|
'Return the name of the thermostat.'
| @property
def name(self):
| return self._name
|
'Return the precision of the system.
Proliphix temperature values are passed back and forth in the
API as tenths of degrees F (i.e. 690 for 69 degrees).'
| @property
def precision(self):
| return PRECISION_TENTHS
|
'Return the device specific state attributes.'
| @property
def device_state_attributes(self):
| return {ATTR_FAN: self._pdp.fan_state}
|
'Return the unit of measurement.'
| @property
def temperature_unit(self):
| return TEMP_FAHRENHEIT
|
'Return the current temperature.'
| @property
def current_temperature(self):
| return self._pdp.cur_temp
|
'Return the temperature we try to reach.'
| @property
def target_temperature(self):
| return self._pdp.setback
|
'Return the current state of the thermostat.'
| @property
def current_operation(self):
| state = self._pdp.hvac_state
if (state in (1, 2)):
return STATE_IDLE
elif (state == 3):
return STATE_HEAT
elif (state == 6):
return STATE_COOL
|
'Set new target temperature.'
| def set_temperature(self, **kwargs):
| temperature = kwargs.get(ATTR_TEMPERATURE)
if (temperature is None):
return
self._pdp.setback = temperature
|
'Return True if unable to access real state of entity.'
| @property
def assumed_state(self):
| return self.gateway.optimistic
|
'Return the unit of measurement.'
| @property
def temperature_unit(self):
| return (TEMP_CELSIUS if self.gateway.metric else TEMP_FAHRENHEIT)
|
'Return the current temperature.'
| @property
def current_temperature(self):
| value = self._values.get(self.gateway.const.SetReq.V_TEMP)
if (value is not None):
value = float(value)
return value
|
'Return the temperature we try to reach.'
| @property
def target_temperature(self):
| set_req = self.gateway.const.SetReq
if ((set_req.V_HVAC_SETPOINT_COOL in self._values) and (set_req.V_HVAC_SETPOINT_HEAT in self._values)):
return None
temp = self._values.get(set_req.V_HVAC_SETPOINT_COOL)
if (temp is None):
temp = self._values.get(set_req.V_HVAC_SETPOINT_HEAT)
retur... |
'Return the highbound target temperature we try to reach.'
| @property
def target_temperature_high(self):
| set_req = self.gateway.const.SetReq
if (set_req.V_HVAC_SETPOINT_HEAT in self._values):
return float(self._values.get(set_req.V_HVAC_SETPOINT_COOL))
|
'Return the lowbound target temperature we try to reach.'
| @property
def target_temperature_low(self):
| set_req = self.gateway.const.SetReq
if (set_req.V_HVAC_SETPOINT_COOL in self._values):
return float(self._values.get(set_req.V_HVAC_SETPOINT_HEAT))
|
'Return current operation ie. heat, cool, idle.'
| @property
def current_operation(self):
| return self._values.get(self.gateway.const.SetReq.V_HVAC_FLOW_STATE)
|
'List of available operation modes.'
| @property
def operation_list(self):
| return [STATE_OFF, STATE_AUTO, STATE_COOL, STATE_HEAT]
|
'Return the fan setting.'
| @property
def current_fan_mode(self):
| return self._values.get(self.gateway.const.SetReq.V_HVAC_SPEED)
|
'List of available fan modes.'
| @property
def fan_list(self):
| return ['Auto', 'Min', 'Normal', 'Max']
|
'Set new target temperature.'
| def set_temperature(self, **kwargs):
| set_req = self.gateway.const.SetReq
temp = kwargs.get(ATTR_TEMPERATURE)
low = kwargs.get(ATTR_TARGET_TEMP_LOW)
high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
heat = self._values.get(set_req.V_HVAC_SETPOINT_HEAT)
cool = self._values.get(set_req.V_HVAC_SETPOINT_COOL)
updates = ()
if (temp is not... |
'Set new target temperature.'
| def set_fan_mode(self, fan):
| set_req = self.gateway.const.SetReq
self.gateway.set_child_value(self.node_id, self.child_id, set_req.V_HVAC_SPEED, fan)
if self.gateway.optimistic:
self._values[set_req.V_HVAC_SPEED] = fan
self.schedule_update_ha_state()
|
'Set new target temperature.'
| def set_operation_mode(self, operation_mode):
| set_req = self.gateway.const.SetReq
self.gateway.set_child_value(self.node_id, self.child_id, set_req.V_HVAC_FLOW_STATE, DICT_HA_TO_MYS[operation_mode])
if self.gateway.optimistic:
self._values[set_req.V_HVAC_FLOW_STATE] = operation_mode
self.schedule_update_ha_state()
|
'Update the controller with the latest value from a sensor.'
| def update(self):
| set_req = self.gateway.const.SetReq
node = self.gateway.sensors[self.node_id]
child = node.children[self.child_id]
for (value_type, value) in child.values.items():
_LOGGER.debug('%s: value_type %s, value = %s', self._name, value_type, value)
if (value_type == set_req.V_HVA... |
'Set new target humidity.'
| def set_humidity(self, humidity):
| _LOGGER.error('Service Not Implemented yet')
|
'Set new target swing operation.'
| def set_swing_mode(self, swing_mode):
| _LOGGER.error('Service Not Implemented yet')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.