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
async_setup_entry
( hass, config_entry, async_add_entities, )
Set up platform.
Set up platform.
async def async_setup_entry( hass, config_entry, async_add_entities, ): """Set up platform.""" discovery_info = config_entry.data data_ids = set() def supported(event): return isinstance(event, (ControlEvent, SensorEvent)) entities = [] for packet_id, entity_info in discove...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ",", ")", ":", "discovery_info", "=", "config_entry", ".", "data", "data_ids", "=", "set", "(", ")", "def", "supported", "(", "event", ")", ":", "return", "isin...
[ 222, 0 ]
[ 283, 57 ]
python
en
['en', 'ru', 'en']
True
RfxtrxSensor.__init__
(self, device, device_id, entity_description, event=None)
Initialize the sensor.
Initialize the sensor.
def __init__(self, device, device_id, entity_description, event=None): """Initialize the sensor.""" super().__init__(device, device_id, event=event) self.entity_description = entity_description self._name = f"{device.type_string} {device.id_string} {entity_description.key}" self....
[ "def", "__init__", "(", "self", ",", "device", ",", "device_id", ",", "entity_description", ",", "event", "=", "None", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "device_id", ",", "event", "=", "event", ")", "self", ".", "entity_...
[ 291, 4 ]
[ 298, 9 ]
python
en
['en', 'en', 'en']
True
RfxtrxSensor.async_added_to_hass
(self)
Restore device state.
Restore device state.
async def async_added_to_hass(self): """Restore device state.""" await super().async_added_to_hass() if self._event is None: old_state = await self.async_get_last_state() if old_state is not None: event = old_state.attributes.get(ATTR_EVENT) ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "if", "self", ".", "_event", "is", "None", ":", "old_state", "=", "await", "self", ".", "async_get_last_state", "(", ")", "if", ...
[ 300, 4 ]
[ 309, 60 ]
python
it
['it', 'it', 'en']
True
RfxtrxSensor.native_value
(self)
Return the state of the sensor.
Return the state of the sensor.
def native_value(self): """Return the state of the sensor.""" if not self._event: return None value = self._event.values.get(self.entity_description.key) return self.entity_description.convert(value)
[ "def", "native_value", "(", "self", ")", ":", "if", "not", "self", ".", "_event", ":", "return", "None", "value", "=", "self", ".", "_event", ".", "values", ".", "get", "(", "self", ".", "entity_description", ".", "key", ")", "return", "self", ".", "...
[ 312, 4 ]
[ 317, 53 ]
python
en
['en', 'en', 'en']
True
RfxtrxSensor.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 320, 4 ]
[ 322, 20 ]
python
en
['en', 'en', 'en']
True
RfxtrxSensor.force_update
(self)
We should force updates. Repeated states have meaning.
We should force updates. Repeated states have meaning.
def force_update(self) -> bool: """We should force updates. Repeated states have meaning.""" return True
[ "def", "force_update", "(", "self", ")", "->", "bool", ":", "return", "True" ]
[ 325, 4 ]
[ 327, 19 ]
python
en
['en', 'en', 'en']
True
RfxtrxSensor._handle_event
(self, event, device_id)
Check if event applies to me and update.
Check if event applies to me and update.
def _handle_event(self, event, device_id): """Check if event applies to me and update.""" if device_id != self._device_id: return if self.entity_description.key not in event.values: return _LOGGER.debug( "Sensor update (Device ID: %s Class: %s Sub: %...
[ "def", "_handle_event", "(", "self", ",", "event", ",", "device_id", ")", ":", "if", "device_id", "!=", "self", ".", "_device_id", ":", "return", "if", "self", ".", "entity_description", ".", "key", "not", "in", "event", ".", "values", ":", "return", "_L...
[ 330, 4 ]
[ 347, 35 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Currencylayer sensor.
Set up the Currencylayer sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Currencylayer sensor.""" base = config[CONF_BASE] api_key = config[CONF_API_KEY] parameters = {"source": base, "access_key": api_key, "format": 1} rest = CurrencylayerData(_RESOURCE, parameters) response = reque...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "base", "=", "config", "[", "CONF_BASE", "]", "api_key", "=", "config", "[", "CONF_API_KEY", "]", "parameters", "=", "{", "\"source\"", ...
[ 39, 0 ]
[ 53, 31 ]
python
en
['en', 'da', 'en']
True
CurrencylayerSensor.__init__
(self, rest, base, quote)
Initialize the sensor.
Initialize the sensor.
def __init__(self, rest, base, quote): """Initialize the sensor.""" self.rest = rest self._quote = quote self._base = base self._state = None
[ "def", "__init__", "(", "self", ",", "rest", ",", "base", ",", "quote", ")", ":", "self", ".", "rest", "=", "rest", "self", ".", "_quote", "=", "quote", "self", ".", "_base", "=", "base", "self", ".", "_state", "=", "None" ]
[ 59, 4 ]
[ 64, 26 ]
python
en
['en', 'en', 'en']
True
CurrencylayerSensor.native_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 native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._quote
[ "def", "native_unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_quote" ]
[ 67, 4 ]
[ 69, 26 ]
python
en
['en', 'en', 'en']
True
CurrencylayerSensor.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._base
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_base" ]
[ 72, 4 ]
[ 74, 25 ]
python
en
['en', 'mi', 'en']
True
CurrencylayerSensor.icon
(self)
Return the icon to use in the frontend, if any.
Return the icon to use in the frontend, if any.
def icon(self): """Return the icon to use in the frontend, if any.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 77, 4 ]
[ 79, 19 ]
python
en
['en', 'en', 'en']
True
CurrencylayerSensor.native_value
(self)
Return the state of the sensor.
Return the state of the sensor.
def native_value(self): """Return the state of the sensor.""" return self._state
[ "def", "native_value", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 82, 4 ]
[ 84, 26 ]
python
en
['en', 'en', 'en']
True
CurrencylayerSensor.extra_state_attributes
(self)
Return the state attributes of the sensor.
Return the state attributes of the sensor.
def extra_state_attributes(self): """Return the state attributes of the sensor.""" return {ATTR_ATTRIBUTION: ATTRIBUTION}
[ "def", "extra_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", "}" ]
[ 87, 4 ]
[ 89, 46 ]
python
en
['en', 'en', 'en']
True
CurrencylayerSensor.update
(self)
Update current date.
Update current date.
def update(self): """Update current date.""" self.rest.update() value = self.rest.data if value is not None: self._state = round(value[f"{self._base}{self._quote}"], 4)
[ "def", "update", "(", "self", ")", ":", "self", ".", "rest", ".", "update", "(", ")", "value", "=", "self", ".", "rest", ".", "data", "if", "value", "is", "not", "None", ":", "self", ".", "_state", "=", "round", "(", "value", "[", "f\"{self._base}{...
[ 91, 4 ]
[ 96, 71 ]
python
co
['ro', 'co', 'en']
False
CurrencylayerData.__init__
(self, resource, parameters)
Initialize the data object.
Initialize the data object.
def __init__(self, resource, parameters): """Initialize the data object.""" self._resource = resource self._parameters = parameters self.data = None
[ "def", "__init__", "(", "self", ",", "resource", ",", "parameters", ")", ":", "self", ".", "_resource", "=", "resource", "self", ".", "_parameters", "=", "parameters", "self", ".", "data", "=", "None" ]
[ 102, 4 ]
[ 106, 24 ]
python
en
['en', 'en', 'en']
True
CurrencylayerData.update
(self)
Get the latest data from Currencylayer.
Get the latest data from Currencylayer.
def update(self): """Get the latest data from Currencylayer.""" try: result = requests.get(self._resource, params=self._parameters, timeout=10) if "error" in result.json(): raise ValueError(result.json()["error"]["info"]) self.data = result.json()["quo...
[ "def", "update", "(", "self", ")", ":", "try", ":", "result", "=", "requests", ".", "get", "(", "self", ".", "_resource", ",", "params", "=", "self", ".", "_parameters", ",", "timeout", "=", "10", ")", "if", "\"error\"", "in", "result", ".", "json", ...
[ 108, 4 ]
[ 118, 28 ]
python
en
['en', 'en', 'en']
True
test_setup_missing_config
(hass)
Test setup with configuration missing required entries.
Test setup with configuration missing required entries.
async def test_setup_missing_config(hass): """Test setup with configuration missing required entries.""" with assert_setup_component(0): assert await async_setup_component( hass, DOMAIN, {"sensor": {"platform": "mhz19"}} )
[ "async", "def", "test_setup_missing_config", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "0", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"mhz19\"", ...
[ 18, 0 ]
[ 23, 9 ]
python
en
['en', 'en', 'en']
True
test_setup_failed_connect
(mock_co2, hass)
Test setup when connection error occurs.
Test setup when connection error occurs.
async def test_setup_failed_connect(mock_co2, hass): """Test setup when connection error occurs.""" assert not mhz19.setup_platform( hass, {"platform": "mhz19", mhz19.CONF_SERIAL_DEVICE: "test.serial"}, None, )
[ "async", "def", "test_setup_failed_connect", "(", "mock_co2", ",", "hass", ")", ":", "assert", "not", "mhz19", ".", "setup_platform", "(", "hass", ",", "{", "\"platform\"", ":", "\"mhz19\"", ",", "mhz19", ".", "CONF_SERIAL_DEVICE", ":", "\"test.serial\"", "}", ...
[ 27, 0 ]
[ 33, 5 ]
python
en
['en', 'en', 'en']
True
test_setup_connected
(hass)
Test setup when connection succeeds.
Test setup when connection succeeds.
async def test_setup_connected(hass): """Test setup when connection succeeds.""" with patch.multiple( "pmsensor.co2sensor", read_mh_z19=DEFAULT, read_mh_z19_with_temperature=DEFAULT, ): read_mh_z19_with_temperature.return_value = None mock_add = Mock() mhz19.s...
[ "async", "def", "test_setup_connected", "(", "hass", ")", ":", "with", "patch", ".", "multiple", "(", "\"pmsensor.co2sensor\"", ",", "read_mh_z19", "=", "DEFAULT", ",", "read_mh_z19_with_temperature", "=", "DEFAULT", ",", ")", ":", "read_mh_z19_with_temperature", "....
[ 36, 0 ]
[ 55, 35 ]
python
en
['en', 'fr', 'en']
True
aiohttp_client_update_oserror
(mock_function)
Test MHZClient when library throws OSError.
Test MHZClient when library throws OSError.
async def aiohttp_client_update_oserror(mock_function): """Test MHZClient when library throws OSError.""" client = mhz19.MHZClient(co2sensor, "test.serial") client.update() assert {} == client.data
[ "async", "def", "aiohttp_client_update_oserror", "(", "mock_function", ")", ":", "client", "=", "mhz19", ".", "MHZClient", "(", "co2sensor", ",", "\"test.serial\"", ")", "client", ".", "update", "(", ")", "assert", "{", "}", "==", "client", ".", "data" ]
[ 62, 0 ]
[ 66, 28 ]
python
en
['en', 'en', 'en']
True
aiohttp_client_update_ppm_overflow
(mock_function)
Test MHZClient when ppm is too high.
Test MHZClient when ppm is too high.
async def aiohttp_client_update_ppm_overflow(mock_function): """Test MHZClient when ppm is too high.""" client = mhz19.MHZClient(co2sensor, "test.serial") client.update() assert client.data.get("co2") is None
[ "async", "def", "aiohttp_client_update_ppm_overflow", "(", "mock_function", ")", ":", "client", "=", "mhz19", ".", "MHZClient", "(", "co2sensor", ",", "\"test.serial\"", ")", "client", ".", "update", "(", ")", "assert", "client", ".", "data", ".", "get", "(", ...
[ 70, 0 ]
[ 74, 41 ]
python
en
['en', 'en', 'en']
True
aiohttp_client_update_good_read
(mock_function)
Test MHZClient when ppm is too high.
Test MHZClient when ppm is too high.
async def aiohttp_client_update_good_read(mock_function): """Test MHZClient when ppm is too high.""" client = mhz19.MHZClient(co2sensor, "test.serial") client.update() assert {"temperature": 24, "co2": 1000} == client.data
[ "async", "def", "aiohttp_client_update_good_read", "(", "mock_function", ")", ":", "client", "=", "mhz19", ".", "MHZClient", "(", "co2sensor", ",", "\"test.serial\"", ")", "client", ".", "update", "(", ")", "assert", "{", "\"temperature\"", ":", "24", ",", "\"...
[ 78, 0 ]
[ 82, 58 ]
python
en
['en', 'en', 'en']
True
test_co2_sensor
(mock_function, hass)
Test CO2 sensor.
Test CO2 sensor.
async def test_co2_sensor(mock_function, hass): """Test CO2 sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, "name", mhz19.SENSOR_TYPES[1]) sensor.hass = hass sensor.update() assert sensor.name == "name: CO2" assert sensor.state == 1000 as...
[ "async", "def", "test_co2_sensor", "(", "mock_function", ",", "hass", ")", ":", "client", "=", "mhz19", ".", "MHZClient", "(", "co2sensor", ",", "\"test.serial\"", ")", "sensor", "=", "mhz19", ".", "MHZ19Sensor", "(", "client", ",", "\"name\"", ",", "mhz19",...
[ 86, 0 ]
[ 97, 63 ]
python
en
['en', 'st', 'en']
True
test_temperature_sensor
(mock_function, hass)
Test temperature sensor.
Test temperature sensor.
async def test_temperature_sensor(mock_function, hass): """Test temperature sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, "name", mhz19.SENSOR_TYPES[0]) sensor.hass = hass sensor.update() assert sensor.name == "name: Temperature" assert sen...
[ "async", "def", "test_temperature_sensor", "(", "mock_function", ",", "hass", ")", ":", "client", "=", "mhz19", ".", "MHZClient", "(", "co2sensor", ",", "\"test.serial\"", ")", "sensor", "=", "mhz19", ".", "MHZ19Sensor", "(", "client", ",", "\"name\"", ",", ...
[ 101, 0 ]
[ 112, 71 ]
python
en
['en', 'la', 'en']
True
test_temperature_sensor_f
(mock_function, hass)
Test temperature sensor.
Test temperature sensor.
async def test_temperature_sensor_f(mock_function, hass): """Test temperature sensor.""" with patch.object(hass.config.units, "temperature_unit", TEMP_FAHRENHEIT): client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, "name", mhz19.SENSOR_TYPES[0]) sensor....
[ "async", "def", "test_temperature_sensor_f", "(", "mock_function", ",", "hass", ")", ":", "with", "patch", ".", "object", "(", "hass", ".", "config", ".", "units", ",", "\"temperature_unit\"", ",", "TEMP_FAHRENHEIT", ")", ":", "client", "=", "mhz19", ".", "M...
[ 116, 0 ]
[ 124, 33 ]
python
en
['en', 'la', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the light platform for ADS.
Set up the light platform for ADS.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the light platform for ADS.""" ads_hub = hass.data.get(DATA_ADS) ads_var_enable = config[CONF_ADS_VAR] ads_var_brightness = config.get(CONF_ADS_VAR_BRIGHTNESS) name = config[CONF_NAME] add_entities([AdsLight(ads_hub...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "ads_hub", "=", "hass", ".", "data", ".", "get", "(", "DATA_ADS", ")", "ads_var_enable", "=", "config", "[", "CONF_ADS_VAR", "]", "ads_v...
[ 33, 0 ]
[ 41, 79 ]
python
en
['en', 'da', 'en']
True
AdsLight.__init__
(self, ads_hub, ads_var_enable, ads_var_brightness, name)
Initialize AdsLight entity.
Initialize AdsLight entity.
def __init__(self, ads_hub, ads_var_enable, ads_var_brightness, name): """Initialize AdsLight entity.""" super().__init__(ads_hub, name, ads_var_enable) self._state_dict[STATE_KEY_BRIGHTNESS] = None self._ads_var_brightness = ads_var_brightness if ads_var_brightness is not None: ...
[ "def", "__init__", "(", "self", ",", "ads_hub", ",", "ads_var_enable", ",", "ads_var_brightness", ",", "name", ")", ":", "super", "(", ")", ".", "__init__", "(", "ads_hub", ",", "name", ",", "ads_var_enable", ")", "self", ".", "_state_dict", "[", "STATE_KE...
[ 47, 4 ]
[ 53, 62 ]
python
fr
['fr', 'zu', 'it']
False
AdsLight.async_added_to_hass
(self)
Register device notification.
Register device notification.
async def async_added_to_hass(self): """Register device notification.""" await self.async_initialize_device(self._ads_var, self._ads_hub.PLCTYPE_BOOL) if self._ads_var_brightness is not None: await self.async_initialize_device( self._ads_var_brightness, ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "self", ".", "async_initialize_device", "(", "self", ".", "_ads_var", ",", "self", ".", "_ads_hub", ".", "PLCTYPE_BOOL", ")", "if", "self", ".", "_ads_var_brightness", "is", "not", "None", ...
[ 55, 4 ]
[ 64, 13 ]
python
en
['da', 'en', 'en']
True
AdsLight.brightness
(self)
Return the brightness of the light (0..255).
Return the brightness of the light (0..255).
def brightness(self) -> int | None: """Return the brightness of the light (0..255).""" return self._state_dict[STATE_KEY_BRIGHTNESS]
[ "def", "brightness", "(", "self", ")", "->", "int", "|", "None", ":", "return", "self", ".", "_state_dict", "[", "STATE_KEY_BRIGHTNESS", "]" ]
[ 67, 4 ]
[ 69, 53 ]
python
en
['en', 'no', 'en']
True
AdsLight.is_on
(self)
Return True if the entity is on.
Return True if the entity is on.
def is_on(self) -> bool: """Return True if the entity is on.""" return self._state_dict[STATE_KEY_STATE]
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_state_dict", "[", "STATE_KEY_STATE", "]" ]
[ 72, 4 ]
[ 74, 48 ]
python
en
['en', 'en', 'en']
True
AdsLight.turn_on
(self, **kwargs)
Turn the light on or set a specific dimmer value.
Turn the light on or set a specific dimmer value.
def turn_on(self, **kwargs): """Turn the light on or set a specific dimmer value.""" brightness = kwargs.get(ATTR_BRIGHTNESS) self._ads_hub.write_by_name(self._ads_var, True, self._ads_hub.PLCTYPE_BOOL) if self._ads_var_brightness is not None and brightness is not None: self...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "brightness", "=", "kwargs", ".", "get", "(", "ATTR_BRIGHTNESS", ")", "self", ".", "_ads_hub", ".", "write_by_name", "(", "self", ".", "_ads_var", ",", "True", ",", "self", ".", "_ads_hu...
[ 76, 4 ]
[ 84, 13 ]
python
en
['en', 'en', 'en']
True
AdsLight.turn_off
(self, **kwargs)
Turn the light off.
Turn the light off.
def turn_off(self, **kwargs): """Turn the light off.""" self._ads_hub.write_by_name(self._ads_var, False, self._ads_hub.PLCTYPE_BOOL)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_ads_hub", ".", "write_by_name", "(", "self", ".", "_ads_var", ",", "False", ",", "self", ".", "_ads_hub", ".", "PLCTYPE_BOOL", ")" ]
[ 86, 4 ]
[ 88, 85 ]
python
en
['en', 'zh', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Flipr from a config entry.
Set up Flipr from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Flipr from a config entry.""" hass.data.setdefault(DOMAIN, {}) coordinator = FliprDataUpdateCoordinator(hass, entry) await coordinator.async_config_entry_first_refresh() hass.data[DOMAIN][entry.entry_id] = coord...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "coordinator", "=", "FliprDataUpdateCoordinator", "("...
[ 25, 0 ]
[ 35, 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) -> bool: """Unload a config entry.""" unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) if unload_ok: hass.data[DOMAIN].pop(entry.entry_id) return unload_ok
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "unload_ok", "=", "await", "hass", ".", "config_entries", ".", "async_unload_platforms", "(", "entry", ",", "PLATFORMS", ")", "if...
[ 38, 0 ]
[ 45, 20 ]
python
en
['en', 'es', 'en']
True
FliprDataUpdateCoordinator.__init__
(self, hass, entry)
Initialize.
Initialize.
def __init__(self, hass, entry): """Initialize.""" username = entry.data[CONF_EMAIL] password = entry.data[CONF_PASSWORD] self.flipr_id = entry.data[CONF_FLIPR_ID] # Establishes the connection. self.client = FliprAPIRestClient(username, password) self.entry = ent...
[ "def", "__init__", "(", "self", ",", "hass", ",", "entry", ")", ":", "username", "=", "entry", ".", "data", "[", "CONF_EMAIL", "]", "password", "=", "entry", ".", "data", "[", "CONF_PASSWORD", "]", "self", ".", "flipr_id", "=", "entry", ".", "data", ...
[ 51, 4 ]
[ 66, 9 ]
python
en
['en', 'en', 'it']
False
FliprDataUpdateCoordinator._async_update_data
(self)
Fetch data from API endpoint.
Fetch data from API endpoint.
async def _async_update_data(self): """Fetch data from API endpoint.""" return await self.hass.async_add_executor_job( self.client.get_pool_measure_latest, self.flipr_id )
[ "async", "def", "_async_update_data", "(", "self", ")", ":", "return", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "client", ".", "get_pool_measure_latest", ",", "self", ".", "flipr_id", ")" ]
[ 68, 4 ]
[ 72, 9 ]
python
en
['en', 'en', 'en']
True
FliprEntity.__init__
( self, coordinator: DataUpdateCoordinator, description: EntityDescription )
Initialize Flipr sensor.
Initialize Flipr sensor.
def __init__( self, coordinator: DataUpdateCoordinator, description: EntityDescription ) -> None: """Initialize Flipr sensor.""" super().__init__(coordinator) self.entity_description = description if coordinator.config_entry: flipr_id = coordinator.config_entry.da...
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "DataUpdateCoordinator", ",", "description", ":", "EntityDescription", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "entity_description", "=", "descri...
[ 80, 4 ]
[ 96, 68 ]
python
da
['en', 'da', 'it']
False
get_service
(hass, config, discovery_info=None)
Get the Telegram notification service.
Get the Telegram notification service.
def get_service(hass, config, discovery_info=None): """Get the Telegram notification service.""" setup_reload_service(hass, TELEGRAM_DOMAIN, PLATFORMS) chat_id = config.get(CONF_CHAT_ID) return TelegramNotificationService(hass, chat_id)
[ "def", "get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "setup_reload_service", "(", "hass", ",", "TELEGRAM_DOMAIN", ",", "PLATFORMS", ")", "chat_id", "=", "config", ".", "get", "(", "CONF_CHAT_ID", ")", "return", "Tel...
[ 33, 0 ]
[ 38, 53 ]
python
en
['en', 'de', 'en']
True
TelegramNotificationService.__init__
(self, hass, chat_id)
Initialize the service.
Initialize the service.
def __init__(self, hass, chat_id): """Initialize the service.""" self._chat_id = chat_id self.hass = hass
[ "def", "__init__", "(", "self", ",", "hass", ",", "chat_id", ")", ":", "self", ".", "_chat_id", "=", "chat_id", "self", ".", "hass", "=", "hass" ]
[ 44, 4 ]
[ 47, 24 ]
python
en
['en', 'en', 'en']
True
TelegramNotificationService.send_message
(self, message="", **kwargs)
Send a message to a user.
Send a message to a user.
def send_message(self, message="", **kwargs): """Send a message to a user.""" service_data = {ATTR_TARGET: kwargs.get(ATTR_TARGET, self._chat_id)} if ATTR_TITLE in kwargs: service_data.update({ATTR_TITLE: kwargs.get(ATTR_TITLE)}) if message: service_data.update({A...
[ "def", "send_message", "(", "self", ",", "message", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "service_data", "=", "{", "ATTR_TARGET", ":", "kwargs", ".", "get", "(", "ATTR_TARGET", ",", "self", ".", "_chat_id", ")", "}", "if", "ATTR_TITLE", "in"...
[ 49, 4 ]
[ 107, 9 ]
python
en
['en', 'en', 'en']
True
test_get_system_info
(hass)
Test the get system info.
Test the get system info.
async def test_get_system_info(hass): """Test the get system info.""" info = await hass.helpers.system_info.async_get_system_info() assert isinstance(info, dict) assert info["version"] == current_version assert info["user"] is not None assert json.dumps(info) is not None
[ "async", "def", "test_get_system_info", "(", "hass", ")", ":", "info", "=", "await", "hass", ".", "helpers", ".", "system_info", ".", "async_get_system_info", "(", ")", "assert", "isinstance", "(", "info", ",", "dict", ")", "assert", "info", "[", "\"version\...
[ 7, 0 ]
[ 13, 39 ]
python
en
['en', 'en', 'en']
True
test_container_installationtype
(hass)
Test container installation type.
Test container installation type.
async def test_container_installationtype(hass): """Test container installation type.""" with patch("platform.system", return_value="Linux"), patch( "os.path.isfile", return_value=True ): info = await hass.helpers.system_info.async_get_system_info() assert info["installation_type"] =...
[ "async", "def", "test_container_installationtype", "(", "hass", ")", ":", "with", "patch", "(", "\"platform.system\"", ",", "return_value", "=", "\"Linux\"", ")", ",", "patch", "(", "\"os.path.isfile\"", ",", "return_value", "=", "True", ")", ":", "info", "=", ...
[ 16, 0 ]
[ 28, 53 ]
python
en
['it', 'en', 'en']
True
ConfigFlow.async_get_options_flow
(config_entry)
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return OptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "OptionsFlowHandler", "(", "config_entry", ")" ]
[ 24, 4 ]
[ 26, 47 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" errors = {} if user_input is not None: name = user_input[CONF_NAME] longitude = user_input[CONF_LONGITUDE] latitude = user_input[CONF_LATITUDE] session = aiohttp_cli...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "name", "=", "user_input", "[", "CONF_NAME", "]", "longitude", "=", "user_input", "[", "CONF_...
[ 28, 4 ]
[ 78, 9 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.__init__
(self, config_entry)
Initialize options flow.
Initialize options flow.
def __init__(self, config_entry): """Initialize options flow.""" self.config_entry = config_entry
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 84, 4 ]
[ 86, 40 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.async_step_init
(self, user_input=None)
Manage options.
Manage options.
async def async_step_init(self, user_input=None): """Manage options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) return self.async_show_form( step_id="init", data_schema=vol.Schema( { ...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "user_input", ")", "return", ...
[ 88, 4 ]
[ 109, 9 ]
python
en
['en', 'en', 'en']
False
is_pathlib_path
(obj)
Check whether obj is a pathlib.Path object. Prefer using `isinstance(obj, os_PathLike)` instead of this function.
Check whether obj is a pathlib.Path object.
def is_pathlib_path(obj): """ Check whether obj is a pathlib.Path object. Prefer using `isinstance(obj, os_PathLike)` instead of this function. """ return Path is not None and isinstance(obj, Path)
[ "def", "is_pathlib_path", "(", "obj", ")", ":", "return", "Path", "is", "not", "None", "and", "isinstance", "(", "obj", ",", "Path", ")" ]
[ 78, 0 ]
[ 84, 53 ]
python
en
['en', 'error', 'th']
False
npy_load_module
(name, fn, info=None)
Load a module. .. versionadded:: 1.11.2 Parameters ---------- name : str Full module name. fn : str Path to module file. info : tuple, optional Only here for backward compatibility with Python 2.*. Returns ------- mod : module
Load a module.
def npy_load_module(name, fn, info=None): """ Load a module. .. versionadded:: 1.11.2 Parameters ---------- name : str Full module name. fn : str Path to module file. info : tuple, optional Only here for backward compatibility with Python 2.*. Returns -...
[ "def", "npy_load_module", "(", "name", ",", "fn", ",", "info", "=", "None", ")", ":", "# Explicitly lazy import this to avoid paying the cost", "# of importing importlib at startup", "from", "importlib", ".", "machinery", "import", "SourceFileLoader", "return", "SourceFileL...
[ 108, 0 ]
[ 131, 51 ]
python
en
['en', 'error', 'th']
False
async_get_scanner
(hass, config)
Return a Sky Hub scanner if successful.
Return a Sky Hub scanner if successful.
async def async_get_scanner(hass, config): """Return a Sky Hub scanner if successful.""" host = config[DOMAIN].get(CONF_HOST, "192.168.1.254") websession = async_get_clientsession(hass) hub = SkyQHub(websession, host) _LOGGER.debug("Initialising Sky Hub") await hub.async_connect() if hub.su...
[ "async", "def", "async_get_scanner", "(", "hass", ",", "config", ")", ":", "host", "=", "config", "[", "DOMAIN", "]", ".", "get", "(", "CONF_HOST", ",", "\"192.168.1.254\"", ")", "websession", "=", "async_get_clientsession", "(", "hass", ")", "hub", "=", "...
[ 20, 0 ]
[ 32, 15 ]
python
en
['en', 'co', 'en']
True
SkyHubDeviceScanner.__init__
(self, hub)
Initialise the scanner.
Initialise the scanner.
def __init__(self, hub): """Initialise the scanner.""" self._hub = hub self.last_results = {}
[ "def", "__init__", "(", "self", ",", "hub", ")", ":", "self", ".", "_hub", "=", "hub", "self", ".", "last_results", "=", "{", "}" ]
[ 38, 4 ]
[ 41, 30 ]
python
en
['en', 'en', 'en']
True
SkyHubDeviceScanner.async_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.
async def async_scan_devices(self): """Scan for new devices and return a list with found device IDs.""" await self._async_update_info() return [device.mac for device in self.last_results]
[ "async", "def", "async_scan_devices", "(", "self", ")", ":", "await", "self", ".", "_async_update_info", "(", ")", "return", "[", "device", ".", "mac", "for", "device", "in", "self", ".", "last_results", "]" ]
[ 43, 4 ]
[ 46, 59 ]
python
en
['en', 'en', 'en']
True
SkyHubDeviceScanner.async_get_device_name
(self, device)
Return the name of the given device.
Return the name of the given device.
async def async_get_device_name(self, device): """Return the name of the given device.""" name = next( (result.name for result in self.last_results if result.mac == device), None, ) return name
[ "async", "def", "async_get_device_name", "(", "self", ",", "device", ")", ":", "name", "=", "next", "(", "(", "result", ".", "name", "for", "result", "in", "self", ".", "last_results", "if", "result", ".", "mac", "==", "device", ")", ",", "None", ",", ...
[ 48, 4 ]
[ 54, 19 ]
python
en
['en', 'en', 'en']
True
SkyHubDeviceScanner.async_get_extra_attributes
(self, device)
Get extra attributes of a device.
Get extra attributes of a device.
async def async_get_extra_attributes(self, device): """Get extra attributes of a device.""" device = next( (result for result in self.last_results if result.mac == device), None ) if device is None: return {} return device.asdict()
[ "async", "def", "async_get_extra_attributes", "(", "self", ",", "device", ")", ":", "device", "=", "next", "(", "(", "result", "for", "result", "in", "self", ".", "last_results", "if", "result", ".", "mac", "==", "device", ")", ",", "None", ")", "if", ...
[ 56, 4 ]
[ 64, 30 ]
python
en
['en', 'en', 'en']
True
SkyHubDeviceScanner._async_update_info
(self)
Ensure the information from the Sky Hub is up to date.
Ensure the information from the Sky Hub is up to date.
async def _async_update_info(self): """Ensure the information from the Sky Hub is up to date.""" _LOGGER.debug("Scanning") data = await self._hub.async_get_skyhub_data() if not data: return self.last_results = data
[ "async", "def", "_async_update_info", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Scanning\"", ")", "data", "=", "await", "self", ".", "_hub", ".", "async_get_skyhub_data", "(", ")", "if", "not", "data", ":", "return", "self", ".", "last_result...
[ 66, 4 ]
[ 75, 32 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Binary Sensor platform for ADS.
Set up the Binary Sensor platform for ADS.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Binary Sensor platform for ADS.""" ads_hub = hass.data.get(DATA_ADS) ads_var = config[CONF_ADS_VAR] name = config[CONF_NAME] device_class = config.get(CONF_DEVICE_CLASS) ads_sensor = AdsBinarySensor(ads_hub, nam...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "ads_hub", "=", "hass", ".", "data", ".", "get", "(", "DATA_ADS", ")", "ads_var", "=", "config", "[", "CONF_ADS_VAR", "]", "name", "="...
[ 24, 0 ]
[ 33, 30 ]
python
en
['en', 'pt', 'en']
True
AdsBinarySensor.__init__
(self, ads_hub, name, ads_var, device_class)
Initialize ADS binary sensor.
Initialize ADS binary sensor.
def __init__(self, ads_hub, name, ads_var, device_class): """Initialize ADS binary sensor.""" super().__init__(ads_hub, name, ads_var) self._attr_device_class = device_class or DEVICE_CLASS_MOVING
[ "def", "__init__", "(", "self", ",", "ads_hub", ",", "name", ",", "ads_var", ",", "device_class", ")", ":", "super", "(", ")", ".", "__init__", "(", "ads_hub", ",", "name", ",", "ads_var", ")", "self", ".", "_attr_device_class", "=", "device_class", "or"...
[ 39, 4 ]
[ 42, 69 ]
python
en
['en', 'pl', 'en']
True
AdsBinarySensor.async_added_to_hass
(self)
Register device notification.
Register device notification.
async def async_added_to_hass(self): """Register device notification.""" await self.async_initialize_device(self._ads_var, self._ads_hub.PLCTYPE_BOOL)
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "self", ".", "async_initialize_device", "(", "self", ".", "_ads_var", ",", "self", ".", "_ads_hub", ".", "PLCTYPE_BOOL", ")" ]
[ 44, 4 ]
[ 46, 85 ]
python
en
['da', 'en', 'en']
True
AdsBinarySensor.is_on
(self)
Return True if the entity is on.
Return True if the entity is on.
def is_on(self) -> bool: """Return True if the entity is on.""" return self._state_dict[STATE_KEY_STATE]
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_state_dict", "[", "STATE_KEY_STATE", "]" ]
[ 49, 4 ]
[ 51, 48 ]
python
en
['en', 'en', 'en']
True
KeeneticFlowHandler.async_get_options_flow
( config_entry: ConfigEntry, )
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow( config_entry: ConfigEntry, ) -> KeeneticOptionsFlowHandler: """Get the options flow for this handler.""" return KeeneticOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ":", "ConfigEntry", ",", ")", "->", "KeeneticOptionsFlowHandler", ":", "return", "KeeneticOptionsFlowHandler", "(", "config_entry", ")" ]
[ 47, 4 ]
[ 51, 55 ]
python
en
['en', 'en', 'en']
True
KeeneticFlowHandler.async_step_user
( self, user_input: dict[str, Any] | None = None )
Handle a flow initialized by the user.
Handle a flow initialized by the user.
async def async_step_user( self, user_input: dict[str, Any] | None = None ) -> FlowResult: """Handle a flow initialized by the user.""" errors = {} if user_input is not None: host = self.context.get(CONF_HOST) or user_input[CONF_HOST] self._async_abort_entries...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", ":", "dict", "[", "str", ",", "Any", "]", "|", "None", "=", "None", ")", "->", "FlowResult", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "host", "=", ...
[ 53, 4 ]
[ 98, 9 ]
python
en
['en', 'en', 'en']
True
KeeneticFlowHandler.async_step_import
( self, user_input: ConfigType | None = None )
Import a config entry.
Import a config entry.
async def async_step_import( self, user_input: ConfigType | None = None ) -> FlowResult: """Import a config entry.""" return await self.async_step_user(user_input)
[ "async", "def", "async_step_import", "(", "self", ",", "user_input", ":", "ConfigType", "|", "None", "=", "None", ")", "->", "FlowResult", ":", "return", "await", "self", ".", "async_step_user", "(", "user_input", ")" ]
[ 100, 4 ]
[ 104, 53 ]
python
en
['en', 'en', 'en']
True
KeeneticFlowHandler.async_step_ssdp
(self, discovery_info: DiscoveryInfoType)
Handle a discovered device.
Handle a discovered device.
async def async_step_ssdp(self, discovery_info: DiscoveryInfoType) -> FlowResult: """Handle a discovered device.""" friendly_name = discovery_info.get(ssdp.ATTR_UPNP_FRIENDLY_NAME, "") # Filter out items not having "keenetic" in their name if "keenetic" not in friendly_name.lower(): ...
[ "async", "def", "async_step_ssdp", "(", "self", ",", "discovery_info", ":", "DiscoveryInfoType", ")", "->", "FlowResult", ":", "friendly_name", "=", "discovery_info", ".", "get", "(", "ssdp", ".", "ATTR_UPNP_FRIENDLY_NAME", ",", "\"\"", ")", "# Filter out items not ...
[ 106, 4 ]
[ 129, 43 ]
python
en
['en', 'en', 'en']
True
KeeneticOptionsFlowHandler.__init__
(self, config_entry: ConfigEntry)
Initialize options flow.
Initialize options flow.
def __init__(self, config_entry: ConfigEntry) -> None: """Initialize options flow.""" self.config_entry = config_entry self._interface_options = {}
[ "def", "__init__", "(", "self", ",", "config_entry", ":", "ConfigEntry", ")", "->", "None", ":", "self", ".", "config_entry", "=", "config_entry", "self", ".", "_interface_options", "=", "{", "}" ]
[ 135, 4 ]
[ 138, 36 ]
python
en
['en', 'en', 'en']
True
KeeneticOptionsFlowHandler.async_step_init
( self, user_input: dict[str, Any] | None = None )
Manage the options.
Manage the options.
async def async_step_init( self, user_input: dict[str, Any] | None = None ) -> FlowResult: """Manage the options.""" router: KeeneticRouter = self.hass.data[DOMAIN][self.config_entry.entry_id][ ROUTER ] interfaces: list[InterfaceInfo] = await self.hass.async_add_...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", ":", "dict", "[", "str", ",", "Any", "]", "|", "None", "=", "None", ")", "->", "FlowResult", ":", "router", ":", "KeeneticRouter", "=", "self", ".", "hass", ".", "data", "[", "DOMAIN", ...
[ 140, 4 ]
[ 157, 43 ]
python
en
['en', 'en', 'en']
True
KeeneticOptionsFlowHandler.async_step_user
( self, user_input: dict[str, Any] | None = None )
Manage the device tracker options.
Manage the device tracker options.
async def async_step_user( self, user_input: dict[str, Any] | None = None ) -> FlowResult: """Manage the device tracker options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) options = vol.Schema( { vo...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", ":", "dict", "[", "str", ",", "Any", "]", "|", "None", "=", "None", ")", "->", "FlowResult", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry"...
[ 159, 4 ]
[ 203, 72 ]
python
en
['en', 'en', 'en']
True
test_duplicate_error
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test that errors are shown when duplicates are added.
Test that errors are shown when duplicates are added.
async def test_duplicate_error( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test that errors are shown when duplicates are added.""" await setup_integration(hass, aioclient_mock, skip_entry_setup=True) mock_connection(aioclient_mock) user_input = {CONF_HOST: HOST} res...
[ "async", "def", "test_duplicate_error", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "await", "setup_integration", "(", "hass", ",", "aioclient_mock", ",", "skip_entry_setup", "=", "True", ")", "mock...
[ 27, 0 ]
[ 56, 51 ]
python
en
['en', 'en', 'en']
True
test_form
(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker)
Test the user step.
Test the user step.
async def test_form(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker) -> None: """Test the user step.""" await async_setup_component(hass, "persistent_notification", {}) mock_connection(aioclient_mock) result = await hass.config_entries.flow.async_init( DOMAIN, context={CONF_SOURCE: SOU...
[ "async", "def", "test_form", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "await", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "mock_connection", "("...
[ 59, 0 ]
[ 86, 48 ]
python
en
['en', 'en', 'en']
True
test_form_cannot_connect
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test we handle cannot connect roku error.
Test we handle cannot connect roku error.
async def test_form_cannot_connect( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we handle cannot connect roku error.""" mock_connection(aioclient_mock, error=True) result = await hass.config_entries.flow.async_init( DOMAIN, context={CONF_SOURCE: SOURCE_USER} ...
[ "async", "def", "test_form_cannot_connect", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "mock_connection", "(", "aioclient_mock", ",", "error", "=", "True", ")", "result", "=", "await", "hass", "....
[ 89, 0 ]
[ 104, 57 ]
python
en
['en', 'en', 'en']
True
test_form_unknown_error
(hass: HomeAssistant)
Test we handle unknown error.
Test we handle unknown error.
async def test_form_unknown_error(hass: HomeAssistant) -> None: """Test we handle unknown error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={CONF_SOURCE: SOURCE_USER} ) user_input = {CONF_HOST: HOST} with patch( "homeassistant.components.roku.config_flow....
[ "async", "def", "test_form_unknown_error", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "CONF_SOURCE", ":", "SOURCE_...
[ 107, 0 ]
[ 126, 51 ]
python
en
['en', 'de', 'en']
True
test_homekit_cannot_connect
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test we abort homekit flow on connection error.
Test we abort homekit flow on connection error.
async def test_homekit_cannot_connect( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we abort homekit flow on connection error.""" mock_connection( aioclient_mock, host=HOMEKIT_HOST, error=True, ) discovery_info = MOCK_HOMEKIT_DISCOVERY_INFO.cop...
[ "async", "def", "test_homekit_cannot_connect", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "mock_connection", "(", "aioclient_mock", ",", "host", "=", "HOMEKIT_HOST", ",", "error", "=", "True", ",",...
[ 129, 0 ]
[ 147, 47 ]
python
en
['en', 'nl', 'en']
True
test_homekit_unknown_error
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test we abort homekit flow on unknown error.
Test we abort homekit flow on unknown error.
async def test_homekit_unknown_error( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we abort homekit flow on unknown error.""" discovery_info = MOCK_HOMEKIT_DISCOVERY_INFO.copy() with patch( "homeassistant.components.roku.config_flow.Roku.update", side_effec...
[ "async", "def", "test_homekit_unknown_error", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "discovery_info", "=", "MOCK_HOMEKIT_DISCOVERY_INFO", ".", "copy", "(", ")", "with", "patch", "(", "\"homeassi...
[ 150, 0 ]
[ 166, 40 ]
python
en
['en', 'de', 'en']
True
test_homekit_discovery
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test the homekit discovery flow.
Test the homekit discovery flow.
async def test_homekit_discovery( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the homekit discovery flow.""" mock_connection(aioclient_mock, device="rokutv", host=HOMEKIT_HOST) discovery_info = MOCK_HOMEKIT_DISCOVERY_INFO.copy() result = await hass.config_entries.flo...
[ "async", "def", "test_homekit_discovery", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "mock_connection", "(", "aioclient_mock", ",", "device", "=", "\"rokutv\"", ",", "host", "=", "HOMEKIT_HOST", ")...
[ 169, 0 ]
[ 209, 51 ]
python
en
['en', 'en', 'en']
True
test_ssdp_cannot_connect
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test we abort SSDP flow on connection error.
Test we abort SSDP flow on connection error.
async def test_ssdp_cannot_connect( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we abort SSDP flow on connection error.""" mock_connection(aioclient_mock, error=True) discovery_info = MOCK_SSDP_DISCOVERY_INFO.copy() result = await hass.config_entries.flow.async_init(...
[ "async", "def", "test_ssdp_cannot_connect", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "mock_connection", "(", "aioclient_mock", ",", "error", "=", "True", ")", "discovery_info", "=", "MOCK_SSDP_DISC...
[ 212, 0 ]
[ 226, 47 ]
python
en
['en', 'de', 'en']
True
test_ssdp_unknown_error
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test we abort SSDP flow on unknown error.
Test we abort SSDP flow on unknown error.
async def test_ssdp_unknown_error( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we abort SSDP flow on unknown error.""" discovery_info = MOCK_SSDP_DISCOVERY_INFO.copy() with patch( "homeassistant.components.roku.config_flow.Roku.update", side_effect=Excepti...
[ "async", "def", "test_ssdp_unknown_error", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "discovery_info", "=", "MOCK_SSDP_DISCOVERY_INFO", ".", "copy", "(", ")", "with", "patch", "(", "\"homeassistant....
[ 229, 0 ]
[ 245, 40 ]
python
en
['en', 'de', 'en']
True
test_ssdp_discovery
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test the SSDP discovery flow.
Test the SSDP discovery flow.
async def test_ssdp_discovery( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the SSDP discovery flow.""" mock_connection(aioclient_mock) discovery_info = MOCK_SSDP_DISCOVERY_INFO.copy() result = await hass.config_entries.flow.async_init( DOMAIN, context={CONF_S...
[ "async", "def", "test_ssdp_discovery", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "mock_connection", "(", "aioclient_mock", ")", "discovery_info", "=", "MOCK_SSDP_DISCOVERY_INFO", ".", "copy", "(", "...
[ 248, 0 ]
[ 279, 48 ]
python
en
['en', 'en', 'en']
True
_async_has_devices
(hass)
Return if there are devices that can be discovered.
Return if there are devices that can be discovered.
async def _async_has_devices(hass) -> bool: """Return if there are devices that can be discovered.""" try: devices = await pyzerproc.discover() return len(devices) > 0 except pyzerproc.ZerprocException: _LOGGER.error("Unable to discover nearby Zerproc devices", exc_info=True) ...
[ "async", "def", "_async_has_devices", "(", "hass", ")", "->", "bool", ":", "try", ":", "devices", "=", "await", "pyzerproc", ".", "discover", "(", ")", "return", "len", "(", "devices", ")", ">", "0", "except", "pyzerproc", ".", "ZerprocException", ":", "...
[ 12, 0 ]
[ 19, 20 ]
python
en
['en', 'en', 'en']
True
async_attach_trigger
( hass: HomeAssistant, config: ConfigType, action: AutomationActionType, automation_info: AutomationTriggerInfo, *, platform_type: str = PLATFORM_TYPE, )
Listen for state changes based on configuration.
Listen for state changes based on configuration.
async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, action: AutomationActionType, automation_info: AutomationTriggerInfo, *, platform_type: str = PLATFORM_TYPE, ) -> CALLBACK_TYPE: """Listen for state changes based on configuration.""" nodes: set[Node] = set() if...
[ "async", "def", "async_attach_trigger", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ",", "action", ":", "AutomationActionType", ",", "automation_info", ":", "AutomationTriggerInfo", ",", "*", ",", "platform_type", ":", "str", "=", "PLATFOR...
[ 81, 0 ]
[ 193, 23 ]
python
en
['en', 'en', 'en']
True
_init_header
(request: web.Request)
Create initial header.
Create initial header.
def _init_header(request: web.Request) -> dict[str, str]: """Create initial header.""" headers = { X_HASSIO: os.environ.get("HASSIO_TOKEN", ""), CONTENT_TYPE: request.content_type, } # Add user data user = request.get("hass_user") if user is not None: headers[X_HASS_USER...
[ "def", "_init_header", "(", "request", ":", "web", ".", "Request", ")", "->", "dict", "[", "str", ",", "str", "]", ":", "headers", "=", "{", "X_HASSIO", ":", "os", ".", "environ", ".", "get", "(", "\"HASSIO_TOKEN\"", ",", "\"\"", ")", ",", "CONTENT_T...
[ 128, 0 ]
[ 141, 18 ]
python
en
['en', 'gd', 'en']
True
_response_header
(response: aiohttp.ClientResponse, path: str)
Create response header.
Create response header.
def _response_header(response: aiohttp.ClientResponse, path: str) -> dict[str, str]: """Create response header.""" headers = {} for name, value in response.headers.items(): if name in ( TRANSFER_ENCODING, CONTENT_LENGTH, CONTENT_TYPE, CONTENT_ENCODING...
[ "def", "_response_header", "(", "response", ":", "aiohttp", ".", "ClientResponse", ",", "path", ":", "str", ")", "->", "dict", "[", "str", ",", "str", "]", ":", "headers", "=", "{", "}", "for", "name", ",", "value", "in", "response", ".", "headers", ...
[ 144, 0 ]
[ 161, 18 ]
python
en
['en', 'be', 'en']
True
_get_timeout
(path: str)
Return timeout for a URL path.
Return timeout for a URL path.
def _get_timeout(path: str) -> ClientTimeout: """Return timeout for a URL path.""" if NO_TIMEOUT.match(path): return ClientTimeout(connect=10, total=None) return ClientTimeout(connect=10, total=300)
[ "def", "_get_timeout", "(", "path", ":", "str", ")", "->", "ClientTimeout", ":", "if", "NO_TIMEOUT", ".", "match", "(", "path", ")", ":", "return", "ClientTimeout", "(", "connect", "=", "10", ",", "total", "=", "None", ")", "return", "ClientTimeout", "("...
[ 164, 0 ]
[ 168, 47 ]
python
en
['en', 'en', 'en']
True
_need_auth
(hass, path: str)
Return if a path need authentication.
Return if a path need authentication.
def _need_auth(hass, path: str) -> bool: """Return if a path need authentication.""" if not async_is_onboarded(hass) and NO_AUTH_ONBOARDING.match(path): return False if NO_AUTH.match(path): return False return True
[ "def", "_need_auth", "(", "hass", ",", "path", ":", "str", ")", "->", "bool", ":", "if", "not", "async_is_onboarded", "(", "hass", ")", "and", "NO_AUTH_ONBOARDING", ".", "match", "(", "path", ")", ":", "return", "False", "if", "NO_AUTH", ".", "match", ...
[ 171, 0 ]
[ 177, 15 ]
python
en
['en', 'en', 'en']
True
HassIOView.__init__
(self, host: str, websession: aiohttp.ClientSession)
Initialize a Hass.io base view.
Initialize a Hass.io base view.
def __init__(self, host: str, websession: aiohttp.ClientSession) -> None: """Initialize a Hass.io base view.""" self._host = host self._websession = websession
[ "def", "__init__", "(", "self", ",", "host", ":", "str", ",", "websession", ":", "aiohttp", ".", "ClientSession", ")", "->", "None", ":", "self", ".", "_host", "=", "host", "self", ".", "_websession", "=", "websession" ]
[ 64, 4 ]
[ 67, 37 ]
python
en
['it', 'en', 'en']
True
HassIOView._handle
( self, request: web.Request, path: str )
Route data to Hass.io.
Route data to Hass.io.
async def _handle( self, request: web.Request, path: str ) -> web.Response | web.StreamResponse: """Route data to Hass.io.""" hass = request.app["hass"] if _need_auth(hass, path) and not request[KEY_AUTHENTICATED]: return web.Response(status=HTTP_UNAUTHORIZED) re...
[ "async", "def", "_handle", "(", "self", ",", "request", ":", "web", ".", "Request", ",", "path", ":", "str", ")", "->", "web", ".", "Response", "|", "web", ".", "StreamResponse", ":", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "if", ...
[ 69, 4 ]
[ 77, 55 ]
python
en
['en', 'en', 'en']
True
HassIOView._command_proxy
( self, path: str, request: web.Request )
Return a client request with proxy origin for Hass.io supervisor. This method is a coroutine.
Return a client request with proxy origin for Hass.io supervisor.
async def _command_proxy( self, path: str, request: web.Request ) -> web.StreamResponse: """Return a client request with proxy origin for Hass.io supervisor. This method is a coroutine. """ headers = _init_header(request) if path in ("snapshots/new/upload", "backups/...
[ "async", "def", "_command_proxy", "(", "self", ",", "path", ":", "str", ",", "request", ":", "web", ".", "Request", ")", "->", "web", ".", "StreamResponse", ":", "headers", "=", "_init_header", "(", "request", ")", "if", "path", "in", "(", "\"snapshots/n...
[ 83, 4 ]
[ 125, 30 ]
python
en
['en', 'en', 'en']
True
RadioType.list
(cls)
Return a list of descriptions.
Return a list of descriptions.
def list(cls) -> list[str]: """Return a list of descriptions.""" return [e.description for e in RadioType]
[ "def", "list", "(", "cls", ")", "->", "list", "[", "str", "]", ":", "return", "[", "e", ".", "description", "for", "e", "in", "RadioType", "]" ]
[ 255, 4 ]
[ 257, 49 ]
python
en
['en', 'ca', 'en']
True
RadioType.get_by_description
(cls, description: str)
Get radio by description.
Get radio by description.
def get_by_description(cls, description: str) -> str: """Get radio by description.""" for radio in cls: if radio.description == description: return radio.name raise ValueError
[ "def", "get_by_description", "(", "cls", ",", "description", ":", "str", ")", "->", "str", ":", "for", "radio", "in", "cls", ":", "if", "radio", ".", "description", "==", "description", ":", "return", "radio", ".", "name", "raise", "ValueError" ]
[ 260, 4 ]
[ 265, 24 ]
python
en
['en', 'es', 'en']
True
RadioType.__init__
(self, description: str, controller_cls: CALLABLE_T)
Init instance.
Init instance.
def __init__(self, description: str, controller_cls: CALLABLE_T) -> None: """Init instance.""" self._desc = description self._ctrl_cls = controller_cls
[ "def", "__init__", "(", "self", ",", "description", ":", "str", ",", "controller_cls", ":", "CALLABLE_T", ")", "->", "None", ":", "self", ".", "_desc", "=", "description", "self", ".", "_ctrl_cls", "=", "controller_cls" ]
[ 267, 4 ]
[ 270, 39 ]
python
en
['en', 'en', 'en']
False
RadioType.controller
(self)
Return controller class.
Return controller class.
def controller(self) -> CALLABLE_T: """Return controller class.""" return self._ctrl_cls
[ "def", "controller", "(", "self", ")", "->", "CALLABLE_T", ":", "return", "self", ".", "_ctrl_cls" ]
[ 273, 4 ]
[ 275, 29 ]
python
en
['sv', 'lb', 'en']
False
RadioType.description
(self)
Return radio type description.
Return radio type description.
def description(self) -> str: """Return radio type description.""" return self._desc
[ "def", "description", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_desc" ]
[ 278, 4 ]
[ 280, 25 ]
python
en
['it', 'la', 'en']
False
BaseSpecifier.__str__
(self)
Returns the str representation of this Specifier like object. This should be representative of the Specifier itself.
Returns the str representation of this Specifier like object. This should be representative of the Specifier itself.
def __str__(self): # type: () -> str """ Returns the str representation of this Specifier like object. This should be representative of the Specifier itself. """
[ "def", "__str__", "(", "self", ")", ":", "# type: () -> str" ]
[ 41, 4 ]
[ 46, 11 ]
python
en
['en', 'error', 'th']
False
BaseSpecifier.__hash__
(self)
Returns a hash value for this Specifier like object.
Returns a hash value for this Specifier like object.
def __hash__(self): # type: () -> int """ Returns a hash value for this Specifier like object. """
[ "def", "__hash__", "(", "self", ")", ":", "# type: () -> int" ]
[ 49, 4 ]
[ 53, 11 ]
python
en
['en', 'error', 'th']
False
BaseSpecifier.__eq__
(self, other)
Returns a boolean representing whether or not the two Specifier like objects are equal.
Returns a boolean representing whether or not the two Specifier like objects are equal.
def __eq__(self, other): # type: (object) -> bool """ Returns a boolean representing whether or not the two Specifier like objects are equal. """
[ "def", "__eq__", "(", "self", ",", "other", ")", ":", "# type: (object) -> bool" ]
[ 56, 4 ]
[ 61, 11 ]
python
en
['en', 'error', 'th']
False
BaseSpecifier.__ne__
(self, other)
Returns a boolean representing whether or not the two Specifier like objects are not equal.
Returns a boolean representing whether or not the two Specifier like objects are not equal.
def __ne__(self, other): # type: (object) -> bool """ Returns a boolean representing whether or not the two Specifier like objects are not equal. """
[ "def", "__ne__", "(", "self", ",", "other", ")", ":", "# type: (object) -> bool" ]
[ 64, 4 ]
[ 69, 11 ]
python
en
['en', 'error', 'th']
False
BaseSpecifier.prereleases
(self)
Returns whether or not pre-releases as a whole are allowed by this specifier.
Returns whether or not pre-releases as a whole are allowed by this specifier.
def prereleases(self): # type: () -> Optional[bool] """ Returns whether or not pre-releases as a whole are allowed by this specifier. """
[ "def", "prereleases", "(", "self", ")", ":", "# type: () -> Optional[bool]" ]
[ 72, 4 ]
[ 77, 11 ]
python
en
['en', 'error', 'th']
False
BaseSpecifier.prereleases
(self, value)
Sets whether or not pre-releases as a whole are allowed by this specifier.
Sets whether or not pre-releases as a whole are allowed by this specifier.
def prereleases(self, value): # type: (bool) -> None """ Sets whether or not pre-releases as a whole are allowed by this specifier. """
[ "def", "prereleases", "(", "self", ",", "value", ")", ":", "# type: (bool) -> None" ]
[ 80, 4 ]
[ 85, 11 ]
python
en
['en', 'error', 'th']
False
BaseSpecifier.contains
(self, item, prereleases=None)
Determines if the given item is contained within this specifier.
Determines if the given item is contained within this specifier.
def contains(self, item, prereleases=None): # type: (str, Optional[bool]) -> bool """ Determines if the given item is contained within this specifier. """
[ "def", "contains", "(", "self", ",", "item", ",", "prereleases", "=", "None", ")", ":", "# type: (str, Optional[bool]) -> bool" ]
[ 88, 4 ]
[ 92, 11 ]
python
en
['en', 'error', 'th']
False
BaseSpecifier.filter
(self, iterable, prereleases=None)
Takes an iterable of items and filters them so that only items which are contained within this specifier are allowed in it.
Takes an iterable of items and filters them so that only items which are contained within this specifier are allowed in it.
def filter(self, iterable, prereleases=None): # type: (Iterable[UnparsedVersion], Optional[bool]) -> Iterable[UnparsedVersion] """ Takes an iterable of items and filters them so that only items which are contained within this specifier are allowed in it. """
[ "def", "filter", "(", "self", ",", "iterable", ",", "prereleases", "=", "None", ")", ":", "# type: (Iterable[UnparsedVersion], Optional[bool]) -> Iterable[UnparsedVersion]" ]
[ 95, 4 ]
[ 100, 11 ]
python
en
['en', 'error', 'th']
False
test_numeric_sensor
(hass, multisensor_6, integration)
Test the numeric sensor.
Test the numeric sensor.
async def test_numeric_sensor(hass, multisensor_6, integration): """Test the numeric sensor.""" state = hass.states.get(AIR_TEMPERATURE_SENSOR) assert state assert state.state == "9.0" assert state.attributes["unit_of_measurement"] == TEMP_CELSIUS assert state.attributes["device_class"] == DEVI...
[ "async", "def", "test_numeric_sensor", "(", "hass", ",", "multisensor_6", ",", "integration", ")", ":", "state", "=", "hass", ".", "states", ".", "get", "(", "AIR_TEMPERATURE_SENSOR", ")", "assert", "state", "assert", "state", ".", "state", "==", "\"9.0\"", ...
[ 51, 0 ]
[ 65, 68 ]
python
en
['en', 'sm', 'en']
True
test_energy_sensors
(hass, hank_binary_switch, integration)
Test power and energy sensors.
Test power and energy sensors.
async def test_energy_sensors(hass, hank_binary_switch, integration): """Test power and energy sensors.""" state = hass.states.get(POWER_SENSOR) assert state assert state.state == "0.0" assert state.attributes["unit_of_measurement"] == POWER_WATT assert state.attributes["device_class"] == DEVIC...
[ "async", "def", "test_energy_sensors", "(", "hass", ",", "hank_binary_switch", ",", "integration", ")", ":", "state", "=", "hass", ".", "states", ".", "get", "(", "POWER_SENSOR", ")", "assert", "state", "assert", "state", ".", "state", "==", "\"0.0\"", "asse...
[ 68, 0 ]
[ 98, 67 ]
python
en
['en', 'en', 'en']
True