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
DomainBlueprints.async_remove_blueprint
(self, blueprint_path: str)
Remove a blueprint file.
Remove a blueprint file.
async def async_remove_blueprint(self, blueprint_path: str) -> None: """Remove a blueprint file.""" path = pathlib.Path( self.hass.config.path(BLUEPRINT_FOLDER, self.domain, blueprint_path) ) await self.hass.async_add_executor_job(path.unlink) self._blueprints[bluepr...
[ "async", "def", "async_remove_blueprint", "(", "self", ",", "blueprint_path", ":", "str", ")", "->", "None", ":", "path", "=", "pathlib", ".", "Path", "(", "self", ".", "hass", ".", "config", ".", "path", "(", "BLUEPRINT_FOLDER", ",", "self", ".", "domai...
[ 257, 4 ]
[ 264, 47 ]
python
en
['en', 'fr', 'en']
True
DomainBlueprints._create_file
(self, blueprint: Blueprint, blueprint_path: str)
Create blueprint file.
Create blueprint file.
def _create_file(self, blueprint: Blueprint, blueprint_path: str) -> None: """Create blueprint file.""" path = pathlib.Path( self.hass.config.path(BLUEPRINT_FOLDER, self.domain, blueprint_path) ) if path.exists(): raise FileAlreadyExists(self.domain, blueprint_pa...
[ "def", "_create_file", "(", "self", ",", "blueprint", ":", "Blueprint", ",", "blueprint_path", ":", "str", ")", "->", "None", ":", "path", "=", "pathlib", ".", "Path", "(", "self", ".", "hass", ".", "config", ".", "path", "(", "BLUEPRINT_FOLDER", ",", ...
[ 266, 4 ]
[ 276, 41 ]
python
en
['fr', 'ro', 'en']
False
DomainBlueprints.async_add_blueprint
( self, blueprint: Blueprint, blueprint_path: str )
Add a blueprint.
Add a blueprint.
async def async_add_blueprint( self, blueprint: Blueprint, blueprint_path: str ) -> None: """Add a blueprint.""" if not blueprint_path.endswith(".yaml"): blueprint_path = f"{blueprint_path}.yaml" await self.hass.async_add_executor_job( self._create_file, blue...
[ "async", "def", "async_add_blueprint", "(", "self", ",", "blueprint", ":", "Blueprint", ",", "blueprint_path", ":", "str", ")", "->", "None", ":", "if", "not", "blueprint_path", ".", "endswith", "(", "\".yaml\"", ")", ":", "blueprint_path", "=", "f\"{blueprint...
[ 278, 4 ]
[ 289, 52 ]
python
en
['en', 'lb', 'en']
True
test_migration
(hass)
Test that we can migrate coronavirus to stable unique ID.
Test that we can migrate coronavirus to stable unique ID.
async def test_migration(hass): """Test that we can migrate coronavirus to stable unique ID.""" nl_entry = MockConfigEntry(domain=DOMAIN, title="Netherlands", data={"country": 34}) nl_entry.add_to_hass(hass) worldwide_entry = MockConfigEntry( domain=DOMAIN, title="Worldwide", data={"country": OP...
[ "async", "def", "test_migration", "(", "hass", ")", ":", "nl_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "title", "=", "\"Netherlands\"", ",", "data", "=", "{", "\"country\"", ":", "34", "}", ")", "nl_entry", ".", "add_to_hass", "(",...
[ 8, 0 ]
[ 48, 56 ]
python
en
['en', 'en', 'en']
True
test_climate
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test the creation and values of Atag climate device.
Test the creation and values of Atag climate device.
async def test_climate( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the creation and values of Atag climate device.""" with patch("pyatag.entities.Climate.status"): entry = await init_integration(hass, aioclient_mock) registry = await hass.helpers.entity_regis...
[ "async", "def", "test_climate", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "with", "patch", "(", "\"pyatag.entities.Climate.status\"", ")", ":", "entry", "=", "await", "init_integration", "(", "has...
[ 28, 0 ]
[ 42, 9 ]
python
en
['en', 'en', 'en']
True
test_setting_climate
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test setting the climate device.
Test setting the climate device.
async def test_setting_climate( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test setting the climate device.""" await init_integration(hass, aioclient_mock) with patch("pyatag.entities.Climate.set_temp") as mock_set_temp: await hass.services.async_call( CLI...
[ "async", "def", "test_setting_climate", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "await", "init_integration", "(", "hass", ",", "aioclient_mock", ")", "with", "patch", "(", "\"pyatag.entities.Clima...
[ 45, 0 ]
[ 78, 61 ]
python
en
['en', 'en', 'en']
True
test_incorrect_modes
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, )
Test incorrect values are handled correctly.
Test incorrect values are handled correctly.
async def test_incorrect_modes( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, ) -> None: """Test incorrect values are handled correctly.""" with patch( "pyatag.entities.Climate.hvac_mode", new_callable=PropertyMock(return_value="bug"), ): await init_integration(ha...
[ "async", "def", "test_incorrect_modes", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ",", ")", "->", "None", ":", "with", "patch", "(", "\"pyatag.entities.Climate.hvac_mode\"", ",", "new_callable", "=", "PropertyMock", "(", "...
[ 81, 0 ]
[ 91, 65 ]
python
en
['en', 'en', 'en']
True
test_update_service
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker )
Test the updater service is called.
Test the updater service is called.
async def test_update_service( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the updater service is called.""" await init_integration(hass, aioclient_mock) await async_setup_component(hass, HA_DOMAIN, {}) with patch("pyatag.AtagOne.update") as updater: await has...
[ "async", "def", "test_update_service", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ")", "->", "None", ":", "await", "init_integration", "(", "hass", ",", "aioclient_mock", ")", "await", "async_setup_component", "(", "hass", ...
[ 94, 0 ]
[ 108, 36 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the air quality component.
Set up the air quality component.
async def async_setup(hass, config): """Set up the air quality component.""" component = hass.data[DOMAIN] = EntityComponent( _LOGGER, DOMAIN, hass, SCAN_INTERVAL ) await component.async_setup(config) return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "component", "=", "hass", ".", "data", "[", "DOMAIN", "]", "=", "EntityComponent", "(", "_LOGGER", ",", "DOMAIN", ",", "hass", ",", "SCAN_INTERVAL", ")", "await", "component", ".", "asy...
[ 49, 0 ]
[ 55, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry)
Set up a config entry.
Set up a config entry.
async def async_setup_entry(hass, entry): """Set up a config entry.""" return await hass.data[DOMAIN].async_setup_entry(entry)
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "return", "await", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_setup_entry", "(", "entry", ")" ]
[ 58, 0 ]
[ 60, 59 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, entry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass, entry): """Unload a config entry.""" return await hass.data[DOMAIN].async_unload_entry(entry)
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "return", "await", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_unload_entry", "(", "entry", ")" ]
[ 63, 0 ]
[ 65, 60 ]
python
en
['en', 'es', 'en']
True
AirQualityEntity.particulate_matter_2_5
(self)
Return the particulate matter 2.5 level.
Return the particulate matter 2.5 level.
def particulate_matter_2_5(self): """Return the particulate matter 2.5 level.""" raise NotImplementedError()
[ "def", "particulate_matter_2_5", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 72, 4 ]
[ 74, 35 ]
python
en
['en', 'en', 'en']
True
AirQualityEntity.particulate_matter_10
(self)
Return the particulate matter 10 level.
Return the particulate matter 10 level.
def particulate_matter_10(self): """Return the particulate matter 10 level.""" return None
[ "def", "particulate_matter_10", "(", "self", ")", ":", "return", "None" ]
[ 77, 4 ]
[ 79, 19 ]
python
en
['en', 'en', 'en']
True
AirQualityEntity.particulate_matter_0_1
(self)
Return the particulate matter 0.1 level.
Return the particulate matter 0.1 level.
def particulate_matter_0_1(self): """Return the particulate matter 0.1 level.""" return None
[ "def", "particulate_matter_0_1", "(", "self", ")", ":", "return", "None" ]
[ 82, 4 ]
[ 84, 19 ]
python
en
['en', 'en', 'en']
True
AirQualityEntity.air_quality_index
(self)
Return the Air Quality Index (AQI).
Return the Air Quality Index (AQI).
def air_quality_index(self): """Return the Air Quality Index (AQI).""" return None
[ "def", "air_quality_index", "(", "self", ")", ":", "return", "None" ]
[ 87, 4 ]
[ 89, 19 ]
python
en
['en', 'cy', 'en']
True
AirQualityEntity.ozone
(self)
Return the O3 (ozone) level.
Return the O3 (ozone) level.
def ozone(self): """Return the O3 (ozone) level.""" return None
[ "def", "ozone", "(", "self", ")", ":", "return", "None" ]
[ 92, 4 ]
[ 94, 19 ]
python
en
['en', 'ig', 'en']
True
AirQualityEntity.carbon_monoxide
(self)
Return the CO (carbon monoxide) level.
Return the CO (carbon monoxide) level.
def carbon_monoxide(self): """Return the CO (carbon monoxide) level.""" return None
[ "def", "carbon_monoxide", "(", "self", ")", ":", "return", "None" ]
[ 97, 4 ]
[ 99, 19 ]
python
en
['en', 'fr', 'en']
True
AirQualityEntity.carbon_dioxide
(self)
Return the CO2 (carbon dioxide) level.
Return the CO2 (carbon dioxide) level.
def carbon_dioxide(self): """Return the CO2 (carbon dioxide) level.""" return None
[ "def", "carbon_dioxide", "(", "self", ")", ":", "return", "None" ]
[ 102, 4 ]
[ 104, 19 ]
python
en
['en', 'en', 'en']
True
AirQualityEntity.attribution
(self)
Return the attribution.
Return the attribution.
def attribution(self): """Return the attribution.""" return None
[ "def", "attribution", "(", "self", ")", ":", "return", "None" ]
[ 107, 4 ]
[ 109, 19 ]
python
en
['en', 'ja', 'en']
True
AirQualityEntity.sulphur_dioxide
(self)
Return the SO2 (sulphur dioxide) level.
Return the SO2 (sulphur dioxide) level.
def sulphur_dioxide(self): """Return the SO2 (sulphur dioxide) level.""" return None
[ "def", "sulphur_dioxide", "(", "self", ")", ":", "return", "None" ]
[ 112, 4 ]
[ 114, 19 ]
python
en
['en', 'no', 'en']
True
AirQualityEntity.nitrogen_oxide
(self)
Return the N2O (nitrogen oxide) level.
Return the N2O (nitrogen oxide) level.
def nitrogen_oxide(self): """Return the N2O (nitrogen oxide) level.""" return None
[ "def", "nitrogen_oxide", "(", "self", ")", ":", "return", "None" ]
[ 117, 4 ]
[ 119, 19 ]
python
en
['en', 'no', 'en']
True
AirQualityEntity.nitrogen_monoxide
(self)
Return the NO (nitrogen monoxide) level.
Return the NO (nitrogen monoxide) level.
def nitrogen_monoxide(self): """Return the NO (nitrogen monoxide) level.""" return None
[ "def", "nitrogen_monoxide", "(", "self", ")", ":", "return", "None" ]
[ 122, 4 ]
[ 124, 19 ]
python
en
['en', 'fr', 'en']
True
AirQualityEntity.nitrogen_dioxide
(self)
Return the NO2 (nitrogen dioxide) level.
Return the NO2 (nitrogen dioxide) level.
def nitrogen_dioxide(self): """Return the NO2 (nitrogen dioxide) level.""" return None
[ "def", "nitrogen_dioxide", "(", "self", ")", ":", "return", "None" ]
[ 127, 4 ]
[ 129, 19 ]
python
en
['en', 'da', 'en']
True
AirQualityEntity.state_attributes
(self)
Return the state attributes.
Return the state attributes.
def state_attributes(self): """Return the state attributes.""" data = {} for prop, attr in PROP_TO_ATTR.items(): value = getattr(self, prop) if value is not None: data[attr] = value return data
[ "def", "state_attributes", "(", "self", ")", ":", "data", "=", "{", "}", "for", "prop", ",", "attr", "in", "PROP_TO_ATTR", ".", "items", "(", ")", ":", "value", "=", "getattr", "(", "self", ",", "prop", ")", "if", "value", "is", "not", "None", ":",...
[ 132, 4 ]
[ 141, 19 ]
python
en
['en', 'en', 'en']
True
AirQualityEntity.state
(self)
Return the current state.
Return the current state.
def state(self): """Return the current state.""" return self.particulate_matter_2_5
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "particulate_matter_2_5" ]
[ 144, 4 ]
[ 146, 42 ]
python
en
['en', 'en', 'en']
True
AirQualityEntity.unit_of_measurement
(self)
Return the unit of measurement of this entity.
Return the unit of measurement of this entity.
def unit_of_measurement(self): """Return the unit of measurement of this entity.""" return CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "CONCENTRATION_MICROGRAMS_PER_CUBIC_METER" ]
[ 149, 4 ]
[ 151, 55 ]
python
en
['en', 'en', 'en']
True
create_model
(samples_x, samples_y_aggregation, percentage_goodbatch=0.34)
Create the Gaussian Mixture Model
Create the Gaussian Mixture Model
def create_model(samples_x, samples_y_aggregation, percentage_goodbatch=0.34): ''' Create the Gaussian Mixture Model ''' samples = [samples_x[i] + [samples_y_aggregation[i]] for i in range(0, len(samples_x))] # Sorts so that we can get the top samples samples = sorted(samples, ke...
[ "def", "create_model", "(", "samples_x", ",", "samples_y_aggregation", ",", "percentage_goodbatch", "=", "0.34", ")", ":", "samples", "=", "[", "samples_x", "[", "i", "]", "+", "[", "samples_y_aggregation", "[", "i", "]", "]", "for", "i", "in", "range", "(...
[ 12, 0 ]
[ 43, 16 ]
python
en
['en', 'error', 'th']
False
get_attention
(model, model_type, tokenizer, sentence_a, sentence_b=None, include_queries_and_keys=False)
Compute representation of attention to pass to the d3 visualization Args: model: pytorch-transformers model model_type: type of model. Valid values 'bert', 'gpt2', 'xlnet', 'roberta' tokenizer: pytorch-transformers tokenizer sentence_a: Sentence A string sentence_b: Sentenc...
Compute representation of attention to pass to the d3 visualization
def get_attention(model, model_type, tokenizer, sentence_a, sentence_b=None, include_queries_and_keys=False): """Compute representation of attention to pass to the d3 visualization Args: model: pytorch-transformers model model_type: type of model. Valid values 'bert', 'gpt2', 'xlnet', 'roberta...
[ "def", "get_attention", "(", "model", ",", "model_type", ",", "tokenizer", ",", "sentence_a", ",", "sentence_b", "=", "None", ",", "include_queries_and_keys", "=", "False", ")", ":", "if", "model_type", "not", "in", "(", "'bert'", ",", "'gpt2'", ",", "'xlnet...
[ 4, 0 ]
[ 169, 18 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the ZAMG sensor platform.
Set up the ZAMG sensor platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the ZAMG sensor platform.""" name = config.get(CONF_NAME) latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude) station_id = config.get(CONF_STATION_ID) ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "latitude", "=", "config", ".", "get", "(", "CONF_LATITUDE", ",", "hass", "....
[ 101, 0 ]
[ 131, 5 ]
python
en
['en', 'cs', 'en']
True
_get_zamg_stations
()
Return {CONF_STATION: (lat, lon)} for all stations, for auto-config.
Return {CONF_STATION: (lat, lon)} for all stations, for auto-config.
def _get_zamg_stations(): """Return {CONF_STATION: (lat, lon)} for all stations, for auto-config.""" capital_stations = {r["Station"] for r in ZamgData.current_observations()} req = requests.get( "https://www.zamg.ac.at/cms/en/documents/climate/" "doc_metnetwork/zamg-observation-points", ...
[ "def", "_get_zamg_stations", "(", ")", ":", "capital_stations", "=", "{", "r", "[", "\"Station\"", "]", "for", "r", "in", "ZamgData", ".", "current_observations", "(", ")", "}", "req", "=", "requests", ".", "get", "(", "\"https://www.zamg.ac.at/cms/en/documents/...
[ 241, 0 ]
[ 259, 19 ]
python
en
['en', 'en', 'en']
True
zamg_stations
(cache_dir)
Return {CONF_STATION: (lat, lon)} for all stations, for auto-config. Results from internet requests are cached as compressed json, making subsequent calls very much faster.
Return {CONF_STATION: (lat, lon)} for all stations, for auto-config.
def zamg_stations(cache_dir): """Return {CONF_STATION: (lat, lon)} for all stations, for auto-config. Results from internet requests are cached as compressed json, making subsequent calls very much faster. """ cache_file = os.path.join(cache_dir, ".zamg-stations.json.gz") if not os.path.isfile(...
[ "def", "zamg_stations", "(", "cache_dir", ")", ":", "cache_file", "=", "os", ".", "path", ".", "join", "(", "cache_dir", ",", "\".zamg-stations.json.gz\"", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "cache_file", ")", ":", "stations", "=", ...
[ 262, 0 ]
[ 275, 65 ]
python
en
['en', 'en', 'en']
True
closest_station
(lat, lon, cache_dir)
Return the ZONE_ID.WMO_ID of the closest station to our lat/lon.
Return the ZONE_ID.WMO_ID of the closest station to our lat/lon.
def closest_station(lat, lon, cache_dir): """Return the ZONE_ID.WMO_ID of the closest station to our lat/lon.""" if lat is None or lon is None or not os.path.isdir(cache_dir): return stations = zamg_stations(cache_dir) def comparable_dist(zamg_id): """Calculate the pseudo-distance from ...
[ "def", "closest_station", "(", "lat", ",", "lon", ",", "cache_dir", ")", ":", "if", "lat", "is", "None", "or", "lon", "is", "None", "or", "not", "os", ".", "path", ".", "isdir", "(", "cache_dir", ")", ":", "return", "stations", "=", "zamg_stations", ...
[ 278, 0 ]
[ 289, 45 ]
python
en
['en', 'en', 'en']
True
ZamgSensor.__init__
(self, probe, variable, name)
Initialize the sensor.
Initialize the sensor.
def __init__(self, probe, variable, name): """Initialize the sensor.""" self.probe = probe self.client_name = name self.variable = variable
[ "def", "__init__", "(", "self", ",", "probe", ",", "variable", ",", "name", ")", ":", "self", ".", "probe", "=", "probe", "self", ".", "client_name", "=", "name", "self", ".", "variable", "=", "variable" ]
[ 137, 4 ]
[ 141, 32 ]
python
en
['en', 'en', 'en']
True
ZamgSensor.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.client_name} {self.variable}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self.client_name} {self.variable}\"" ]
[ 144, 4 ]
[ 146, 52 ]
python
en
['en', 'mi', 'en']
True
ZamgSensor.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.probe.get_data(self.variable)
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "probe", ".", "get_data", "(", "self", ".", "variable", ")" ]
[ 149, 4 ]
[ 151, 49 ]
python
en
['en', 'en', 'en']
True
ZamgSensor.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 SENSOR_TYPES[self.variable][1]
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "SENSOR_TYPES", "[", "self", ".", "variable", "]", "[", "1", "]" ]
[ 154, 4 ]
[ 156, 45 ]
python
en
['en', 'en', 'en']
True
ZamgSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return { ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_STATION: self.probe.get_data("station_name"), ATTR_UPDATED: self.probe.last_update.isoformat(), }
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", ",", "ATTR_STATION", ":", "self", ".", "probe", ".", "get_data", "(", "\"station_name\"", ")", ",", "ATTR_UPDATED", ":", "self", ".", "probe", ".", ...
[ 159, 4 ]
[ 165, 9 ]
python
en
['en', 'en', 'en']
True
ZamgSensor.update
(self)
Delegate update to probe.
Delegate update to probe.
def update(self): """Delegate update to probe.""" self.probe.update()
[ "def", "update", "(", "self", ")", ":", "self", ".", "probe", ".", "update", "(", ")" ]
[ 167, 4 ]
[ 169, 27 ]
python
en
['en', 'co', 'en']
True
ZamgData.__init__
(self, station_id)
Initialize the probe.
Initialize the probe.
def __init__(self, station_id): """Initialize the probe.""" self._station_id = station_id self.data = {}
[ "def", "__init__", "(", "self", ",", "station_id", ")", ":", "self", ".", "_station_id", "=", "station_id", "self", ".", "data", "=", "{", "}" ]
[ 178, 4 ]
[ 181, 22 ]
python
en
['en', 'en', 'en']
True
ZamgData.last_update
(self)
Return the timestamp of the most recent data.
Return the timestamp of the most recent data.
def last_update(self): """Return the timestamp of the most recent data.""" date, time = self.data.get("update_date"), self.data.get("update_time") if date is not None and time is not None: return datetime.strptime(date + time, "%d-%m-%Y%H:%M").replace( tzinfo=pytz.tim...
[ "def", "last_update", "(", "self", ")", ":", "date", ",", "time", "=", "self", ".", "data", ".", "get", "(", "\"update_date\"", ")", ",", "self", ".", "data", ".", "get", "(", "\"update_time\"", ")", "if", "date", "is", "not", "None", "and", "time", ...
[ 184, 4 ]
[ 190, 13 ]
python
en
['en', 'en', 'en']
True
ZamgData.current_observations
(cls)
Fetch the latest CSV data.
Fetch the latest CSV data.
def current_observations(cls): """Fetch the latest CSV data.""" try: response = requests.get(cls.API_URL, headers=cls.API_HEADERS, timeout=15) response.raise_for_status() response.encoding = "UTF8" return csv.DictReader( response.text.split...
[ "def", "current_observations", "(", "cls", ")", ":", "try", ":", "response", "=", "requests", ".", "get", "(", "cls", ".", "API_URL", ",", "headers", "=", "cls", ".", "API_HEADERS", ",", "timeout", "=", "15", ")", "response", ".", "raise_for_status", "("...
[ 193, 4 ]
[ 203, 48 ]
python
en
['en', 'en', 'en']
True
ZamgData.update
(self)
Get the latest data from ZAMG.
Get the latest data from ZAMG.
def update(self): """Get the latest data from ZAMG.""" if self.last_update and ( self.last_update + timedelta(hours=1) > datetime.utcnow().replace(tzinfo=pytz.utc) ): return # Not time to update yet; data is only hourly for row in self.current_observ...
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "last_update", "and", "(", "self", ".", "last_update", "+", "timedelta", "(", "hours", "=", "1", ")", ">", "datetime", ".", "utcnow", "(", ")", ".", "replace", "(", "tzinfo", "=", "pytz", "...
[ 206, 4 ]
[ 234, 79 ]
python
en
['en', 'en', 'en']
True
ZamgData.get_data
(self, variable)
Get the data.
Get the data.
def get_data(self, variable): """Get the data.""" return self.data.get(variable)
[ "def", "get_data", "(", "self", ",", "variable", ")", ":", "return", "self", ".", "data", ".", "get", "(", "variable", ")" ]
[ 236, 4 ]
[ 238, 38 ]
python
en
['en', 'en', 'en']
True
test_platform_manually_configured
(hass)
Test that we do not discover anything or try to set up a gateway.
Test that we do not discover anything or try to set up a gateway.
async def test_platform_manually_configured(hass): """Test that we do not discover anything or try to set up a gateway.""" assert ( await async_setup_component( hass, COVER_DOMAIN, {"cover": {"platform": DECONZ_DOMAIN}} ) is True ) assert DECONZ_DOMAIN not in hass.dat...
[ "async", "def", "test_platform_manually_configured", "(", "hass", ")", ":", "assert", "(", "await", "async_setup_component", "(", "hass", ",", "COVER_DOMAIN", ",", "{", "\"cover\"", ":", "{", "\"platform\"", ":", "DECONZ_DOMAIN", "}", "}", ")", "is", "True", "...
[ 62, 0 ]
[ 70, 41 ]
python
en
['en', 'en', 'en']
True
test_no_covers
(hass)
Test that no cover entities are created.
Test that no cover entities are created.
async def test_no_covers(hass): """Test that no cover entities are created.""" await setup_deconz_integration(hass) assert len(hass.states.async_all()) == 0
[ "async", "def", "test_no_covers", "(", "hass", ")", ":", "await", "setup_deconz_integration", "(", "hass", ")", "assert", "len", "(", "hass", ".", "states", ".", "async_all", "(", ")", ")", "==", "0" ]
[ 73, 0 ]
[ 76, 44 ]
python
en
['en', 'en', 'en']
True
test_cover
(hass)
Test that all supported cover entities are created.
Test that all supported cover entities are created.
async def test_cover(hass): """Test that all supported cover entities are created.""" data = deepcopy(DECONZ_WEB_REQUEST) data["lights"] = deepcopy(COVERS) config_entry = await setup_deconz_integration(hass, get_state_response=data) gateway = get_gateway_from_config_entry(hass, config_entry) as...
[ "async", "def", "test_cover", "(", "hass", ")", ":", "data", "=", "deepcopy", "(", "DECONZ_WEB_REQUEST", ")", "data", "[", "\"lights\"", "]", "=", "deepcopy", "(", "COVERS", ")", "config_entry", "=", "await", "setup_deconz_integration", "(", "hass", ",", "ge...
[ 79, 0 ]
[ 174, 44 ]
python
en
['en', 'en', 'en']
True
get_google_type
(domain, device_class)
Google type based on domain and device class.
Google type based on domain and device class.
def get_google_type(domain, device_class): """Google type based on domain and device class.""" typ = DEVICE_CLASS_TO_GOOGLE_TYPES.get((domain, device_class)) return typ if typ is not None else DOMAIN_TO_GOOGLE_TYPES[domain]
[ "def", "get_google_type", "(", "domain", ",", "device_class", ")", ":", "typ", "=", "DEVICE_CLASS_TO_GOOGLE_TYPES", ".", "get", "(", "(", "domain", ",", "device_class", ")", ")", "return", "typ", "if", "typ", "is", "not", "None", "else", "DOMAIN_TO_GOOGLE_TYPE...
[ 314, 0 ]
[ 318, 69 ]
python
en
['en', 'en', 'en']
True
deep_update
(target, source)
Update a nested dictionary with another nested dictionary.
Update a nested dictionary with another nested dictionary.
def deep_update(target, source): """Update a nested dictionary with another nested dictionary.""" for key, value in source.items(): if isinstance(value, Mapping): target[key] = deep_update(target.get(key, {}), value) else: target[key] = value return target
[ "def", "deep_update", "(", "target", ",", "source", ")", ":", "for", "key", ",", "value", "in", "source", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "Mapping", ")", ":", "target", "[", "key", "]", "=", "deep_update", "(", "...
[ 530, 0 ]
[ 537, 17 ]
python
en
['en', 'en', 'en']
True
async_get_entities
(hass, config)
Return all entities that are supported by Google.
Return all entities that are supported by Google.
def async_get_entities(hass, config) -> List[GoogleEntity]: """Return all entities that are supported by Google.""" entities = [] for state in hass.states.async_all(): if state.entity_id in CLOUD_NEVER_EXPOSED_ENTITIES: continue entity = GoogleEntity(hass, config, state) ...
[ "def", "async_get_entities", "(", "hass", ",", "config", ")", "->", "List", "[", "GoogleEntity", "]", ":", "entities", "=", "[", "]", "for", "state", "in", "hass", ".", "states", ".", "async_all", "(", ")", ":", "if", "state", ".", "entity_id", "in", ...
[ 541, 0 ]
[ 553, 19 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.__init__
(self, hass)
Initialize abstract config.
Initialize abstract config.
def __init__(self, hass): """Initialize abstract config.""" self.hass = hass self._store = None self._google_sync_unsub = {} self._local_sdk_active = False
[ "def", "__init__", "(", "self", ",", "hass", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "_store", "=", "None", "self", ".", "_google_sync_unsub", "=", "{", "}", "self", ".", "_local_sdk_active", "=", "False" ]
[ 46, 4 ]
[ 51, 38 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.async_initialize
(self)
Perform async initialization of config.
Perform async initialization of config.
async def async_initialize(self): """Perform async initialization of config.""" self._store = GoogleConfigStore(self.hass) await self._store.async_load()
[ "async", "def", "async_initialize", "(", "self", ")", ":", "self", ".", "_store", "=", "GoogleConfigStore", "(", "self", ".", "hass", ")", "await", "self", ".", "_store", ".", "async_load", "(", ")" ]
[ 53, 4 ]
[ 56, 38 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.enabled
(self)
Return if Google is enabled.
Return if Google is enabled.
def enabled(self): """Return if Google is enabled.""" return False
[ "def", "enabled", "(", "self", ")", ":", "return", "False" ]
[ 59, 4 ]
[ 61, 20 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.entity_config
(self)
Return entity config.
Return entity config.
def entity_config(self): """Return entity config.""" return {}
[ "def", "entity_config", "(", "self", ")", ":", "return", "{", "}" ]
[ 64, 4 ]
[ 66, 17 ]
python
en
['en', 'cy', 'en']
True
AbstractConfig.secure_devices_pin
(self)
Return entity config.
Return entity config.
def secure_devices_pin(self): """Return entity config.""" return None
[ "def", "secure_devices_pin", "(", "self", ")", ":", "return", "None" ]
[ 69, 4 ]
[ 71, 19 ]
python
en
['en', 'cy', 'en']
True
AbstractConfig.is_reporting_state
(self)
Return if we're actively reporting states.
Return if we're actively reporting states.
def is_reporting_state(self): """Return if we're actively reporting states.""" return self._unsub_report_state is not None
[ "def", "is_reporting_state", "(", "self", ")", ":", "return", "self", ".", "_unsub_report_state", "is", "not", "None" ]
[ 74, 4 ]
[ 76, 51 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.is_local_sdk_active
(self)
Return if we're actively accepting local messages.
Return if we're actively accepting local messages.
def is_local_sdk_active(self): """Return if we're actively accepting local messages.""" return self._local_sdk_active
[ "def", "is_local_sdk_active", "(", "self", ")", ":", "return", "self", ".", "_local_sdk_active" ]
[ 79, 4 ]
[ 81, 37 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.should_report_state
(self)
Return if states should be proactively reported.
Return if states should be proactively reported.
def should_report_state(self): """Return if states should be proactively reported.""" return False
[ "def", "should_report_state", "(", "self", ")", ":", "return", "False" ]
[ 84, 4 ]
[ 86, 20 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.local_sdk_webhook_id
(self)
Return the local SDK webhook ID. Return None to disable the local SDK.
Return the local SDK webhook ID.
def local_sdk_webhook_id(self): """Return the local SDK webhook ID. Return None to disable the local SDK. """ return None
[ "def", "local_sdk_webhook_id", "(", "self", ")", ":", "return", "None" ]
[ 89, 4 ]
[ 94, 19 ]
python
en
['en', 'zh', 'en']
True
AbstractConfig.local_sdk_user_id
(self)
Return the user ID to be used for actions received via the local SDK.
Return the user ID to be used for actions received via the local SDK.
def local_sdk_user_id(self): """Return the user ID to be used for actions received via the local SDK.""" raise NotImplementedError
[ "def", "local_sdk_user_id", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 97, 4 ]
[ 99, 33 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.get_agent_user_id
(self, context)
Get agent user ID from context.
Get agent user ID from context.
def get_agent_user_id(self, context): """Get agent user ID from context."""
[ "def", "get_agent_user_id", "(", "self", ",", "context", ")", ":" ]
[ 102, 4 ]
[ 103, 45 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.should_expose
(self, state)
Return if entity should be exposed.
Return if entity should be exposed.
def should_expose(self, state) -> bool: """Return if entity should be exposed."""
[ "def", "should_expose", "(", "self", ",", "state", ")", "->", "bool", ":" ]
[ 106, 4 ]
[ 107, 49 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.should_2fa
(self, state)
If an entity should have 2FA checked.
If an entity should have 2FA checked.
def should_2fa(self, state): """If an entity should have 2FA checked.""" # pylint: disable=no-self-use return True
[ "def", "should_2fa", "(", "self", ",", "state", ")", ":", "# pylint: disable=no-self-use", "return", "True" ]
[ 109, 4 ]
[ 112, 19 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.async_report_state
(self, message, agent_user_id: str)
Send a state report to Google.
Send a state report to Google.
async def async_report_state(self, message, agent_user_id: str): """Send a state report to Google.""" raise NotImplementedError
[ "async", "def", "async_report_state", "(", "self", ",", "message", ",", "agent_user_id", ":", "str", ")", ":", "raise", "NotImplementedError" ]
[ 114, 4 ]
[ 116, 33 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.async_report_state_all
(self, message)
Send a state report to Google for all previously synced users.
Send a state report to Google for all previously synced users.
async def async_report_state_all(self, message): """Send a state report to Google for all previously synced users.""" jobs = [ self.async_report_state(message, agent_user_id) for agent_user_id in self._store.agent_user_ids ] await gather(*jobs)
[ "async", "def", "async_report_state_all", "(", "self", ",", "message", ")", ":", "jobs", "=", "[", "self", ".", "async_report_state", "(", "message", ",", "agent_user_id", ")", "for", "agent_user_id", "in", "self", ".", "_store", ".", "agent_user_ids", "]", ...
[ 118, 4 ]
[ 124, 27 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.async_enable_report_state
(self)
Enable proactive mode.
Enable proactive mode.
def async_enable_report_state(self): """Enable proactive mode.""" # Circular dep # pylint: disable=import-outside-toplevel from .report_state import async_enable_report_state if self._unsub_report_state is None: self._unsub_report_state = async_enable_report_state(se...
[ "def", "async_enable_report_state", "(", "self", ")", ":", "# Circular dep", "# pylint: disable=import-outside-toplevel", "from", ".", "report_state", "import", "async_enable_report_state", "if", "self", ".", "_unsub_report_state", "is", "None", ":", "self", ".", "_unsub_...
[ 127, 4 ]
[ 134, 81 ]
python
en
['fr', 'xh', 'en']
False
AbstractConfig.async_disable_report_state
(self)
Disable report state.
Disable report state.
def async_disable_report_state(self): """Disable report state.""" if self._unsub_report_state is not None: self._unsub_report_state() self._unsub_report_state = None
[ "def", "async_disable_report_state", "(", "self", ")", ":", "if", "self", ".", "_unsub_report_state", "is", "not", "None", ":", "self", ".", "_unsub_report_state", "(", ")", "self", ".", "_unsub_report_state", "=", "None" ]
[ 137, 4 ]
[ 141, 43 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.async_sync_entities
(self, agent_user_id: str)
Sync all entities to Google.
Sync all entities to Google.
async def async_sync_entities(self, agent_user_id: str): """Sync all entities to Google.""" # Remove any pending sync self._google_sync_unsub.pop(agent_user_id, lambda: None)() return await self._async_request_sync_devices(agent_user_id)
[ "async", "def", "async_sync_entities", "(", "self", ",", "agent_user_id", ":", "str", ")", ":", "# Remove any pending sync", "self", ".", "_google_sync_unsub", ".", "pop", "(", "agent_user_id", ",", "lambda", ":", "None", ")", "(", ")", "return", "await", "sel...
[ 143, 4 ]
[ 147, 68 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.async_sync_entities_all
(self)
Sync all entities to Google for all registered agents.
Sync all entities to Google for all registered agents.
async def async_sync_entities_all(self): """Sync all entities to Google for all registered agents.""" res = await gather( *[ self.async_sync_entities(agent_user_id) for agent_user_id in self._store.agent_user_ids ] ) return max(res,...
[ "async", "def", "async_sync_entities_all", "(", "self", ")", ":", "res", "=", "await", "gather", "(", "*", "[", "self", ".", "async_sync_entities", "(", "agent_user_id", ")", "for", "agent_user_id", "in", "self", ".", "_store", ".", "agent_user_ids", "]", ")...
[ 149, 4 ]
[ 157, 36 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.async_schedule_google_sync
(self, agent_user_id: str)
Schedule a sync.
Schedule a sync.
def async_schedule_google_sync(self, agent_user_id: str): """Schedule a sync.""" async def _schedule_callback(_now): """Handle a scheduled sync callback.""" self._google_sync_unsub.pop(agent_user_id, None) await self.async_sync_entities(agent_user_id) self._...
[ "def", "async_schedule_google_sync", "(", "self", ",", "agent_user_id", ":", "str", ")", ":", "async", "def", "_schedule_callback", "(", "_now", ")", ":", "\"\"\"Handle a scheduled sync callback.\"\"\"", "self", ".", "_google_sync_unsub", ".", "pop", "(", "agent_user_...
[ 160, 4 ]
[ 172, 9 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.async_schedule_google_sync_all
(self)
Schedule a sync for all registered agents.
Schedule a sync for all registered agents.
def async_schedule_google_sync_all(self): """Schedule a sync for all registered agents.""" for agent_user_id in self._store.agent_user_ids: self.async_schedule_google_sync(agent_user_id)
[ "def", "async_schedule_google_sync_all", "(", "self", ")", ":", "for", "agent_user_id", "in", "self", ".", "_store", ".", "agent_user_ids", ":", "self", ".", "async_schedule_google_sync", "(", "agent_user_id", ")" ]
[ 175, 4 ]
[ 178, 58 ]
python
en
['en', 'en', 'en']
True
AbstractConfig._async_request_sync_devices
(self, agent_user_id: str)
Trigger a sync with Google. Return value is the HTTP status code of the sync request.
Trigger a sync with Google.
async def _async_request_sync_devices(self, agent_user_id: str) -> int: """Trigger a sync with Google. Return value is the HTTP status code of the sync request. """ raise NotImplementedError
[ "async", "def", "_async_request_sync_devices", "(", "self", ",", "agent_user_id", ":", "str", ")", "->", "int", ":", "raise", "NotImplementedError" ]
[ 180, 4 ]
[ 185, 33 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.async_connect_agent_user
(self, agent_user_id: str)
Add an synced and known agent_user_id. Called when a completed sync response have been sent to Google.
Add an synced and known agent_user_id.
async def async_connect_agent_user(self, agent_user_id: str): """Add an synced and known agent_user_id. Called when a completed sync response have been sent to Google. """ self._store.add_agent_user_id(agent_user_id)
[ "async", "def", "async_connect_agent_user", "(", "self", ",", "agent_user_id", ":", "str", ")", ":", "self", ".", "_store", ".", "add_agent_user_id", "(", "agent_user_id", ")" ]
[ 187, 4 ]
[ 192, 52 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.async_disconnect_agent_user
(self, agent_user_id: str)
Turn off report state and disable further state reporting. Called when the user disconnects their account from Google.
Turn off report state and disable further state reporting.
async def async_disconnect_agent_user(self, agent_user_id: str): """Turn off report state and disable further state reporting. Called when the user disconnects their account from Google. """ self._store.pop_agent_user_id(agent_user_id)
[ "async", "def", "async_disconnect_agent_user", "(", "self", ",", "agent_user_id", ":", "str", ")", ":", "self", ".", "_store", ".", "pop_agent_user_id", "(", "agent_user_id", ")" ]
[ 194, 4 ]
[ 199, 52 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.async_enable_local_sdk
(self)
Enable the local SDK.
Enable the local SDK.
def async_enable_local_sdk(self): """Enable the local SDK.""" webhook_id = self.local_sdk_webhook_id if webhook_id is None: return webhook.async_register( self.hass, DOMAIN, "Local Support", webhook_id, self._handl...
[ "def", "async_enable_local_sdk", "(", "self", ")", ":", "webhook_id", "=", "self", ".", "local_sdk_webhook_id", "if", "webhook_id", "is", "None", ":", "return", "webhook", ".", "async_register", "(", "self", ".", "hass", ",", "DOMAIN", ",", "\"Local Support\"", ...
[ 202, 4 ]
[ 217, 37 ]
python
en
['en', 'en', 'en']
True
AbstractConfig.async_disable_local_sdk
(self)
Disable the local SDK.
Disable the local SDK.
def async_disable_local_sdk(self): """Disable the local SDK.""" if not self._local_sdk_active: return webhook.async_unregister(self.hass, self.local_sdk_webhook_id) self._local_sdk_active = False
[ "def", "async_disable_local_sdk", "(", "self", ")", ":", "if", "not", "self", ".", "_local_sdk_active", ":", "return", "webhook", ".", "async_unregister", "(", "self", ".", "hass", ",", "self", ".", "local_sdk_webhook_id", ")", "self", ".", "_local_sdk_active", ...
[ 220, 4 ]
[ 226, 38 ]
python
en
['en', 'en', 'en']
True
AbstractConfig._handle_local_webhook
(self, hass, webhook_id, request)
Handle an incoming local SDK message.
Handle an incoming local SDK message.
async def _handle_local_webhook(self, hass, webhook_id, request): """Handle an incoming local SDK message.""" # Circular dep # pylint: disable=import-outside-toplevel from . import smart_home payload = await request.json() if _LOGGER.isEnabledFor(logging.DEBUG): ...
[ "async", "def", "_handle_local_webhook", "(", "self", ",", "hass", ",", "webhook_id", ",", "request", ")", ":", "# Circular dep", "# pylint: disable=import-outside-toplevel", "from", ".", "import", "smart_home", "payload", "=", "await", "request", ".", "json", "(", ...
[ 228, 4 ]
[ 249, 36 ]
python
en
['en', 'en', 'en']
True
GoogleConfigStore.__init__
(self, hass)
Initialize a configuration store.
Initialize a configuration store.
def __init__(self, hass): """Initialize a configuration store.""" self._hass = hass self._store = Store(hass, self._STORAGE_VERSION, self._STORAGE_KEY) self._data = {STORE_AGENT_USER_IDS: {}}
[ "def", "__init__", "(", "self", ",", "hass", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_store", "=", "Store", "(", "hass", ",", "self", ".", "_STORAGE_VERSION", ",", "self", ".", "_STORAGE_KEY", ")", "self", ".", "_data", "=", "{", ...
[ 258, 4 ]
[ 262, 47 ]
python
en
['es', 'en', 'en']
True
GoogleConfigStore.agent_user_ids
(self)
Return a list of connected agent user_ids.
Return a list of connected agent user_ids.
def agent_user_ids(self): """Return a list of connected agent user_ids.""" return self._data[STORE_AGENT_USER_IDS]
[ "def", "agent_user_ids", "(", "self", ")", ":", "return", "self", ".", "_data", "[", "STORE_AGENT_USER_IDS", "]" ]
[ 265, 4 ]
[ 267, 47 ]
python
en
['en', 'en', 'en']
True
GoogleConfigStore.add_agent_user_id
(self, agent_user_id)
Add an agent user id to store.
Add an agent user id to store.
def add_agent_user_id(self, agent_user_id): """Add an agent user id to store.""" if agent_user_id not in self._data[STORE_AGENT_USER_IDS]: self._data[STORE_AGENT_USER_IDS][agent_user_id] = {} self._store.async_delay_save(lambda: self._data, 1.0)
[ "def", "add_agent_user_id", "(", "self", ",", "agent_user_id", ")", ":", "if", "agent_user_id", "not", "in", "self", ".", "_data", "[", "STORE_AGENT_USER_IDS", "]", ":", "self", ".", "_data", "[", "STORE_AGENT_USER_IDS", "]", "[", "agent_user_id", "]", "=", ...
[ 270, 4 ]
[ 274, 65 ]
python
en
['en', 'en', 'en']
True
GoogleConfigStore.pop_agent_user_id
(self, agent_user_id)
Remove agent user id from store.
Remove agent user id from store.
def pop_agent_user_id(self, agent_user_id): """Remove agent user id from store.""" if agent_user_id in self._data[STORE_AGENT_USER_IDS]: self._data[STORE_AGENT_USER_IDS].pop(agent_user_id, None) self._store.async_delay_save(lambda: self._data, 1.0)
[ "def", "pop_agent_user_id", "(", "self", ",", "agent_user_id", ")", ":", "if", "agent_user_id", "in", "self", ".", "_data", "[", "STORE_AGENT_USER_IDS", "]", ":", "self", ".", "_data", "[", "STORE_AGENT_USER_IDS", "]", ".", "pop", "(", "agent_user_id", ",", ...
[ 277, 4 ]
[ 281, 65 ]
python
en
['en', 'en', 'en']
True
GoogleConfigStore.async_load
(self)
Store current configuration to disk.
Store current configuration to disk.
async def async_load(self): """Store current configuration to disk.""" data = await self._store.async_load() if data: self._data = data
[ "async", "def", "async_load", "(", "self", ")", ":", "data", "=", "await", "self", ".", "_store", ".", "async_load", "(", ")", "if", "data", ":", "self", ".", "_data", "=", "data" ]
[ 283, 4 ]
[ 287, 29 ]
python
en
['en', 'en', 'en']
True
RequestData.__init__
( self, config: AbstractConfig, user_id: str, source: str, request_id: str, devices: Optional[List[dict]], )
Initialize the request data.
Initialize the request data.
def __init__( self, config: AbstractConfig, user_id: str, source: str, request_id: str, devices: Optional[List[dict]], ): """Initialize the request data.""" self.config = config self.source = source self.request_id = request_id ...
[ "def", "__init__", "(", "self", ",", "config", ":", "AbstractConfig", ",", "user_id", ":", "str", ",", "source", ":", "str", ",", "request_id", ":", "str", ",", "devices", ":", "Optional", "[", "List", "[", "dict", "]", "]", ",", ")", ":", "self", ...
[ 293, 4 ]
[ 306, 30 ]
python
en
['en', 'en', 'en']
True
RequestData.is_local_request
(self)
Return if this is a local request.
Return if this is a local request.
def is_local_request(self): """Return if this is a local request.""" return self.source == SOURCE_LOCAL
[ "def", "is_local_request", "(", "self", ")", ":", "return", "self", ".", "source", "==", "SOURCE_LOCAL" ]
[ 309, 4 ]
[ 311, 42 ]
python
en
['en', 'en', 'en']
True
GoogleEntity.__init__
(self, hass: HomeAssistant, config: AbstractConfig, state: State)
Initialize a Google entity.
Initialize a Google entity.
def __init__(self, hass: HomeAssistant, config: AbstractConfig, state: State): """Initialize a Google entity.""" self.hass = hass self.config = config self.state = state self._traits = None
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "config", ":", "AbstractConfig", ",", "state", ":", "State", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "config", "=", "config", "self", ".", "state", "=", "state", ...
[ 324, 4 ]
[ 329, 27 ]
python
en
['en', 'en', 'it']
True
GoogleEntity.entity_id
(self)
Return entity ID.
Return entity ID.
def entity_id(self): """Return entity ID.""" return self.state.entity_id
[ "def", "entity_id", "(", "self", ")", ":", "return", "self", ".", "state", ".", "entity_id" ]
[ 332, 4 ]
[ 334, 35 ]
python
en
['en', 'cy', 'en']
True
GoogleEntity.traits
(self)
Return traits for entity.
Return traits for entity.
def traits(self): """Return traits for entity.""" if self._traits is not None: return self._traits state = self.state domain = state.domain features = state.attributes.get(ATTR_SUPPORTED_FEATURES, 0) if not isinstance(features, int): _LOGGER.warn...
[ "def", "traits", "(", "self", ")", ":", "if", "self", ".", "_traits", "is", "not", "None", ":", "return", "self", ".", "_traits", "state", "=", "self", ".", "state", "domain", "=", "state", ".", "domain", "features", "=", "state", ".", "attributes", ...
[ 337, 4 ]
[ 361, 27 ]
python
en
['en', 'cy', 'en']
True
GoogleEntity.should_expose
(self)
If entity should be exposed.
If entity should be exposed.
def should_expose(self): """If entity should be exposed.""" return self.config.should_expose(self.state)
[ "def", "should_expose", "(", "self", ")", ":", "return", "self", ".", "config", ".", "should_expose", "(", "self", ".", "state", ")" ]
[ 364, 4 ]
[ 366, 52 ]
python
en
['en', 'en', 'en']
True
GoogleEntity.should_expose_local
(self)
Return if the entity should be exposed locally.
Return if the entity should be exposed locally.
def should_expose_local(self) -> bool: """Return if the entity should be exposed locally.""" return ( self.should_expose() and get_google_type( self.state.domain, self.state.attributes.get(ATTR_DEVICE_CLASS) ) not in NOT_EXPOSE_LOCAL ...
[ "def", "should_expose_local", "(", "self", ")", "->", "bool", ":", "return", "(", "self", ".", "should_expose", "(", ")", "and", "get_google_type", "(", "self", ".", "state", ".", "domain", ",", "self", ".", "state", ".", "attributes", ".", "get", "(", ...
[ 369, 4 ]
[ 378, 9 ]
python
en
['en', 'en', 'en']
True
GoogleEntity.is_supported
(self)
Return if the entity is supported by Google.
Return if the entity is supported by Google.
def is_supported(self) -> bool: """Return if the entity is supported by Google.""" return bool(self.traits())
[ "def", "is_supported", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "traits", "(", ")", ")" ]
[ 381, 4 ]
[ 383, 34 ]
python
en
['en', 'en', 'en']
True
GoogleEntity.might_2fa
(self)
Return if the entity might encounter 2FA.
Return if the entity might encounter 2FA.
def might_2fa(self) -> bool: """Return if the entity might encounter 2FA.""" if not self.config.should_2fa(self.state): return False return self.might_2fa_traits()
[ "def", "might_2fa", "(", "self", ")", "->", "bool", ":", "if", "not", "self", ".", "config", ".", "should_2fa", "(", "self", ".", "state", ")", ":", "return", "False", "return", "self", ".", "might_2fa_traits", "(", ")" ]
[ 386, 4 ]
[ 391, 38 ]
python
en
['en', 'en', 'en']
True
GoogleEntity.might_2fa_traits
(self)
Return if the entity might encounter 2FA based on just traits.
Return if the entity might encounter 2FA based on just traits.
def might_2fa_traits(self) -> bool: """Return if the entity might encounter 2FA based on just traits.""" state = self.state domain = state.domain features = state.attributes.get(ATTR_SUPPORTED_FEATURES, 0) device_class = state.attributes.get(ATTR_DEVICE_CLASS) return any...
[ "def", "might_2fa_traits", "(", "self", ")", "->", "bool", ":", "state", "=", "self", ".", "state", "domain", "=", "state", ".", "domain", "features", "=", "state", ".", "attributes", ".", "get", "(", "ATTR_SUPPORTED_FEATURES", ",", "0", ")", "device_class...
[ 394, 4 ]
[ 403, 9 ]
python
en
['en', 'en', 'en']
True
GoogleEntity.sync_serialize
(self, agent_user_id)
Serialize entity for a SYNC response. https://developers.google.com/actions/smarthome/create-app#actiondevicessync
Serialize entity for a SYNC response.
async def sync_serialize(self, agent_user_id): """Serialize entity for a SYNC response. https://developers.google.com/actions/smarthome/create-app#actiondevicessync """ state = self.state entity_config = self.config.entity_config.get(state.entity_id, {}) name = (entity_...
[ "async", "def", "sync_serialize", "(", "self", ",", "agent_user_id", ")", ":", "state", "=", "self", ".", "state", "entity_config", "=", "self", ".", "config", ".", "entity_config", ".", "get", "(", "state", ".", "entity_id", ",", "{", "}", ")", "name", ...
[ 405, 4 ]
[ 472, 21 ]
python
en
['en', 'en', 'en']
True
GoogleEntity.query_serialize
(self)
Serialize entity for a QUERY response. https://developers.google.com/actions/smarthome/create-app#actiondevicesquery
Serialize entity for a QUERY response.
def query_serialize(self): """Serialize entity for a QUERY response. https://developers.google.com/actions/smarthome/create-app#actiondevicesquery """ state = self.state if state.state == STATE_UNAVAILABLE: return {"online": False} attrs = {"online": True} ...
[ "def", "query_serialize", "(", "self", ")", ":", "state", "=", "self", ".", "state", "if", "state", ".", "state", "==", "STATE_UNAVAILABLE", ":", "return", "{", "\"online\"", ":", "False", "}", "attrs", "=", "{", "\"online\"", ":", "True", "}", "for", ...
[ 475, 4 ]
[ 490, 20 ]
python
en
['en', 'en', 'en']
True
GoogleEntity.reachable_device_serialize
(self)
Serialize entity for a REACHABLE_DEVICE response.
Serialize entity for a REACHABLE_DEVICE response.
def reachable_device_serialize(self): """Serialize entity for a REACHABLE_DEVICE response.""" return {"verificationId": self.entity_id}
[ "def", "reachable_device_serialize", "(", "self", ")", ":", "return", "{", "\"verificationId\"", ":", "self", ".", "entity_id", "}" ]
[ 493, 4 ]
[ 495, 49 ]
python
en
['en', 'en', 'en']
True
GoogleEntity.execute
(self, data, command_payload)
Execute a command. https://developers.google.com/actions/smarthome/create-app#actiondevicesexecute
Execute a command.
async def execute(self, data, command_payload): """Execute a command. https://developers.google.com/actions/smarthome/create-app#actiondevicesexecute """ command = command_payload["command"] params = command_payload.get("params", {}) challenge = command_payload.get("chal...
[ "async", "def", "execute", "(", "self", ",", "data", ",", "command_payload", ")", ":", "command", "=", "command_payload", "[", "\"command\"", "]", "params", "=", "command_payload", ".", "get", "(", "\"params\"", ",", "{", "}", ")", "challenge", "=", "comma...
[ 497, 4 ]
[ 516, 13 ]
python
en
['ro', 'en', 'en']
True
GoogleEntity.async_update
(self)
Update the entity with latest info from Home Assistant.
Update the entity with latest info from Home Assistant.
def async_update(self): """Update the entity with latest info from Home Assistant.""" self.state = self.hass.states.get(self.entity_id) if self._traits is None: return for trt in self._traits: trt.state = self.state
[ "def", "async_update", "(", "self", ")", ":", "self", ".", "state", "=", "self", ".", "hass", ".", "states", ".", "get", "(", "self", ".", "entity_id", ")", "if", "self", ".", "_traits", "is", "None", ":", "return", "for", "trt", "in", "self", ".",...
[ 519, 4 ]
[ 527, 34 ]
python
en
['en', 'en', 'en']
True
scanner
(hass)
Initialize components.
Initialize components.
def scanner(hass): """Initialize components.""" scanner = getattr(hass.components, "test.device_tracker").get_scanner(None, None) scanner.reset() scanner.come_home("DEV1") getattr(hass.components, "test.light").init() with patch( "homeassistant.components.device_tracker.legacy.load_ya...
[ "def", "scanner", "(", "hass", ")", ":", "scanner", "=", "getattr", "(", "hass", ".", "components", ",", "\"test.device_tracker\"", ")", ".", "get_scanner", "(", "None", ",", "None", ")", "scanner", ".", "reset", "(", ")", "scanner", ".", "come_home", "(...
[ 31, 0 ]
[ 73, 18 ]
python
en
['de', 'en', 'en']
False
test_lights_on_when_sun_sets
(hass, scanner)
Test lights go on when there is someone home and the sun sets.
Test lights go on when there is someone home and the sun sets.
async def test_lights_on_when_sun_sets(hass, scanner): """Test lights go on when there is someone home and the sun sets.""" test_time = datetime(2017, 4, 5, 1, 2, 3, tzinfo=dt_util.UTC) with patch("homeassistant.util.dt.utcnow", return_value=test_time): assert await async_setup_component( ...
[ "async", "def", "test_lights_on_when_sun_sets", "(", "hass", ",", "scanner", ")", ":", "test_time", "=", "datetime", "(", "2017", ",", "4", ",", "5", ",", "1", ",", "2", ",", "3", ",", "tzinfo", "=", "dt_util", ".", "UTC", ")", "with", "patch", "(", ...
[ 76, 0 ]
[ 99, 5 ]
python
en
['en', 'en', 'en']
True
test_lights_turn_off_when_everyone_leaves
(hass)
Test lights turn off when everyone leaves the house.
Test lights turn off when everyone leaves the house.
async def test_lights_turn_off_when_everyone_leaves(hass): """Test lights turn off when everyone leaves the house.""" assert await async_setup_component( hass, "light", {light.DOMAIN: {CONF_PLATFORM: "test"}} ) await hass.services.async_call( light.DOMAIN, light.SERVICE_TURN_ON, ...
[ "async", "def", "test_lights_turn_off_when_everyone_leaves", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"light\"", ",", "{", "light", ".", "DOMAIN", ":", "{", "CONF_PLATFORM", ":", "\"test\"", "}", "}", ")", "await", ...
[ 102, 0 ]
[ 126, 5 ]
python
en
['en', 'en', 'en']
True
test_lights_turn_on_when_coming_home_after_sun_set
(hass, scanner)
Test lights turn on when coming home after sun set.
Test lights turn on when coming home after sun set.
async def test_lights_turn_on_when_coming_home_after_sun_set(hass, scanner): """Test lights turn on when coming home after sun set.""" test_time = datetime(2017, 4, 5, 3, 2, 3, tzinfo=dt_util.UTC) with patch("homeassistant.util.dt.utcnow", return_value=test_time): await hass.services.async_call( ...
[ "async", "def", "test_lights_turn_on_when_coming_home_after_sun_set", "(", "hass", ",", "scanner", ")", ":", "test_time", "=", "datetime", "(", "2017", ",", "4", ",", "5", ",", "3", ",", "2", ",", "3", ",", "tzinfo", "=", "dt_util", ".", "UTC", ")", "wit...
[ 129, 0 ]
[ 148, 5 ]
python
en
['en', 'en', 'en']
True