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
StateVacuumEntity.async_toggle
(self, **kwargs)
Not supported.
Not supported.
async def async_toggle(self, **kwargs): """Not supported."""
[ "async", "def", "async_toggle", "(", "self", ",", "*", "*", "kwargs", ")", ":" ]
[ 379, 4 ]
[ 380, 28 ]
python
en
['de', 'en', 'en']
False
StateVacuumDevice.__init_subclass__
(cls, **kwargs)
Print deprecation warning.
Print deprecation warning.
def __init_subclass__(cls, **kwargs): """Print deprecation warning.""" super().__init_subclass__(**kwargs) _LOGGER.warning( "StateVacuumDevice is deprecated, modify %s to extend StateVacuumEntity", cls.__name__, )
[ "def", "__init_subclass__", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init_subclass__", "(", "*", "*", "kwargs", ")", "_LOGGER", ".", "warning", "(", "\"StateVacuumDevice is deprecated, modify %s to extend StateVacuumEntity\"", ",", ...
[ 386, 4 ]
[ 392, 9 ]
python
de
['de', 'sv', 'en']
False
BertJapaneseTokenizer.__init__
( self, vocab_file, do_lower_case=False, do_word_tokenize=True, do_subword_tokenize=True, word_tokenizer_type="basic", subword_tokenizer_type="wordpiece", never_split=None, unk_token="[UNK]", sep_token="[SEP]", pad_token="[PAD]", ...
Constructs a MecabBertTokenizer. Args: **vocab_file**: Path to a one-wordpiece-per-line vocabulary file. **do_lower_case**: (`optional`) boolean (default True) Whether to lower case the input. Only has an effect when do_basic_tokenize=True. **do_word...
Constructs a MecabBertTokenizer.
def __init__( self, vocab_file, do_lower_case=False, do_word_tokenize=True, do_subword_tokenize=True, word_tokenizer_type="basic", subword_tokenizer_type="wordpiece", never_split=None, unk_token="[UNK]", sep_token="[SEP]", pad_token...
[ "def", "__init__", "(", "self", ",", "vocab_file", ",", "do_lower_case", "=", "False", ",", "do_word_tokenize", "=", "True", ",", "do_subword_tokenize", "=", "True", ",", "word_tokenizer_type", "=", "\"basic\"", ",", "subword_tokenizer_type", "=", "\"wordpiece\"", ...
[ 79, 4 ]
[ 163, 116 ]
python
en
['en', 'error', 'th']
False
MecabTokenizer.__init__
( self, do_lower_case=False, never_split=None, normalize_text=True, mecab_dic: Optional[str] = "ipadic", mecab_option: Optional[str] = None, )
Constructs a MecabTokenizer. Args: **do_lower_case**: (`optional`) boolean (default True) Whether to lowercase the input. **never_split**: (`optional`) list of str Kept for backward compatibility purposes. Now implemented directly at the base cla...
Constructs a MecabTokenizer.
def __init__( self, do_lower_case=False, never_split=None, normalize_text=True, mecab_dic: Optional[str] = "ipadic", mecab_option: Optional[str] = None, ): """ Constructs a MecabTokenizer. Args: **do_lower_case**: (`optional`) bool...
[ "def", "__init__", "(", "self", ",", "do_lower_case", "=", "False", ",", "never_split", "=", "None", ",", "normalize_text", "=", "True", ",", "mecab_dic", ":", "Optional", "[", "str", "]", "=", "\"ipadic\"", ",", "mecab_option", ":", "Optional", "[", "str"...
[ 199, 4 ]
[ 283, 56 ]
python
en
['en', 'error', 'th']
False
MecabTokenizer.tokenize
(self, text, never_split=None, **kwargs)
Tokenizes a piece of text.
Tokenizes a piece of text.
def tokenize(self, text, never_split=None, **kwargs): """Tokenizes a piece of text.""" if self.normalize_text: text = unicodedata.normalize("NFKC", text) never_split = self.never_split + (never_split if never_split is not None else []) tokens = [] for word in self.m...
[ "def", "tokenize", "(", "self", ",", "text", ",", "never_split", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "normalize_text", ":", "text", "=", "unicodedata", ".", "normalize", "(", "\"NFKC\"", ",", "text", ")", "never_split", "...
[ 285, 4 ]
[ 301, 21 ]
python
en
['en', 'el-Latn', 'en']
True
CharacterTokenizer.__init__
(self, vocab, unk_token, normalize_text=True)
Constructs a CharacterTokenizer. Args: **vocab**: Vocabulary object. **unk_token**: str A special symbol for out-of-vocabulary token. **normalize_text**: (`optional`) boolean (default True) Whether to apply unicode nor...
Constructs a CharacterTokenizer.
def __init__(self, vocab, unk_token, normalize_text=True): """ Constructs a CharacterTokenizer. Args: **vocab**: Vocabulary object. **unk_token**: str A special symbol for out-of-vocabulary token. **normalize_text**: (`optional...
[ "def", "__init__", "(", "self", ",", "vocab", ",", "unk_token", ",", "normalize_text", "=", "True", ")", ":", "self", ".", "vocab", "=", "vocab", "self", ".", "unk_token", "=", "unk_token", "self", ".", "normalize_text", "=", "normalize_text" ]
[ 307, 4 ]
[ 321, 44 ]
python
en
['en', 'error', 'th']
False
CharacterTokenizer.tokenize
(self, text)
Tokenizes a piece of text into characters. For example, :obj:`input = "apple""` wil return as output :obj:`["a", "p", "p", "l", "e"]`. Args: text: A single token or whitespace separated tokens. This should have already been passed through `BasicTokenizer`. ...
Tokenizes a piece of text into characters.
def tokenize(self, text): """ Tokenizes a piece of text into characters. For example, :obj:`input = "apple""` wil return as output :obj:`["a", "p", "p", "l", "e"]`. Args: text: A single token or whitespace separated tokens. This should have already been pass...
[ "def", "tokenize", "(", "self", ",", "text", ")", ":", "if", "self", ".", "normalize_text", ":", "text", "=", "unicodedata", ".", "normalize", "(", "\"NFKC\"", ",", "text", ")", "output_tokens", "=", "[", "]", "for", "char", "in", "text", ":", "if", ...
[ 323, 4 ]
[ 347, 28 ]
python
en
['en', 'error', 'th']
False
async_validate_trigger_config
(hass, config)
Validate config.
Validate config.
async def async_validate_trigger_config(hass, config): """Validate config.""" platform = _get_trigger_platform(config) if hasattr(platform, "async_validate_trigger_config"): return await getattr(platform, "async_validate_trigger_config")(hass, config) return platform.TRIGGER_SCHEMA(config)
[ "async", "def", "async_validate_trigger_config", "(", "hass", ",", "config", ")", ":", "platform", "=", "_get_trigger_platform", "(", "config", ")", "if", "hasattr", "(", "platform", ",", "\"async_validate_trigger_config\"", ")", ":", "return", "await", "getattr", ...
[ 10, 0 ]
[ 16, 42 ]
python
en
['en', 'la', 'it']
False
async_attach_trigger
(hass, config, action, automation_info)
Attach trigger of specified platform.
Attach trigger of specified platform.
async def async_attach_trigger(hass, config, action, automation_info): """Attach trigger of specified platform.""" platform = _get_trigger_platform(config) return await platform.async_attach_trigger(hass, config, action, automation_info)
[ "async", "def", "async_attach_trigger", "(", "hass", ",", "config", ",", "action", ",", "automation_info", ")", ":", "platform", "=", "_get_trigger_platform", "(", "config", ")", "return", "await", "platform", ".", "async_attach_trigger", "(", "hass", ",", "conf...
[ 19, 0 ]
[ 22, 85 ]
python
en
['en', 'de', 'en']
True
test_form
(hass)
Test we get the form.
Test we get the form.
async def test_form(hass): """Test we get the form.""" await setup.async_setup_component(hass, "persistent_notification", {}) mock_mac = "FF-00-00-00-00-00" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] ...
[ "async", "def", "test_form", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "mock_mac", "=", "\"FF-00-00-00-00-00\"", "result", "=", "await", "hass", ".", "config_entrie...
[ 10, 0 ]
[ 41, 48 ]
python
en
['en', 'en', 'en']
True
test_form_invalid_auth
(hass)
Test we handle invalid auth.
Test we handle invalid auth.
async def test_form_invalid_auth(hass): """Test we handle invalid auth.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch("vilfo.Client.ping", return_value=None), patch( "vilfo.Client.resolve_mac_address", return_v...
[ "async", "def", "test_form_invalid_auth", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ")"...
[ 44, 0 ]
[ 62, 56 ]
python
en
['en', 'en', 'en']
True
test_form_cannot_connect
(hass)
Test we handle cannot connect error.
Test we handle cannot connect error.
async def test_form_cannot_connect(hass): """Test we handle cannot connect error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch("vilfo.Client.ping", side_effect=vilfo.exceptions.VilfoException), patch( "vilfo.C...
[ "async", "def", "test_form_cannot_connect", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", "...
[ 65, 0 ]
[ 91, 58 ]
python
en
['en', 'en', 'en']
True
test_form_wrong_host
(hass)
Test we handle wrong host errors.
Test we handle wrong host errors.
async def test_form_wrong_host(hass): """Test we handle wrong host errors.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data={"host": "this is an invalid hostname", "access_token": "test-token"}, ) assert result["...
[ "async", "def", "test_form_wrong_host", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ",", ...
[ 94, 0 ]
[ 102, 53 ]
python
en
['de', 'en', 'en']
True
test_form_already_configured
(hass)
Test that we handle already configured exceptions appropriately.
Test that we handle already configured exceptions appropriately.
async def test_form_already_configured(hass): """Test that we handle already configured exceptions appropriately.""" first_flow_result1 = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch("vilfo.Client.ping", return_value=None), patch...
[ "async", "def", "test_form_already_configured", "(", "hass", ")", ":", "first_flow_result1", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_U...
[ 105, 0 ]
[ 135, 64 ]
python
en
['en', 'en', 'en']
True
test_form_unexpected_exception
(hass)
Test that we handle unexpected exceptions.
Test that we handle unexpected exceptions.
async def test_form_unexpected_exception(hass): """Test that we handle unexpected exceptions.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.components.vilfo.config_flow.VilfoClient", ) as mo...
[ "async", "def", "test_form_unexpected_exception", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}...
[ 138, 0 ]
[ 153, 51 ]
python
en
['en', 'en', 'en']
True
test_validate_input_returns_data
(hass)
Test we handle the MAC address being resolved or not.
Test we handle the MAC address being resolved or not.
async def test_validate_input_returns_data(hass): """Test we handle the MAC address being resolved or not.""" mock_data = {"host": "testadmin.vilfo.com", "access_token": "test-token"} mock_data_with_ip = {"host": "192.168.0.1", "access_token": "test-token"} mock_mac = "FF-00-00-00-00-00" with patch...
[ "async", "def", "test_validate_input_returns_data", "(", "hass", ")", ":", "mock_data", "=", "{", "\"host\"", ":", "\"testadmin.vilfo.com\"", ",", "\"access_token\"", ":", "\"test-token\"", "}", "mock_data_with_ip", "=", "{", "\"host\"", ":", "\"192.168.0.1\"", ",", ...
[ 156, 0 ]
[ 192, 39 ]
python
en
['en', 'en', 'en']
True
get_and_check_entity_basics
(hass, mock_hap, entity_id, entity_name, device_model)
Get and test basic device.
Get and test basic device.
def get_and_check_entity_basics(hass, mock_hap, entity_id, entity_name, device_model): """Get and test basic device.""" ha_state = hass.states.get(entity_id) assert ha_state is not None if device_model: assert ha_state.attributes[ATTR_MODEL_TYPE] == device_model assert ha_state.name == entit...
[ "def", "get_and_check_entity_basics", "(", "hass", ",", "mock_hap", ",", "entity_id", ",", "entity_name", ",", "device_model", ")", ":", "ha_state", "=", "hass", ".", "states", ".", "get", "(", "entity_id", ")", "assert", "ha_state", "is", "not", "None", "if...
[ 33, 0 ]
[ 48, 32 ]
python
en
['en', 'en', 'en']
True
async_manipulate_test_data
( hass, hmip_device, attribute, new_value, channel=1, fire_device=None )
Set new value on hmip device.
Set new value on hmip device.
async def async_manipulate_test_data( hass, hmip_device, attribute, new_value, channel=1, fire_device=None ): """Set new value on hmip device.""" if channel == 1: setattr(hmip_device, attribute, new_value) if hasattr(hmip_device, "functionalChannels"): functional_channel = hmip_device.fu...
[ "async", "def", "async_manipulate_test_data", "(", "hass", ",", "hmip_device", ",", "attribute", ",", "new_value", ",", "channel", "=", "1", ",", "fire_device", "=", "None", ")", ":", "if", "channel", "==", "1", ":", "setattr", "(", "hmip_device", ",", "at...
[ 51, 0 ]
[ 70, 38 ]
python
en
['nl', 'en', 'en']
True
_get_mock
(instance)
Create a mock and copy instance attributes over mock.
Create a mock and copy instance attributes over mock.
def _get_mock(instance): """Create a mock and copy instance attributes over mock.""" if isinstance(instance, Mock): instance.__dict__.update( instance._mock_wraps.__dict__ # pylint: disable=protected-access ) return instance mock = Mock(spec=instance, wraps=instance) ...
[ "def", "_get_mock", "(", "instance", ")", ":", "if", "isinstance", "(", "instance", ",", "Mock", ")", ":", "instance", ".", "__dict__", ".", "update", "(", "instance", ".", "_mock_wraps", ".", "__dict__", "# pylint: disable=protected-access", ")", "return", "i...
[ 205, 0 ]
[ 215, 15 ]
python
en
['en', 'en', 'en']
True
HomeFactory.__init__
( self, hass: HomeAssistantType, mock_connection, hmip_config_entry: config_entries.ConfigEntry, )
Initialize the Factory.
Initialize the Factory.
def __init__( self, hass: HomeAssistantType, mock_connection, hmip_config_entry: config_entries.ConfigEntry, ): """Initialize the Factory.""" self.hass = hass self.mock_connection = mock_connection self.hmip_config_entry = hmip_config_entry
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistantType", ",", "mock_connection", ",", "hmip_config_entry", ":", "config_entries", ".", "ConfigEntry", ",", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "mock_connection", "=", "mock_conn...
[ 76, 4 ]
[ 85, 50 ]
python
en
['en', 'en', 'en']
True
HomeFactory.async_get_mock_hap
( self, test_devices=[], test_groups=[] )
Create a mocked homematic access point.
Create a mocked homematic access point.
async def async_get_mock_hap( self, test_devices=[], test_groups=[] ) -> HomematicipHAP: """Create a mocked homematic access point.""" home_name = self.hmip_config_entry.data["name"] mock_home = ( HomeTemplate( connection=self.mock_connection, ...
[ "async", "def", "async_get_mock_hap", "(", "self", ",", "test_devices", "=", "[", "]", ",", "test_groups", "=", "[", "]", ")", "->", "HomematicipHAP", ":", "home_name", "=", "self", ".", "hmip_config_entry", ".", "data", "[", "\"name\"", "]", "mock_home", ...
[ 87, 4 ]
[ 115, 18 ]
python
en
['en', 'en', 'en']
True
HomeTemplate.__init__
(self, connection=None, home_name="", test_devices=[], test_groups=[])
Init template with connection.
Init template with connection.
def __init__(self, connection=None, home_name="", test_devices=[], test_groups=[]): """Init template with connection.""" super().__init__(connection=connection) self.name = home_name self.label = "Home" self.model_type = "HomematicIP Home" self.init_json_state = None ...
[ "def", "__init__", "(", "self", ",", "connection", "=", "None", ",", "home_name", "=", "\"\"", ",", "test_devices", "=", "[", "]", ",", "test_groups", "=", "[", "]", ")", ":", "super", "(", ")", ".", "__init__", "(", "connection", "=", "connection", ...
[ 135, 4 ]
[ 143, 38 ]
python
en
['en', 'en', 'en']
True
HomeTemplate.init_home
(self)
Init template with json.
Init template with json.
def init_home(self): """Init template with json.""" self.init_json_state = self._cleanup_json(json.loads(FIXTURE_DATA)) self.update_home(json_state=self.init_json_state, clearConfig=True) return self
[ "def", "init_home", "(", "self", ")", ":", "self", ".", "init_json_state", "=", "self", ".", "_cleanup_json", "(", "json", ".", "loads", "(", "FIXTURE_DATA", ")", ")", "self", ".", "update_home", "(", "json_state", "=", "self", ".", "init_json_state", ",",...
[ 162, 4 ]
[ 166, 19 ]
python
en
['en', 'en', 'en']
True
HomeTemplate.update_home
(self, json_state, clearConfig: bool = False)
Update home and ensure that mocks are created.
Update home and ensure that mocks are created.
def update_home(self, json_state, clearConfig: bool = False): """Update home and ensure that mocks are created.""" result = super().update_home(json_state, clearConfig) self._generate_mocks() return result
[ "def", "update_home", "(", "self", ",", "json_state", ",", "clearConfig", ":", "bool", "=", "False", ")", ":", "result", "=", "super", "(", ")", ".", "update_home", "(", "json_state", ",", "clearConfig", ")", "self", ".", "_generate_mocks", "(", ")", "re...
[ 168, 4 ]
[ 172, 21 ]
python
en
['en', 'en', 'en']
True
HomeTemplate._generate_mocks
(self)
Generate mocks for groups and devices.
Generate mocks for groups and devices.
def _generate_mocks(self): """Generate mocks for groups and devices.""" mock_devices = [] for device in self.devices: mock_devices.append(_get_mock(device)) self.devices = mock_devices mock_groups = [] for group in self.groups: mock_groups.append(...
[ "def", "_generate_mocks", "(", "self", ")", ":", "mock_devices", "=", "[", "]", "for", "device", "in", "self", ".", "devices", ":", "mock_devices", ".", "append", "(", "_get_mock", "(", "device", ")", ")", "self", ".", "devices", "=", "mock_devices", "mo...
[ 174, 4 ]
[ 184, 33 ]
python
en
['en', 'en', 'en']
True
HomeTemplate.download_configuration
(self)
Return the initial json config.
Return the initial json config.
def download_configuration(self): """Return the initial json config.""" return self.init_json_state
[ "def", "download_configuration", "(", "self", ")", ":", "return", "self", ".", "init_json_state" ]
[ 186, 4 ]
[ 188, 35 ]
python
en
['en', 'en', 'en']
True
HomeTemplate.get_async_home_mock
(self)
Create Mock for Async_Home. based on template to be used for testing. It adds collections of mocked devices and groups to the home objects, and sets required attributes.
Create Mock for Async_Home. based on template to be used for testing.
def get_async_home_mock(self): """ Create Mock for Async_Home. based on template to be used for testing. It adds collections of mocked devices and groups to the home objects, and sets required attributes. """ mock_home = Mock( spec=AsyncHome, wraps=self, labe...
[ "def", "get_async_home_mock", "(", "self", ")", ":", "mock_home", "=", "Mock", "(", "spec", "=", "AsyncHome", ",", "wraps", "=", "self", ",", "label", "=", "\"Home\"", ",", "modelType", "=", "\"HomematicIP Home\"", ")", "mock_home", ".", "__dict__", ".", "...
[ 190, 4 ]
[ 202, 24 ]
python
en
['en', 'error', 'th']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Import YAML configuration when available.
Import YAML configuration when available.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Import YAML configuration when available.""" hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_IMPORT}, data=dict(config) ) )
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",...
[ 27, 0 ]
[ 33, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Add solarlog entry.
Add solarlog entry.
async def async_setup_entry(hass, entry, async_add_entities): """Add solarlog entry.""" host_entry = entry.data[CONF_HOST] url = urlparse(host_entry, "http") netloc = url.netloc or url.path path = url.path if url.netloc else "" url = ParseResult("http", netloc, path, *url[3:]) host = url.ge...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "host_entry", "=", "entry", ".", "data", "[", "CONF_HOST", "]", "url", "=", "urlparse", "(", "host_entry", ",", "\"http\"", ")", "netloc", "=", "url", ".",...
[ 36, 0 ]
[ 67, 15 ]
python
en
['en', 'cy', 'en']
True
SolarlogSensor.__init__
(self, entry_id, platform_name, sensor_key, data)
Initialize the sensor.
Initialize the sensor.
def __init__(self, entry_id, platform_name, sensor_key, data): """Initialize the sensor.""" self.platform_name = platform_name self.sensor_key = sensor_key self.data = data self.entry_id = entry_id self._state = None self._json_key = SENSOR_TYPES[self.sensor_key]...
[ "def", "__init__", "(", "self", ",", "entry_id", ",", "platform_name", ",", "sensor_key", ",", "data", ")", ":", "self", ".", "platform_name", "=", "platform_name", "self", ".", "sensor_key", "=", "sensor_key", "self", ".", "data", "=", "data", "self", "."...
[ 73, 4 ]
[ 84, 53 ]
python
en
['en', 'en', 'en']
True
SolarlogSensor.unique_id
(self)
Return the unique id.
Return the unique id.
def unique_id(self): """Return the unique id.""" return f"{self.entry_id}_{self.sensor_key}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self.entry_id}_{self.sensor_key}\"" ]
[ 87, 4 ]
[ 89, 51 ]
python
en
['en', 'la', 'en']
True
SolarlogSensor.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.platform_name} {self._label}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self.platform_name} {self._label}\"" ]
[ 92, 4 ]
[ 94, 52 ]
python
en
['en', 'mi', 'en']
True
SolarlogSensor.unit_of_measurement
(self)
Return the state of the sensor.
Return the state of the sensor.
def unit_of_measurement(self): """Return the state of the sensor.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 97, 4 ]
[ 99, 40 ]
python
en
['en', 'en', 'en']
True
SolarlogSensor.icon
(self)
Return the sensor icon.
Return the sensor icon.
def icon(self): """Return the sensor icon.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 102, 4 ]
[ 104, 25 ]
python
en
['en', 'fa', 'en']
True
SolarlogSensor.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" ]
[ 107, 4 ]
[ 109, 26 ]
python
en
['en', 'en', 'en']
True
SolarlogSensor.update
(self)
Get the latest data from the sensor and update the state.
Get the latest data from the sensor and update the state.
def update(self): """Get the latest data from the sensor and update the state.""" self.data.update() self._state = self.data.data[self._json_key]
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "update", "(", ")", "self", ".", "_state", "=", "self", ".", "data", ".", "data", "[", "self", ".", "_json_key", "]" ]
[ 111, 4 ]
[ 114, 52 ]
python
en
['en', 'en', 'en']
True
SolarlogData.__init__
(self, hass, api, host)
Initialize the data object.
Initialize the data object.
def __init__(self, hass, api, host): """Initialize the data object.""" self.api = api self.hass = hass self.host = host self.update = Throttle(SCAN_INTERVAL)(self._update) self.data = {}
[ "def", "__init__", "(", "self", ",", "hass", ",", "api", ",", "host", ")", ":", "self", ".", "api", "=", "api", "self", ".", "hass", "=", "hass", "self", ".", "host", "=", "host", "self", ".", "update", "=", "Throttle", "(", "SCAN_INTERVAL", ")", ...
[ 120, 4 ]
[ 126, 22 ]
python
en
['en', 'en', 'en']
True
SolarlogData._update
(self)
Update the data from the SolarLog device.
Update the data from the SolarLog device.
def _update(self): """Update the data from the SolarLog device.""" try: self.api = SolarLog(self.host) response = self.api.time _LOGGER.debug( "Connection to Solarlog successful. Retrieving latest Solarlog update of %s", response, ...
[ "def", "_update", "(", "self", ")", ":", "try", ":", "self", ".", "api", "=", "SolarLog", "(", "self", ".", "host", ")", "response", "=", "self", ".", "api", ".", "time", "_LOGGER", ".", "debug", "(", "\"Connection to Solarlog successful. Retrieving latest S...
[ 128, 4 ]
[ 166, 70 ]
python
en
['en', 'en', 'en']
True
LotteryTicketPruner.validate_config
(self, model, config_list)
Parameters ---------- model : torch.nn.Module Model to be pruned config_list : list Supported keys: - prune_iterations : The number of rounds for the iterative pruning. - sparsity : The final sparsity when the compression is done. ...
Parameters ---------- model : torch.nn.Module Model to be pruned config_list : list Supported keys: - prune_iterations : The number of rounds for the iterative pruning. - sparsity : The final sparsity when the compression is done. ...
def validate_config(self, model, config_list): """ Parameters ---------- model : torch.nn.Module Model to be pruned config_list : list Supported keys: - prune_iterations : The number of rounds for the iterative pruning. - sp...
[ "def", "validate_config", "(", "self", ",", "model", ",", "config_list", ")", ":", "schema", "=", "CompressorSchema", "(", "[", "{", "'sparsity'", ":", "And", "(", "float", ",", "lambda", "n", ":", "0", "<", "n", "<", "1", ")", ",", "'prune_iterations'...
[ 47, 4 ]
[ 66, 137 ]
python
en
['en', 'error', 'th']
False
LotteryTicketPruner.calc_mask
(self, wrapper, **kwargs)
Generate mask for the given ``weight``. Parameters ---------- wrapper : Module The layer to be pruned Returns ------- tensor The mask for this weight, it is ```None``` because this pruner calculates and assigns masks in ```pr...
Generate mask for the given ``weight``.
def calc_mask(self, wrapper, **kwargs): """ Generate mask for the given ``weight``. Parameters ---------- wrapper : Module The layer to be pruned Returns ------- tensor The mask for this weight, it is ```None``` because this prune...
[ "def", "calc_mask", "(", "self", ",", "wrapper", ",", "*", "*", "kwargs", ")", ":", "return", "None" ]
[ 82, 4 ]
[ 98, 19 ]
python
en
['en', 'error', 'th']
False
LotteryTicketPruner.get_prune_iterations
(self)
Return the range for iterations. In the first prune iteration, masks are all one, thus, add one more iteration Returns ------- list A list for pruning iterations
Return the range for iterations. In the first prune iteration, masks are all one, thus, add one more iteration
def get_prune_iterations(self): """ Return the range for iterations. In the first prune iteration, masks are all one, thus, add one more iteration Returns ------- list A list for pruning iterations """ return range(self.prune_iterations + 1)
[ "def", "get_prune_iterations", "(", "self", ")", ":", "return", "range", "(", "self", ".", "prune_iterations", "+", "1", ")" ]
[ 100, 4 ]
[ 110, 47 ]
python
en
['en', 'error', 'th']
False
LotteryTicketPruner.prune_iteration_start
(self)
Control the pruning procedure on updated epoch number. Should be called at the beginning of the epoch.
Control the pruning procedure on updated epoch number. Should be called at the beginning of the epoch.
def prune_iteration_start(self): """ Control the pruning procedure on updated epoch number. Should be called at the beginning of the epoch. """ if self.curr_prune_iteration is None: self.curr_prune_iteration = 0 else: self.curr_prune_iteration += 1...
[ "def", "prune_iteration_start", "(", "self", ")", ":", "if", "self", ".", "curr_prune_iteration", "is", "None", ":", "self", ".", "curr_prune_iteration", "=", "0", "else", ":", "self", ".", "curr_prune_iteration", "+=", "1", "assert", "self", ".", "curr_prune_...
[ 112, 4 ]
[ 145, 73 ]
python
en
['en', 'error', 'th']
False
async_setup
(hass: HomeAssistant, config: ConfigType)
Set up the Remote Python Debugger component.
Set up the Remote Python Debugger component.
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Remote Python Debugger component.""" conf = config[DOMAIN] async def debug_start( call: Optional[ServiceCall] = None, *, wait: bool = True ) -> None: """Start the debugger.""" debugpy.listen((c...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "conf", "=", "config", "[", "DOMAIN", "]", "async", "def", "debug_start", "(", "call", ":", "Optional", "[", "ServiceCall", "]", "...
[ 37, 0 ]
[ 78, 15 ]
python
en
['en', 'da', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Tesla binary_sensors by config_entry.
Set up the Tesla binary_sensors by config_entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Tesla binary_sensors by config_entry.""" entities = [ TeslaDeviceEntity( device, hass.data[TESLA_DOMAIN][config_entry.entry_id]["coordinator"], ) for device in hass.data[TESLA_DOMAI...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "entities", "=", "[", "TeslaDeviceEntity", "(", "device", ",", "hass", ".", "data", "[", "TESLA_DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]",...
[ 9, 0 ]
[ 20, 38 ]
python
en
['en', 'en', 'en']
True
TeslaDeviceEntity.latitude
(self)
Return latitude value of the device.
Return latitude value of the device.
def latitude(self) -> Optional[float]: """Return latitude value of the device.""" location = self.tesla_device.get_location() return self.tesla_device.get_location().get("latitude") if location else None
[ "def", "latitude", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "location", "=", "self", ".", "tesla_device", ".", "get_location", "(", ")", "return", "self", ".", "tesla_device", ".", "get_location", "(", ")", ".", "get", "(", "\"latitude...
[ 27, 4 ]
[ 30, 85 ]
python
en
['en', 'en', 'en']
True
TeslaDeviceEntity.longitude
(self)
Return longitude value of the device.
Return longitude value of the device.
def longitude(self) -> Optional[float]: """Return longitude value of the device.""" location = self.tesla_device.get_location() return self.tesla_device.get_location().get("longitude") if location else None
[ "def", "longitude", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "location", "=", "self", ".", "tesla_device", ".", "get_location", "(", ")", "return", "self", ".", "tesla_device", ".", "get_location", "(", ")", ".", "get", "(", "\"longitu...
[ 33, 4 ]
[ 36, 86 ]
python
en
['en', 'zu', 'en']
True
TeslaDeviceEntity.source_type
(self)
Return the source type, eg gps or router, of the device.
Return the source type, eg gps or router, of the device.
def source_type(self): """Return the source type, eg gps or router, of the device.""" return SOURCE_TYPE_GPS
[ "def", "source_type", "(", "self", ")", ":", "return", "SOURCE_TYPE_GPS" ]
[ 39, 4 ]
[ 41, 30 ]
python
en
['en', 'en', 'en']
True
TeslaDeviceEntity.device_state_attributes
(self)
Return the state attributes of the device.
Return the state attributes of the device.
def device_state_attributes(self): """Return the state attributes of the device.""" attr = super().device_state_attributes.copy() location = self.tesla_device.get_location() if location: attr.update( { "trackr_id": self.unique_id, ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attr", "=", "super", "(", ")", ".", "device_state_attributes", ".", "copy", "(", ")", "location", "=", "self", ".", "tesla_device", ".", "get_location", "(", ")", "if", "location", ":", "attr", ".",...
[ 44, 4 ]
[ 56, 19 ]
python
en
['en', 'en', 'en']
True
async_parse_motion_alarm
(uid: str, msg)
Handle parsing event message. Topic: tns1:VideoSource/MotionAlarm
Handle parsing event message.
async def async_parse_motion_alarm(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:VideoSource/MotionAlarm """ try: source = msg.Message._value_1.Source.SimpleItem[0].Value return Event( f"{uid}_{msg.Topic._value_1}_{source}", f"{source} Mot...
[ "async", "def", "async_parse_motion_alarm", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "source", "=", "msg", ".", "Message", ".", "_value_1", ".", "Source", ".", "SimpleItem", "[", "0", "]", ".", "Value", "return", "Event"...
[ 11, 0 ]
[ 27, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_image_too_blurry
(uid: str, msg)
Handle parsing event message. Topic: tns1:VideoSource/ImageTooBlurry/*
Handle parsing event message.
async def async_parse_image_too_blurry(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:VideoSource/ImageTooBlurry/* """ try: source = msg.Message._value_1.Source.SimpleItem[0].Value return Event( f"{uid}_{msg.Topic._value_1}_{source}", f"{so...
[ "async", "def", "async_parse_image_too_blurry", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "source", "=", "msg", ".", "Message", ".", "_value_1", ".", "Source", ".", "SimpleItem", "[", "0", "]", ".", "Value", "return", "Ev...
[ 34, 0 ]
[ 50, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_image_too_dark
(uid: str, msg)
Handle parsing event message. Topic: tns1:VideoSource/ImageTooDark/*
Handle parsing event message.
async def async_parse_image_too_dark(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:VideoSource/ImageTooDark/* """ try: source = msg.Message._value_1.Source.SimpleItem[0].Value return Event( f"{uid}_{msg.Topic._value_1}_{source}", f"{source...
[ "async", "def", "async_parse_image_too_dark", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "source", "=", "msg", ".", "Message", ".", "_value_1", ".", "Source", ".", "SimpleItem", "[", "0", "]", ".", "Value", "return", "Even...
[ 57, 0 ]
[ 73, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_image_too_bright
(uid: str, msg)
Handle parsing event message. Topic: tns1:VideoSource/ImageTooBright/*
Handle parsing event message.
async def async_parse_image_too_bright(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:VideoSource/ImageTooBright/* """ try: source = msg.Message._value_1.Source.SimpleItem[0].Value return Event( f"{uid}_{msg.Topic._value_1}_{source}", f"{so...
[ "async", "def", "async_parse_image_too_bright", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "source", "=", "msg", ".", "Message", ".", "_value_1", ".", "Source", ".", "SimpleItem", "[", "0", "]", ".", "Value", "return", "Ev...
[ 80, 0 ]
[ 96, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_scene_change
(uid: str, msg)
Handle parsing event message. Topic: tns1:VideoSource/GlobalSceneChange/*
Handle parsing event message.
async def async_parse_scene_change(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:VideoSource/GlobalSceneChange/* """ try: source = msg.Message._value_1.Source.SimpleItem[0].Value return Event( f"{uid}_{msg.Topic._value_1}_{source}", f"{sou...
[ "async", "def", "async_parse_scene_change", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "source", "=", "msg", ".", "Message", ".", "_value_1", ".", "Source", ".", "SimpleItem", "[", "0", "]", ".", "Value", "return", "Event"...
[ 103, 0 ]
[ 119, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_detected_sound
(uid: str, msg)
Handle parsing event message. Topic: tns1:AudioAnalytics/Audio/DetectedSound
Handle parsing event message.
async def async_parse_detected_sound(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:AudioAnalytics/Audio/DetectedSound """ try: audio_source = "" audio_analytics = "" rule = "" for source in msg.Message._value_1.Source.SimpleItem: if so...
[ "async", "def", "async_parse_detected_sound", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "audio_source", "=", "\"\"", "audio_analytics", "=", "\"\"", "rule", "=", "\"\"", "for", "source", "in", "msg", ".", "Message", ".", "_...
[ 124, 0 ]
[ 150, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_field_detector
(uid: str, msg)
Handle parsing event message. Topic: tns1:RuleEngine/FieldDetector/ObjectsInside
Handle parsing event message.
async def async_parse_field_detector(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:RuleEngine/FieldDetector/ObjectsInside """ try: video_source = "" video_analytics = "" rule = "" for source in msg.Message._value_1.Source.SimpleItem: i...
[ "async", "def", "async_parse_field_detector", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "video_source", "=", "\"\"", "video_analytics", "=", "\"\"", "rule", "=", "\"\"", "for", "source", "in", "msg", ".", "Message", ".", "_...
[ 155, 0 ]
[ 182, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_cell_motion_detector
(uid: str, msg)
Handle parsing event message. Topic: tns1:RuleEngine/CellMotionDetector/Motion
Handle parsing event message.
async def async_parse_cell_motion_detector(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:RuleEngine/CellMotionDetector/Motion """ try: video_source = "" video_analytics = "" rule = "" for source in msg.Message._value_1.Source.SimpleItem: ...
[ "async", "def", "async_parse_cell_motion_detector", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "video_source", "=", "\"\"", "video_analytics", "=", "\"\"", "rule", "=", "\"\"", "for", "source", "in", "msg", ".", "Message", "."...
[ 187, 0 ]
[ 213, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_motion_region_detector
(uid: str, msg)
Handle parsing event message. Topic: tns1:RuleEngine/MotionRegionDetector/Motion
Handle parsing event message.
async def async_parse_motion_region_detector(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:RuleEngine/MotionRegionDetector/Motion """ try: video_source = "" video_analytics = "" rule = "" for source in msg.Message._value_1.Source.SimpleItem: ...
[ "async", "def", "async_parse_motion_region_detector", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "video_source", "=", "\"\"", "video_analytics", "=", "\"\"", "rule", "=", "\"\"", "for", "source", "in", "msg", ".", "Message", "...
[ 218, 0 ]
[ 244, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_tamper_detector
(uid: str, msg)
Handle parsing event message. Topic: tns1:RuleEngine/TamperDetector/Tamper
Handle parsing event message.
async def async_parse_tamper_detector(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:RuleEngine/TamperDetector/Tamper """ try: video_source = "" video_analytics = "" rule = "" for source in msg.Message._value_1.Source.SimpleItem: if sou...
[ "async", "def", "async_parse_tamper_detector", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "video_source", "=", "\"\"", "video_analytics", "=", "\"\"", "rule", "=", "\"\"", "for", "source", "in", "msg", ".", "Message", ".", "...
[ 249, 0 ]
[ 275, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_storage_failure
(uid: str, msg)
Handle parsing event message. Topic: tns1:Device/HardwareFailure/StorageFailure
Handle parsing event message.
async def async_parse_storage_failure(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:Device/HardwareFailure/StorageFailure """ try: source = msg.Message._value_1.Source.SimpleItem[0].Value return Event( f"{uid}_{msg.Topic._value_1}_{source}", ...
[ "async", "def", "async_parse_storage_failure", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "source", "=", "msg", ".", "Message", ".", "_value_1", ".", "Source", ".", "SimpleItem", "[", "0", "]", ".", "Value", "return", "Eve...
[ 280, 0 ]
[ 296, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_processor_usage
(uid: str, msg)
Handle parsing event message. Topic: tns1:Monitoring/ProcessorUsage
Handle parsing event message.
async def async_parse_processor_usage(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:Monitoring/ProcessorUsage """ try: usage = float(msg.Message._value_1.Data.SimpleItem[0].Value) if usage <= 1: usage *= 100 return Event( f"{uid}_...
[ "async", "def", "async_parse_processor_usage", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "usage", "=", "float", "(", "msg", ".", "Message", ".", "_value_1", ".", "Data", ".", "SimpleItem", "[", "0", "]", ".", "Value", "...
[ 301, 0 ]
[ 320, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_last_reboot
(uid: str, msg)
Handle parsing event message. Topic: tns1:Monitoring/OperatingTime/LastReboot
Handle parsing event message.
async def async_parse_last_reboot(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:Monitoring/OperatingTime/LastReboot """ try: return Event( f"{uid}_{msg.Topic._value_1}", "Last Reboot", "sensor", "timestamp", Non...
[ "async", "def", "async_parse_last_reboot", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "return", "Event", "(", "f\"{uid}_{msg.Topic._value_1}\"", ",", "\"Last Reboot\"", ",", "\"sensor\"", ",", "\"timestamp\"", ",", "None", ",", "d...
[ 325, 0 ]
[ 342, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_last_reset
(uid: str, msg)
Handle parsing event message. Topic: tns1:Monitoring/OperatingTime/LastReset
Handle parsing event message.
async def async_parse_last_reset(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:Monitoring/OperatingTime/LastReset """ try: return Event( f"{uid}_{msg.Topic._value_1}", "Last Reset", "sensor", "timestamp", None, ...
[ "async", "def", "async_parse_last_reset", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "return", "Event", "(", "f\"{uid}_{msg.Topic._value_1}\"", ",", "\"Last Reset\"", ",", "\"sensor\"", ",", "\"timestamp\"", ",", "None", ",", "dt_...
[ 347, 0 ]
[ 365, 19 ]
python
en
['en', 'fr', 'en']
True
async_parse_last_clock_sync
(uid: str, msg)
Handle parsing event message. Topic: tns1:Monitoring/OperatingTime/LastClockSynchronization
Handle parsing event message.
async def async_parse_last_clock_sync(uid: str, msg) -> Event: """Handle parsing event message. Topic: tns1:Monitoring/OperatingTime/LastClockSynchronization """ try: return Event( f"{uid}_{msg.Topic._value_1}", "Last Clock Synchronization", "sensor", ...
[ "async", "def", "async_parse_last_clock_sync", "(", "uid", ":", "str", ",", "msg", ")", "->", "Event", ":", "try", ":", "return", "Event", "(", "f\"{uid}_{msg.Topic._value_1}\"", ",", "\"Last Clock Synchronization\"", ",", "\"sensor\"", ",", "\"timestamp\"", ",", ...
[ 370, 0 ]
[ 388, 19 ]
python
en
['en', 'fr', 'en']
True
test_setup_with_config
(hass)
Test that we import the config and setup the integration.
Test that we import the config and setup the integration.
async def test_setup_with_config(hass): """Test that we import the config and setup the integration.""" config = { speedtestdotnet.DOMAIN: { speedtestdotnet.CONF_SERVER_ID: "1", speedtestdotnet.CONF_MANUAL: True, speedtestdotnet.CONF_SCAN_INTERVAL: "00:01:00", ...
[ "async", "def", "test_setup_with_config", "(", "hass", ")", ":", "config", "=", "{", "speedtestdotnet", ".", "DOMAIN", ":", "{", "speedtestdotnet", ".", "CONF_SERVER_ID", ":", "\"1\"", ",", "speedtestdotnet", ".", "CONF_MANUAL", ":", "True", ",", "speedtestdotne...
[ 11, 0 ]
[ 21, 80 ]
python
en
['en', 'en', 'en']
True
test_successful_config_entry
(hass)
Test that SpeedTestDotNet is configured successfully.
Test that SpeedTestDotNet is configured successfully.
async def test_successful_config_entry(hass): """Test that SpeedTestDotNet is configured successfully.""" entry = MockConfigEntry( domain=speedtestdotnet.DOMAIN, data={}, ) entry.add_to_hass(hass) with patch("speedtest.Speedtest"), patch( "homeassistant.config_entries.Confi...
[ "async", "def", "test_successful_config_entry", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "speedtestdotnet", ".", "DOMAIN", ",", "data", "=", "{", "}", ",", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "with", "patc...
[ 24, 0 ]
[ 43, 5 ]
python
en
['en', 'de', 'en']
True
test_setup_failed
(hass)
Test SpeedTestDotNet failed due to an error.
Test SpeedTestDotNet failed due to an error.
async def test_setup_failed(hass): """Test SpeedTestDotNet failed due to an error.""" entry = MockConfigEntry( domain=speedtestdotnet.DOMAIN, data={}, ) entry.add_to_hass(hass) with patch("speedtest.Speedtest", side_effect=speedtest.ConfigRetrievalError): await hass.config...
[ "async", "def", "test_setup_failed", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "speedtestdotnet", ".", "DOMAIN", ",", "data", "=", "{", "}", ",", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "with", "patch", "(", ...
[ 46, 0 ]
[ 59, 64 ]
python
en
['en', 'lb', 'en']
True
test_unload_entry
(hass)
Test removing SpeedTestDotNet.
Test removing SpeedTestDotNet.
async def test_unload_entry(hass): """Test removing SpeedTestDotNet.""" entry = MockConfigEntry( domain=speedtestdotnet.DOMAIN, data={}, ) entry.add_to_hass(hass) with patch("speedtest.Speedtest"): await hass.config_entries.async_setup(entry.entry_id) assert await hass....
[ "async", "def", "test_unload_entry", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "speedtestdotnet", ".", "DOMAIN", ",", "data", "=", "{", "}", ",", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "with", "patch", "(", ...
[ 62, 0 ]
[ 77, 50 ]
python
en
['en', 'ru-Latn', 'en']
True
validate_input
(hass: HomeAssistantType, data: dict)
Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user.
Validate the user input allows us to connect.
async def validate_input(hass: HomeAssistantType, data: dict) -> Dict[str, Any]: """Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user. """ session = async_get_clientsession(hass) directv = DIRECTV(data[CONF_HOST], session=session) ...
[ "async", "def", "validate_input", "(", "hass", ":", "HomeAssistantType", ",", "data", ":", "dict", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "session", "=", "async_get_clientsession", "(", "hass", ")", "directv", "=", "DIRECTV", "(", "data", "...
[ 27, 0 ]
[ 36, 54 ]
python
en
['en', 'en', 'en']
True
DirecTVConfigFlow.__init__
(self)
Set up the instance.
Set up the instance.
def __init__(self): """Set up the instance.""" self.discovery_info = {}
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "discovery_info", "=", "{", "}" ]
[ 45, 4 ]
[ 47, 32 ]
python
en
['en', 'en', 'en']
True
DirecTVConfigFlow.async_step_user
( self, user_input: Optional[ConfigType] = None )
Handle a flow initiated by the user.
Handle a flow initiated by the user.
async def async_step_user( self, user_input: Optional[ConfigType] = None ) -> Dict[str, Any]: """Handle a flow initiated by the user.""" if user_input is None: return self._show_setup_form() try: info = await validate_input(self.hass, user_input) exce...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", ":", "Optional", "[", "ConfigType", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "user_input", "is", "None", ":", "return", "self", ".", "_show_setup_form"...
[ 49, 4 ]
[ 69, 84 ]
python
en
['en', 'en', 'en']
True
DirecTVConfigFlow.async_step_ssdp
( self, discovery_info: DiscoveryInfoType )
Handle SSDP discovery.
Handle SSDP discovery.
async def async_step_ssdp( self, discovery_info: DiscoveryInfoType ) -> Dict[str, Any]: """Handle SSDP discovery.""" host = urlparse(discovery_info[ATTR_SSDP_LOCATION]).hostname receiver_id = None if discovery_info.get(ATTR_UPNP_SERIAL): receiver_id = discovery_i...
[ "async", "def", "async_step_ssdp", "(", "self", ",", "discovery_info", ":", "DiscoveryInfoType", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "host", "=", "urlparse", "(", "discovery_info", "[", "ATTR_SSDP_LOCATION", "]", ")", ".", "hostname", "recei...
[ 71, 4 ]
[ 103, 51 ]
python
en
['en', 'en', 'en']
True
DirecTVConfigFlow.async_step_ssdp_confirm
( self, user_input: ConfigType = None )
Handle a confirmation flow initiated by SSDP.
Handle a confirmation flow initiated by SSDP.
async def async_step_ssdp_confirm( self, user_input: ConfigType = None ) -> Dict[str, Any]: """Handle a confirmation flow initiated by SSDP.""" if user_input is None: return self.async_show_form( step_id="ssdp_confirm", description_placeholders={"n...
[ "async", "def", "async_step_ssdp_confirm", "(", "self", ",", "user_input", ":", "ConfigType", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "user_input", "is", "None", ":", "return", "self", ".", "async_show_form", "(", "step_id",...
[ 105, 4 ]
[ 119, 9 ]
python
en
['en', 'en', 'en']
True
DirecTVConfigFlow._show_setup_form
(self, errors: Optional[Dict] = None)
Show the setup form to the user.
Show the setup form to the user.
def _show_setup_form(self, errors: Optional[Dict] = None) -> Dict[str, Any]: """Show the setup form to the user.""" return self.async_show_form( step_id="user", data_schema=vol.Schema({vol.Required(CONF_HOST): str}), errors=errors or {}, )
[ "def", "_show_setup_form", "(", "self", ",", "errors", ":", "Optional", "[", "Dict", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"user\"", ",", "data_schema", "...
[ 121, 4 ]
[ 127, 9 ]
python
en
['en', 'en', 'en']
True
test_sensors
(hass)
Test creation of the binary sensors.
Test creation of the binary sensors.
async def test_sensors(hass): """Test creation of the binary sensors.""" mock_powerwall = await _mock_powerwall_with_fixtures(hass) with patch( "homeassistant.components.powerwall.config_flow.Powerwall", return_value=mock_powerwall, ), patch( "homeassistant.components.powerwall...
[ "async", "def", "test_sensors", "(", "hass", ")", ":", "mock_powerwall", "=", "await", "_mock_powerwall_with_fixtures", "(", "hass", ")", "with", "patch", "(", "\"homeassistant.components.powerwall.config_flow.Powerwall\"", ",", "return_value", "=", "mock_powerwall", ",",...
[ 11, 0 ]
[ 61, 88 ]
python
en
['en', 'en', 'en']
True
async_get_triggers
(hass: HomeAssistant, device_id: str)
List device triggers for Alarm control panel devices.
List device triggers for Alarm control panel devices.
async def async_get_triggers(hass: HomeAssistant, device_id: str) -> List[dict]: """List device triggers for Alarm control panel devices.""" registry = await entity_registry.async_get_registry(hass) triggers = [] # Get all the integrations entities for this device for entry in entity_registry.async...
[ "async", "def", "async_get_triggers", "(", "hass", ":", "HomeAssistant", ",", "device_id", ":", "str", ")", "->", "List", "[", "dict", "]", ":", "registry", "=", "await", "entity_registry", ".", "async_get_registry", "(", "hass", ")", "triggers", "=", "[", ...
[ 51, 0 ]
[ 124, 19 ]
python
en
['fr', 'en', 'en']
True
async_attach_trigger
( hass: HomeAssistant, config: ConfigType, action: AutomationActionType, automation_info: dict, )
Attach a trigger.
Attach a trigger.
async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, action: AutomationActionType, automation_info: dict, ) -> CALLBACK_TYPE: """Attach a trigger.""" config = TRIGGER_SCHEMA(config) from_state = None if config[CONF_TYPE] == "triggered": to_state = STATE_ALARM...
[ "async", "def", "async_attach_trigger", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ",", "action", ":", "AutomationActionType", ",", "automation_info", ":", "dict", ",", ")", "->", "CALLBACK_TYPE", ":", "config", "=", "TRIGGER_SCHEMA", "...
[ 127, 0 ]
[ 164, 5 ]
python
en
['en', 'lb', 'en']
True
HfArgumentParser.__init__
(self, dataclass_types: Union[DataClassType, Iterable[DataClassType]], **kwargs)
Args: dataclass_types: Dataclass type, or list of dataclass types for which we will "fill" instances with the parsed args. kwargs: (Optional) Passed to `argparse.ArgumentParser()` in the regular way.
Args: dataclass_types: Dataclass type, or list of dataclass types for which we will "fill" instances with the parsed args. kwargs: (Optional) Passed to `argparse.ArgumentParser()` in the regular way.
def __init__(self, dataclass_types: Union[DataClassType, Iterable[DataClassType]], **kwargs): """ Args: dataclass_types: Dataclass type, or list of dataclass types for which we will "fill" instances with the parsed args. kwargs: (Optional) Passed t...
[ "def", "__init__", "(", "self", ",", "dataclass_types", ":", "Union", "[", "DataClassType", ",", "Iterable", "[", "DataClassType", "]", "]", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init__", "(", "*", "*", "kwargs", ")", "if", "d...
[ 53, 4 ]
[ 66, 48 ]
python
en
['en', 'error', 'th']
False
HfArgumentParser.parse_args_into_dataclasses
( self, args=None, return_remaining_strings=False, look_for_args_file=True, args_filename=None )
Parse command-line args into instances of the specified dataclass types. This relies on argparse's `ArgumentParser.parse_known_args`. See the doc at: docs.python.org/3.7/library/argparse.html#argparse.ArgumentParser.parse_args Args: args: List of strings to...
Parse command-line args into instances of the specified dataclass types.
def parse_args_into_dataclasses( self, args=None, return_remaining_strings=False, look_for_args_file=True, args_filename=None ) -> Tuple[DataClass, ...]: """ Parse command-line args into instances of the specified dataclass types. This relies on argparse's `ArgumentParser.parse_know...
[ "def", "parse_args_into_dataclasses", "(", "self", ",", "args", "=", "None", ",", "return_remaining_strings", "=", "False", ",", "look_for_args_file", "=", "True", ",", "args_filename", "=", "None", ")", "->", "Tuple", "[", "DataClass", ",", "...", "]", ":", ...
[ 140, 4 ]
[ 197, 30 ]
python
en
['en', 'error', 'th']
False
HfArgumentParser.parse_json_file
(self, json_file: str)
Alternative helper method that does not use `argparse` at all, instead loading a json file and populating the dataclass types.
Alternative helper method that does not use `argparse` at all, instead loading a json file and populating the dataclass types.
def parse_json_file(self, json_file: str) -> Tuple[DataClass, ...]: """ Alternative helper method that does not use `argparse` at all, instead loading a json file and populating the dataclass types. """ data = json.loads(Path(json_file).read_text()) outputs = [] f...
[ "def", "parse_json_file", "(", "self", ",", "json_file", ":", "str", ")", "->", "Tuple", "[", "DataClass", ",", "...", "]", ":", "data", "=", "json", ".", "loads", "(", "Path", "(", "json_file", ")", ".", "read_text", "(", ")", ")", "outputs", "=", ...
[ 199, 4 ]
[ 211, 26 ]
python
en
['en', 'error', 'th']
False
HfArgumentParser.parse_dict
(self, args: dict)
Alternative helper method that does not use `argparse` at all, instead uses a dict and populating the dataclass types.
Alternative helper method that does not use `argparse` at all, instead uses a dict and populating the dataclass types.
def parse_dict(self, args: dict) -> Tuple[DataClass, ...]: """ Alternative helper method that does not use `argparse` at all, instead uses a dict and populating the dataclass types. """ outputs = [] for dtype in self.dataclass_types: keys = {f.name for f in da...
[ "def", "parse_dict", "(", "self", ",", "args", ":", "dict", ")", "->", "Tuple", "[", "DataClass", ",", "...", "]", ":", "outputs", "=", "[", "]", "for", "dtype", "in", "self", ".", "dataclass_types", ":", "keys", "=", "{", "f", ".", "name", "for", ...
[ 213, 4 ]
[ 224, 26 ]
python
en
['en', 'error', 'th']
False
test_config_non_unique_profile
(hass: HomeAssistant)
Test setup a non-unique profile.
Test setup a non-unique profile.
async def test_config_non_unique_profile(hass: HomeAssistant) -> None: """Test setup a non-unique profile.""" config_entry = MockConfigEntry( domain=const.DOMAIN, data={const.PROFILE: "person0"}, unique_id="0" ) config_entry.add_to_hass(hass) result = await hass.config_entries.flow.async_in...
[ "async", "def", "test_config_non_unique_profile", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "const", ".", "DOMAIN", ",", "data", "=", "{", "const", ".", "PROFILE", ":", "\"person0\"",...
[ 20, 0 ]
[ 32, 59 ]
python
fr
['fr', 'fr', 'it']
True
test_config_reauth_profile
( hass: HomeAssistant, aiohttp_client, aioclient_mock )
Test reauth an existing profile re-creates the config entry.
Test reauth an existing profile re-creates the config entry.
async def test_config_reauth_profile( hass: HomeAssistant, aiohttp_client, aioclient_mock ) -> None: """Test reauth an existing profile re-creates the config entry.""" hass_config = { HA_DOMAIN: { CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_METRIC, CONF_EXTERNAL_URL: "http://127.0.0.1...
[ "async", "def", "test_config_reauth_profile", "(", "hass", ":", "HomeAssistant", ",", "aiohttp_client", ",", "aioclient_mock", ")", "->", "None", ":", "hass_config", "=", "{", "HA_DOMAIN", ":", "{", "CONF_UNIT_SYSTEM", ":", "CONF_UNIT_SYSTEM_METRIC", ",", "CONF_EXTE...
[ 35, 0 ]
[ 99, 76 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the IHC sensor platform.
Set up the IHC sensor platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the IHC sensor platform.""" if discovery_info is None: return devices = [] for name, device in discovery_info.items(): ihc_id = device["ihc_id"] product_cfg = device["product_cfg"] product = de...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "devices", "=", "[", "]", "for", "name", ",", "device", "in", "discovery_info", "."...
[ 8, 0 ]
[ 25, 25 ]
python
en
['en', 'ru', 'en']
True
IHCSensor.__init__
( self, ihc_controller, name, ihc_id: int, info: bool, unit, product=None )
Initialize the IHC sensor.
Initialize the IHC sensor.
def __init__( self, ihc_controller, name, ihc_id: int, info: bool, unit, product=None ) -> None: """Initialize the IHC sensor.""" super().__init__(ihc_controller, name, ihc_id, info, product) self._state = None self._unit_of_measurement = unit
[ "def", "__init__", "(", "self", ",", "ihc_controller", ",", "name", ",", "ihc_id", ":", "int", ",", "info", ":", "bool", ",", "unit", ",", "product", "=", "None", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "ihc_controller", ",",...
[ 31, 4 ]
[ 37, 40 ]
python
en
['en', 'pl', 'en']
True
IHCSensor.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" ]
[ 40, 4 ]
[ 42, 26 ]
python
en
['en', 'en', 'en']
True
IHCSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 45, 4 ]
[ 47, 40 ]
python
en
['en', 'en', 'en']
True
IHCSensor.on_ihc_change
(self, ihc_id, value)
Handle IHC resource change.
Handle IHC resource change.
def on_ihc_change(self, ihc_id, value): """Handle IHC resource change.""" self._state = value self.schedule_update_ha_state()
[ "def", "on_ihc_change", "(", "self", ",", "ihc_id", ",", "value", ")", ":", "self", ".", "_state", "=", "value", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 49, 4 ]
[ 52, 39 ]
python
en
['en', 'xh', 'en']
True
async_get_conditions
( hass: HomeAssistant, device_id: str )
List device conditions for Vacuum devices.
List device conditions for Vacuum devices.
async def async_get_conditions( hass: HomeAssistant, device_id: str ) -> List[Dict[str, str]]: """List device conditions for Vacuum devices.""" registry = await entity_registry.async_get_registry(hass) conditions = [] # Get all the integrations entities for this device for entry in entity_regis...
[ "async", "def", "async_get_conditions", "(", "hass", ":", "HomeAssistant", ",", "device_id", ":", "str", ")", "->", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ":", "registry", "=", "await", "entity_registry", ".", "async_get_registry", "(", "ha...
[ 30, 0 ]
[ 61, 21 ]
python
en
['fr', 'en', 'en']
True
async_condition_from_config
( config: ConfigType, config_validation: bool )
Create a function to test a device condition.
Create a function to test a device condition.
def async_condition_from_config( config: ConfigType, config_validation: bool ) -> condition.ConditionCheckerType: """Create a function to test a device condition.""" if config_validation: config = CONDITION_SCHEMA(config) if config[CONF_TYPE] == "is_docked": test_states = [STATE_DOCKED] ...
[ "def", "async_condition_from_config", "(", "config", ":", "ConfigType", ",", "config_validation", ":", "bool", ")", "->", "condition", ".", "ConditionCheckerType", ":", "if", "config_validation", ":", "config", "=", "CONDITION_SCHEMA", "(", "config", ")", "if", "c...
[ 65, 0 ]
[ 81, 24 ]
python
en
['en', 'en', 'en']
True
async_get_conditions
( hass: HomeAssistant, device_id: str )
List device conditions for NEW_NAME devices.
List device conditions for NEW_NAME devices.
async def async_get_conditions( hass: HomeAssistant, device_id: str ) -> List[Dict[str, str]]: """List device conditions for NEW_NAME devices.""" registry = await entity_registry.async_get_registry(hass) conditions = [] # Get all the integrations entities for this device for entry in entity_reg...
[ "async", "def", "async_get_conditions", "(", "hass", ":", "HomeAssistant", ",", "device_id", ":", "str", ")", "->", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ":", "registry", "=", "await", "entity_registry", ".", "async_get_registry", "(", "ha...
[ 33, 0 ]
[ 66, 21 ]
python
en
['fr', 'en', 'en']
True
async_condition_from_config
( config: ConfigType, config_validation: bool )
Create a function to test a device condition.
Create a function to test a device condition.
def async_condition_from_config( config: ConfigType, config_validation: bool ) -> condition.ConditionCheckerType: """Create a function to test a device condition.""" if config_validation: config = CONDITION_SCHEMA(config) if config[CONF_TYPE] == "is_on": state = STATE_ON else: ...
[ "def", "async_condition_from_config", "(", "config", ":", "ConfigType", ",", "config_validation", ":", "bool", ")", "->", "condition", ".", "ConditionCheckerType", ":", "if", "config_validation", ":", "config", "=", "CONDITION_SCHEMA", "(", "config", ")", "if", "c...
[ 70, 0 ]
[ 86, 24 ]
python
en
['en', 'en', 'en']
True
server_id_valid
(server_id)
Check if server_id is valid.
Check if server_id is valid.
def server_id_valid(server_id): """Check if server_id is valid.""" try: api = speedtest.Speedtest() api.get_servers([int(server_id)]) except (speedtest.ConfigRetrievalError, speedtest.NoMatchedServers): return False return True
[ "def", "server_id_valid", "(", "server_id", ")", ":", "try", ":", "api", "=", "speedtest", ".", "Speedtest", "(", ")", "api", ".", "get_servers", "(", "[", "int", "(", "server_id", ")", "]", ")", "except", "(", "speedtest", ".", "ConfigRetrievalError", "...
[ 49, 0 ]
[ 57, 15 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Import integration from config.
Import integration from config.
async def async_setup(hass, config): """Import integration from config.""" if DOMAIN in config: hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_IMPORT}, data=config[DOMAIN] ) ) return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "if", "DOMAIN", "in", "config", ":", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"so...
[ 60, 0 ]
[ 68, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry)
Set up the Speedtest.net component.
Set up the Speedtest.net component.
async def async_setup_entry(hass, config_entry): """Set up the Speedtest.net component.""" coordinator = SpeedTestDataCoordinator(hass, config_entry) await coordinator.async_setup() async def _enable_scheduled_speedtests(*_): """Activate the data update coordinator.""" coordinator.updat...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ")", ":", "coordinator", "=", "SpeedTestDataCoordinator", "(", "hass", ",", "config_entry", ")", "await", "coordinator", ".", "async_setup", "(", ")", "async", "def", "_enable_scheduled_speedtest...
[ 71, 0 ]
[ 102, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, config_entry)
Unload SpeedTest Entry from config_entry.
Unload SpeedTest Entry from config_entry.
async def async_unload_entry(hass, config_entry): """Unload SpeedTest Entry from config_entry.""" hass.services.async_remove(DOMAIN, SPEED_TEST_SERVICE) hass.data[DOMAIN].async_unload() await hass.config_entries.async_forward_entry_unload(config_entry, "sensor") hass.data.pop(DOMAIN) return ...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "config_entry", ")", ":", "hass", ".", "services", ".", "async_remove", "(", "DOMAIN", ",", "SPEED_TEST_SERVICE", ")", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_unload", "(", ")", "await", ...
[ 105, 0 ]
[ 115, 15 ]
python
en
['en', 'en', 'en']
True
options_updated_listener
(hass, entry)
Handle options update.
Handle options update.
async def options_updated_listener(hass, entry): """Handle options update.""" if entry.options[CONF_MANUAL]: hass.data[DOMAIN].update_interval = None return hass.data[DOMAIN].update_interval = timedelta( minutes=entry.options[CONF_SCAN_INTERVAL] ) await hass.data[DOMAIN].asy...
[ "async", "def", "options_updated_listener", "(", "hass", ",", "entry", ")", ":", "if", "entry", ".", "options", "[", "CONF_MANUAL", "]", ":", "hass", ".", "data", "[", "DOMAIN", "]", ".", "update_interval", "=", "None", "return", "hass", ".", "data", "["...
[ 220, 0 ]
[ 229, 51 ]
python
en
['en', 'nl', 'en']
True
SpeedTestDataCoordinator.__init__
(self, hass, config_entry)
Initialize the data object.
Initialize the data object.
def __init__(self, hass, config_entry): """Initialize the data object.""" self.hass = hass self.config_entry = config_entry self.api = None self.servers = {} self._unsub_update_listener = None super().__init__( self.hass, _LOGGER, ...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config_entry", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "config_entry", "=", "config_entry", "self", ".", "api", "=", "None", "self", ".", "servers", "=", "{", "}", "self", ".", "_uns...
[ 121, 4 ]
[ 133, 9 ]
python
en
['en', 'en', 'en']
True
SpeedTestDataCoordinator.update_servers
(self)
Update list of test servers.
Update list of test servers.
def update_servers(self): """Update list of test servers.""" try: server_list = self.api.get_servers() except speedtest.ConfigRetrievalError: _LOGGER.debug("Error retrieving server list") return self.servers[DEFAULT_SERVER] = {} for server in ...
[ "def", "update_servers", "(", "self", ")", ":", "try", ":", "server_list", "=", "self", ".", "api", ".", "get_servers", "(", ")", "except", "speedtest", ".", "ConfigRetrievalError", ":", "_LOGGER", ".", "debug", "(", "\"Error retrieving server list\"", ")", "r...
[ 135, 4 ]
[ 150, 25 ]
python
en
['en', 'et', 'en']
True
SpeedTestDataCoordinator.update_data
(self)
Get the latest data from speedtest.net.
Get the latest data from speedtest.net.
def update_data(self): """Get the latest data from speedtest.net.""" self.update_servers() self.api.closest.clear() if self.config_entry.options.get(CONF_SERVER_ID): server_id = self.config_entry.options.get(CONF_SERVER_ID) self.api.get_servers(servers=[server_id...
[ "def", "update_data", "(", "self", ")", ":", "self", ".", "update_servers", "(", ")", "self", ".", "api", ".", "closest", ".", "clear", "(", ")", "if", "self", ".", "config_entry", ".", "options", ".", "get", "(", "CONF_SERVER_ID", ")", ":", "server_id...
[ 152, 4 ]
[ 168, 38 ]
python
en
['en', 'en', 'en']
True
SpeedTestDataCoordinator.async_update
(self, *_)
Update Speedtest data.
Update Speedtest data.
async def async_update(self, *_): """Update Speedtest data.""" try: return await self.hass.async_add_executor_job(self.update_data) except (speedtest.ConfigRetrievalError, speedtest.NoMatchedServers) as err: raise UpdateFailed from err
[ "async", "def", "async_update", "(", "self", ",", "*", "_", ")", ":", "try", ":", "return", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "update_data", ")", "except", "(", "speedtest", ".", "ConfigRetrievalError", ",", "sp...
[ 170, 4 ]
[ 175, 39 ]
python
da
['da', 'de', 'en']
False