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
InstallationTypeOnboardingView.__init__
(self, data)
Initialize the onboarding installation type view.
Initialize the onboarding installation type view.
def __init__(self, data): """Initialize the onboarding installation type view.""" self._data = data
[ "def", "__init__", "(", "self", ",", "data", ")", ":", "self", ".", "_data", "=", "data" ]
[ 62, 4 ]
[ 64, 25 ]
python
en
['en', 'en', 'en']
True
InstallationTypeOnboardingView.get
(self, request)
Return the onboarding status.
Return the onboarding status.
async def get(self, request): """Return the onboarding status.""" if self._data["done"]: raise HTTPUnauthorized() hass = request.app["hass"] info = await async_get_system_info(hass) return self.json({"installation_type": info["installation_type"]})
[ "async", "def", "get", "(", "self", ",", "request", ")", ":", "if", "self", ".", "_data", "[", "\"done\"", "]", ":", "raise", "HTTPUnauthorized", "(", ")", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "info", "=", "await", "async_get_syste...
[ 66, 4 ]
[ 73, 74 ]
python
en
['en', 'af', 'en']
True
_BaseOnboardingView.__init__
(self, data, store)
Initialize the onboarding view.
Initialize the onboarding view.
def __init__(self, data, store): """Initialize the onboarding view.""" self._store = store self._data = data self._lock = asyncio.Lock()
[ "def", "__init__", "(", "self", ",", "data", ",", "store", ")", ":", "self", ".", "_store", "=", "store", "self", ".", "_data", "=", "data", "self", ".", "_lock", "=", "asyncio", ".", "Lock", "(", ")" ]
[ 81, 4 ]
[ 85, 35 ]
python
en
['en', 'en', 'en']
True
_BaseOnboardingView._async_is_done
(self)
Return if this step is done.
Return if this step is done.
def _async_is_done(self): """Return if this step is done.""" return self.step in self._data["done"]
[ "def", "_async_is_done", "(", "self", ")", ":", "return", "self", ".", "step", "in", "self", ".", "_data", "[", "\"done\"", "]" ]
[ 88, 4 ]
[ 90, 46 ]
python
en
['en', 'en', 'en']
True
_BaseOnboardingView._async_mark_done
(self, hass)
Mark step as done.
Mark step as done.
async def _async_mark_done(self, hass): """Mark step as done.""" self._data["done"].append(self.step) await self._store.async_save(self._data) if set(self._data["done"]) == set(STEPS): hass.data[DOMAIN] = True
[ "async", "def", "_async_mark_done", "(", "self", ",", "hass", ")", ":", "self", ".", "_data", "[", "\"done\"", "]", ".", "append", "(", "self", ".", "step", ")", "await", "self", ".", "_store", ".", "async_save", "(", "self", ".", "_data", ")", "if",...
[ 92, 4 ]
[ 98, 36 ]
python
en
['pt', 'en', 'en']
True
UserOnboardingView.post
(self, request, data)
Handle user creation, area creation.
Handle user creation, area creation.
async def post(self, request, data): """Handle user creation, area creation.""" hass = request.app["hass"] async with self._lock: if self._async_is_done(): return self.json_message("User step already done", HTTP_FORBIDDEN) provider = _async_get_hass_prov...
[ "async", "def", "post", "(", "self", ",", "request", ",", "data", ")", ":", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "async", "with", "self", ".", "_lock", ":", "if", "self", ".", "_async_is_done", "(", ")", ":", "return", "self", ...
[ 120, 4 ]
[ 164, 54 ]
python
en
['en', 'tg', 'en']
True
CoreConfigOnboardingView.post
(self, request)
Handle finishing core config step.
Handle finishing core config step.
async def post(self, request): """Handle finishing core config step.""" hass = request.app["hass"] async with self._lock: if self._async_is_done(): return self.json_message( "Core config step already done", HTTP_FORBIDDEN ) ...
[ "async", "def", "post", "(", "self", ",", "request", ")", ":", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "async", "with", "self", ".", "_lock", ":", "if", "self", ".", "_async_is_done", "(", ")", ":", "return", "self", ".", "json_mess...
[ 174, 4 ]
[ 198, 32 ]
python
en
['en', 'en', 'en']
True
IntegrationOnboardingView.post
(self, request, data)
Handle token creation.
Handle token creation.
async def post(self, request, data): """Handle token creation.""" hass = request.app["hass"] refresh_token_id = request[KEY_HASS_REFRESH_TOKEN_ID] async with self._lock: if self._async_is_done(): return self.json_message( "Integration step...
[ "async", "def", "post", "(", "self", ",", "request", ",", "data", ")", ":", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "refresh_token_id", "=", "request", "[", "KEY_HASS_REFRESH_TOKEN_ID", "]", "async", "with", "self", ".", "_lock", ":", "...
[ 211, 4 ]
[ 242, 54 ]
python
nl
['nl', 'nl', 'en']
True
AnalyticsOnboardingView.post
(self, request)
Handle finishing analytics step.
Handle finishing analytics step.
async def post(self, request): """Handle finishing analytics step.""" hass = request.app["hass"] async with self._lock: if self._async_is_done(): return self.json_message( "Analytics config step already done", HTTP_FORBIDDEN ) ...
[ "async", "def", "post", "(", "self", ",", "request", ")", ":", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "async", "with", "self", ".", "_lock", ":", "if", "self", ".", "_async_is_done", "(", ")", ":", "return", "self", ".", "json_mess...
[ 252, 4 ]
[ 264, 32 ]
python
en
['en', 'zu', 'en']
True
async_reload_integration_platforms
( hass: HomeAssistant, integration_name: str, integration_platforms: Iterable[str] )
Reload an integration's platforms. The platform must support being re-setup. This functionality is only intended to be used for integrations that process Home Assistant data and make this available to other integrations. Examples are template, stats, derivative, utility meter.
Reload an integration's platforms.
async def async_reload_integration_platforms( hass: HomeAssistant, integration_name: str, integration_platforms: Iterable[str] ) -> None: """Reload an integration's platforms. The platform must support being re-setup. This functionality is only intended to be used for integrations that process Hom...
[ "async", "def", "async_reload_integration_platforms", "(", "hass", ":", "HomeAssistant", ",", "integration_name", ":", "str", ",", "integration_platforms", ":", "Iterable", "[", "str", "]", ")", "->", "None", ":", "try", ":", "unprocessed_conf", "=", "await", "c...
[ 23, 0 ]
[ 48, 32 ]
python
en
['en', 'da', 'en']
True
_resetup_platform
( hass: HomeAssistant, integration_name: str, integration_platform: str, unprocessed_conf: ConfigType, )
Resetup a platform.
Resetup a platform.
async def _resetup_platform( hass: HomeAssistant, integration_name: str, integration_platform: str, unprocessed_conf: ConfigType, ) -> None: """Resetup a platform.""" integration = await async_get_integration(hass, integration_platform) conf = await conf_util.async_process_component_config(...
[ "async", "def", "_resetup_platform", "(", "hass", ":", "HomeAssistant", ",", "integration_name", ":", "str", ",", "integration_platform", ":", "str", ",", "unprocessed_conf", ":", "ConfigType", ",", ")", "->", "None", ":", "integration", "=", "await", "async_get...
[ 51, 0 ]
[ 100, 5 ]
python
en
['en', 'ru', 'en']
True
_async_setup_platform
( hass: HomeAssistant, integration_name: str, integration_platform: str, platform_configs: list[dict[str, Any]], )
Platform for the first time when new configuration is added.
Platform for the first time when new configuration is added.
async def _async_setup_platform( hass: HomeAssistant, integration_name: str, integration_platform: str, platform_configs: list[dict[str, Any]], ) -> None: """Platform for the first time when new configuration is added.""" if integration_platform not in hass.data: await async_setup_compon...
[ "async", "def", "_async_setup_platform", "(", "hass", ":", "HomeAssistant", ",", "integration_name", ":", "str", ",", "integration_platform", ":", "str", ",", "platform_configs", ":", "list", "[", "dict", "[", "str", ",", "Any", "]", "]", ",", ")", "->", "...
[ 103, 0 ]
[ 121, 32 ]
python
en
['en', 'en', 'en']
True
_async_reconfig_platform
( platform: EntityPlatform, platform_configs: list[dict[str, Any]] )
Reconfigure an already loaded platform.
Reconfigure an already loaded platform.
async def _async_reconfig_platform( platform: EntityPlatform, platform_configs: list[dict[str, Any]] ) -> None: """Reconfigure an already loaded platform.""" await platform.async_reset() tasks = [platform.async_setup(p_config) for p_config in platform_configs] await asyncio.gather(*tasks)
[ "async", "def", "_async_reconfig_platform", "(", "platform", ":", "EntityPlatform", ",", "platform_configs", ":", "list", "[", "dict", "[", "str", ",", "Any", "]", "]", ")", "->", "None", ":", "await", "platform", ".", "async_reset", "(", ")", "tasks", "="...
[ 124, 0 ]
[ 130, 32 ]
python
en
['en', 'lb', 'en']
True
async_integration_yaml_config
( hass: HomeAssistant, integration_name: str )
Fetch the latest yaml configuration for an integration.
Fetch the latest yaml configuration for an integration.
async def async_integration_yaml_config( hass: HomeAssistant, integration_name: str ) -> ConfigType | None: """Fetch the latest yaml configuration for an integration.""" integration = await async_get_integration(hass, integration_name) return await conf_util.async_process_component_config( hass...
[ "async", "def", "async_integration_yaml_config", "(", "hass", ":", "HomeAssistant", ",", "integration_name", ":", "str", ")", "->", "ConfigType", "|", "None", ":", "integration", "=", "await", "async_get_integration", "(", "hass", ",", "integration_name", ")", "re...
[ 133, 0 ]
[ 141, 5 ]
python
en
['en', 'en', 'en']
True
async_get_platform_without_config_entry
( hass: HomeAssistant, integration_name: str, integration_platform_name: str )
Find an existing platform that is not a config entry.
Find an existing platform that is not a config entry.
def async_get_platform_without_config_entry( hass: HomeAssistant, integration_name: str, integration_platform_name: str ) -> EntityPlatform | None: """Find an existing platform that is not a config entry.""" for integration_platform in async_get_platforms(hass, integration_name): if integration_plat...
[ "def", "async_get_platform_without_config_entry", "(", "hass", ":", "HomeAssistant", ",", "integration_name", ":", "str", ",", "integration_platform_name", ":", "str", ")", "->", "EntityPlatform", "|", "None", ":", "for", "integration_platform", "in", "async_get_platfor...
[ 145, 0 ]
[ 156, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_reload_service
( hass: HomeAssistant, domain: str, platforms: Iterable[str] )
Create the reload service for the domain.
Create the reload service for the domain.
async def async_setup_reload_service( hass: HomeAssistant, domain: str, platforms: Iterable[str] ) -> None: """Create the reload service for the domain.""" if hass.services.has_service(domain, SERVICE_RELOAD): return async def _reload_config(call: Event) -> None: """Reload the platforms...
[ "async", "def", "async_setup_reload_service", "(", "hass", ":", "HomeAssistant", ",", "domain", ":", "str", ",", "platforms", ":", "Iterable", "[", "str", "]", ")", "->", "None", ":", "if", "hass", ".", "services", ".", "has_service", "(", "domain", ",", ...
[ 159, 0 ]
[ 173, 5 ]
python
en
['en', 'en', 'en']
True
setup_reload_service
( hass: HomeAssistant, domain: str, platforms: Iterable[str] )
Sync version of async_setup_reload_service.
Sync version of async_setup_reload_service.
def setup_reload_service( hass: HomeAssistant, domain: str, platforms: Iterable[str] ) -> None: """Sync version of async_setup_reload_service.""" asyncio.run_coroutine_threadsafe( async_setup_reload_service(hass, domain, platforms), hass.loop, ).result()
[ "def", "setup_reload_service", "(", "hass", ":", "HomeAssistant", ",", "domain", ":", "str", ",", "platforms", ":", "Iterable", "[", "str", "]", ")", "->", "None", ":", "asyncio", ".", "run_coroutine_threadsafe", "(", "async_setup_reload_service", "(", "hass", ...
[ 176, 0 ]
[ 183, 14 ]
python
en
['en', 'en', 'en']
True
test_sensor_availability
( hass, caplog, legacy_patchable_time, pvpc_aioclient_mock: AiohttpClientMocker )
Test sensor availability and handling of cloud access.
Test sensor availability and handling of cloud access.
async def test_sensor_availability( hass, caplog, legacy_patchable_time, pvpc_aioclient_mock: AiohttpClientMocker ): """Test sensor availability and handling of cloud access.""" hass.config.time_zone = dt_util.get_time_zone("Europe/Madrid") config_entry = MockConfigEntry( domain=DOMAIN, data={CO...
[ "async", "def", "test_sensor_availability", "(", "hass", ",", "caplog", ",", "legacy_patchable_time", ",", "pvpc_aioclient_mock", ":", "AiohttpClientMocker", ")", ":", "hass", ".", "config", ".", "time_zone", "=", "dt_util", ".", "get_time_zone", "(", "\"Europe/Madr...
[ 34, 0 ]
[ 104, 63 ]
python
en
['en', 'en', 'en']
True
test_multi_sensor_migration
( hass, caplog, legacy_patchable_time, pvpc_aioclient_mock: AiohttpClientMocker )
Test tariff migration when there are >1 old sensors.
Test tariff migration when there are >1 old sensors.
async def test_multi_sensor_migration( hass, caplog, legacy_patchable_time, pvpc_aioclient_mock: AiohttpClientMocker ): """Test tariff migration when there are >1 old sensors.""" entity_reg = mock_registry(hass) hass.config.time_zone = dt_util.get_time_zone("Europe/Madrid") uid_1 = "discrimination" ...
[ "async", "def", "test_multi_sensor_migration", "(", "hass", ",", "caplog", ",", "legacy_patchable_time", ",", "pvpc_aioclient_mock", ":", "AiohttpClientMocker", ")", ":", "entity_reg", "=", "mock_registry", "(", "hass", ")", "hass", ".", "config", ".", "time_zone", ...
[ 107, 0 ]
[ 165, 54 ]
python
en
['en', 'en', 'en']
True
compare_partial_dicts
(result, expected)
Make sure all the keys in expected are matched by keys in result, and that the values stored in those keys match. Result can contain more items than expected - those are ignored. Used in the test_lvs, test_pvs and test_vgs tests.
Make sure all the keys in expected are matched by keys in result, and that the values stored in those keys match. Result can contain more items than expected - those are ignored.
def compare_partial_dicts(result, expected): """ Make sure all the keys in expected are matched by keys in result, and that the values stored in those keys match. Result can contain more items than expected - those are ignored. Used in the test_lvs, test_pvs and test_vgs tests. """ # retur...
[ "def", "compare_partial_dicts", "(", "result", ",", "expected", ")", ":", "# return all(result[k] == expected[k] for k in expected.keys())", "mismatches", "=", "0", "for", "k", "in", "expected", ".", "keys", "(", ")", ":", "if", "not", "result", "[", "k", "]", "...
[ 53, 0 ]
[ 67, 26 ]
python
en
['en', 'error', 'th']
False
test_create_binary_sensors
(hass)
Test creation of binary_sensors.
Test creation of binary_sensors.
async def test_create_binary_sensors(hass): """Test creation of binary_sensors.""" await async_init_integration(hass) state = hass.states.get("binary_sensor.happy_place_myq_gateway") assert state.state == STATE_ON expected_attributes = {"device_class": "connectivity"} # Only test for a subset ...
[ "async", "def", "test_create_binary_sensors", "(", "hass", ")", ":", "await", "async_init_integration", "(", "hass", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "\"binary_sensor.happy_place_myq_gateway\"", ")", "assert", "state", ".", "state", "==",...
[ 7, 0 ]
[ 19, 5 ]
python
en
['en', 'tg', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up Eufy bulbs.
Set up Eufy bulbs.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up Eufy bulbs.""" if discovery_info is None: return add_entities([EufyLight(discovery_info)], True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "add_entities", "(", "[", "EufyLight", "(", "discovery_info", ")", "]", ",", "True", ...
[ 22, 0 ]
[ 26, 51 ]
python
en
['en', 'ga', 'en']
True
EufyLight.__init__
(self, device)
Initialize the light.
Initialize the light.
def __init__(self, device): """Initialize the light.""" self._temp = None self._brightness = None self._hs = None self._state = None self._name = device["name"] self._address = device["address"] self._code = device["code"] self._type = device["typ...
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "self", ".", "_temp", "=", "None", "self", ".", "_brightness", "=", "None", "self", ".", "_hs", "=", "None", "self", ".", "_state", "=", "None", "self", ".", "_name", "=", "device", "[", "\"n...
[ 32, 4 ]
[ 51, 28 ]
python
en
['en', 'en', 'en']
True
EufyLight.update
(self)
Synchronise state from the bulb.
Synchronise state from the bulb.
def update(self): """Synchronise state from the bulb.""" self._bulb.update() if self._bulb.power: self._brightness = self._bulb.brightness self._temp = self._bulb.temperature if self._bulb.colors: self._colormode = True self._hs...
[ "def", "update", "(", "self", ")", ":", "self", ".", "_bulb", ".", "update", "(", ")", "if", "self", ".", "_bulb", ".", "power", ":", "self", ".", "_brightness", "=", "self", ".", "_bulb", ".", "brightness", "self", ".", "_temp", "=", "self", ".", ...
[ 53, 4 ]
[ 64, 38 ]
python
en
['en', 'en', 'en']
True
EufyLight.unique_id
(self)
Return the ID of this light.
Return the ID of this light.
def unique_id(self): """Return the ID of this light.""" return self._address
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_address" ]
[ 67, 4 ]
[ 69, 28 ]
python
en
['en', 'en', 'en']
True
EufyLight.name
(self)
Return the name of the device if any.
Return the name of the device if any.
def name(self): """Return the name of the device if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 72, 4 ]
[ 74, 25 ]
python
en
['en', 'en', 'en']
True
EufyLight.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 77, 4 ]
[ 79, 26 ]
python
en
['en', 'fy', 'en']
True
EufyLight.brightness
(self)
Return the brightness of this light between 0..255.
Return the brightness of this light between 0..255.
def brightness(self): """Return the brightness of this light between 0..255.""" return int(self._brightness * 255 / 100)
[ "def", "brightness", "(", "self", ")", ":", "return", "int", "(", "self", ".", "_brightness", "*", "255", "/", "100", ")" ]
[ 82, 4 ]
[ 84, 48 ]
python
en
['en', 'en', 'en']
True
EufyLight.min_mireds
(self)
Return minimum supported color temperature.
Return minimum supported color temperature.
def min_mireds(self): """Return minimum supported color temperature.""" return kelvin_to_mired(EUFY_MAX_KELVIN)
[ "def", "min_mireds", "(", "self", ")", ":", "return", "kelvin_to_mired", "(", "EUFY_MAX_KELVIN", ")" ]
[ 87, 4 ]
[ 89, 47 ]
python
en
['ro', 'la', 'en']
False
EufyLight.max_mireds
(self)
Return maximu supported color temperature.
Return maximu supported color temperature.
def max_mireds(self): """Return maximu supported color temperature.""" return kelvin_to_mired(EUFY_MIN_KELVIN)
[ "def", "max_mireds", "(", "self", ")", ":", "return", "kelvin_to_mired", "(", "EUFY_MIN_KELVIN", ")" ]
[ 92, 4 ]
[ 94, 47 ]
python
en
['en', 'it', 'en']
True
EufyLight.color_temp
(self)
Return the color temperature of this light.
Return the color temperature of this light.
def color_temp(self): """Return the color temperature of this light.""" temp_in_k = int( EUFY_MIN_KELVIN + (self._temp * (EUFY_MAX_KELVIN - EUFY_MIN_KELVIN) / 100) ) return kelvin_to_mired(temp_in_k)
[ "def", "color_temp", "(", "self", ")", ":", "temp_in_k", "=", "int", "(", "EUFY_MIN_KELVIN", "+", "(", "self", ".", "_temp", "*", "(", "EUFY_MAX_KELVIN", "-", "EUFY_MIN_KELVIN", ")", "/", "100", ")", ")", "return", "kelvin_to_mired", "(", "temp_in_k", ")" ...
[ 97, 4 ]
[ 102, 41 ]
python
en
['en', 'en', 'en']
True
EufyLight.hs_color
(self)
Return the color of this light.
Return the color of this light.
def hs_color(self): """Return the color of this light.""" if not self._colormode: return None return self._hs
[ "def", "hs_color", "(", "self", ")", ":", "if", "not", "self", ".", "_colormode", ":", "return", "None", "return", "self", ".", "_hs" ]
[ 105, 4 ]
[ 109, 23 ]
python
en
['en', 'en', 'en']
True
EufyLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return self._features
[ "def", "supported_features", "(", "self", ")", ":", "return", "self", ".", "_features" ]
[ 112, 4 ]
[ 114, 29 ]
python
en
['da', 'en', 'en']
True
EufyLight.turn_on
(self, **kwargs)
Turn the specified light on.
Turn the specified light on.
def turn_on(self, **kwargs): """Turn the specified light on.""" brightness = kwargs.get(ATTR_BRIGHTNESS) colortemp = kwargs.get(ATTR_COLOR_TEMP) # pylint: disable=invalid-name hs = kwargs.get(ATTR_HS_COLOR) if brightness is not None: brightness = int(brightne...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "brightness", "=", "kwargs", ".", "get", "(", "ATTR_BRIGHTNESS", ")", "colortemp", "=", "kwargs", ".", "get", "(", "ATTR_COLOR_TEMP", ")", "# pylint: disable=invalid-name", "hs", "=", "kwargs"...
[ 116, 4 ]
[ 156, 13 ]
python
en
['en', 'en', 'en']
True
EufyLight.turn_off
(self, **kwargs)
Turn the specified light off.
Turn the specified light off.
def turn_off(self, **kwargs): """Turn the specified light off.""" try: self._bulb.set_state(power=False) except BrokenPipeError: self._bulb.connect() self._bulb.set_state(power=False)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "_bulb", ".", "set_state", "(", "power", "=", "False", ")", "except", "BrokenPipeError", ":", "self", ".", "_bulb", ".", "connect", "(", ")", "self", ".", "...
[ 158, 4 ]
[ 164, 45 ]
python
en
['en', 'en', 'en']
True
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 34, 0 ]
[ 36, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 40, 0 ]
[ 42, 30 ]
python
en
['en', 'fy', 'en']
True
calls
(hass)
Track calls to a mock service.
Track calls to a mock service.
def calls(hass): """Track calls to a mock service.""" return async_mock_service(hass, "test", "automation")
[ "def", "calls", "(", "hass", ")", ":", "return", "async_mock_service", "(", "hass", ",", "\"test\"", ",", "\"automation\"", ")" ]
[ 46, 0 ]
[ 48, 57 ]
python
en
['en', 'en', 'en']
True
test_get_conditions
( hass, device_reg, entity_reg, set_state, features_reg, features_state, expected_condition_types, )
Test we get the expected conditions from a cover.
Test we get the expected conditions from a cover.
async def test_get_conditions( hass, device_reg, entity_reg, set_state, features_reg, features_state, expected_condition_types, ): """Test we get the expected conditions from a cover.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) dev...
[ "async", "def", "test_get_conditions", "(", "hass", ",", "device_reg", ",", "entity_reg", ",", "set_state", ",", "features_reg", ",", "features_state", ",", "expected_condition_types", ",", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"t...
[ 66, 0 ]
[ 107, 54 ]
python
en
['en', 'en', 'en']
True
test_get_condition_capabilities
( hass, device_reg, entity_reg, enable_custom_integrations )
Test we get the expected capabilities from a cover condition.
Test we get the expected capabilities from a cover condition.
async def test_get_condition_capabilities( hass, device_reg, entity_reg, enable_custom_integrations ): """Test we get the expected capabilities from a cover condition.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[0] config_entry = MockConfigEn...
[ "async", "def", "test_get_condition_capabilities", "(", "hass", ",", "device_reg", ",", "entity_reg", ",", "enable_custom_integrations", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", ...
[ 110, 0 ]
[ 136, 51 ]
python
en
['en', 'en', 'en']
True
test_get_condition_capabilities_set_pos
( hass, device_reg, entity_reg, enable_custom_integrations )
Test we get the expected capabilities from a cover condition.
Test we get the expected capabilities from a cover condition.
async def test_get_condition_capabilities_set_pos( hass, device_reg, entity_reg, enable_custom_integrations ): """Test we get the expected capabilities from a cover condition.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[1] config_entry = Mock...
[ "async", "def", "test_get_condition_capabilities_set_pos", "(", "hass", ",", "device_reg", ",", "entity_reg", ",", "enable_custom_integrations", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "i...
[ 139, 0 ]
[ 188, 55 ]
python
en
['en', 'en', 'en']
True
test_get_condition_capabilities_set_tilt_pos
( hass, device_reg, entity_reg, enable_custom_integrations )
Test we get the expected capabilities from a cover condition.
Test we get the expected capabilities from a cover condition.
async def test_get_condition_capabilities_set_tilt_pos( hass, device_reg, entity_reg, enable_custom_integrations ): """Test we get the expected capabilities from a cover condition.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[2] config_entry =...
[ "async", "def", "test_get_condition_capabilities_set_tilt_pos", "(", "hass", ",", "device_reg", ",", "entity_reg", ",", "enable_custom_integrations", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".",...
[ 191, 0 ]
[ 240, 55 ]
python
en
['en', 'en', 'en']
True
test_if_state
(hass, calls)
Test for turn_on and turn_off conditions.
Test for turn_on and turn_off conditions.
async def test_if_state(hass, calls): """Test for turn_on and turn_off conditions.""" hass.states.async_set("cover.entity", STATE_OPEN) assert await async_setup_component( hass, automation.DOMAIN, { automation.DOMAIN: [ { "trigger": {"...
[ "async", "def", "test_if_state", "(", "hass", ",", "calls", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"cover.entity\"", ",", "STATE_OPEN", ")", "assert", "await", "async_setup_component", "(", "hass", ",", "automation", ".", "DOMAIN", ",", "{...
[ 243, 0 ]
[ 352, 70 ]
python
en
['en', 'en', 'en']
True
test_if_position
(hass, calls, enable_custom_integrations)
Test for position conditions.
Test for position conditions.
async def test_if_position(hass, calls, enable_custom_integrations): """Test for position conditions.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[1] assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) await hass...
[ "async", "def", "test_if_position", "(", "hass", ",", "calls", ",", "enable_custom_integrations", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "ent", "=", "platform", ...
[ 355, 0 ]
[ 456, 72 ]
python
en
['en', 'en', 'en']
True
test_if_tilt_position
(hass, calls, enable_custom_integrations)
Test for tilt position conditions.
Test for tilt position conditions.
async def test_if_tilt_position(hass, calls, enable_custom_integrations): """Test for tilt position conditions.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() ent = platform.ENTITIES[2] assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) ...
[ "async", "def", "test_if_tilt_position", "(", "hass", ",", "calls", ",", "enable_custom_integrations", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "ent", "=", "platfor...
[ 459, 0 ]
[ 560, 72 ]
python
en
['da', 'en', 'en']
True
ConfigEntryAuth.__init__
( self, hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry, implementation: config_entry_oauth2_flow.AbstractOAuth2Implementation, )
Initialize Home Connect Auth.
Initialize Home Connect Auth.
def __init__( self, hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry, implementation: config_entry_oauth2_flow.AbstractOAuth2Implementation, ) -> None: """Initialize Home Connect Auth.""" self.hass = hass self.config_entry = config_entry ...
[ "def", "__init__", "(", "self", ",", "hass", ":", "core", ".", "HomeAssistant", ",", "config_entry", ":", "config_entries", ".", "ConfigEntry", ",", "implementation", ":", "config_entry_oauth2_flow", ".", "AbstractOAuth2Implementation", ",", ")", "->", "None", ":"...
[ 43, 4 ]
[ 56, 25 ]
python
en
['en', 'en', 'en']
True
ConfigEntryAuth.refresh_tokens
(self)
Refresh and return new Home Connect tokens using Home Assistant OAuth2 session.
Refresh and return new Home Connect tokens using Home Assistant OAuth2 session.
def refresh_tokens(self) -> dict: """Refresh and return new Home Connect tokens using Home Assistant OAuth2 session.""" run_coroutine_threadsafe( self.session.async_ensure_token_valid(), self.hass.loop ).result() return self.session.token
[ "def", "refresh_tokens", "(", "self", ")", "->", "dict", ":", "run_coroutine_threadsafe", "(", "self", ".", "session", ".", "async_ensure_token_valid", "(", ")", ",", "self", ".", "hass", ".", "loop", ")", ".", "result", "(", ")", "return", "self", ".", ...
[ 58, 4 ]
[ 64, 33 ]
python
en
['en', 'en', 'en']
True
ConfigEntryAuth.get_devices
(self)
Get a dictionary of devices.
Get a dictionary of devices.
def get_devices(self): """Get a dictionary of devices.""" appl = self.get_appliances() devices = [] for app in appl: if app.type == "Dryer": device = Dryer(self.hass, app) elif app.type == "Washer": device = Washer(self.hass, app) ...
[ "def", "get_devices", "(", "self", ")", ":", "appl", "=", "self", ".", "get_appliances", "(", ")", "devices", "=", "[", "]", "for", "app", "in", "appl", ":", "if", "app", ".", "type", "==", "\"Dryer\"", ":", "device", "=", "Dryer", "(", "self", "."...
[ 66, 4 ]
[ 94, 22 ]
python
en
['en', 'en', 'en']
True
HomeConnectDevice.__init__
(self, hass, appliance)
Initialize the device class.
Initialize the device class.
def __init__(self, hass, appliance): """Initialize the device class.""" self.hass = hass self.appliance = appliance
[ "def", "__init__", "(", "self", ",", "hass", ",", "appliance", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "appliance", "=", "appliance" ]
[ 104, 4 ]
[ 107, 34 ]
python
en
['en', 'en', 'en']
True
HomeConnectDevice.initialize
(self)
Fetch the info needed to initialize the device.
Fetch the info needed to initialize the device.
def initialize(self): """Fetch the info needed to initialize the device.""" try: self.appliance.get_status() except (HomeConnectError, ValueError): _LOGGER.debug("Unable to fetch appliance status. Probably offline") try: self.appliance.get_settings() ...
[ "def", "initialize", "(", "self", ")", ":", "try", ":", "self", ".", "appliance", ".", "get_status", "(", ")", "except", "(", "HomeConnectError", ",", "ValueError", ")", ":", "_LOGGER", ".", "debug", "(", "\"Unable to fetch appliance status. Probably offline\"", ...
[ 109, 4 ]
[ 128, 66 ]
python
en
['en', 'en', 'en']
True
HomeConnectDevice.event_callback
(self, appliance)
Handle event.
Handle event.
def event_callback(self, appliance): """Handle event.""" _LOGGER.debug("Update triggered on %s", appliance.name) _LOGGER.debug(self.appliance.status) dispatcher_send(self.hass, SIGNAL_UPDATE_ENTITIES, appliance.haId)
[ "def", "event_callback", "(", "self", ",", "appliance", ")", ":", "_LOGGER", ".", "debug", "(", "\"Update triggered on %s\"", ",", "appliance", ".", "name", ")", "_LOGGER", ".", "debug", "(", "self", ".", "appliance", ".", "status", ")", "dispatcher_send", "...
[ 130, 4 ]
[ 134, 74 ]
python
en
['es', 'en', 'en']
False
DeviceWithPrograms.get_programs_available
(self)
Get the available programs.
Get the available programs.
def get_programs_available(self): """Get the available programs.""" return self.PROGRAMS
[ "def", "get_programs_available", "(", "self", ")", ":", "return", "self", ".", "PROGRAMS" ]
[ 142, 4 ]
[ 144, 28 ]
python
en
['en', 'en', 'en']
True
DeviceWithPrograms.get_program_switches
(self)
Get a dictionary with info about program switches. There will be one switch for each program.
Get a dictionary with info about program switches.
def get_program_switches(self): """Get a dictionary with info about program switches. There will be one switch for each program. """ programs = self.get_programs_available() return [{ATTR_DEVICE: self, "program_name": p["name"]} for p in programs]
[ "def", "get_program_switches", "(", "self", ")", ":", "programs", "=", "self", ".", "get_programs_available", "(", ")", "return", "[", "{", "ATTR_DEVICE", ":", "self", ",", "\"program_name\"", ":", "p", "[", "\"name\"", "]", "}", "for", "p", "in", "program...
[ 146, 4 ]
[ 152, 81 ]
python
en
['en', 'en', 'en']
True
DeviceWithPrograms.get_program_sensors
(self)
Get a dictionary with info about program sensors. There will be one of the four types of sensors for each device.
Get a dictionary with info about program sensors.
def get_program_sensors(self): """Get a dictionary with info about program sensors. There will be one of the four types of sensors for each device. """ sensors = { "Remaining Program Time": (None, None, DEVICE_CLASS_TIMESTAMP, 1), "Duration": (TIME_SECOND...
[ "def", "get_program_sensors", "(", "self", ")", ":", "sensors", "=", "{", "\"Remaining Program Time\"", ":", "(", "None", ",", "None", ",", "DEVICE_CLASS_TIMESTAMP", ",", "1", ")", ",", "\"Duration\"", ":", "(", "TIME_SECONDS", ",", "\"mdi:update\"", ",", "Non...
[ 154, 4 ]
[ 176, 9 ]
python
en
['en', 'en', 'en']
True
DeviceWithOpState.get_opstate_sensor
(self)
Get a list with info about operation state sensors.
Get a list with info about operation state sensors.
def get_opstate_sensor(self): """Get a list with info about operation state sensors.""" return [ { ATTR_DEVICE: self, ATTR_DESC: "Operation State", ATTR_UNIT: None, ATTR_KEY: BSH_OPERATION_STATE, ATTR_ICON: "mdi...
[ "def", "get_opstate_sensor", "(", "self", ")", ":", "return", "[", "{", "ATTR_DEVICE", ":", "self", ",", "ATTR_DESC", ":", "\"Operation State\"", ",", "ATTR_UNIT", ":", "None", ",", "ATTR_KEY", ":", "BSH_OPERATION_STATE", ",", "ATTR_ICON", ":", "\"mdi:state-mach...
[ 182, 4 ]
[ 195, 9 ]
python
en
['en', 'en', 'en']
True
DeviceWithDoor.get_door_entity
(self)
Get a dictionary with info about the door binary sensor.
Get a dictionary with info about the door binary sensor.
def get_door_entity(self): """Get a dictionary with info about the door binary sensor.""" return { ATTR_DEVICE: self, ATTR_DESC: "Door", ATTR_SENSOR_TYPE: "door", ATTR_DEVICE_CLASS: "door", }
[ "def", "get_door_entity", "(", "self", ")", ":", "return", "{", "ATTR_DEVICE", ":", "self", ",", "ATTR_DESC", ":", "\"Door\"", ",", "ATTR_SENSOR_TYPE", ":", "\"door\"", ",", "ATTR_DEVICE_CLASS", ":", "\"door\"", ",", "}" ]
[ 201, 4 ]
[ 208, 9 ]
python
en
['en', 'en', 'en']
True
DeviceWithLight.get_light_entity
(self)
Get a dictionary with info about the lighting.
Get a dictionary with info about the lighting.
def get_light_entity(self): """Get a dictionary with info about the lighting.""" return {ATTR_DEVICE: self, ATTR_DESC: "Light", ATTR_AMBIENT: None}
[ "def", "get_light_entity", "(", "self", ")", ":", "return", "{", "ATTR_DEVICE", ":", "self", ",", "ATTR_DESC", ":", "\"Light\"", ",", "ATTR_AMBIENT", ":", "None", "}" ]
[ 214, 4 ]
[ 216, 74 ]
python
en
['en', 'en', 'en']
True
DeviceWithAmbientLight.get_ambientlight_entity
(self)
Get a dictionary with info about the ambient lighting.
Get a dictionary with info about the ambient lighting.
def get_ambientlight_entity(self): """Get a dictionary with info about the ambient lighting.""" return {ATTR_DEVICE: self, ATTR_DESC: "AmbientLight", ATTR_AMBIENT: True}
[ "def", "get_ambientlight_entity", "(", "self", ")", ":", "return", "{", "ATTR_DEVICE", ":", "self", ",", "ATTR_DESC", ":", "\"AmbientLight\"", ",", "ATTR_AMBIENT", ":", "True", "}" ]
[ 222, 4 ]
[ 224, 81 ]
python
en
['en', 'en', 'en']
True
DeviceWithRemoteControl.get_remote_control
(self)
Get a dictionary with info about the remote control sensor.
Get a dictionary with info about the remote control sensor.
def get_remote_control(self): """Get a dictionary with info about the remote control sensor.""" return { ATTR_DEVICE: self, ATTR_DESC: "Remote Control", ATTR_SENSOR_TYPE: "remote_control", }
[ "def", "get_remote_control", "(", "self", ")", ":", "return", "{", "ATTR_DEVICE", ":", "self", ",", "ATTR_DESC", ":", "\"Remote Control\"", ",", "ATTR_SENSOR_TYPE", ":", "\"remote_control\"", ",", "}" ]
[ 230, 4 ]
[ 236, 9 ]
python
en
['en', 'en', 'en']
True
DeviceWithRemoteStart.get_remote_start
(self)
Get a dictionary with info about the remote start sensor.
Get a dictionary with info about the remote start sensor.
def get_remote_start(self): """Get a dictionary with info about the remote start sensor.""" return { ATTR_DEVICE: self, ATTR_DESC: "Remote Start", ATTR_SENSOR_TYPE: "remote_start", }
[ "def", "get_remote_start", "(", "self", ")", ":", "return", "{", "ATTR_DEVICE", ":", "self", ",", "ATTR_DESC", ":", "\"Remote Start\"", ",", "ATTR_SENSOR_TYPE", ":", "\"remote_start\"", ",", "}" ]
[ 242, 4 ]
[ 248, 9 ]
python
en
['en', 'en', 'en']
True
Dryer.get_entity_info
(self)
Get a dictionary with infos about the associated entities.
Get a dictionary with infos about the associated entities.
def get_entity_info(self): """Get a dictionary with infos about the associated entities.""" door_entity = self.get_door_entity() remote_control = self.get_remote_control() remote_start = self.get_remote_start() op_state_sensor = self.get_opstate_sensor() program_sensors =...
[ "def", "get_entity_info", "(", "self", ")", ":", "door_entity", "=", "self", ".", "get_door_entity", "(", ")", "remote_control", "=", "self", ".", "get_remote_control", "(", ")", "remote_start", "=", "self", ".", "get_remote_start", "(", ")", "op_state_sensor", ...
[ 279, 4 ]
[ 291, 9 ]
python
en
['en', 'en', 'en']
True
Dishwasher.get_entity_info
(self)
Get a dictionary with infos about the associated entities.
Get a dictionary with infos about the associated entities.
def get_entity_info(self): """Get a dictionary with infos about the associated entities.""" door_entity = self.get_door_entity() remote_control = self.get_remote_control() remote_start = self.get_remote_start() op_state_sensor = self.get_opstate_sensor() program_sensors =...
[ "def", "get_entity_info", "(", "self", ")", ":", "door_entity", "=", "self", ".", "get_door_entity", "(", ")", "remote_control", "=", "self", ".", "get_remote_control", "(", ")", "remote_start", "=", "self", ".", "get_remote_start", "(", ")", "op_state_sensor", ...
[ 329, 4 ]
[ 341, 9 ]
python
en
['en', 'en', 'en']
True
Oven.get_entity_info
(self)
Get a dictionary with infos about the associated entities.
Get a dictionary with infos about the associated entities.
def get_entity_info(self): """Get a dictionary with infos about the associated entities.""" door_entity = self.get_door_entity() remote_control = self.get_remote_control() remote_start = self.get_remote_start() op_state_sensor = self.get_opstate_sensor() program_sensors =...
[ "def", "get_entity_info", "(", "self", ")", ":", "door_entity", "=", "self", ".", "get_door_entity", "(", ")", "remote_control", "=", "self", ".", "get_remote_control", "(", ")", "remote_start", "=", "self", ".", "get_remote_start", "(", ")", "op_state_sensor", ...
[ 363, 4 ]
[ 375, 9 ]
python
en
['en', 'en', 'en']
True
Washer.get_entity_info
(self)
Get a dictionary with infos about the associated entities.
Get a dictionary with infos about the associated entities.
def get_entity_info(self): """Get a dictionary with infos about the associated entities.""" door_entity = self.get_door_entity() remote_control = self.get_remote_control() remote_start = self.get_remote_start() op_state_sensor = self.get_opstate_sensor() program_sensors =...
[ "def", "get_entity_info", "(", "self", ")", ":", "door_entity", "=", "self", ".", "get_door_entity", "(", ")", "remote_control", "=", "self", ".", "get_remote_control", "(", ")", "remote_start", "=", "self", ".", "get_remote_start", "(", ")", "op_state_sensor", ...
[ 411, 4 ]
[ 423, 9 ]
python
en
['en', 'en', 'en']
True
CoffeeMaker.get_entity_info
(self)
Get a dictionary with infos about the associated entities.
Get a dictionary with infos about the associated entities.
def get_entity_info(self): """Get a dictionary with infos about the associated entities.""" remote_start = self.get_remote_start() op_state_sensor = self.get_opstate_sensor() program_sensors = self.get_program_sensors() program_switches = self.get_program_switches() retur...
[ "def", "get_entity_info", "(", "self", ")", ":", "remote_start", "=", "self", ".", "get_remote_start", "(", ")", "op_state_sensor", "=", "self", ".", "get_opstate_sensor", "(", ")", "program_sensors", "=", "self", ".", "get_program_sensors", "(", ")", "program_s...
[ 448, 4 ]
[ 458, 9 ]
python
en
['en', 'en', 'en']
True
Hood.get_entity_info
(self)
Get a dictionary with infos about the associated entities.
Get a dictionary with infos about the associated entities.
def get_entity_info(self): """Get a dictionary with infos about the associated entities.""" remote_control = self.get_remote_control() remote_start = self.get_remote_start() light_entity = self.get_light_entity() ambientlight_entity = self.get_ambientlight_entity() op_sta...
[ "def", "get_entity_info", "(", "self", ")", ":", "remote_control", "=", "self", ".", "get_remote_control", "(", ")", "remote_start", "=", "self", ".", "get_remote_start", "(", ")", "light_entity", "=", "self", ".", "get_light_entity", "(", ")", "ambientlight_ent...
[ 477, 4 ]
[ 491, 9 ]
python
en
['en', 'en', 'en']
True
FridgeFreezer.get_entity_info
(self)
Get a dictionary with infos about the associated entities.
Get a dictionary with infos about the associated entities.
def get_entity_info(self): """Get a dictionary with infos about the associated entities.""" door_entity = self.get_door_entity() return {"binary_sensor": [door_entity]}
[ "def", "get_entity_info", "(", "self", ")", ":", "door_entity", "=", "self", ".", "get_door_entity", "(", ")", "return", "{", "\"binary_sensor\"", ":", "[", "door_entity", "]", "}" ]
[ 497, 4 ]
[ 500, 47 ]
python
en
['en', 'en', 'en']
True
Hob.get_entity_info
(self)
Get a dictionary with infos about the associated entities.
Get a dictionary with infos about the associated entities.
def get_entity_info(self): """Get a dictionary with infos about the associated entities.""" remote_control = self.get_remote_control() op_state_sensor = self.get_opstate_sensor() program_sensors = self.get_program_sensors() program_switches = self.get_program_switches() r...
[ "def", "get_entity_info", "(", "self", ")", ":", "remote_control", "=", "self", ".", "get_remote_control", "(", ")", "op_state_sensor", "=", "self", ".", "get_opstate_sensor", "(", ")", "program_sensors", "=", "self", ".", "get_program_sensors", "(", ")", "progr...
[ 508, 4 ]
[ 518, 9 ]
python
en
['en', 'en', 'en']
True
validate_station
(station)
Check that the station ID is well-formed.
Check that the station ID is well-formed.
def validate_station(station): """Check that the station ID is well-formed.""" if station is None: return if not re.fullmatch(r"[A-Z]{2}/s0000\d{3}", station): raise vol.error.Invalid('Station ID must be of the form "XX/s0000###"') return station
[ "def", "validate_station", "(", "station", ")", ":", "if", "station", "is", "None", ":", "return", "if", "not", "re", ".", "fullmatch", "(", "r\"[A-Z]{2}/s0000\\d{3}\"", ",", "station", ")", ":", "raise", "vol", ".", "error", ".", "Invalid", "(", "'Station...
[ 37, 0 ]
[ 43, 18 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_devices, discovery_info=None)
Set up the Environment Canada weather.
Set up the Environment Canada weather.
def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Environment Canada weather.""" if config.get(CONF_STATION): ec_data = ECData(station_id=config[CONF_STATION]) else: lat = config.get(CONF_LATITUDE, hass.config.latitude) lon = config.get(CONF_LONGITUDE,...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_devices", ",", "discovery_info", "=", "None", ")", ":", "if", "config", ".", "get", "(", "CONF_STATION", ")", ":", "ec_data", "=", "ECData", "(", "station_id", "=", "config", "[", "CONF_STATION...
[ 74, 0 ]
[ 83, 45 ]
python
en
['en', 'en', 'en']
True
get_forecast
(ec_data, forecast_type)
Build the forecast array.
Build the forecast array.
def get_forecast(ec_data, forecast_type): """Build the forecast array.""" forecast_array = [] if forecast_type == "daily": half_days = ec_data.daily_forecasts today = { ATTR_FORECAST_TIME: dt.now().isoformat(), ATTR_FORECAST_CONDITION: icon_code_to_condition( ...
[ "def", "get_forecast", "(", "ec_data", ",", "forecast_type", ")", ":", "forecast_array", "=", "[", "]", "if", "forecast_type", "==", "\"daily\"", ":", "half_days", "=", "ec_data", ".", "daily_forecasts", "today", "=", "{", "ATTR_FORECAST_TIME", ":", "dt", ".",...
[ 180, 0 ]
[ 252, 25 ]
python
en
['en', 'ga', 'en']
True
icon_code_to_condition
(icon_code)
Return the condition corresponding to an icon code.
Return the condition corresponding to an icon code.
def icon_code_to_condition(icon_code): """Return the condition corresponding to an icon code.""" for condition, codes in ICON_CONDITION_MAP.items(): if icon_code in codes: return condition return None
[ "def", "icon_code_to_condition", "(", "icon_code", ")", ":", "for", "condition", ",", "codes", "in", "ICON_CONDITION_MAP", ".", "items", "(", ")", ":", "if", "icon_code", "in", "codes", ":", "return", "condition", "return", "None" ]
[ 255, 0 ]
[ 260, 15 ]
python
en
['en', 'en', 'en']
True
ECWeather.__init__
(self, ec_data, config)
Initialize Environment Canada weather.
Initialize Environment Canada weather.
def __init__(self, ec_data, config): """Initialize Environment Canada weather.""" self.ec_data = ec_data self.platform_name = config.get(CONF_NAME) self.forecast_type = config[CONF_FORECAST]
[ "def", "__init__", "(", "self", ",", "ec_data", ",", "config", ")", ":", "self", ".", "ec_data", "=", "ec_data", "self", ".", "platform_name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "self", ".", "forecast_type", "=", "config", "[", "CONF_FOREC...
[ 89, 4 ]
[ 93, 50 ]
python
en
['en', 'en', 'en']
True
ECWeather.attribution
(self)
Return the attribution.
Return the attribution.
def attribution(self): """Return the attribution.""" return CONF_ATTRIBUTION
[ "def", "attribution", "(", "self", ")", ":", "return", "CONF_ATTRIBUTION" ]
[ 96, 4 ]
[ 98, 31 ]
python
en
['en', 'ja', 'en']
True
ECWeather.name
(self)
Return the name of the weather entity.
Return the name of the weather entity.
def name(self): """Return the name of the weather entity.""" if self.platform_name: return self.platform_name return self.ec_data.metadata.get("location")
[ "def", "name", "(", "self", ")", ":", "if", "self", ".", "platform_name", ":", "return", "self", ".", "platform_name", "return", "self", ".", "ec_data", ".", "metadata", ".", "get", "(", "\"location\"", ")" ]
[ 101, 4 ]
[ 105, 52 ]
python
en
['en', 'en', 'en']
True
ECWeather.temperature
(self)
Return the temperature.
Return the temperature.
def temperature(self): """Return the temperature.""" if self.ec_data.conditions.get("temperature", {}).get("value"): return float(self.ec_data.conditions["temperature"]["value"]) if self.ec_data.hourly_forecasts[0].get("temperature"): return float(self.ec_data.hourly_fore...
[ "def", "temperature", "(", "self", ")", ":", "if", "self", ".", "ec_data", ".", "conditions", ".", "get", "(", "\"temperature\"", ",", "{", "}", ")", ".", "get", "(", "\"value\"", ")", ":", "return", "float", "(", "self", ".", "ec_data", ".", "condit...
[ 108, 4 ]
[ 114, 19 ]
python
en
['en', 'la', 'en']
True
ECWeather.temperature_unit
(self)
Return the unit of measurement.
Return the unit of measurement.
def temperature_unit(self): """Return the unit of measurement.""" return TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_CELSIUS" ]
[ 117, 4 ]
[ 119, 27 ]
python
en
['en', 'la', 'en']
True
ECWeather.humidity
(self)
Return the humidity.
Return the humidity.
def humidity(self): """Return the humidity.""" if self.ec_data.conditions.get("humidity", {}).get("value"): return float(self.ec_data.conditions["humidity"]["value"]) return None
[ "def", "humidity", "(", "self", ")", ":", "if", "self", ".", "ec_data", ".", "conditions", ".", "get", "(", "\"humidity\"", ",", "{", "}", ")", ".", "get", "(", "\"value\"", ")", ":", "return", "float", "(", "self", ".", "ec_data", ".", "conditions",...
[ 122, 4 ]
[ 126, 19 ]
python
en
['en', 'sw', 'en']
True
ECWeather.wind_speed
(self)
Return the wind speed.
Return the wind speed.
def wind_speed(self): """Return the wind speed.""" if self.ec_data.conditions.get("wind_speed", {}).get("value"): return float(self.ec_data.conditions["wind_speed"]["value"]) return None
[ "def", "wind_speed", "(", "self", ")", ":", "if", "self", ".", "ec_data", ".", "conditions", ".", "get", "(", "\"wind_speed\"", ",", "{", "}", ")", ".", "get", "(", "\"value\"", ")", ":", "return", "float", "(", "self", ".", "ec_data", ".", "conditio...
[ 129, 4 ]
[ 133, 19 ]
python
en
['en', 'zh', 'en']
True
ECWeather.wind_bearing
(self)
Return the wind bearing.
Return the wind bearing.
def wind_bearing(self): """Return the wind bearing.""" if self.ec_data.conditions.get("wind_bearing", {}).get("value"): return float(self.ec_data.conditions["wind_bearing"]["value"]) return None
[ "def", "wind_bearing", "(", "self", ")", ":", "if", "self", ".", "ec_data", ".", "conditions", ".", "get", "(", "\"wind_bearing\"", ",", "{", "}", ")", ".", "get", "(", "\"value\"", ")", ":", "return", "float", "(", "self", ".", "ec_data", ".", "cond...
[ 136, 4 ]
[ 140, 19 ]
python
en
['en', 'ig', 'en']
True
ECWeather.pressure
(self)
Return the pressure.
Return the pressure.
def pressure(self): """Return the pressure.""" if self.ec_data.conditions.get("pressure", {}).get("value"): return 10 * float(self.ec_data.conditions["pressure"]["value"]) return None
[ "def", "pressure", "(", "self", ")", ":", "if", "self", ".", "ec_data", ".", "conditions", ".", "get", "(", "\"pressure\"", ",", "{", "}", ")", ".", "get", "(", "\"value\"", ")", ":", "return", "10", "*", "float", "(", "self", ".", "ec_data", ".", ...
[ 143, 4 ]
[ 147, 19 ]
python
en
['en', 'ig', 'en']
True
ECWeather.visibility
(self)
Return the visibility.
Return the visibility.
def visibility(self): """Return the visibility.""" if self.ec_data.conditions.get("visibility", {}).get("value"): return float(self.ec_data.conditions["visibility"]["value"]) return None
[ "def", "visibility", "(", "self", ")", ":", "if", "self", ".", "ec_data", ".", "conditions", ".", "get", "(", "\"visibility\"", ",", "{", "}", ")", ".", "get", "(", "\"value\"", ")", ":", "return", "float", "(", "self", ".", "ec_data", ".", "conditio...
[ 150, 4 ]
[ 154, 19 ]
python
en
['en', 'en', 'en']
True
ECWeather.condition
(self)
Return the weather condition.
Return the weather condition.
def condition(self): """Return the weather condition.""" icon_code = None if self.ec_data.conditions.get("icon_code", {}).get("value"): icon_code = self.ec_data.conditions["icon_code"]["value"] elif self.ec_data.hourly_forecasts[0].get("icon_code"): icon_code = s...
[ "def", "condition", "(", "self", ")", ":", "icon_code", "=", "None", "if", "self", ".", "ec_data", ".", "conditions", ".", "get", "(", "\"icon_code\"", ",", "{", "}", ")", ".", "get", "(", "\"value\"", ")", ":", "icon_code", "=", "self", ".", "ec_dat...
[ 157, 4 ]
[ 168, 17 ]
python
en
['en', 'en', 'en']
True
ECWeather.forecast
(self)
Return the forecast array.
Return the forecast array.
def forecast(self): """Return the forecast array.""" return get_forecast(self.ec_data, self.forecast_type)
[ "def", "forecast", "(", "self", ")", ":", "return", "get_forecast", "(", "self", ".", "ec_data", ",", "self", ".", "forecast_type", ")" ]
[ 171, 4 ]
[ 173, 61 ]
python
en
['en', 'ga', 'en']
True
ECWeather.update
(self)
Get the latest data from Environment Canada.
Get the latest data from Environment Canada.
def update(self): """Get the latest data from Environment Canada.""" self.ec_data.update()
[ "def", "update", "(", "self", ")", ":", "self", ".", "ec_data", ".", "update", "(", ")" ]
[ 175, 4 ]
[ 177, 29 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the openSenseMap air quality platform.
Set up the openSenseMap air quality platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the openSenseMap air quality platform.""" name = config.get(CONF_NAME) station_id = config[CONF_STATION_ID] session = async_get_clientsession(hass) osm_api = OpenSenseMapData(OpenSenseMap(station_id, h...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "station_id", "=", "config", "[", "CONF_STATION_ID", "]", "...
[ 28, 0 ]
[ 45, 74 ]
python
en
['en', 'lb', 'en']
True
OpenSenseMapQuality.__init__
(self, name, osm)
Initialize the air quality entity.
Initialize the air quality entity.
def __init__(self, name, osm): """Initialize the air quality entity.""" self._name = name self._osm = osm
[ "def", "__init__", "(", "self", ",", "name", ",", "osm", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_osm", "=", "osm" ]
[ 51, 4 ]
[ 54, 23 ]
python
en
['en', 'en', 'en']
True
OpenSenseMapQuality.name
(self)
Return the name of the air quality entity.
Return the name of the air quality entity.
def name(self): """Return the name of the air quality entity.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 57, 4 ]
[ 59, 25 ]
python
en
['en', 'en', 'en']
True
OpenSenseMapQuality.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.""" return self._osm.api.pm2_5
[ "def", "particulate_matter_2_5", "(", "self", ")", ":", "return", "self", ".", "_osm", ".", "api", ".", "pm2_5" ]
[ 62, 4 ]
[ 64, 34 ]
python
en
['en', 'en', 'en']
True
OpenSenseMapQuality.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 self._osm.api.pm10
[ "def", "particulate_matter_10", "(", "self", ")", ":", "return", "self", ".", "_osm", ".", "api", ".", "pm10" ]
[ 67, 4 ]
[ 69, 33 ]
python
en
['en', 'en', 'en']
True
OpenSenseMapQuality.attribution
(self)
Return the attribution.
Return the attribution.
def attribution(self): """Return the attribution.""" return ATTRIBUTION
[ "def", "attribution", "(", "self", ")", ":", "return", "ATTRIBUTION" ]
[ 72, 4 ]
[ 74, 26 ]
python
en
['en', 'ja', 'en']
True
OpenSenseMapQuality.async_update
(self)
Get the latest data from the openSenseMap API.
Get the latest data from the openSenseMap API.
async def async_update(self): """Get the latest data from the openSenseMap API.""" await self._osm.async_update()
[ "async", "def", "async_update", "(", "self", ")", ":", "await", "self", ".", "_osm", ".", "async_update", "(", ")" ]
[ 76, 4 ]
[ 78, 38 ]
python
en
['en', 'en', 'en']
True
OpenSenseMapData.__init__
(self, api)
Initialize the data object.
Initialize the data object.
def __init__(self, api): """Initialize the data object.""" self.api = api
[ "def", "__init__", "(", "self", ",", "api", ")", ":", "self", ".", "api", "=", "api" ]
[ 84, 4 ]
[ 86, 22 ]
python
en
['en', 'en', 'en']
True
OpenSenseMapData.async_update
(self)
Get the latest data from the Pi-hole.
Get the latest data from the Pi-hole.
async def async_update(self): """Get the latest data from the Pi-hole.""" try: await self.api.get_data() except OpenSenseMapError as err: _LOGGER.error("Unable to fetch data: %s", err)
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "await", "self", ".", "api", ".", "get_data", "(", ")", "except", "OpenSenseMapError", "as", "err", ":", "_LOGGER", ".", "error", "(", "\"Unable to fetch data: %s\"", ",", "err", ")" ]
[ 89, 4 ]
[ 95, 58 ]
python
en
['en', 'en', 'en']
True
get_status
(hass, host, port)
Get the status of a Konnected Panel.
Get the status of a Konnected Panel.
async def get_status(hass, host, port): """Get the status of a Konnected Panel.""" client = konnected.Client( host, str(port), aiohttp_client.async_get_clientsession(hass) ) try: return await client.get_status() except client.ClientError as err: _LOGGER.error("Exception tryi...
[ "async", "def", "get_status", "(", "hass", ",", "host", ",", "port", ")", ":", "client", "=", "konnected", ".", "Client", "(", "host", ",", "str", "(", "port", ")", ",", "aiohttp_client", ".", "async_get_clientsession", "(", "hass", ")", ")", "try", ":...
[ 382, 0 ]
[ 392, 36 ]
python
en
['en', 'en', 'en']
True
AlarmPanel.__init__
(self, hass, config_entry)
Initialize the Konnected device.
Initialize the Konnected device.
def __init__(self, hass, config_entry): """Initialize the Konnected device.""" self.hass = hass self.config_entry = config_entry self.config = config_entry.data self.options = config_entry.options or config_entry.data.get( CONF_DEFAULT_OPTIONS, {} ) se...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config_entry", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "config_entry", "=", "config_entry", "self", ".", "config", "=", "config_entry", ".", "data", "self", ".", "options", "=", "config_...
[ 62, 4 ]
[ 77, 40 ]
python
en
['en', 'en', 'en']
True
AlarmPanel.device_id
(self)
Device id is the chipId (pro) or MAC address as string with punctuation removed.
Device id is the chipId (pro) or MAC address as string with punctuation removed.
def device_id(self): """Device id is the chipId (pro) or MAC address as string with punctuation removed.""" return self.config.get(CONF_ID)
[ "def", "device_id", "(", "self", ")", ":", "return", "self", ".", "config", ".", "get", "(", "CONF_ID", ")" ]
[ 80, 4 ]
[ 82, 39 ]
python
en
['en', 'en', 'en']
True
AlarmPanel.stored_configuration
(self)
Return the configuration stored in `hass.data` for this device.
Return the configuration stored in `hass.data` for this device.
def stored_configuration(self): """Return the configuration stored in `hass.data` for this device.""" return self.hass.data[DOMAIN][CONF_DEVICES].get(self.device_id)
[ "def", "stored_configuration", "(", "self", ")", ":", "return", "self", ".", "hass", ".", "data", "[", "DOMAIN", "]", "[", "CONF_DEVICES", "]", ".", "get", "(", "self", ".", "device_id", ")" ]
[ 85, 4 ]
[ 87, 71 ]
python
en
['en', 'en', 'en']
True
AlarmPanel.available
(self)
Return whether the device is available.
Return whether the device is available.
def available(self): """Return whether the device is available.""" return self.connected
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "connected" ]
[ 90, 4 ]
[ 92, 29 ]
python
en
['en', 'en', 'en']
True
AlarmPanel.format_zone
(self, zone, other_items=None)
Get zone or pin based dict based on the client type.
Get zone or pin based dict based on the client type.
def format_zone(self, zone, other_items=None): """Get zone or pin based dict based on the client type.""" payload = { self.api_version: zone if self.api_version == CONF_ZONE else ZONE_TO_PIN[zone] } payload.update(other_items or {}) return payl...
[ "def", "format_zone", "(", "self", ",", "zone", ",", "other_items", "=", "None", ")", ":", "payload", "=", "{", "self", ".", "api_version", ":", "zone", "if", "self", ".", "api_version", "==", "CONF_ZONE", "else", "ZONE_TO_PIN", "[", "zone", "]", "}", ...
[ 94, 4 ]
[ 102, 22 ]
python
en
['en', 'en', 'en']
True