Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
sequence
start_point
sequence
end_point
sequence
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
test_whitelist_no_match
(mock_debug, hass)
Check whitelist filter with unmatched data, should not work.
Check whitelist filter with unmatched data, should not work.
async def test_whitelist_no_match(mock_debug, hass): """Check whitelist filter with unmatched data, should not work.""" with assert_setup_component(4): whitelist = { "protocol": ["wrong_protocol"], "id": [PilightDaemonSim.test_message["message"]["id"]], } assert await async_setup_component( hass, pilight.DOMAIN, {pilight.DOMAIN: {"whitelist": whitelist}} ) await hass.async_start() await hass.async_block_till_done() debug_log_call = mock_debug.call_args_list[-3] assert not ("Event pilight_received" in debug_log_call)
[ "async", "def", "test_whitelist_no_match", "(", "mock_debug", ",", "hass", ")", ":", "with", "assert_setup_component", "(", "4", ")", ":", "whitelist", "=", "{", "\"protocol\"", ":", "[", "\"wrong_protocol\"", "]", ",", "\"id\"", ":", "[", "PilightDaemonSim", ".", "test_message", "[", "\"message\"", "]", "[", "\"id\"", "]", "]", ",", "}", "assert", "await", "async_setup_component", "(", "hass", ",", "pilight", ".", "DOMAIN", ",", "{", "pilight", ".", "DOMAIN", ":", "{", "\"whitelist\"", ":", "whitelist", "}", "}", ")", "await", "hass", ".", "async_start", "(", ")", "await", "hass", ".", "async_block_till_done", "(", ")", "debug_log_call", "=", "mock_debug", ".", "call_args_list", "[", "-", "3", "]", "assert", "not", "(", "\"Event pilight_received\"", "in", "debug_log_call", ")" ]
[ 347, 0 ]
[ 362, 63 ]
python
en
['en', 'en', 'en']
True
test_call_rate_delay_throttle_enabled
(hass)
Test that throttling actually work.
Test that throttling actually work.
async def test_call_rate_delay_throttle_enabled(hass): """Test that throttling actually work.""" runs = [] delay = 5.0 limit = pilight.CallRateDelayThrottle(hass, delay) action = limit.limited(lambda x: runs.append(x)) for i in range(3): await hass.async_add_executor_job(action, i) await hass.async_block_till_done() assert runs == [0] exp = [] now = dt_util.utcnow() for i in range(3): exp.append(i) shifted_time = now + (timedelta(seconds=delay + 0.1) * i) async_fire_time_changed(hass, shifted_time) await hass.async_block_till_done() assert runs == exp
[ "async", "def", "test_call_rate_delay_throttle_enabled", "(", "hass", ")", ":", "runs", "=", "[", "]", "delay", "=", "5.0", "limit", "=", "pilight", ".", "CallRateDelayThrottle", "(", "hass", ",", "delay", ")", "action", "=", "limit", ".", "limited", "(", "lambda", "x", ":", "runs", ".", "append", "(", "x", ")", ")", "for", "i", "in", "range", "(", "3", ")", ":", "await", "hass", ".", "async_add_executor_job", "(", "action", ",", "i", ")", "await", "hass", ".", "async_block_till_done", "(", ")", "assert", "runs", "==", "[", "0", "]", "exp", "=", "[", "]", "now", "=", "dt_util", ".", "utcnow", "(", ")", "for", "i", "in", "range", "(", "3", ")", ":", "exp", ".", "append", "(", "i", ")", "shifted_time", "=", "now", "+", "(", "timedelta", "(", "seconds", "=", "delay", "+", "0.1", ")", "*", "i", ")", "async_fire_time_changed", "(", "hass", ",", "shifted_time", ")", "await", "hass", ".", "async_block_till_done", "(", ")", "assert", "runs", "==", "exp" ]
[ 365, 0 ]
[ 386, 26 ]
python
en
['en', 'en', 'en']
True
test_call_rate_delay_throttle_disabled
(hass)
Test that the limiter is a noop if no delay set.
Test that the limiter is a noop if no delay set.
def test_call_rate_delay_throttle_disabled(hass): """Test that the limiter is a noop if no delay set.""" runs = [] limit = pilight.CallRateDelayThrottle(hass, 0.0) action = limit.limited(lambda x: runs.append(x)) for i in range(3): action(i) assert runs == [0, 1, 2]
[ "def", "test_call_rate_delay_throttle_disabled", "(", "hass", ")", ":", "runs", "=", "[", "]", "limit", "=", "pilight", ".", "CallRateDelayThrottle", "(", "hass", ",", "0.0", ")", "action", "=", "limit", ".", "limited", "(", "lambda", "x", ":", "runs", ".", "append", "(", "x", ")", ")", "for", "i", "in", "range", "(", "3", ")", ":", "action", "(", "i", ")", "assert", "runs", "==", "[", "0", ",", "1", ",", "2", "]" ]
[ 389, 0 ]
[ 399, 28 ]
python
en
['en', 'en', 'en']
True
PilightDaemonSim.__init__
(self, host, port)
Init pilight client, ignore parameters.
Init pilight client, ignore parameters.
def __init__(self, host, port): """Init pilight client, ignore parameters."""
[ "def", "__init__", "(", "self", ",", "host", ",", "port", ")", ":" ]
[ 35, 4 ]
[ 36, 53 ]
python
en
['fr', 'la', 'en']
False
PilightDaemonSim.send_code
(self, call)
Handle pilight.send service callback.
Handle pilight.send service callback.
def send_code(self, call): # pylint: disable=no-self-use """Handle pilight.send service callback.""" _LOGGER.error("PilightDaemonSim payload: %s", call)
[ "def", "send_code", "(", "self", ",", "call", ")", ":", "# pylint: disable=no-self-use", "_LOGGER", ".", "error", "(", "\"PilightDaemonSim payload: %s\"", ",", "call", ")" ]
[ 38, 4 ]
[ 40, 59 ]
python
en
['en', 'ro', 'en']
True
PilightDaemonSim.start
(self)
Handle homeassistant.start callback. Also sends one test message after start up
Handle homeassistant.start callback.
def start(self): """Handle homeassistant.start callback. Also sends one test message after start up """ _LOGGER.error("PilightDaemonSim start") # Fake one code receive after daemon started if not self.called: self.callback(self.test_message) self.called = True
[ "def", "start", "(", "self", ")", ":", "_LOGGER", ".", "error", "(", "\"PilightDaemonSim start\"", ")", "# Fake one code receive after daemon started", "if", "not", "self", ".", "called", ":", "self", ".", "callback", "(", "self", ".", "test_message", ")", "self", ".", "called", "=", "True" ]
[ 42, 4 ]
[ 51, 30 ]
python
en
['en', 'da', 'en']
True
PilightDaemonSim.stop
(self)
Handle homeassistant.stop callback.
Handle homeassistant.stop callback.
def stop(self): # pylint: disable=no-self-use """Handle homeassistant.stop callback.""" _LOGGER.error("PilightDaemonSim stop")
[ "def", "stop", "(", "self", ")", ":", "# pylint: disable=no-self-use", "_LOGGER", ".", "error", "(", "\"PilightDaemonSim stop\"", ")" ]
[ 53, 4 ]
[ 55, 46 ]
python
en
['en', 'en', 'en']
True
PilightDaemonSim.set_callback
(self, function)
Handle pilight.pilight_received event callback.
Handle pilight.pilight_received event callback.
def set_callback(self, function): """Handle pilight.pilight_received event callback.""" self.callback = function _LOGGER.error("PilightDaemonSim callback: %s", function)
[ "def", "set_callback", "(", "self", ",", "function", ")", ":", "self", ".", "callback", "=", "function", "_LOGGER", ".", "error", "(", "\"PilightDaemonSim callback: %s\"", ",", "function", ")" ]
[ 57, 4 ]
[ 60, 64 ]
python
en
['en', 'en', 'en']
True
get_yml_content
(file_path)
Load yaml file content
Load yaml file content
def get_yml_content(file_path): '''Load yaml file content''' try: with open(file_path, 'r') as file: return yaml.safe_load(file) except yaml.scanner.ScannerError as err: print_error('yaml file format error!') print_error(err) exit(1) except Exception as exception: print_error(exception) exit(1)
[ "def", "get_yml_content", "(", "file_path", ")", ":", "try", ":", "with", "open", "(", "file_path", ",", "'r'", ")", "as", "file", ":", "return", "yaml", ".", "safe_load", "(", "file", ")", "except", "yaml", ".", "scanner", ".", "ScannerError", "as", "err", ":", "print_error", "(", "'yaml file format error!'", ")", "print_error", "(", "err", ")", "exit", "(", "1", ")", "except", "Exception", "as", "exception", ":", "print_error", "(", "exception", ")", "exit", "(", "1", ")" ]
[ 19, 0 ]
[ 30, 15 ]
python
en
['tr', 'en', 'sw']
False
get_json_content
(file_path)
Load json file content
Load json file content
def get_json_content(file_path): '''Load json file content''' try: with open(file_path, 'r') as file: return json.load(file) except TypeError as err: print_error('json file format error!') print_error(err) return None
[ "def", "get_json_content", "(", "file_path", ")", ":", "try", ":", "with", "open", "(", "file_path", ",", "'r'", ")", "as", "file", ":", "return", "json", ".", "load", "(", "file", ")", "except", "TypeError", "as", "err", ":", "print_error", "(", "'json file format error!'", ")", "print_error", "(", "err", ")", "return", "None" ]
[ 32, 0 ]
[ 40, 19 ]
python
en
['en', 'fr', 'sw']
False
print_error
(*content)
Print error information to screen
Print error information to screen
def print_error(*content): '''Print error information to screen''' print(Fore.RED + ERROR_INFO + ' '.join([str(c) for c in content]) + Fore.RESET)
[ "def", "print_error", "(", "*", "content", ")", ":", "print", "(", "Fore", ".", "RED", "+", "ERROR_INFO", "+", "' '", ".", "join", "(", "[", "str", "(", "c", ")", "for", "c", "in", "content", "]", ")", "+", "Fore", ".", "RESET", ")" ]
[ 43, 0 ]
[ 45, 83 ]
python
en
['en', 'en', 'en']
True
print_green
(*content)
Print information to screen in green
Print information to screen in green
def print_green(*content): '''Print information to screen in green''' print(Fore.GREEN + ' '.join([str(c) for c in content]) + Fore.RESET)
[ "def", "print_green", "(", "*", "content", ")", ":", "print", "(", "Fore", ".", "GREEN", "+", "' '", ".", "join", "(", "[", "str", "(", "c", ")", "for", "c", "in", "content", "]", ")", "+", "Fore", ".", "RESET", ")" ]
[ 47, 0 ]
[ 49, 72 ]
python
en
['en', 'en', 'en']
True
print_normal
(*content)
Print error information to screen
Print error information to screen
def print_normal(*content): '''Print error information to screen''' print(NORMAL_INFO, *content)
[ "def", "print_normal", "(", "*", "content", ")", ":", "print", "(", "NORMAL_INFO", ",", "*", "content", ")" ]
[ 51, 0 ]
[ 53, 32 ]
python
en
['en', 'en', 'en']
True
print_warning
(*content)
Print warning information to screen
Print warning information to screen
def print_warning(*content): '''Print warning information to screen''' print(Fore.YELLOW + WARNING_INFO + ' '.join([str(c) for c in content]) + Fore.RESET)
[ "def", "print_warning", "(", "*", "content", ")", ":", "print", "(", "Fore", ".", "YELLOW", "+", "WARNING_INFO", "+", "' '", ".", "join", "(", "[", "str", "(", "c", ")", "for", "c", "in", "content", "]", ")", "+", "Fore", ".", "RESET", ")" ]
[ 55, 0 ]
[ 57, 88 ]
python
en
['en', 'jv', 'en']
True
detect_process
(pid)
Detect if a process is alive
Detect if a process is alive
def detect_process(pid): '''Detect if a process is alive''' try: process = psutil.Process(pid) return process.is_running() except: return False
[ "def", "detect_process", "(", "pid", ")", ":", "try", ":", "process", "=", "psutil", ".", "Process", "(", "pid", ")", "return", "process", ".", "is_running", "(", ")", "except", ":", "return", "False" ]
[ 59, 0 ]
[ 65, 20 ]
python
en
['en', 'en', 'en']
True
detect_port
(port)
Detect if the port is used
Detect if the port is used
def detect_port(port): '''Detect if the port is used''' socket_test = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: socket_test.connect(('127.0.0.1', int(port))) socket_test.close() return True except: return False
[ "def", "detect_port", "(", "port", ")", ":", "socket_test", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "try", ":", "socket_test", ".", "connect", "(", "(", "'127.0.0.1'", ",", "int", "(", "port", ")", ")", ")", "socket_test", ".", "close", "(", ")", "return", "True", "except", ":", "return", "False" ]
[ 67, 0 ]
[ 75, 20 ]
python
en
['en', 'en', 'en']
True
generate_temp_dir
()
generate a temp folder
generate a temp folder
def generate_temp_dir(): '''generate a temp folder''' def generate_folder_name(): return os.path.join(tempfile.gettempdir(), 'nni', ''.join(random.sample(string.ascii_letters + string.digits, 8))) temp_dir = generate_folder_name() while os.path.exists(temp_dir): temp_dir = generate_folder_name() os.makedirs(temp_dir) return temp_dir
[ "def", "generate_temp_dir", "(", ")", ":", "def", "generate_folder_name", "(", ")", ":", "return", "os", ".", "path", ".", "join", "(", "tempfile", ".", "gettempdir", "(", ")", ",", "'nni'", ",", "''", ".", "join", "(", "random", ".", "sample", "(", "string", ".", "ascii_letters", "+", "string", ".", "digits", ",", "8", ")", ")", ")", "temp_dir", "=", "generate_folder_name", "(", ")", "while", "os", ".", "path", ".", "exists", "(", "temp_dir", ")", ":", "temp_dir", "=", "generate_folder_name", "(", ")", "os", ".", "makedirs", "(", "temp_dir", ")", "return", "temp_dir" ]
[ 83, 0 ]
[ 91, 19 ]
python
en
['en', 'co', 'en']
True
sense_to_mdi
(sense_icon)
Convert sense icon to mdi icon.
Convert sense icon to mdi icon.
def sense_to_mdi(sense_icon): """Convert sense icon to mdi icon.""" return "mdi:{}".format(MDI_ICONS.get(sense_icon, "power-plug"))
[ "def", "sense_to_mdi", "(", "sense_icon", ")", ":", "return", "\"mdi:{}\"", ".", "format", "(", "MDI_ICONS", ".", "get", "(", "sense_icon", ",", "\"power-plug\"", ")", ")" ]
[ 55, 0 ]
[ 57, 67 ]
python
el-Latn
['en', 'el-Latn', 'pt']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Sense sensor.
Set up the Sense sensor.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Sense sensor.""" data = hass.data[DOMAIN][config_entry.entry_id][SENSE_DATA] sense_devices_data = hass.data[DOMAIN][config_entry.entry_id][SENSE_DEVICES_DATA] trends_coordinator = hass.data[DOMAIN][config_entry.entry_id][ SENSE_TRENDS_COORDINATOR ] # Request only in case it takes longer # than 60s await trends_coordinator.async_request_refresh() sense_monitor_id = data.sense_monitor_id sense_devices = hass.data[DOMAIN][config_entry.entry_id][ SENSE_DISCOVERED_DEVICES_DATA ] devices = [ SenseEnergyDevice(sense_devices_data, device, sense_monitor_id) for device in sense_devices if device["tags"]["DeviceListAllowed"] == "true" ] for var in SENSOR_VARIANTS: name = ACTIVE_SENSOR_TYPE.name sensor_type = ACTIVE_SENSOR_TYPE.sensor_type is_production = var == PRODUCTION_ID unique_id = f"{sense_monitor_id}-active-{var}" devices.append( SenseActiveSensor( data, name, sensor_type, is_production, sense_monitor_id, var, unique_id ) ) for i in range(len(data.active_voltage)): devices.append(SenseVoltageSensor(data, i, sense_monitor_id)) for type_id in TRENDS_SENSOR_TYPES: typ = TRENDS_SENSOR_TYPES[type_id] for var in SENSOR_VARIANTS: name = typ.name sensor_type = typ.sensor_type is_production = var == PRODUCTION_ID unique_id = f"{sense_monitor_id}-{type_id}-{var}" devices.append( SenseTrendsSensor( data, name, sensor_type, is_production, trends_coordinator, unique_id, ) ) async_add_entities(devices)
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "[", "SENSE_DATA", "]", "sense_devices_data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "[", "SENSE_DEVICES_DATA", "]", "trends_coordinator", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "[", "SENSE_TRENDS_COORDINATOR", "]", "# Request only in case it takes longer", "# than 60s", "await", "trends_coordinator", ".", "async_request_refresh", "(", ")", "sense_monitor_id", "=", "data", ".", "sense_monitor_id", "sense_devices", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "[", "SENSE_DISCOVERED_DEVICES_DATA", "]", "devices", "=", "[", "SenseEnergyDevice", "(", "sense_devices_data", ",", "device", ",", "sense_monitor_id", ")", "for", "device", "in", "sense_devices", "if", "device", "[", "\"tags\"", "]", "[", "\"DeviceListAllowed\"", "]", "==", "\"true\"", "]", "for", "var", "in", "SENSOR_VARIANTS", ":", "name", "=", "ACTIVE_SENSOR_TYPE", ".", "name", "sensor_type", "=", "ACTIVE_SENSOR_TYPE", ".", "sensor_type", "is_production", "=", "var", "==", "PRODUCTION_ID", "unique_id", "=", "f\"{sense_monitor_id}-active-{var}\"", "devices", ".", "append", "(", "SenseActiveSensor", "(", "data", ",", "name", ",", "sensor_type", ",", "is_production", ",", "sense_monitor_id", ",", "var", ",", "unique_id", ")", ")", "for", "i", "in", "range", "(", "len", "(", "data", ".", "active_voltage", ")", ")", ":", "devices", ".", "append", "(", "SenseVoltageSensor", "(", "data", ",", "i", ",", "sense_monitor_id", ")", ")", "for", "type_id", "in", "TRENDS_SENSOR_TYPES", ":", "typ", "=", "TRENDS_SENSOR_TYPES", "[", "type_id", "]", "for", "var", "in", "SENSOR_VARIANTS", ":", "name", "=", "typ", ".", "name", "sensor_type", "=", "typ", ".", "sensor_type", "is_production", "=", "var", "==", "PRODUCTION_ID", "unique_id", "=", "f\"{sense_monitor_id}-{type_id}-{var}\"", "devices", ".", "append", "(", "SenseTrendsSensor", "(", "data", ",", "name", ",", "sensor_type", ",", "is_production", ",", "trends_coordinator", ",", "unique_id", ",", ")", ")", "async_add_entities", "(", "devices", ")" ]
[ 60, 0 ]
[ 117, 31 ]
python
en
['en', 'sq', 'en']
True
SensorConfig.__init__
(self, name, sensor_type)
Sensor name and type to pass to API.
Sensor name and type to pass to API.
def __init__(self, name, sensor_type): """Sensor name and type to pass to API.""" self.name = name self.sensor_type = sensor_type
[ "def", "__init__", "(", "self", ",", "name", ",", "sensor_type", ")", ":", "self", ".", "name", "=", "name", "self", ".", "sensor_type", "=", "sensor_type" ]
[ 34, 4 ]
[ 37, 38 ]
python
en
['en', 'mi', 'en']
True
SenseActiveSensor.__init__
( self, data, name, sensor_type, is_production, sense_monitor_id, sensor_id, unique_id, )
Initialize the Sense sensor.
Initialize the Sense sensor.
def __init__( self, data, name, sensor_type, is_production, sense_monitor_id, sensor_id, unique_id, ): """Initialize the Sense sensor.""" name_type = PRODUCTION_NAME if is_production else CONSUMPTION_NAME self._name = f"{name} {name_type}" self._unique_id = unique_id self._available = False self._data = data self._sense_monitor_id = sense_monitor_id self._sensor_type = sensor_type self._is_production = is_production self._state = None
[ "def", "__init__", "(", "self", ",", "data", ",", "name", ",", "sensor_type", ",", "is_production", ",", "sense_monitor_id", ",", "sensor_id", ",", "unique_id", ",", ")", ":", "name_type", "=", "PRODUCTION_NAME", "if", "is_production", "else", "CONSUMPTION_NAME", "self", ".", "_name", "=", "f\"{name} {name_type}\"", "self", ".", "_unique_id", "=", "unique_id", "self", ".", "_available", "=", "False", "self", ".", "_data", "=", "data", "self", ".", "_sense_monitor_id", "=", "sense_monitor_id", "self", ".", "_sensor_type", "=", "sensor_type", "self", ".", "_is_production", "=", "is_production", "self", ".", "_state", "=", "None" ]
[ 123, 4 ]
[ 142, 26 ]
python
en
['en', 'sq', 'en']
True
SenseActiveSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 145, 4 ]
[ 147, 25 ]
python
en
['en', 'mi', 'en']
True
SenseActiveSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 150, 4 ]
[ 152, 26 ]
python
en
['en', 'en', 'en']
True
SenseActiveSensor.available
(self)
Return the availability of the sensor.
Return the availability of the sensor.
def available(self): """Return the availability of the sensor.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 155, 4 ]
[ 157, 30 ]
python
en
['en', 'ga', 'en']
True
SenseActiveSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return POWER_WATT
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "POWER_WATT" ]
[ 160, 4 ]
[ 162, 25 ]
python
en
['en', 'en', 'en']
True
SenseActiveSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return {ATTR_ATTRIBUTION: ATTRIBUTION}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", "}" ]
[ 165, 4 ]
[ 167, 46 ]
python
en
['en', 'en', 'en']
True
SenseActiveSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 170, 4 ]
[ 172, 19 ]
python
en
['en', 'en', 'en']
True
SenseActiveSensor.unique_id
(self)
Return the unique id.
Return the unique id.
def unique_id(self): """Return the unique id.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 175, 4 ]
[ 177, 30 ]
python
en
['en', 'la', 'en']
True
SenseActiveSensor.should_poll
(self)
Return the device should not poll for updates.
Return the device should not poll for updates.
def should_poll(self): """Return the device should not poll for updates.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 180, 4 ]
[ 182, 20 ]
python
en
['en', 'en', 'en']
True
SenseActiveSensor.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self): """Register callbacks.""" self.async_on_remove( async_dispatcher_connect( self.hass, f"{SENSE_DEVICE_UPDATE}-{self._sense_monitor_id}", self._async_update_from_data, ) )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "f\"{SENSE_DEVICE_UPDATE}-{self._sense_monitor_id}\"", ",", "self", ".", "_async_update_from_data", ",", ")", ")" ]
[ 184, 4 ]
[ 192, 9 ]
python
en
['en', 'no', 'en']
False
SenseActiveSensor._async_update_from_data
(self)
Update the sensor from the data. Must not do I/O.
Update the sensor from the data. Must not do I/O.
def _async_update_from_data(self): """Update the sensor from the data. Must not do I/O.""" new_state = round( self._data.active_solar_power if self._is_production else self._data.active_power ) if self._available and self._state == new_state: return self._state = new_state self._available = True self.async_write_ha_state()
[ "def", "_async_update_from_data", "(", "self", ")", ":", "new_state", "=", "round", "(", "self", ".", "_data", ".", "active_solar_power", "if", "self", ".", "_is_production", "else", "self", ".", "_data", ".", "active_power", ")", "if", "self", ".", "_available", "and", "self", ".", "_state", "==", "new_state", ":", "return", "self", ".", "_state", "=", "new_state", "self", ".", "_available", "=", "True", "self", ".", "async_write_ha_state", "(", ")" ]
[ 195, 4 ]
[ 206, 35 ]
python
en
['en', 'en', 'en']
True
SenseVoltageSensor.__init__
( self, data, index, sense_monitor_id, )
Initialize the Sense sensor.
Initialize the Sense sensor.
def __init__( self, data, index, sense_monitor_id, ): """Initialize the Sense sensor.""" line_num = index + 1 self._name = f"L{line_num} Voltage" self._unique_id = f"{sense_monitor_id}-L{line_num}" self._available = False self._data = data self._sense_monitor_id = sense_monitor_id self._voltage_index = index self._state = None
[ "def", "__init__", "(", "self", ",", "data", ",", "index", ",", "sense_monitor_id", ",", ")", ":", "line_num", "=", "index", "+", "1", "self", ".", "_name", "=", "f\"L{line_num} Voltage\"", "self", ".", "_unique_id", "=", "f\"{sense_monitor_id}-L{line_num}\"", "self", ".", "_available", "=", "False", "self", ".", "_data", "=", "data", "self", ".", "_sense_monitor_id", "=", "sense_monitor_id", "self", ".", "_voltage_index", "=", "index", "self", ".", "_state", "=", "None" ]
[ 212, 4 ]
[ 226, 26 ]
python
en
['en', 'sq', 'en']
True
SenseVoltageSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 229, 4 ]
[ 231, 25 ]
python
en
['en', 'mi', 'en']
True
SenseVoltageSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 234, 4 ]
[ 236, 26 ]
python
en
['en', 'en', 'en']
True
SenseVoltageSensor.available
(self)
Return the availability of the sensor.
Return the availability of the sensor.
def available(self): """Return the availability of the sensor.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 239, 4 ]
[ 241, 30 ]
python
en
['en', 'ga', 'en']
True
SenseVoltageSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return VOLT
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "VOLT" ]
[ 244, 4 ]
[ 246, 19 ]
python
en
['en', 'en', 'en']
True
SenseVoltageSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return {ATTR_ATTRIBUTION: ATTRIBUTION}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", "}" ]
[ 249, 4 ]
[ 251, 46 ]
python
en
['en', 'en', 'en']
True
SenseVoltageSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 254, 4 ]
[ 256, 19 ]
python
en
['en', 'en', 'en']
True
SenseVoltageSensor.unique_id
(self)
Return the unique id.
Return the unique id.
def unique_id(self): """Return the unique id.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 259, 4 ]
[ 261, 30 ]
python
en
['en', 'la', 'en']
True
SenseVoltageSensor.should_poll
(self)
Return the device should not poll for updates.
Return the device should not poll for updates.
def should_poll(self): """Return the device should not poll for updates.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 264, 4 ]
[ 266, 20 ]
python
en
['en', 'en', 'en']
True
SenseVoltageSensor.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self): """Register callbacks.""" self.async_on_remove( async_dispatcher_connect( self.hass, f"{SENSE_DEVICE_UPDATE}-{self._sense_monitor_id}", self._async_update_from_data, ) )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "f\"{SENSE_DEVICE_UPDATE}-{self._sense_monitor_id}\"", ",", "self", ".", "_async_update_from_data", ",", ")", ")" ]
[ 268, 4 ]
[ 276, 9 ]
python
en
['en', 'no', 'en']
False
SenseVoltageSensor._async_update_from_data
(self)
Update the sensor from the data. Must not do I/O.
Update the sensor from the data. Must not do I/O.
def _async_update_from_data(self): """Update the sensor from the data. Must not do I/O.""" new_state = round(self._data.active_voltage[self._voltage_index], 1) if self._available and self._state == new_state: return self._available = True self._state = new_state self.async_write_ha_state()
[ "def", "_async_update_from_data", "(", "self", ")", ":", "new_state", "=", "round", "(", "self", ".", "_data", ".", "active_voltage", "[", "self", ".", "_voltage_index", "]", ",", "1", ")", "if", "self", ".", "_available", "and", "self", ".", "_state", "==", "new_state", ":", "return", "self", ".", "_available", "=", "True", "self", ".", "_state", "=", "new_state", "self", ".", "async_write_ha_state", "(", ")" ]
[ 279, 4 ]
[ 286, 35 ]
python
en
['en', 'en', 'en']
True
SenseTrendsSensor.__init__
( self, data, name, sensor_type, is_production, trends_coordinator, unique_id, )
Initialize the Sense sensor.
Initialize the Sense sensor.
def __init__( self, data, name, sensor_type, is_production, trends_coordinator, unique_id, ): """Initialize the Sense sensor.""" name_type = PRODUCTION_NAME if is_production else CONSUMPTION_NAME self._name = f"{name} {name_type}" self._unique_id = unique_id self._available = False self._data = data self._sensor_type = sensor_type self._coordinator = trends_coordinator self._is_production = is_production self._state = None self._unit_of_measurement = ENERGY_KILO_WATT_HOUR self._had_any_update = False
[ "def", "__init__", "(", "self", ",", "data", ",", "name", ",", "sensor_type", ",", "is_production", ",", "trends_coordinator", ",", "unique_id", ",", ")", ":", "name_type", "=", "PRODUCTION_NAME", "if", "is_production", "else", "CONSUMPTION_NAME", "self", ".", "_name", "=", "f\"{name} {name_type}\"", "self", ".", "_unique_id", "=", "unique_id", "self", ".", "_available", "=", "False", "self", ".", "_data", "=", "data", "self", ".", "_sensor_type", "=", "sensor_type", "self", ".", "_coordinator", "=", "trends_coordinator", "self", ".", "_is_production", "=", "is_production", "self", ".", "_state", "=", "None", "self", ".", "_unit_of_measurement", "=", "ENERGY_KILO_WATT_HOUR", "self", ".", "_had_any_update", "=", "False" ]
[ 292, 4 ]
[ 312, 36 ]
python
en
['en', 'sq', 'en']
True
SenseTrendsSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 315, 4 ]
[ 317, 25 ]
python
en
['en', 'mi', 'en']
True
SenseTrendsSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return round(self._data.get_trend(self._sensor_type, self._is_production), 1)
[ "def", "state", "(", "self", ")", ":", "return", "round", "(", "self", ".", "_data", ".", "get_trend", "(", "self", ".", "_sensor_type", ",", "self", ".", "_is_production", ")", ",", "1", ")" ]
[ 320, 4 ]
[ 322, 85 ]
python
en
['en', 'en', 'en']
True
SenseTrendsSensor.available
(self)
Return if entity is available.
Return if entity is available.
def available(self): """Return if entity is available.""" return self._had_any_update and self._coordinator.last_update_success
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_had_any_update", "and", "self", ".", "_coordinator", ".", "last_update_success" ]
[ 325, 4 ]
[ 327, 77 ]
python
en
['en', 'en', 'en']
True
SenseTrendsSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 330, 4 ]
[ 332, 40 ]
python
en
['en', 'en', 'en']
True
SenseTrendsSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return {ATTR_ATTRIBUTION: ATTRIBUTION}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", "}" ]
[ 335, 4 ]
[ 337, 46 ]
python
en
['en', 'en', 'en']
True
SenseTrendsSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 340, 4 ]
[ 342, 19 ]
python
en
['en', 'en', 'en']
True
SenseTrendsSensor.unique_id
(self)
Return the unique id.
Return the unique id.
def unique_id(self): """Return the unique id.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 345, 4 ]
[ 347, 30 ]
python
en
['en', 'la', 'en']
True
SenseTrendsSensor.should_poll
(self)
No need to poll. Coordinator notifies entity of updates.
No need to poll. Coordinator notifies entity of updates.
def should_poll(self): """No need to poll. Coordinator notifies entity of updates.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 350, 4 ]
[ 352, 20 ]
python
en
['en', 'en', 'en']
True
SenseTrendsSensor._async_update
(self)
Track if we had an update so we do not report zero data.
Track if we had an update so we do not report zero data.
def _async_update(self): """Track if we had an update so we do not report zero data.""" self._had_any_update = True self.async_write_ha_state()
[ "def", "_async_update", "(", "self", ")", ":", "self", ".", "_had_any_update", "=", "True", "self", ".", "async_write_ha_state", "(", ")" ]
[ 355, 4 ]
[ 358, 35 ]
python
en
['br', 'en', 'en']
True
SenseTrendsSensor.async_update
(self)
Update the entity. Only used by the generic entity update service.
Update the entity.
async def async_update(self): """Update the entity. Only used by the generic entity update service. """ await self._coordinator.async_request_refresh()
[ "async", "def", "async_update", "(", "self", ")", ":", "await", "self", ".", "_coordinator", ".", "async_request_refresh", "(", ")" ]
[ 360, 4 ]
[ 365, 55 ]
python
en
['en', 'en', 'en']
True
SenseTrendsSensor.async_added_to_hass
(self)
When entity is added to hass.
When entity is added to hass.
async def async_added_to_hass(self): """When entity is added to hass.""" self.async_on_remove(self._coordinator.async_add_listener(self._async_update))
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "self", ".", "_coordinator", ".", "async_add_listener", "(", "self", ".", "_async_update", ")", ")" ]
[ 367, 4 ]
[ 369, 86 ]
python
en
['en', 'en', 'en']
True
SenseEnergyDevice.__init__
(self, sense_devices_data, device, sense_monitor_id)
Initialize the Sense binary sensor.
Initialize the Sense binary sensor.
def __init__(self, sense_devices_data, device, sense_monitor_id): """Initialize the Sense binary sensor.""" self._name = f"{device['name']} {CONSUMPTION_NAME}" self._id = device["id"] self._available = False self._sense_monitor_id = sense_monitor_id self._unique_id = f"{sense_monitor_id}-{self._id}-{CONSUMPTION_ID}" self._icon = sense_to_mdi(device["icon"]) self._sense_devices_data = sense_devices_data self._state = None
[ "def", "__init__", "(", "self", ",", "sense_devices_data", ",", "device", ",", "sense_monitor_id", ")", ":", "self", ".", "_name", "=", "f\"{device['name']} {CONSUMPTION_NAME}\"", "self", ".", "_id", "=", "device", "[", "\"id\"", "]", "self", ".", "_available", "=", "False", "self", ".", "_sense_monitor_id", "=", "sense_monitor_id", "self", ".", "_unique_id", "=", "f\"{sense_monitor_id}-{self._id}-{CONSUMPTION_ID}\"", "self", ".", "_icon", "=", "sense_to_mdi", "(", "device", "[", "\"icon\"", "]", ")", "self", ".", "_sense_devices_data", "=", "sense_devices_data", "self", ".", "_state", "=", "None" ]
[ 375, 4 ]
[ 384, 26 ]
python
en
['en', 'pt', 'en']
True
SenseEnergyDevice.state
(self)
Return the wattage of the sensor.
Return the wattage of the sensor.
def state(self): """Return the wattage of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 387, 4 ]
[ 389, 26 ]
python
en
['en', 'ja', 'en']
True
SenseEnergyDevice.available
(self)
Return the availability of the sensor.
Return the availability of the sensor.
def available(self): """Return the availability of the sensor.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 392, 4 ]
[ 394, 30 ]
python
en
['en', 'ga', 'en']
True
SenseEnergyDevice.name
(self)
Return the name of the power sensor.
Return the name of the power sensor.
def name(self): """Return the name of the power sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 397, 4 ]
[ 399, 25 ]
python
en
['en', 'mi', 'en']
True
SenseEnergyDevice.unique_id
(self)
Return the unique id of the power sensor.
Return the unique id of the power sensor.
def unique_id(self): """Return the unique id of the power sensor.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 402, 4 ]
[ 404, 30 ]
python
en
['en', 'en', 'en']
True
SenseEnergyDevice.icon
(self)
Return the icon of the power sensor.
Return the icon of the power sensor.
def icon(self): """Return the icon of the power sensor.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 407, 4 ]
[ 409, 25 ]
python
en
['en', 'en', 'en']
True
SenseEnergyDevice.unit_of_measurement
(self)
Return the unit of measurement of this entity.
Return the unit of measurement of this entity.
def unit_of_measurement(self): """Return the unit of measurement of this entity.""" return POWER_WATT
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "POWER_WATT" ]
[ 412, 4 ]
[ 414, 25 ]
python
en
['en', 'en', 'en']
True
SenseEnergyDevice.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return {ATTR_ATTRIBUTION: ATTRIBUTION}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", "}" ]
[ 417, 4 ]
[ 419, 46 ]
python
en
['en', 'en', 'en']
True
SenseEnergyDevice.device_class
(self)
Return the device class of the power sensor.
Return the device class of the power sensor.
def device_class(self): """Return the device class of the power sensor.""" return DEVICE_CLASS_POWER
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_POWER" ]
[ 422, 4 ]
[ 424, 33 ]
python
en
['en', 'en', 'en']
True
SenseEnergyDevice.should_poll
(self)
Return the device should not poll for updates.
Return the device should not poll for updates.
def should_poll(self): """Return the device should not poll for updates.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 427, 4 ]
[ 429, 20 ]
python
en
['en', 'en', 'en']
True
SenseEnergyDevice.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self): """Register callbacks.""" self.async_on_remove( async_dispatcher_connect( self.hass, f"{SENSE_DEVICE_UPDATE}-{self._sense_monitor_id}", self._async_update_from_data, ) )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "f\"{SENSE_DEVICE_UPDATE}-{self._sense_monitor_id}\"", ",", "self", ".", "_async_update_from_data", ",", ")", ")" ]
[ 431, 4 ]
[ 439, 9 ]
python
en
['en', 'no', 'en']
False
SenseEnergyDevice._async_update_from_data
(self)
Get the latest data, update state. Must not do I/O.
Get the latest data, update state. Must not do I/O.
def _async_update_from_data(self): """Get the latest data, update state. Must not do I/O.""" device_data = self._sense_devices_data.get_device_by_id(self._id) if not device_data or "w" not in device_data: new_state = 0 else: new_state = int(device_data["w"]) if self._available and self._state == new_state: return self._state = new_state self._available = True self.async_write_ha_state()
[ "def", "_async_update_from_data", "(", "self", ")", ":", "device_data", "=", "self", ".", "_sense_devices_data", ".", "get_device_by_id", "(", "self", ".", "_id", ")", "if", "not", "device_data", "or", "\"w\"", "not", "in", "device_data", ":", "new_state", "=", "0", "else", ":", "new_state", "=", "int", "(", "device_data", "[", "\"w\"", "]", ")", "if", "self", ".", "_available", "and", "self", ".", "_state", "==", "new_state", ":", "return", "self", ".", "_state", "=", "new_state", "self", ".", "_available", "=", "True", "self", ".", "async_write_ha_state", "(", ")" ]
[ 442, 4 ]
[ 453, 35 ]
python
en
['en', 'en', 'en']
True
TotalConnectConfigFlow.async_step_user
(self, user_input=None)
Handle a flow initiated by the user.
Handle a flow initiated by the user.
async def async_step_user(self, user_input=None): """Handle a flow initiated by the user.""" errors = {} if user_input is not None: # Validate user input username = user_input[CONF_USERNAME] password = user_input[CONF_PASSWORD] await self.async_set_unique_id(username) self._abort_if_unique_id_configured() valid = await self.is_valid(username, password) if valid: # authentication success / valid return self.async_create_entry( title="Total Connect", data={CONF_USERNAME: username, CONF_PASSWORD: password}, ) # authentication failed / invalid errors["base"] = "invalid_auth" data_schema = vol.Schema( {vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str} ) return self.async_show_form( step_id="user", data_schema=data_schema, errors=errors )
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "# Validate user input", "username", "=", "user_input", "[", "CONF_USERNAME", "]", "password", "=", "user_input", "[", "CONF_PASSWORD", "]", "await", "self", ".", "async_set_unique_id", "(", "username", ")", "self", ".", "_abort_if_unique_id_configured", "(", ")", "valid", "=", "await", "self", ".", "is_valid", "(", "username", ",", "password", ")", "if", "valid", ":", "# authentication success / valid", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"Total Connect\"", ",", "data", "=", "{", "CONF_USERNAME", ":", "username", ",", "CONF_PASSWORD", ":", "password", "}", ",", ")", "# authentication failed / invalid", "errors", "[", "\"base\"", "]", "=", "\"invalid_auth\"", "data_schema", "=", "vol", ".", "Schema", "(", "{", "vol", ".", "Required", "(", "CONF_USERNAME", ")", ":", "str", ",", "vol", ".", "Required", "(", "CONF_PASSWORD", ")", ":", "str", "}", ")", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"user\"", ",", "data_schema", "=", "data_schema", ",", "errors", "=", "errors", ")" ]
[ 15, 4 ]
[ 44, 9 ]
python
en
['en', 'en', 'en']
True
TotalConnectConfigFlow.async_step_import
(self, user_input)
Import a config entry.
Import a config entry.
async def async_step_import(self, user_input): """Import a config entry.""" return await self.async_step_user(user_input)
[ "async", "def", "async_step_import", "(", "self", ",", "user_input", ")", ":", "return", "await", "self", ".", "async_step_user", "(", "user_input", ")" ]
[ 46, 4 ]
[ 48, 53 ]
python
en
['en', 'en', 'en']
True
TotalConnectConfigFlow.is_valid
(self, username="", password="")
Return true if the given username and password are valid.
Return true if the given username and password are valid.
async def is_valid(self, username="", password=""): """Return true if the given username and password are valid.""" client = await self.hass.async_add_executor_job( TotalConnectClient.TotalConnectClient, username, password ) return client.is_valid_credentials()
[ "async", "def", "is_valid", "(", "self", ",", "username", "=", "\"\"", ",", "password", "=", "\"\"", ")", ":", "client", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "TotalConnectClient", ".", "TotalConnectClient", ",", "username", ",", "password", ")", "return", "client", ".", "is_valid_credentials", "(", ")" ]
[ 50, 4 ]
[ 55, 44 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistant, config: dict)
Set up the Aurora component.
Set up the Aurora component.
async def async_setup(hass: HomeAssistant, config: dict): """Set up the Aurora component.""" hass.data.setdefault(DOMAIN, {}) return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ")", ":", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "return", "True" ]
[ 29, 0 ]
[ 33, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Aurora from a config entry.
Set up Aurora from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Aurora from a config entry.""" conf = entry.data options = entry.options session = aiohttp_client.async_get_clientsession(hass) api = AuroraForecast(session) longitude = conf[CONF_LONGITUDE] latitude = conf[CONF_LATITUDE] polling_interval = DEFAULT_POLLING_INTERVAL threshold = options.get(CONF_THRESHOLD, DEFAULT_THRESHOLD) name = conf[CONF_NAME] coordinator = AuroraDataUpdateCoordinator( hass=hass, name=name, polling_interval=polling_interval, api=api, latitude=latitude, longitude=longitude, threshold=threshold, ) await coordinator.async_refresh() if not coordinator.last_update_success: raise ConfigEntryNotReady hass.data[DOMAIN][entry.entry_id] = { COORDINATOR: coordinator, AURORA_API: api, } for component in PLATFORMS: hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, component) ) return True
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "conf", "=", "entry", ".", "data", "options", "=", "entry", ".", "options", "session", "=", "aiohttp_client", ".", "async_get_clientsession", "(", "hass", ")", "api", "=", "AuroraForecast", "(", "session", ")", "longitude", "=", "conf", "[", "CONF_LONGITUDE", "]", "latitude", "=", "conf", "[", "CONF_LATITUDE", "]", "polling_interval", "=", "DEFAULT_POLLING_INTERVAL", "threshold", "=", "options", ".", "get", "(", "CONF_THRESHOLD", ",", "DEFAULT_THRESHOLD", ")", "name", "=", "conf", "[", "CONF_NAME", "]", "coordinator", "=", "AuroraDataUpdateCoordinator", "(", "hass", "=", "hass", ",", "name", "=", "name", ",", "polling_interval", "=", "polling_interval", ",", "api", "=", "api", ",", "latitude", "=", "latitude", ",", "longitude", "=", "longitude", ",", "threshold", "=", "threshold", ",", ")", "await", "coordinator", ".", "async_refresh", "(", ")", "if", "not", "coordinator", ".", "last_update_success", ":", "raise", "ConfigEntryNotReady", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "=", "{", "COORDINATOR", ":", "coordinator", ",", "AURORA_API", ":", "api", ",", "}", "for", "component", "in", "PLATFORMS", ":", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "async_forward_entry_setup", "(", "entry", ",", "component", ")", ")", "return", "True" ]
[ 36, 0 ]
[ 76, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, component) for component in PLATFORMS ] ) ) if unload_ok: hass.data[DOMAIN].pop(entry.entry_id) return unload_ok
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload", "(", "entry", ",", "component", ")", "for", "component", "in", "PLATFORMS", "]", ")", ")", "if", "unload_ok", ":", "hass", ".", "data", "[", "DOMAIN", "]", ".", "pop", "(", "entry", ".", "entry_id", ")", "return", "unload_ok" ]
[ 79, 0 ]
[ 92, 20 ]
python
en
['en', 'es', 'en']
True
AuroraDataUpdateCoordinator.__init__
( self, hass: HomeAssistant, name: str, polling_interval: int, api: str, latitude: float, longitude: float, threshold: float, )
Initialize the data updater.
Initialize the data updater.
def __init__( self, hass: HomeAssistant, name: str, polling_interval: int, api: str, latitude: float, longitude: float, threshold: float, ): """Initialize the data updater.""" super().__init__( hass=hass, logger=_LOGGER, name=name, update_interval=timedelta(minutes=polling_interval), ) self.api = api self.name = name self.latitude = int(latitude) self.longitude = int(longitude) self.threshold = int(threshold)
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "name", ":", "str", ",", "polling_interval", ":", "int", ",", "api", ":", "str", ",", "latitude", ":", "float", ",", "longitude", ":", "float", ",", "threshold", ":", "float", ",", ")", ":", "super", "(", ")", ".", "__init__", "(", "hass", "=", "hass", ",", "logger", "=", "_LOGGER", ",", "name", "=", "name", ",", "update_interval", "=", "timedelta", "(", "minutes", "=", "polling_interval", ")", ",", ")", "self", ".", "api", "=", "api", "self", ".", "name", "=", "name", "self", ".", "latitude", "=", "int", "(", "latitude", ")", "self", ".", "longitude", "=", "int", "(", "longitude", ")", "self", ".", "threshold", "=", "int", "(", "threshold", ")" ]
[ 98, 4 ]
[ 121, 39 ]
python
en
['en', 'en', 'en']
True
AuroraDataUpdateCoordinator._async_update_data
(self)
Fetch the data from the NOAA Aurora Forecast.
Fetch the data from the NOAA Aurora Forecast.
async def _async_update_data(self): """Fetch the data from the NOAA Aurora Forecast.""" try: return await self.api.get_forecast_data(self.longitude, self.latitude) except ConnectionError as error: raise UpdateFailed(f"Error updating from NOAA: {error}") from error
[ "async", "def", "_async_update_data", "(", "self", ")", ":", "try", ":", "return", "await", "self", ".", "api", ".", "get_forecast_data", "(", "self", ".", "longitude", ",", "self", ".", "latitude", ")", "except", "ConnectionError", "as", "error", ":", "raise", "UpdateFailed", "(", "f\"Error updating from NOAA: {error}\"", ")", "from", "error" ]
[ 123, 4 ]
[ 129, 79 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Venstar thermostat.
Set up the Venstar thermostat.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Venstar thermostat.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) pin = config.get(CONF_PIN) host = config.get(CONF_HOST) timeout = config.get(CONF_TIMEOUT) humidifier = config.get(CONF_HUMIDIFIER) protocol = "https" if config[CONF_SSL] else "http" client = VenstarColorTouch( addr=host, timeout=timeout, user=username, password=password, pin=pin, proto=protocol, ) add_entities([VenstarThermostat(client, humidifier)], True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "username", "=", "config", ".", "get", "(", "CONF_USERNAME", ")", "password", "=", "config", ".", "get", "(", "CONF_PASSWORD", ")", "pin", "=", "config", ".", "get", "(", "CONF_PIN", ")", "host", "=", "config", ".", "get", "(", "CONF_HOST", ")", "timeout", "=", "config", ".", "get", "(", "CONF_TIMEOUT", ")", "humidifier", "=", "config", ".", "get", "(", "CONF_HUMIDIFIER", ")", "protocol", "=", "\"https\"", "if", "config", "[", "CONF_SSL", "]", "else", "\"http\"", "client", "=", "VenstarColorTouch", "(", "addr", "=", "host", ",", "timeout", "=", "timeout", ",", "user", "=", "username", ",", "password", "=", "password", ",", "pin", "=", "pin", ",", "proto", "=", "protocol", ",", ")", "add_entities", "(", "[", "VenstarThermostat", "(", "client", ",", "humidifier", ")", "]", ",", "True", ")" ]
[ 74, 0 ]
[ 95, 63 ]
python
en
['en', 'cs', 'en']
True
VenstarThermostat.__init__
(self, client, humidifier)
Initialize the thermostat.
Initialize the thermostat.
def __init__(self, client, humidifier): """Initialize the thermostat.""" self._client = client self._humidifier = humidifier self._mode_map = { HVAC_MODE_HEAT: self._client.MODE_HEAT, HVAC_MODE_COOL: self._client.MODE_COOL, HVAC_MODE_AUTO: self._client.MODE_AUTO, }
[ "def", "__init__", "(", "self", ",", "client", ",", "humidifier", ")", ":", "self", ".", "_client", "=", "client", "self", ".", "_humidifier", "=", "humidifier", "self", ".", "_mode_map", "=", "{", "HVAC_MODE_HEAT", ":", "self", ".", "_client", ".", "MODE_HEAT", ",", "HVAC_MODE_COOL", ":", "self", ".", "_client", ".", "MODE_COOL", ",", "HVAC_MODE_AUTO", ":", "self", ".", "_client", ".", "MODE_AUTO", ",", "}" ]
[ 101, 4 ]
[ 109, 9 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.update
(self)
Update the data from the thermostat.
Update the data from the thermostat.
def update(self): """Update the data from the thermostat.""" info_success = self._client.update_info() sensor_success = self._client.update_sensors() if not info_success or not sensor_success: _LOGGER.error("Failed to update data")
[ "def", "update", "(", "self", ")", ":", "info_success", "=", "self", ".", "_client", ".", "update_info", "(", ")", "sensor_success", "=", "self", ".", "_client", ".", "update_sensors", "(", ")", "if", "not", "info_success", "or", "not", "sensor_success", ":", "_LOGGER", ".", "error", "(", "\"Failed to update data\"", ")" ]
[ 111, 4 ]
[ 116, 50 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self): """Return the list of supported features.""" features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE | SUPPORT_PRESET_MODE if self._client.mode == self._client.MODE_AUTO: features |= SUPPORT_TARGET_TEMPERATURE_RANGE if self._humidifier and hasattr(self._client, "hum_active"): features |= SUPPORT_TARGET_HUMIDITY return features
[ "def", "supported_features", "(", "self", ")", ":", "features", "=", "SUPPORT_TARGET_TEMPERATURE", "|", "SUPPORT_FAN_MODE", "|", "SUPPORT_PRESET_MODE", "if", "self", ".", "_client", ".", "mode", "==", "self", ".", "_client", ".", "MODE_AUTO", ":", "features", "|=", "SUPPORT_TARGET_TEMPERATURE_RANGE", "if", "self", ".", "_humidifier", "and", "hasattr", "(", "self", ".", "_client", ",", "\"hum_active\"", ")", ":", "features", "|=", "SUPPORT_TARGET_HUMIDITY", "return", "features" ]
[ 119, 4 ]
[ 129, 23 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.name
(self)
Return the name of the thermostat.
Return the name of the thermostat.
def name(self): """Return the name of the thermostat.""" return self._client.name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_client", ".", "name" ]
[ 132, 4 ]
[ 134, 32 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.precision
(self)
Return the precision of the system. Venstar temperature values are passed back and forth in the API in C or F, with half-degree accuracy.
Return the precision of the system.
def precision(self): """Return the precision of the system. Venstar temperature values are passed back and forth in the API in C or F, with half-degree accuracy. """ return PRECISION_HALVES
[ "def", "precision", "(", "self", ")", ":", "return", "PRECISION_HALVES" ]
[ 137, 4 ]
[ 143, 31 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.temperature_unit
(self)
Return the unit of measurement, as defined by the API.
Return the unit of measurement, as defined by the API.
def temperature_unit(self): """Return the unit of measurement, as defined by the API.""" if self._client.tempunits == self._client.TEMPUNITS_F: return TEMP_FAHRENHEIT return TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "tempunits", "==", "self", ".", "_client", ".", "TEMPUNITS_F", ":", "return", "TEMP_FAHRENHEIT", "return", "TEMP_CELSIUS" ]
[ 146, 4 ]
[ 150, 27 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.fan_modes
(self)
Return the list of available fan modes.
Return the list of available fan modes.
def fan_modes(self): """Return the list of available fan modes.""" return VALID_FAN_STATES
[ "def", "fan_modes", "(", "self", ")", ":", "return", "VALID_FAN_STATES" ]
[ 153, 4 ]
[ 155, 31 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.hvac_modes
(self)
Return the list of available operation modes.
Return the list of available operation modes.
def hvac_modes(self): """Return the list of available operation modes.""" return VALID_THERMOSTAT_MODES
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "VALID_THERMOSTAT_MODES" ]
[ 158, 4 ]
[ 160, 37 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" return self._client.get_indoor_temp()
[ "def", "current_temperature", "(", "self", ")", ":", "return", "self", ".", "_client", ".", "get_indoor_temp", "(", ")" ]
[ 163, 4 ]
[ 165, 45 ]
python
en
['en', 'la', 'en']
True
VenstarThermostat.current_humidity
(self)
Return the current humidity.
Return the current humidity.
def current_humidity(self): """Return the current humidity.""" return self._client.get_indoor_humidity()
[ "def", "current_humidity", "(", "self", ")", ":", "return", "self", ".", "_client", ".", "get_indoor_humidity", "(", ")" ]
[ 168, 4 ]
[ 170, 49 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.hvac_mode
(self)
Return current operation mode ie. heat, cool, auto.
Return current operation mode ie. heat, cool, auto.
def hvac_mode(self): """Return current operation mode ie. heat, cool, auto.""" if self._client.mode == self._client.MODE_HEAT: return HVAC_MODE_HEAT if self._client.mode == self._client.MODE_COOL: return HVAC_MODE_COOL if self._client.mode == self._client.MODE_AUTO: return HVAC_MODE_AUTO return HVAC_MODE_OFF
[ "def", "hvac_mode", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "mode", "==", "self", ".", "_client", ".", "MODE_HEAT", ":", "return", "HVAC_MODE_HEAT", "if", "self", ".", "_client", ".", "mode", "==", "self", ".", "_client", ".", "MODE_COOL", ":", "return", "HVAC_MODE_COOL", "if", "self", ".", "_client", ".", "mode", "==", "self", ".", "_client", ".", "MODE_AUTO", ":", "return", "HVAC_MODE_AUTO", "return", "HVAC_MODE_OFF" ]
[ 173, 4 ]
[ 181, 28 ]
python
en
['nl', 'en', 'en']
True
VenstarThermostat.hvac_action
(self)
Return current operation mode ie. heat, cool, auto.
Return current operation mode ie. heat, cool, auto.
def hvac_action(self): """Return current operation mode ie. heat, cool, auto.""" if self._client.state == self._client.STATE_IDLE: return CURRENT_HVAC_IDLE if self._client.state == self._client.STATE_HEATING: return CURRENT_HVAC_HEAT if self._client.state == self._client.STATE_COOLING: return CURRENT_HVAC_COOL return CURRENT_HVAC_OFF
[ "def", "hvac_action", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "state", "==", "self", ".", "_client", ".", "STATE_IDLE", ":", "return", "CURRENT_HVAC_IDLE", "if", "self", ".", "_client", ".", "state", "==", "self", ".", "_client", ".", "STATE_HEATING", ":", "return", "CURRENT_HVAC_HEAT", "if", "self", ".", "_client", ".", "state", "==", "self", ".", "_client", ".", "STATE_COOLING", ":", "return", "CURRENT_HVAC_COOL", "return", "CURRENT_HVAC_OFF" ]
[ 184, 4 ]
[ 192, 31 ]
python
en
['nl', 'en', 'en']
True
VenstarThermostat.fan_mode
(self)
Return the current fan mode.
Return the current fan mode.
def fan_mode(self): """Return the current fan mode.""" if self._client.fan == self._client.FAN_ON: return FAN_ON return FAN_AUTO
[ "def", "fan_mode", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "fan", "==", "self", ".", "_client", ".", "FAN_ON", ":", "return", "FAN_ON", "return", "FAN_AUTO" ]
[ 195, 4 ]
[ 199, 23 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.device_state_attributes
(self)
Return the optional state attributes.
Return the optional state attributes.
def device_state_attributes(self): """Return the optional state attributes.""" return { ATTR_FAN_STATE: self._client.fanstate, ATTR_HVAC_STATE: self._client.state, }
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_FAN_STATE", ":", "self", ".", "_client", ".", "fanstate", ",", "ATTR_HVAC_STATE", ":", "self", ".", "_client", ".", "state", ",", "}" ]
[ 202, 4 ]
[ 207, 9 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.target_temperature
(self)
Return the target temperature we try to reach.
Return the target temperature we try to reach.
def target_temperature(self): """Return the target temperature we try to reach.""" if self._client.mode == self._client.MODE_HEAT: return self._client.heattemp if self._client.mode == self._client.MODE_COOL: return self._client.cooltemp return None
[ "def", "target_temperature", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "mode", "==", "self", ".", "_client", ".", "MODE_HEAT", ":", "return", "self", ".", "_client", ".", "heattemp", "if", "self", ".", "_client", ".", "mode", "==", "self", ".", "_client", ".", "MODE_COOL", ":", "return", "self", ".", "_client", ".", "cooltemp", "return", "None" ]
[ 210, 4 ]
[ 216, 19 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.target_temperature_low
(self)
Return the lower bound temp if auto mode is on.
Return the lower bound temp if auto mode is on.
def target_temperature_low(self): """Return the lower bound temp if auto mode is on.""" if self._client.mode == self._client.MODE_AUTO: return self._client.heattemp return None
[ "def", "target_temperature_low", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "mode", "==", "self", ".", "_client", ".", "MODE_AUTO", ":", "return", "self", ".", "_client", ".", "heattemp", "return", "None" ]
[ 219, 4 ]
[ 223, 19 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.target_temperature_high
(self)
Return the upper bound temp if auto mode is on.
Return the upper bound temp if auto mode is on.
def target_temperature_high(self): """Return the upper bound temp if auto mode is on.""" if self._client.mode == self._client.MODE_AUTO: return self._client.cooltemp return None
[ "def", "target_temperature_high", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "mode", "==", "self", ".", "_client", ".", "MODE_AUTO", ":", "return", "self", ".", "_client", ".", "cooltemp", "return", "None" ]
[ 226, 4 ]
[ 230, 19 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.target_humidity
(self)
Return the humidity we try to reach.
Return the humidity we try to reach.
def target_humidity(self): """Return the humidity we try to reach.""" return self._client.hum_setpoint
[ "def", "target_humidity", "(", "self", ")", ":", "return", "self", ".", "_client", ".", "hum_setpoint" ]
[ 233, 4 ]
[ 235, 40 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.min_humidity
(self)
Return the minimum humidity. Hardcoded to 0 in API.
Return the minimum humidity. Hardcoded to 0 in API.
def min_humidity(self): """Return the minimum humidity. Hardcoded to 0 in API.""" return 0
[ "def", "min_humidity", "(", "self", ")", ":", "return", "0" ]
[ 238, 4 ]
[ 240, 16 ]
python
en
['en', 'zu', 'en']
True
VenstarThermostat.max_humidity
(self)
Return the maximum humidity. Hardcoded to 60 in API.
Return the maximum humidity. Hardcoded to 60 in API.
def max_humidity(self): """Return the maximum humidity. Hardcoded to 60 in API.""" return 60
[ "def", "max_humidity", "(", "self", ")", ":", "return", "60" ]
[ 243, 4 ]
[ 245, 17 ]
python
en
['en', 'mg', 'en']
True
VenstarThermostat.preset_mode
(self)
Return current preset.
Return current preset.
def preset_mode(self): """Return current preset.""" if self._client.away: return PRESET_AWAY if self._client.schedule == 0: return HOLD_MODE_TEMPERATURE return PRESET_NONE
[ "def", "preset_mode", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "away", ":", "return", "PRESET_AWAY", "if", "self", ".", "_client", ".", "schedule", "==", "0", ":", "return", "HOLD_MODE_TEMPERATURE", "return", "PRESET_NONE" ]
[ 248, 4 ]
[ 254, 26 ]
python
en
['en', 'la', 'en']
True
VenstarThermostat.preset_modes
(self)
Return valid preset modes.
Return valid preset modes.
def preset_modes(self): """Return valid preset modes.""" return [PRESET_NONE, PRESET_AWAY, HOLD_MODE_TEMPERATURE]
[ "def", "preset_modes", "(", "self", ")", ":", "return", "[", "PRESET_NONE", ",", "PRESET_AWAY", ",", "HOLD_MODE_TEMPERATURE", "]" ]
[ 257, 4 ]
[ 259, 64 ]
python
en
['en', 'et', 'en']
True
VenstarThermostat._set_operation_mode
(self, operation_mode)
Change the operation mode (internal).
Change the operation mode (internal).
def _set_operation_mode(self, operation_mode): """Change the operation mode (internal).""" if operation_mode == HVAC_MODE_HEAT: success = self._client.set_mode(self._client.MODE_HEAT) elif operation_mode == HVAC_MODE_COOL: success = self._client.set_mode(self._client.MODE_COOL) elif operation_mode == HVAC_MODE_AUTO: success = self._client.set_mode(self._client.MODE_AUTO) else: success = self._client.set_mode(self._client.MODE_OFF) if not success: _LOGGER.error("Failed to change the operation mode") return success
[ "def", "_set_operation_mode", "(", "self", ",", "operation_mode", ")", ":", "if", "operation_mode", "==", "HVAC_MODE_HEAT", ":", "success", "=", "self", ".", "_client", ".", "set_mode", "(", "self", ".", "_client", ".", "MODE_HEAT", ")", "elif", "operation_mode", "==", "HVAC_MODE_COOL", ":", "success", "=", "self", ".", "_client", ".", "set_mode", "(", "self", ".", "_client", ".", "MODE_COOL", ")", "elif", "operation_mode", "==", "HVAC_MODE_AUTO", ":", "success", "=", "self", ".", "_client", ".", "set_mode", "(", "self", ".", "_client", ".", "MODE_AUTO", ")", "else", ":", "success", "=", "self", ".", "_client", ".", "set_mode", "(", "self", ".", "_client", ".", "MODE_OFF", ")", "if", "not", "success", ":", "_LOGGER", ".", "error", "(", "\"Failed to change the operation mode\"", ")", "return", "success" ]
[ 261, 4 ]
[ 274, 22 ]
python
en
['en', 'en', 'en']
True
VenstarThermostat.set_temperature
(self, **kwargs)
Set a new target temperature.
Set a new target temperature.
def set_temperature(self, **kwargs): """Set a new target temperature.""" set_temp = True operation_mode = kwargs.get(ATTR_HVAC_MODE) temp_low = kwargs.get(ATTR_TARGET_TEMP_LOW) temp_high = kwargs.get(ATTR_TARGET_TEMP_HIGH) temperature = kwargs.get(ATTR_TEMPERATURE) if operation_mode and self._mode_map.get(operation_mode) != self._client.mode: set_temp = self._set_operation_mode(operation_mode) if set_temp: if ( self._mode_map.get(operation_mode, self._client.mode) == self._client.MODE_HEAT ): success = self._client.set_setpoints(temperature, self._client.cooltemp) elif ( self._mode_map.get(operation_mode, self._client.mode) == self._client.MODE_COOL ): success = self._client.set_setpoints(self._client.heattemp, temperature) elif ( self._mode_map.get(operation_mode, self._client.mode) == self._client.MODE_AUTO ): success = self._client.set_setpoints(temp_low, temp_high) else: success = False _LOGGER.error( "The thermostat is currently not in a mode " "that supports target temperature: %s", operation_mode, ) if not success: _LOGGER.error("Failed to change the temperature")
[ "def", "set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "set_temp", "=", "True", "operation_mode", "=", "kwargs", ".", "get", "(", "ATTR_HVAC_MODE", ")", "temp_low", "=", "kwargs", ".", "get", "(", "ATTR_TARGET_TEMP_LOW", ")", "temp_high", "=", "kwargs", ".", "get", "(", "ATTR_TARGET_TEMP_HIGH", ")", "temperature", "=", "kwargs", ".", "get", "(", "ATTR_TEMPERATURE", ")", "if", "operation_mode", "and", "self", ".", "_mode_map", ".", "get", "(", "operation_mode", ")", "!=", "self", ".", "_client", ".", "mode", ":", "set_temp", "=", "self", ".", "_set_operation_mode", "(", "operation_mode", ")", "if", "set_temp", ":", "if", "(", "self", ".", "_mode_map", ".", "get", "(", "operation_mode", ",", "self", ".", "_client", ".", "mode", ")", "==", "self", ".", "_client", ".", "MODE_HEAT", ")", ":", "success", "=", "self", ".", "_client", ".", "set_setpoints", "(", "temperature", ",", "self", ".", "_client", ".", "cooltemp", ")", "elif", "(", "self", ".", "_mode_map", ".", "get", "(", "operation_mode", ",", "self", ".", "_client", ".", "mode", ")", "==", "self", ".", "_client", ".", "MODE_COOL", ")", ":", "success", "=", "self", ".", "_client", ".", "set_setpoints", "(", "self", ".", "_client", ".", "heattemp", ",", "temperature", ")", "elif", "(", "self", ".", "_mode_map", ".", "get", "(", "operation_mode", ",", "self", ".", "_client", ".", "mode", ")", "==", "self", ".", "_client", ".", "MODE_AUTO", ")", ":", "success", "=", "self", ".", "_client", ".", "set_setpoints", "(", "temp_low", ",", "temp_high", ")", "else", ":", "success", "=", "False", "_LOGGER", ".", "error", "(", "\"The thermostat is currently not in a mode \"", "\"that supports target temperature: %s\"", ",", "operation_mode", ",", ")", "if", "not", "success", ":", "_LOGGER", ".", "error", "(", "\"Failed to change the temperature\"", ")" ]
[ 276, 4 ]
[ 312, 65 ]
python
en
['en', 'ca', 'en']
True
VenstarThermostat.set_fan_mode
(self, fan_mode)
Set new target fan mode.
Set new target fan mode.
def set_fan_mode(self, fan_mode): """Set new target fan mode.""" if fan_mode == STATE_ON: success = self._client.set_fan(self._client.FAN_ON) else: success = self._client.set_fan(self._client.FAN_AUTO) if not success: _LOGGER.error("Failed to change the fan mode")
[ "def", "set_fan_mode", "(", "self", ",", "fan_mode", ")", ":", "if", "fan_mode", "==", "STATE_ON", ":", "success", "=", "self", ".", "_client", ".", "set_fan", "(", "self", ".", "_client", ".", "FAN_ON", ")", "else", ":", "success", "=", "self", ".", "_client", ".", "set_fan", "(", "self", ".", "_client", ".", "FAN_AUTO", ")", "if", "not", "success", ":", "_LOGGER", ".", "error", "(", "\"Failed to change the fan mode\"", ")" ]
[ 314, 4 ]
[ 322, 58 ]
python
en
['sv', 'fy', 'en']
False