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
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
main
(params)
Main function, build mnist network, run and send result to NNI.
Main function, build mnist network, run and send result to NNI.
def main(params): ''' Main function, build mnist network, run and send result to NNI. ''' # Import data mnist = download_mnist_retry(params['data_dir']) print('Mnist download data done.') logger.debug('Mnist download data done.') # Create the model # Build the graph for the deep net...
[ "def", "main", "(", "params", ")", ":", "# Import data", "mnist", "=", "download_mnist_retry", "(", "params", "[", "'data_dir'", "]", ")", "print", "(", "'Mnist download data done.'", ")", "logger", ".", "debug", "(", "'Mnist download data done.'", ")", "# Create ...
[ 155, 0 ]
[ 206, 47 ]
python
en
['en', 'error', 'th']
False
get_params
()
Get parameters from command line
Get parameters from command line
def get_params(): ''' Get parameters from command line ''' parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, default='/tmp/tensorflow/mnist/input_data', help="data directory") parser.add_argument("--dropout_rate", type=float, default=0.5, help="dropout rate") parser.add_...
[ "def", "get_params", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "\"--data_dir\"", ",", "type", "=", "str", ",", "default", "=", "'/tmp/tensorflow/mnist/input_data'", ",", "help", "=", "\"data ...
[ 208, 0 ]
[ 223, 15 ]
python
en
['en', 'en', 'en']
True
MnistNetwork.build_network
(self)
Building network for mnist
Building network for mnist
def build_network(self): ''' Building network for mnist ''' # Reshape to use within a convolutional neural net. # Last dimension is for "features" - there is only one here, since images are # grayscale -- it would be 3 for an RGB image, 4 for RGBA, etc. with tf.n...
[ "def", "build_network", "(", "self", ")", ":", "# Reshape to use within a convolutional neural net.", "# Last dimension is for \"features\" - there is only one here, since images are", "# grayscale -- it would be 3 for an RGB image, 4 for RGBA, etc.", "with", "tf", ".", "name_scope", "(", ...
[ 47, 4 ]
[ 121, 56 ]
python
en
['en', 'error', 'th']
False
create_rfx_test_cfg
(device="abcd", automatic_add=False, devices=None)
Create rfxtrx config entry data.
Create rfxtrx config entry data.
def create_rfx_test_cfg(device="abcd", automatic_add=False, devices=None): """Create rfxtrx config entry data.""" return { "device": device, "host": None, "port": None, "automatic_add": automatic_add, "debug": False, "devices": devices, }
[ "def", "create_rfx_test_cfg", "(", "device", "=", "\"abcd\"", ",", "automatic_add", "=", "False", ",", "devices", "=", "None", ")", ":", "return", "{", "\"device\"", ":", "device", ",", "\"host\"", ":", "None", ",", "\"port\"", ":", "None", ",", "\"automat...
[ 14, 0 ]
[ 23, 5 ]
python
en
['en', 'cy', 'en']
True
rfxtrx_fixture
(hass)
Fixture that cleans up threads from integration.
Fixture that cleans up threads from integration.
async def rfxtrx_fixture(hass): """Fixture that cleans up threads from integration.""" with patch("RFXtrx.Connect") as connect, patch("RFXtrx.DummyTransport2"): rfx = connect.return_value async def _signal_event(packet_id): event = rfxtrx.get_rfx_object(packet_id) await...
[ "async", "def", "rfxtrx_fixture", "(", "hass", ")", ":", "with", "patch", "(", "\"RFXtrx.Connect\"", ")", "as", "connect", ",", "patch", "(", "\"RFXtrx.DummyTransport2\"", ")", ":", "rfx", "=", "connect", ".", "return_value", "async", "def", "_signal_event", "...
[ 27, 0 ]
[ 46, 17 ]
python
en
['en', 'en', 'en']
True
rfxtrx_automatic_fixture
(hass, rfxtrx)
Fixture that starts up with automatic additions.
Fixture that starts up with automatic additions.
async def rfxtrx_automatic_fixture(hass, rfxtrx): """Fixture that starts up with automatic additions.""" entry_data = create_rfx_test_cfg(automatic_add=True, devices={}) mock_entry = MockConfigEntry(domain="rfxtrx", unique_id=DOMAIN, data=entry_data) mock_entry.add_to_hass(hass) await hass.config_...
[ "async", "def", "rfxtrx_automatic_fixture", "(", "hass", ",", "rfxtrx", ")", ":", "entry_data", "=", "create_rfx_test_cfg", "(", "automatic_add", "=", "True", ",", "devices", "=", "{", "}", ")", "mock_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"rfxt...
[ 50, 0 ]
[ 60, 16 ]
python
en
['en', 'en', 'en']
True
timestep
(hass)
Step system time forward.
Step system time forward.
async def timestep(hass): """Step system time forward.""" with patch("homeassistant.core.dt_util.utcnow") as mock_utcnow: mock_utcnow.return_value = utcnow() async def delay(seconds): """Trigger delay in system.""" mock_utcnow.return_value += timedelta(seconds=seconds) ...
[ "async", "def", "timestep", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.core.dt_util.utcnow\"", ")", "as", "mock_utcnow", ":", "mock_utcnow", ".", "return_value", "=", "utcnow", "(", ")", "async", "def", "delay", "(", "seconds", ")", ":", "...
[ 64, 0 ]
[ 76, 19 ]
python
en
['en', 'en', 'en']
True
mock_legacy_time
(legacy_patchable_time)
Make time patchable for all the tests.
Make time patchable for all the tests.
def mock_legacy_time(legacy_patchable_time): """Make time patchable for all the tests.""" yield
[ "def", "mock_legacy_time", "(", "legacy_patchable_time", ")", ":", "yield" ]
[ 25, 0 ]
[ 27, 9 ]
python
en
['en', 'en', 'en']
True
test_setup_platform
(hass)
Test setup of demo platform via configuration.
Test setup of demo platform via configuration.
async def test_setup_platform(hass): """Test setup of demo platform via configuration.""" utcnow = dt_util.utcnow() # Patching 'utcnow' to gain more control over the timed update. with patch("homeassistant.util.dt.utcnow", return_value=utcnow): with assert_setup_component(1, geo_location.DOMAIN)...
[ "async", "def", "test_setup_platform", "(", "hass", ")", ":", "utcnow", "=", "dt_util", ".", "utcnow", "(", ")", "# Patching 'utcnow' to gain more control over the timed update.", "with", "patch", "(", "\"homeassistant.util.dt.utcnow\"", ",", "return_value", "=", "utcnow"...
[ 30, 0 ]
[ 66, 47 ]
python
en
['en', 'pt', 'en']
True
async_get_service
( hass: HomeAssistantType, config: Dict[str, Any], discovery_info: Optional[Dict[str, Any]] = None, )
Get the notification service.
Get the notification service.
async def async_get_service( hass: HomeAssistantType, config: Dict[str, Any], discovery_info: Optional[Dict[str, Any]] = None, ) -> Optional["HuaweiLteSmsNotificationService"]: """Get the notification service.""" if discovery_info is None: return None router = hass.data[DOMAIN].routers[...
[ "async", "def", "async_get_service", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "Dict", "[", "str", ",", "Any", "]", ",", "discovery_info", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ",", ")", "->", "...
[ 19, 0 ]
[ 31, 67 ]
python
en
['en', 'en', 'en']
True
get_scanner
(hass, config)
Return the Swisscom device scanner.
Return the Swisscom device scanner.
def get_scanner(hass, config): """Return the Swisscom device scanner.""" scanner = SwisscomDeviceScanner(config[DOMAIN]) return scanner if scanner.success_init else None
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "scanner", "=", "SwisscomDeviceScanner", "(", "config", "[", "DOMAIN", "]", ")", "return", "scanner", "if", "scanner", ".", "success_init", "else", "None" ]
[ 24, 0 ]
[ 28, 52 ]
python
en
['en', 'no', 'en']
True
SwisscomDeviceScanner.__init__
(self, config)
Initialize the scanner.
Initialize the scanner.
def __init__(self, config): """Initialize the scanner.""" self.host = config[CONF_HOST] self.last_results = {} # Test the router is accessible. data = self.get_swisscom_data() self.success_init = data is not None
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "self", ".", "host", "=", "config", "[", "CONF_HOST", "]", "self", ".", "last_results", "=", "{", "}", "# Test the router is accessible.", "data", "=", "self", ".", "get_swisscom_data", "(", ")", "se...
[ 34, 4 ]
[ 41, 44 ]
python
en
['en', 'en', 'en']
True
SwisscomDeviceScanner.scan_devices
(self)
Scan for new devices and return a list with found device IDs.
Scan for new devices and return a list with found device IDs.
def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" self._update_info() return [client["mac"] for client in self.last_results]
[ "def", "scan_devices", "(", "self", ")", ":", "self", ".", "_update_info", "(", ")", "return", "[", "client", "[", "\"mac\"", "]", "for", "client", "in", "self", ".", "last_results", "]" ]
[ 43, 4 ]
[ 46, 62 ]
python
en
['en', 'en', 'en']
True
SwisscomDeviceScanner.get_device_name
(self, device)
Return the name of the given device or None if we don't know.
Return the name of the given device or None if we don't know.
def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" if not self.last_results: return None for client in self.last_results: if client["mac"] == device: return client["host"] return None
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "if", "not", "self", ".", "last_results", ":", "return", "None", "for", "client", "in", "self", ".", "last_results", ":", "if", "client", "[", "\"mac\"", "]", "==", "device", ":", "return", ...
[ 48, 4 ]
[ 55, 19 ]
python
en
['en', 'en', 'en']
True
SwisscomDeviceScanner._update_info
(self)
Ensure the information from the Swisscom router is up to date. Return boolean if scanning successful.
Ensure the information from the Swisscom router is up to date.
def _update_info(self): """Ensure the information from the Swisscom router is up to date. Return boolean if scanning successful. """ if not self.success_init: return False _LOGGER.info("Loading data from Swisscom Internet Box") data = self.get_swisscom_data(...
[ "def", "_update_info", "(", "self", ")", ":", "if", "not", "self", ".", "success_init", ":", "return", "False", "_LOGGER", ".", "info", "(", "\"Loading data from Swisscom Internet Box\"", ")", "data", "=", "self", ".", "get_swisscom_data", "(", ")", "if", "not...
[ 57, 4 ]
[ 72, 19 ]
python
en
['en', 'en', 'en']
True
SwisscomDeviceScanner.get_swisscom_data
(self)
Retrieve data from Swisscom and return parsed result.
Retrieve data from Swisscom and return parsed result.
def get_swisscom_data(self): """Retrieve data from Swisscom and return parsed result.""" url = f"http://{self.host}/ws" headers = {CONTENT_TYPE: "application/x-sah-ws-4-call+json"} data = """ {"service":"Devices", "method":"get", "parameters":{"expression":"lan and not se...
[ "def", "get_swisscom_data", "(", "self", ")", ":", "url", "=", "f\"http://{self.host}/ws\"", "headers", "=", "{", "CONTENT_TYPE", ":", "\"application/x-sah-ws-4-call+json\"", "}", "data", "=", "\"\"\"\n {\"service\":\"Devices\", \"method\":\"get\",\n \"parameters\":...
[ 74, 4 ]
[ 108, 22 ]
python
en
['en', 'en', 'en']
True
Flattener.__init__
(self)
Flattens last 3 dimensions to make it only batch size, -1
Flattens last 3 dimensions to make it only batch size, -1
def __init__(self): """ Flattens last 3 dimensions to make it only batch size, -1 """ super(Flattener, self).__init__()
[ "def", "__init__", "(", "self", ")", ":", "super", "(", "Flattener", ",", "self", ")", ".", "__init__", "(", ")" ]
[ 4, 4 ]
[ 8, 41 ]
python
en
['en', 'error', 'th']
False
async_setup
(hass: HomeAssistant, config: dict)
Set up the Network UPS Tools (NUT) component.
Set up the Network UPS Tools (NUT) component.
async def async_setup(hass: HomeAssistant, config: dict): """Set up the Network UPS Tools (NUT) component.""" hass.data.setdefault(DOMAIN, {}) return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ")", ":", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "return", "True" ]
[ 39, 0 ]
[ 43, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Network UPS Tools (NUT) from a config entry.
Set up Network UPS Tools (NUT) from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Network UPS Tools (NUT) from a config entry.""" config = entry.data host = config[CONF_HOST] port = config[CONF_PORT] alias = config.get(CONF_ALIAS) username = config.get(CONF_USERNAME) password = config.get(CO...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "config", "=", "entry", ".", "data", "host", "=", "config", "[", "CONF_HOST", "]", "port", "=", "config", "[", "CONF_PORT", "]", "alias", ...
[ 46, 0 ]
[ 108, 15 ]
python
en
['en', 'en', 'en']
True
_async_update_listener
(hass: HomeAssistant, entry: ConfigEntry)
Handle options update.
Handle options update.
async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry): """Handle options update.""" await hass.config_entries.async_reload(entry.entry_id)
[ "async", "def", "_async_update_listener", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "await", "hass", ".", "config_entries", ".", "async_reload", "(", "entry", ".", "entry_id", ")" ]
[ 111, 0 ]
[ 113, 58 ]
python
en
['en', 'nl', 'en']
True
_manufacturer_from_status
(status)
Find the best manufacturer value from the status.
Find the best manufacturer value from the status.
def _manufacturer_from_status(status): """Find the best manufacturer value from the status.""" return ( status.get("device.mfr") or status.get("ups.mfr") or status.get("ups.vendorid") or status.get("driver.version.data") )
[ "def", "_manufacturer_from_status", "(", "status", ")", ":", "return", "(", "status", ".", "get", "(", "\"device.mfr\"", ")", "or", "status", ".", "get", "(", "\"ups.mfr\"", ")", "or", "status", ".", "get", "(", "\"ups.vendorid\"", ")", "or", "status", "."...
[ 116, 0 ]
[ 123, 5 ]
python
en
['en', 'en', 'en']
True
_model_from_status
(status)
Find the best model value from the status.
Find the best model value from the status.
def _model_from_status(status): """Find the best model value from the status.""" return ( status.get("device.model") or status.get("ups.model") or status.get("ups.productid") )
[ "def", "_model_from_status", "(", "status", ")", ":", "return", "(", "status", ".", "get", "(", "\"device.model\"", ")", "or", "status", ".", "get", "(", "\"ups.model\"", ")", "or", "status", ".", "get", "(", "\"ups.productid\"", ")", ")" ]
[ 126, 0 ]
[ 132, 5 ]
python
en
['en', 'en', 'en']
True
_firmware_from_status
(status)
Find the best firmware value from the status.
Find the best firmware value from the status.
def _firmware_from_status(status): """Find the best firmware value from the status.""" return status.get("ups.firmware") or status.get("ups.firmware.aux")
[ "def", "_firmware_from_status", "(", "status", ")", ":", "return", "status", ".", "get", "(", "\"ups.firmware\"", ")", "or", "status", ".", "get", "(", "\"ups.firmware.aux\"", ")" ]
[ 135, 0 ]
[ 137, 71 ]
python
en
['en', 'en', 'en']
True
_serial_from_status
(status)
Find the best serialvalue from the status.
Find the best serialvalue from the status.
def _serial_from_status(status): """Find the best serialvalue from the status.""" serial = status.get("device.serial") or status.get("ups.serial") if serial and (serial.lower() == "unknown" or serial.count("0") == len(serial)): return None return serial
[ "def", "_serial_from_status", "(", "status", ")", ":", "serial", "=", "status", ".", "get", "(", "\"device.serial\"", ")", "or", "status", ".", "get", "(", "\"ups.serial\"", ")", "if", "serial", "and", "(", "serial", ".", "lower", "(", ")", "==", "\"unkn...
[ 140, 0 ]
[ 145, 17 ]
python
en
['en', 'en', 'en']
True
_unique_id_from_status
(status)
Find the best unique id value from the status.
Find the best unique id value from the status.
def _unique_id_from_status(status): """Find the best unique id value from the status.""" serial = _serial_from_status(status) # We must have a serial for this to be unique if not serial: return None manufacturer = _manufacturer_from_status(status) model = _model_from_status(status) ...
[ "def", "_unique_id_from_status", "(", "status", ")", ":", "serial", "=", "_serial_from_status", "(", "status", ")", "# We must have a serial for this to be unique", "if", "not", "serial", ":", "return", "None", "manufacturer", "=", "_manufacturer_from_status", "(", "sta...
[ 148, 0 ]
[ 165, 36 ]
python
en
['en', 'en', 'en']
True
find_resources_in_config_entry
(config_entry)
Find the configured resources in the config entry.
Find the configured resources in the config entry.
def find_resources_in_config_entry(config_entry): """Find the configured resources in the config entry.""" if CONF_RESOURCES in config_entry.options: return config_entry.options[CONF_RESOURCES] return config_entry.data[CONF_RESOURCES]
[ "def", "find_resources_in_config_entry", "(", "config_entry", ")", ":", "if", "CONF_RESOURCES", "in", "config_entry", ".", "options", ":", "return", "config_entry", ".", "options", "[", "CONF_RESOURCES", "]", "return", "config_entry", ".", "data", "[", "CONF_RESOURC...
[ 168, 0 ]
[ 172, 44 ]
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 ] ) ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload...
[ 175, 0 ]
[ 191, 20 ]
python
en
['en', 'es', 'en']
True
PyNUTData.__init__
(self, host, port, alias, username, password)
Initialize the data object.
Initialize the data object.
def __init__(self, host, port, alias, username, password): """Initialize the data object.""" self._host = host self._alias = alias # Establish client with persistent=False to open/close connection on # each update call. This is more reliable with async. self._client = ...
[ "def", "__init__", "(", "self", ",", "host", ",", "port", ",", "alias", ",", "username", ",", "password", ")", ":", "self", ".", "_host", "=", "host", "self", ".", "_alias", "=", "alias", "# Establish client with persistent=False to open/close connection on", "#...
[ 201, 4 ]
[ 211, 27 ]
python
en
['en', 'en', 'en']
True
PyNUTData.status
(self)
Get latest update if throttle allows. Return status.
Get latest update if throttle allows. Return status.
def status(self): """Get latest update if throttle allows. Return status.""" return self._status
[ "def", "status", "(", "self", ")", ":", "return", "self", ".", "_status" ]
[ 214, 4 ]
[ 216, 27 ]
python
en
['en', 'en', 'en']
True
PyNUTData.name
(self)
Return the name of the ups.
Return the name of the ups.
def name(self): """Return the name of the ups.""" return self._alias
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_alias" ]
[ 219, 4 ]
[ 221, 26 ]
python
en
['en', 'en', 'en']
True
PyNUTData._get_alias
(self)
Get the ups alias from NUT.
Get the ups alias from NUT.
def _get_alias(self): """Get the ups alias from NUT.""" try: ups_list = self._client.list_ups() except PyNUTError as err: _LOGGER.error("Failure getting NUT ups alias, %s", err) return None if not ups_list: _LOGGER.error("Empty list while ...
[ "def", "_get_alias", "(", "self", ")", ":", "try", ":", "ups_list", "=", "self", ".", "_client", ".", "list_ups", "(", ")", "except", "PyNUTError", "as", "err", ":", "_LOGGER", ".", "error", "(", "\"Failure getting NUT ups alias, %s\"", ",", "err", ")", "r...
[ 223, 4 ]
[ 236, 32 ]
python
en
['en', 'en', 'en']
True
PyNUTData._get_status
(self)
Get the ups status from NUT.
Get the ups status from NUT.
def _get_status(self): """Get the ups status from NUT.""" if self._alias is None: self._alias = self._get_alias() try: return self._client.list_vars(self._alias) except (PyNUTError, ConnectionResetError) as err: _LOGGER.debug("Error getting NUT vars f...
[ "def", "_get_status", "(", "self", ")", ":", "if", "self", ".", "_alias", "is", "None", ":", "self", ".", "_alias", "=", "self", ".", "_get_alias", "(", ")", "try", ":", "return", "self", ".", "_client", ".", "list_vars", "(", "self", ".", "_alias", ...
[ 238, 4 ]
[ 247, 23 ]
python
en
['en', 'en', 'en']
True
PyNUTData.update
(self, **kwargs)
Fetch the latest status from NUT.
Fetch the latest status from NUT.
def update(self, **kwargs): """Fetch the latest status from NUT.""" self._status = self._get_status()
[ "def", "update", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_status", "=", "self", ".", "_get_status", "(", ")" ]
[ 249, 4 ]
[ 251, 41 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Demo camera platform.
Set up the Demo camera platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Demo camera platform.""" async_add_entities([DemoCamera("Demo camera")])
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "async_add_entities", "(", "[", "DemoCamera", "(", "\"Demo camera\"", ")", "]", ")" ]
[ 6, 0 ]
[ 8, 51 ]
python
en
['en', 'pt', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Demo config entry.
Set up the Demo config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Demo config entry.""" await async_setup_platform(hass, {}, async_add_entities)
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "await", "async_setup_platform", "(", "hass", ",", "{", "}", ",", "async_add_entities", ")" ]
[ 11, 0 ]
[ 13, 60 ]
python
en
['en', 'en', 'en']
True
DemoCamera.__init__
(self, name)
Initialize demo camera component.
Initialize demo camera component.
def __init__(self, name): """Initialize demo camera component.""" super().__init__() self._name = name self._motion_status = False self.is_streaming = True self._images_index = 0
[ "def", "__init__", "(", "self", ",", "name", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_name", "=", "name", "self", ".", "_motion_status", "=", "False", "self", ".", "is_streaming", "=", "True", "self", ".", "_images_index",...
[ 19, 4 ]
[ 25, 30 ]
python
es
['es', 'pt', 'it']
False
DemoCamera.async_camera_image
(self)
Return a faked still image response.
Return a faked still image response.
async def async_camera_image(self): """Return a faked still image response.""" self._images_index = (self._images_index + 1) % 4 image_path = Path(__file__).parent / f"demo_{self._images_index}.jpg" return await self.hass.async_add_executor_job(image_path.read_bytes)
[ "async", "def", "async_camera_image", "(", "self", ")", ":", "self", ".", "_images_index", "=", "(", "self", ".", "_images_index", "+", "1", ")", "%", "4", "image_path", "=", "Path", "(", "__file__", ")", ".", "parent", "/", "f\"demo_{self._images_index}.jpg...
[ 27, 4 ]
[ 32, 76 ]
python
en
['en', 'sv', 'en']
True
DemoCamera.name
(self)
Return the name of this camera.
Return the name of this camera.
def name(self): """Return the name of this camera.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 35, 4 ]
[ 37, 25 ]
python
en
['en', 'en', 'en']
True
DemoCamera.supported_features
(self)
Camera support turn on/off features.
Camera support turn on/off features.
def supported_features(self): """Camera support turn on/off features.""" return SUPPORT_ON_OFF
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_ON_OFF" ]
[ 40, 4 ]
[ 42, 29 ]
python
en
['es', 'en', 'en']
True
DemoCamera.is_on
(self)
Whether camera is on (streaming).
Whether camera is on (streaming).
def is_on(self): """Whether camera is on (streaming).""" return self.is_streaming
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "is_streaming" ]
[ 45, 4 ]
[ 47, 32 ]
python
en
['en', 'en', 'en']
True
DemoCamera.motion_detection_enabled
(self)
Camera Motion Detection Status.
Camera Motion Detection Status.
def motion_detection_enabled(self): """Camera Motion Detection Status.""" return self._motion_status
[ "def", "motion_detection_enabled", "(", "self", ")", ":", "return", "self", ".", "_motion_status" ]
[ 50, 4 ]
[ 52, 34 ]
python
en
['sv', 'ja', 'en']
False
DemoCamera.async_enable_motion_detection
(self)
Enable the Motion detection in base station (Arm).
Enable the Motion detection in base station (Arm).
async def async_enable_motion_detection(self): """Enable the Motion detection in base station (Arm).""" self._motion_status = True self.async_write_ha_state()
[ "async", "def", "async_enable_motion_detection", "(", "self", ")", ":", "self", ".", "_motion_status", "=", "True", "self", ".", "async_write_ha_state", "(", ")" ]
[ 54, 4 ]
[ 57, 35 ]
python
en
['en', 'en', 'en']
True
DemoCamera.async_disable_motion_detection
(self)
Disable the motion detection in base station (Disarm).
Disable the motion detection in base station (Disarm).
async def async_disable_motion_detection(self): """Disable the motion detection in base station (Disarm).""" self._motion_status = False self.async_write_ha_state()
[ "async", "def", "async_disable_motion_detection", "(", "self", ")", ":", "self", ".", "_motion_status", "=", "False", "self", ".", "async_write_ha_state", "(", ")" ]
[ 59, 4 ]
[ 62, 35 ]
python
en
['en', 'en', 'en']
True
DemoCamera.async_turn_off
(self)
Turn off camera.
Turn off camera.
async def async_turn_off(self): """Turn off camera.""" self.is_streaming = False self.async_write_ha_state()
[ "async", "def", "async_turn_off", "(", "self", ")", ":", "self", ".", "is_streaming", "=", "False", "self", ".", "async_write_ha_state", "(", ")" ]
[ 64, 4 ]
[ 67, 35 ]
python
en
['en', 'ja', 'en']
True
DemoCamera.async_turn_on
(self)
Turn on camera.
Turn on camera.
async def async_turn_on(self): """Turn on camera.""" self.is_streaming = True self.async_write_ha_state()
[ "async", "def", "async_turn_on", "(", "self", ")", ":", "self", ".", "is_streaming", "=", "True", "self", ".", "async_write_ha_state", "(", ")" ]
[ 69, 4 ]
[ 72, 35 ]
python
en
['en', 'et', 'en']
True
create_security_system_service
(accessory)
Define a security-system characteristics as per page 219 of HAP spec.
Define a security-system characteristics as per page 219 of HAP spec.
def create_security_system_service(accessory): """Define a security-system characteristics as per page 219 of HAP spec.""" service = accessory.add_service(ServicesTypes.SECURITY_SYSTEM) cur_state = service.add_char(CharacteristicsTypes.SECURITY_SYSTEM_STATE_CURRENT) cur_state.value = 0 targ_state ...
[ "def", "create_security_system_service", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "SECURITY_SYSTEM", ")", "cur_state", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "SECURITY_SYSTEM_ST...
[ 10, 0 ]
[ 25, 25 ]
python
en
['en', 'en', 'en']
True
test_switch_change_alarm_state
(hass, utcnow)
Test that we can turn a HomeKit alarm on and off again.
Test that we can turn a HomeKit alarm on and off again.
async def test_switch_change_alarm_state(hass, utcnow): """Test that we can turn a HomeKit alarm on and off again.""" helper = await setup_test_component(hass, create_security_system_service) await hass.services.async_call( "alarm_control_panel", "alarm_arm_home", {"entity_id": "ala...
[ "async", "def", "test_switch_change_alarm_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_security_system_service", ")", "await", "hass", ".", "services", ".", "async_call", "(", "\"alarm_contro...
[ 28, 0 ]
[ 62, 58 ]
python
en
['en', 'en', 'en']
True
test_switch_read_alarm_state
(hass, utcnow)
Test that we can read the state of a HomeKit alarm accessory.
Test that we can read the state of a HomeKit alarm accessory.
async def test_switch_read_alarm_state(hass, utcnow): """Test that we can read the state of a HomeKit alarm accessory.""" helper = await setup_test_component(hass, create_security_system_service) helper.characteristics[CURRENT_STATE].value = 0 state = await helper.poll_and_get_state() assert state....
[ "async", "def", "test_switch_read_alarm_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_security_system_service", ")", "helper", ".", "characteristics", "[", "CURRENT_STATE", "]", ".", "value", ...
[ 65, 0 ]
[ 88, 37 ]
python
en
['en', 'en', 'en']
True
_generate_mock_feed_entry
( external_id, title, distance_to_home, coordinates, region=None, attribution=None, published=None, magnitude=None, image_url=None, )
Construct a mock feed entry for testing purposes.
Construct a mock feed entry for testing purposes.
def _generate_mock_feed_entry( external_id, title, distance_to_home, coordinates, region=None, attribution=None, published=None, magnitude=None, image_url=None, ): """Construct a mock feed entry for testing purposes.""" feed_entry = MagicMock() feed_entry.external_id = ex...
[ "def", "_generate_mock_feed_entry", "(", "external_id", ",", "title", ",", "distance_to_home", ",", "coordinates", ",", "region", "=", "None", ",", "attribution", "=", "None", ",", "published", "=", "None", ",", "magnitude", "=", "None", ",", "image_url", "=",...
[ 47, 0 ]
[ 69, 21 ]
python
en
['en', 'en', 'en']
True
test_setup
(hass)
Test the general setup of the platform.
Test the general setup of the platform.
async def test_setup(hass): """Test the general setup of the platform.""" # Set up some mock feed entries for this test. mock_entry_1 = _generate_mock_feed_entry( "1234", "Title 1", 15.5, (38.0, -3.0), region="Region 1", attribution="Attribution 1", pu...
[ "async", "def", "test_setup", "(", "hass", ")", ":", "# Set up some mock feed entries for this test.", "mock_entry_1", "=", "_generate_mock_feed_entry", "(", "\"1234\"", ",", "\"Title 1\"", ",", "15.5", ",", "(", "38.0", ",", "-", "3.0", ")", ",", "region", "=", ...
[ 72, 0 ]
[ 195, 39 ]
python
en
['en', 'da', 'en']
True
test_setup_with_custom_location
(hass)
Test the setup with a custom location.
Test the setup with a custom location.
async def test_setup_with_custom_location(hass): """Test the setup with a custom location.""" # Set up some mock feed entries for this test. mock_entry_1 = _generate_mock_feed_entry("1234", "Title 1", 20.5, (38.1, -3.1)) with patch("georss_ign_sismologia_client.IgnSismologiaFeed") as mock_feed: ...
[ "async", "def", "test_setup_with_custom_location", "(", "hass", ")", ":", "# Set up some mock feed entries for this test.", "mock_entry_1", "=", "_generate_mock_feed_entry", "(", "\"1234\"", ",", "\"Title 1\"", ",", "20.5", ",", "(", "38.1", ",", "-", "3.1", ")", ")",...
[ 198, 0 ]
[ 222, 13 ]
python
en
['en', 'en', 'en']
True
test_homeassistant_location_exists
()
Test if Home Assistant location exists it should return True.
Test if Home Assistant location exists it should return True.
async def test_homeassistant_location_exists() -> None: """Test if Home Assistant location exists it should return True.""" hass = Mock() flow = config_flow.SmhiFlowHandler() flow.hass = hass with patch.object(flow, "_check_location", return_value=True): # Test exists hass.config.loc...
[ "async", "def", "test_homeassistant_location_exists", "(", ")", "->", "None", ":", "hass", "=", "Mock", "(", ")", "flow", "=", "config_flow", ".", "SmhiFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "with", "patch", ".", "object", "(", "flow", ...
[ 10, 0 ]
[ 28, 67 ]
python
en
['en', 'en', 'en']
True
test_name_in_configuration_exists
()
Test if home location exists in configuration.
Test if home location exists in configuration.
async def test_name_in_configuration_exists() -> None: """Test if home location exists in configuration.""" hass = Mock() flow = config_flow.SmhiFlowHandler() flow.hass = hass # Test exists hass.config.location_name = "Home" hass.config.latitude = 17.8419 hass.config.longitude = 59.3262...
[ "async", "def", "test_name_in_configuration_exists", "(", ")", "->", "None", ":", "hass", "=", "Mock", "(", ")", "flow", "=", "config_flow", ".", "SmhiFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "# Test exists", "hass", ".", "config", ".", "l...
[ 31, 0 ]
[ 58, 71 ]
python
en
['en', 'en', 'en']
True
test_smhi_locations
(hass)
Test return empty set.
Test return empty set.
def test_smhi_locations(hass) -> None: """Test return empty set.""" locations = config_flow.smhi_locations(hass) assert not locations
[ "def", "test_smhi_locations", "(", "hass", ")", "->", "None", ":", "locations", "=", "config_flow", ".", "smhi_locations", "(", "hass", ")", "assert", "not", "locations" ]
[ 61, 0 ]
[ 64, 24 ]
python
en
['en', 'hu', 'en']
True
test_show_config_form
()
Test show configuration form.
Test show configuration form.
async def test_show_config_form() -> None: """Test show configuration form.""" hass = Mock() flow = config_flow.SmhiFlowHandler() flow.hass = hass result = await flow._show_config_form() assert result["type"] == "form" assert result["step_id"] == "user"
[ "async", "def", "test_show_config_form", "(", ")", "->", "None", ":", "hass", "=", "Mock", "(", ")", "flow", "=", "config_flow", ".", "SmhiFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "result", "=", "await", "flow", ".", "_show_config_form", ...
[ 67, 0 ]
[ 76, 38 ]
python
en
['en', 'fr', 'en']
True
test_show_config_form_default_values
()
Test show configuration form.
Test show configuration form.
async def test_show_config_form_default_values() -> None: """Test show configuration form.""" hass = Mock() flow = config_flow.SmhiFlowHandler() flow.hass = hass result = await flow._show_config_form(name="test", latitude="65", longitude="17") assert result["type"] == "form" assert result[...
[ "async", "def", "test_show_config_form_default_values", "(", ")", "->", "None", ":", "hass", "=", "Mock", "(", ")", "flow", "=", "config_flow", ".", "SmhiFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "result", "=", "await", "flow", ".", "_show_...
[ 79, 0 ]
[ 88, 38 ]
python
en
['en', 'fr', 'en']
True
test_flow_with_home_location
(hass)
Test config flow . Tests the flow when a default location is configured then it should return a form with default values
Test config flow .
async def test_flow_with_home_location(hass) -> None: """Test config flow . Tests the flow when a default location is configured then it should return a form with default values """ flow = config_flow.SmhiFlowHandler() flow.hass = hass with patch.object(flow, "_check_location", return_valu...
[ "async", "def", "test_flow_with_home_location", "(", "hass", ")", "->", "None", ":", "flow", "=", "config_flow", ".", "SmhiFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "with", "patch", ".", "object", "(", "flow", ",", "\"_check_location\"", ",",...
[ 91, 0 ]
[ 107, 42 ]
python
en
['en', 'da', 'en']
True
test_flow_show_form
()
Test show form scenarios first time. Test when the form should show when no configurations exists
Test show form scenarios first time.
async def test_flow_show_form() -> None: """Test show form scenarios first time. Test when the form should show when no configurations exists """ hass = Mock() flow = config_flow.SmhiFlowHandler() flow.hass = hass # Test show form when Home Assistant config exists and # home is already...
[ "async", "def", "test_flow_show_form", "(", ")", "->", "None", ":", "hass", "=", "Mock", "(", ")", "flow", "=", "config_flow", ".", "SmhiFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "# Test show form when Home Assistant config exists and", "# home is ...
[ 110, 0 ]
[ 146, 47 ]
python
en
['es', 'en', 'en']
True
test_flow_show_form_name_exists
()
Test show form if name already exists. Test when the form should show when no configurations exists
Test show form if name already exists.
async def test_flow_show_form_name_exists() -> None: """Test show form if name already exists. Test when the form should show when no configurations exists """ hass = Mock() flow = config_flow.SmhiFlowHandler() flow.hass = hass test_data = {"name": "home", CONF_LONGITUDE: "0", CONF_LATITUDE...
[ "async", "def", "test_flow_show_form_name_exists", "(", ")", "->", "None", ":", "hass", "=", "Mock", "(", ")", "flow", "=", "config_flow", ".", "SmhiFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "test_data", "=", "{", "\"name\"", ":", "\"home\"...
[ 149, 0 ]
[ 175, 37 ]
python
en
['en', 'en', 'en']
True
test_flow_entry_created_from_user_input
()
Test that create data from user input. Test when the form should show when no configurations exists
Test that create data from user input.
async def test_flow_entry_created_from_user_input() -> None: """Test that create data from user input. Test when the form should show when no configurations exists """ hass = Mock() flow = config_flow.SmhiFlowHandler() flow.hass = hass test_data = {"name": "home", CONF_LONGITUDE: "0", CONF...
[ "async", "def", "test_flow_entry_created_from_user_input", "(", ")", "->", "None", ":", "hass", "=", "Mock", "(", ")", "flow", "=", "config_flow", ".", "SmhiFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "test_data", "=", "{", "\"name\"", ":", "...
[ 178, 0 ]
[ 208, 41 ]
python
en
['en', 'en', 'en']
True
test_flow_entry_created_user_input_faulty
()
Test that create data from user input and are faulty. Test when the form should show when user puts faulty location in the config gui. Then the form should show with error
Test that create data from user input and are faulty.
async def test_flow_entry_created_user_input_faulty() -> None: """Test that create data from user input and are faulty. Test when the form should show when user puts faulty location in the config gui. Then the form should show with error """ hass = Mock() flow = config_flow.SmhiFlowHandler() ...
[ "async", "def", "test_flow_entry_created_user_input_faulty", "(", ")", "->", "None", ":", "hass", "=", "Mock", "(", ")", "flow", "=", "config_flow", ".", "SmhiFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "test_data", "=", "{", "\"name\"", ":", ...
[ 211, 0 ]
[ 241, 37 ]
python
en
['en', 'en', 'en']
True
test_check_location_correct
()
Test check location when correct input.
Test check location when correct input.
async def test_check_location_correct() -> None: """Test check location when correct input.""" hass = Mock() flow = config_flow.SmhiFlowHandler() flow.hass = hass with patch.object( config_flow.aiohttp_client, "async_get_clientsession" ), patch.object(SmhiApi, "async_get_forecast", retu...
[ "async", "def", "test_check_location_correct", "(", ")", "->", "None", ":", "hass", "=", "Mock", "(", ")", "flow", "=", "config_flow", ".", "SmhiFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "with", "patch", ".", "object", "(", "config_flow", ...
[ 244, 0 ]
[ 254, 61 ]
python
en
['en', 'en', 'en']
True
test_check_location_faulty
()
Test check location when faulty input.
Test check location when faulty input.
async def test_check_location_faulty() -> None: """Test check location when faulty input.""" hass = Mock() flow = config_flow.SmhiFlowHandler() flow.hass = hass with patch.object( config_flow.aiohttp_client, "async_get_clientsession" ), patch.object(SmhiApi, "async_get_forecast", side_e...
[ "async", "def", "test_check_location_faulty", "(", ")", "->", "None", ":", "hass", "=", "Mock", "(", ")", "flow", "=", "config_flow", ".", "SmhiFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "with", "patch", ".", "object", "(", "config_flow", ...
[ 257, 0 ]
[ 267, 62 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the OhmConnect sensor.
Set up the OhmConnect sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the OhmConnect sensor.""" name = config.get(CONF_NAME) ohmid = config.get(CONF_ID) add_entities([OhmconnectSensor(name, ohmid)], True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "ohmid", "=", "config", ".", "get", "(", "CONF_ID", ")", "add_entities", "("...
[ 30, 0 ]
[ 35, 55 ]
python
en
['en', 'haw', 'en']
True
OhmconnectSensor.__init__
(self, name, ohmid)
Initialize the sensor.
Initialize the sensor.
def __init__(self, name, ohmid): """Initialize the sensor.""" self._name = name self._ohmid = ohmid self._data = {}
[ "def", "__init__", "(", "self", ",", "name", ",", "ohmid", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_ohmid", "=", "ohmid", "self", ".", "_data", "=", "{", "}" ]
[ 41, 4 ]
[ 45, 23 ]
python
en
['en', 'en', 'en']
True
OhmconnectSensor.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" ]
[ 48, 4 ]
[ 50, 25 ]
python
en
['en', 'mi', 'en']
True
OhmconnectSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" if self._data.get("active") == "True": return "Active" return "Inactive"
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_data", ".", "get", "(", "\"active\"", ")", "==", "\"True\"", ":", "return", "\"Active\"", "return", "\"Inactive\"" ]
[ 53, 4 ]
[ 57, 25 ]
python
en
['en', 'en', 'en']
True
OhmconnectSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return {"Address": self._data.get("address"), "ID": self._ohmid}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "\"Address\"", ":", "self", ".", "_data", ".", "get", "(", "\"address\"", ")", ",", "\"ID\"", ":", "self", ".", "_ohmid", "}" ]
[ 60, 4 ]
[ 62, 72 ]
python
en
['en', 'en', 'en']
True
OhmconnectSensor.update
(self)
Get the latest data from OhmConnect.
Get the latest data from OhmConnect.
def update(self): """Get the latest data from OhmConnect.""" try: url = f"https://login.ohmconnect.com/verify-ohm-hour/{self._ohmid}" response = requests.get(url, timeout=10) root = ET.fromstring(response.text) for child in root: self._dat...
[ "def", "update", "(", "self", ")", ":", "try", ":", "url", "=", "f\"https://login.ohmconnect.com/verify-ohm-hour/{self._ohmid}\"", "response", "=", "requests", ".", "get", "(", "url", ",", "timeout", "=", "10", ")", "root", "=", "ET", ".", "fromstring", "(", ...
[ 65, 4 ]
[ 76, 27 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistant, config: Config)
Set up Awair integration.
Set up Awair integration.
async def async_setup(hass: HomeAssistant, config: Config) -> bool: """Set up Awair integration.""" return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "Config", ")", "->", "bool", ":", "return", "True" ]
[ 20, 0 ]
[ 22, 15 ]
python
en
['en', 'su', 'en']
True
async_setup_entry
(hass, config_entry)
Set up Awair integration from a config entry.
Set up Awair integration from a config entry.
async def async_setup_entry(hass, config_entry) -> bool: """Set up Awair integration from a config entry.""" session = async_get_clientsession(hass) coordinator = AwairDataUpdateCoordinator(hass, config_entry, session) await coordinator.async_refresh() if not coordinator.last_update_success: ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ")", "->", "bool", ":", "session", "=", "async_get_clientsession", "(", "hass", ")", "coordinator", "=", "AwairDataUpdateCoordinator", "(", "hass", ",", "config_entry", ",", "session", ")", "...
[ 25, 0 ]
[ 43, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, config_entry)
Unload Awair configuration.
Unload Awair configuration.
async def async_unload_entry(hass, config_entry) -> bool: """Unload Awair configuration.""" tasks = [] for platform in PLATFORMS: tasks.append( hass.config_entries.async_forward_entry_unload(config_entry, platform) ) unload_ok = all(await gather(*tasks)) if unload_ok: ...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "config_entry", ")", "->", "bool", ":", "tasks", "=", "[", "]", "for", "platform", "in", "PLATFORMS", ":", "tasks", ".", "append", "(", "hass", ".", "config_entries", ".", "async_forward_entry_unload", ...
[ 46, 0 ]
[ 58, 20 ]
python
en
['fr', 'lb', 'en']
False
AwairDataUpdateCoordinator.__init__
(self, hass, config_entry, session)
Set up the AwairDataUpdateCoordinator class.
Set up the AwairDataUpdateCoordinator class.
def __init__(self, hass, config_entry, session) -> None: """Set up the AwairDataUpdateCoordinator class.""" access_token = config_entry.data[CONF_ACCESS_TOKEN] self._awair = Awair(access_token=access_token, session=session) self._config_entry = config_entry super().__init__(hass...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config_entry", ",", "session", ")", "->", "None", ":", "access_token", "=", "config_entry", ".", "data", "[", "CONF_ACCESS_TOKEN", "]", "self", ".", "_awair", "=", "Awair", "(", "access_token", "=", "acces...
[ 64, 4 ]
[ 70, 84 ]
python
en
['en', 'sn', 'en']
True
AwairDataUpdateCoordinator._async_update_data
(self)
Update data via Awair client library.
Update data via Awair client library.
async def _async_update_data(self) -> Optional[Any]: """Update data via Awair client library.""" with timeout(API_TIMEOUT): try: LOGGER.debug("Fetching users and devices") user = await self._awair.user() devices = await user.devices() ...
[ "async", "def", "_async_update_data", "(", "self", ")", "->", "Optional", "[", "Any", "]", ":", "with", "timeout", "(", "API_TIMEOUT", ")", ":", "try", ":", "LOGGER", ".", "debug", "(", "\"Fetching users and devices\"", ")", "user", "=", "await", "self", "...
[ 72, 4 ]
[ 106, 48 ]
python
en
['fr', 'lb', 'en']
False
AwairDataUpdateCoordinator._fetch_air_data
(self, device)
Fetch latest air quality data.
Fetch latest air quality data.
async def _fetch_air_data(self, device): """Fetch latest air quality data.""" LOGGER.debug("Fetching data for %s", device.uuid) air_data = await device.air_data_latest() LOGGER.debug(air_data) return AwairResult(device=device, air_data=air_data)
[ "async", "def", "_fetch_air_data", "(", "self", ",", "device", ")", ":", "LOGGER", ".", "debug", "(", "\"Fetching data for %s\"", ",", "device", ".", "uuid", ")", "air_data", "=", "await", "device", ".", "air_data_latest", "(", ")", "LOGGER", ".", "debug", ...
[ 108, 4 ]
[ 113, 60 ]
python
en
['en', 'cy', 'en']
True
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities )
Set up the Tado sensor platform.
Set up the Tado sensor platform.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities ): """Set up the Tado sensor platform.""" tado = hass.data[DOMAIN][entry.entry_id][DATA] # Create zone sensors zones = tado.zones devices = tado.devices entities = [] for zone in zones: zon...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", ":", "tado", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "[", "DATA", "]", "# ...
[ 51, 0 ]
[ 87, 42 ]
python
en
['en', 'pt', 'en']
True
TadoZoneSensor.__init__
(self, tado, zone_name, zone_id, zone_variable, device_info)
Initialize of the Tado Sensor.
Initialize of the Tado Sensor.
def __init__(self, tado, zone_name, zone_id, zone_variable, device_info): """Initialize of the Tado Sensor.""" self._tado = tado super().__init__(zone_name, device_info, tado.device_id, zone_id) self.zone_id = zone_id self.zone_variable = zone_variable self._unique_id =...
[ "def", "__init__", "(", "self", ",", "tado", ",", "zone_name", ",", "zone_id", ",", "zone_variable", ",", "device_info", ")", ":", "self", ".", "_tado", "=", "tado", "super", "(", ")", ".", "__init__", "(", "zone_name", ",", "device_info", ",", "tado", ...
[ 93, 4 ]
[ 105, 35 ]
python
en
['en', 'pt', 'en']
True
TadoZoneSensor.async_added_to_hass
(self)
Register for sensor updates.
Register for sensor updates.
async def async_added_to_hass(self): """Register for sensor updates.""" self.async_on_remove( async_dispatcher_connect( self.hass, SIGNAL_TADO_UPDATE_RECEIVED.format( self._tado.device_id, "zone", self.zone_id ), ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "SIGNAL_TADO_UPDATE_RECEIVED", ".", "format", "(", "self", ".", "_tado", ".", "device_id", ",", "\"zone\...
[ 107, 4 ]
[ 119, 38 ]
python
da
['da', 'no', 'en']
False
TadoZoneSensor.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" ]
[ 122, 4 ]
[ 124, 30 ]
python
en
['en', 'la', 'en']
True
TadoZoneSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return f"{self.zone_name} {self.zone_variable}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self.zone_name} {self.zone_variable}\"" ]
[ 127, 4 ]
[ 129, 55 ]
python
en
['en', 'mi', 'en']
True
TadoZoneSensor.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" ]
[ 132, 4 ]
[ 134, 26 ]
python
en
['en', 'en', 'en']
True
TadoZoneSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return self._state_attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_state_attributes" ]
[ 137, 4 ]
[ 139, 37 ]
python
en
['en', 'en', 'en']
True
TadoZoneSensor.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" if self.zone_variable == "temperature": return self.hass.config.units.temperature_unit if self.zone_variable == "humidity": return PERCENTAGE if self.zone_variable == "heating": retur...
[ "def", "unit_of_measurement", "(", "self", ")", ":", "if", "self", ".", "zone_variable", "==", "\"temperature\"", ":", "return", "self", ".", "hass", ".", "config", ".", "units", ".", "temperature_unit", "if", "self", ".", "zone_variable", "==", "\"humidity\""...
[ 142, 4 ]
[ 151, 23 ]
python
en
['en', 'la', 'en']
True
TadoZoneSensor.icon
(self)
Icon for the sensor.
Icon for the sensor.
def icon(self): """Icon for the sensor.""" if self.zone_variable == "temperature": return "mdi:thermometer" if self.zone_variable == "humidity": return "mdi:water-percent"
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "zone_variable", "==", "\"temperature\"", ":", "return", "\"mdi:thermometer\"", "if", "self", ".", "zone_variable", "==", "\"humidity\"", ":", "return", "\"mdi:water-percent\"" ]
[ 154, 4 ]
[ 159, 38 ]
python
en
['en', 'en', 'en']
True
TadoZoneSensor._async_update_callback
(self)
Update and write state.
Update and write state.
def _async_update_callback(self): """Update and write state.""" self._async_update_zone_data() self.async_write_ha_state()
[ "def", "_async_update_callback", "(", "self", ")", ":", "self", ".", "_async_update_zone_data", "(", ")", "self", ".", "async_write_ha_state", "(", ")" ]
[ 162, 4 ]
[ 165, 35 ]
python
en
['en', 'en', 'en']
True
TadoZoneSensor._async_update_zone_data
(self)
Handle update callbacks.
Handle update callbacks.
def _async_update_zone_data(self): """Handle update callbacks.""" try: self._tado_zone_data = self._tado.data["zone"][self.zone_id] except KeyError: return if self.zone_variable == "temperature": self._state = self.hass.config.units.temperature( ...
[ "def", "_async_update_zone_data", "(", "self", ")", ":", "try", ":", "self", ".", "_tado_zone_data", "=", "self", ".", "_tado", ".", "data", "[", "\"zone\"", "]", "[", "self", ".", "zone_id", "]", "except", "KeyError", ":", "return", "if", "self", ".", ...
[ 168, 4 ]
[ 228, 74 ]
python
en
['en', 'xh', 'en']
True
TadoDeviceSensor.__init__
(self, tado, device_name, device_id, device_variable, device_info)
Initialize of the Tado Sensor.
Initialize of the Tado Sensor.
def __init__(self, tado, device_name, device_id, device_variable, device_info): """Initialize of the Tado Sensor.""" self._tado = tado self._device_info = device_info self.device_name = device_name self.device_id = device_id self.device_variable = device_variable ...
[ "def", "__init__", "(", "self", ",", "tado", ",", "device_name", ",", "device_id", ",", "device_variable", ",", "device_info", ")", ":", "self", ".", "_tado", "=", "tado", "self", ".", "_device_info", "=", "device_info", "self", ".", "device_name", "=", "d...
[ 234, 4 ]
[ 247, 37 ]
python
en
['en', 'pt', 'en']
True
TadoDeviceSensor.async_added_to_hass
(self)
Register for sensor updates.
Register for sensor updates.
async def async_added_to_hass(self): """Register for sensor updates.""" self.async_on_remove( async_dispatcher_connect( self.hass, SIGNAL_TADO_UPDATE_RECEIVED.format( self._tado.device_id, "device", self.device_id ), ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "SIGNAL_TADO_UPDATE_RECEIVED", ".", "format", "(", "self", ".", "_tado", ".", "device_id", ",", "\"devic...
[ 249, 4 ]
[ 261, 40 ]
python
da
['da', 'no', 'en']
False
TadoDeviceSensor.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" ]
[ 264, 4 ]
[ 266, 30 ]
python
en
['en', 'la', 'en']
True
TadoDeviceSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return f"{self.device_name} {self.device_variable}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self.device_name} {self.device_variable}\"" ]
[ 269, 4 ]
[ 271, 59 ]
python
en
['en', 'mi', 'en']
True
TadoDeviceSensor.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" ]
[ 274, 4 ]
[ 276, 26 ]
python
en
['en', 'en', 'en']
True
TadoDeviceSensor.should_poll
(self)
Do not poll.
Do not poll.
def should_poll(self): """Do not poll.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 279, 4 ]
[ 281, 20 ]
python
en
['en', 'lb', 'en']
True
TadoDeviceSensor._async_update_callback
(self)
Update and write state.
Update and write state.
def _async_update_callback(self): """Update and write state.""" self._async_update_device_data() self.async_write_ha_state()
[ "def", "_async_update_callback", "(", "self", ")", ":", "self", ".", "_async_update_device_data", "(", ")", "self", ".", "async_write_ha_state", "(", ")" ]
[ 284, 4 ]
[ 287, 35 ]
python
en
['en', 'en', 'en']
True
TadoDeviceSensor._async_update_device_data
(self)
Handle update callbacks.
Handle update callbacks.
def _async_update_device_data(self): """Handle update callbacks.""" try: data = self._tado.data["device"][self.device_id] except KeyError: return if self.device_variable == "tado bridge status": self._state = data.get("connectionState", {}).get("value...
[ "def", "_async_update_device_data", "(", "self", ")", ":", "try", ":", "data", "=", "self", ".", "_tado", ".", "data", "[", "\"device\"", "]", "[", "self", ".", "device_id", "]", "except", "KeyError", ":", "return", "if", "self", ".", "device_variable", ...
[ 290, 4 ]
[ 298, 77 ]
python
en
['en', 'xh', 'en']
True
TadoDeviceSensor.device_info
(self)
Return the device_info of the device.
Return the device_info of the device.
def device_info(self): """Return the device_info of the device.""" return { "identifiers": {(DOMAIN, self.device_id)}, "name": self.device_name, "manufacturer": DEFAULT_NAME, "model": TADO_BRIDGE, }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "device_id", ")", "}", ",", "\"name\"", ":", "self", ".", "device_name", ",", "\"manufacturer\"", ":", "DEFAULT_NAME", ",", "\"model\"...
[ 301, 4 ]
[ 308, 9 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the RaspyRFM switch.
Set up the RaspyRFM switch.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the RaspyRFM switch.""" gateway_manufacturer = config.get( CONF_GATEWAY_MANUFACTURER, Manufacturer.SEEGEL_SYSTEME.value ) gateway_model = config.get(CONF_GATEWAY_MODEL, GatewayModel.RASPYRFM.value) host = config[...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "gateway_manufacturer", "=", "config", ".", "get", "(", "CONF_GATEWAY_MANUFACTURER", ",", "Manufacturer", ".", "SEEGEL_SYSTEME", ".", "value", ...
[ 51, 0 ]
[ 82, 33 ]
python
en
['en', 'pl', 'en']
True
RaspyRFMSwitch.__init__
(self, raspyrfm_client, name: str, gateway, controlunit)
Initialize the switch.
Initialize the switch.
def __init__(self, raspyrfm_client, name: str, gateway, controlunit): """Initialize the switch.""" self._raspyrfm_client = raspyrfm_client self._name = name self._gateway = gateway self._controlunit = controlunit self._state = None
[ "def", "__init__", "(", "self", ",", "raspyrfm_client", ",", "name", ":", "str", ",", "gateway", ",", "controlunit", ")", ":", "self", ".", "_raspyrfm_client", "=", "raspyrfm_client", "self", ".", "_name", "=", "name", "self", ".", "_gateway", "=", "gatewa...
[ 88, 4 ]
[ 96, 26 ]
python
en
['en', 'en', 'en']
True
RaspyRFMSwitch.name
(self)
Return the name of the device if any.
Return the name of the device if any.
def name(self): """Return the name of the device if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 99, 4 ]
[ 101, 25 ]
python
en
['en', 'en', 'en']
True
RaspyRFMSwitch.should_poll
(self)
Return True if polling should be used.
Return True if polling should be used.
def should_poll(self): """Return True if polling should be used.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 104, 4 ]
[ 106, 20 ]
python
en
['en', 'en', 'en']
True
RaspyRFMSwitch.assumed_state
(self)
Return True when the current state can not be queried.
Return True when the current state can not be queried.
def assumed_state(self): """Return True when the current state can not be queried.""" return True
[ "def", "assumed_state", "(", "self", ")", ":", "return", "True" ]
[ 109, 4 ]
[ 111, 19 ]
python
en
['en', 'en', 'en']
True