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
KWBSensor.available
(self)
Return if sensor is available.
Return if sensor is available.
def available(self) -> bool: """Return if sensor is available.""" return self._sensor.available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_sensor", ".", "available" ]
[ 92, 4 ]
[ 94, 37 ]
python
en
['en', 'en', 'en']
True
KWBSensor.state
(self)
Return the state of value.
Return the state of value.
def state(self): """Return the state of value.""" if self._sensor.value is not None and self._sensor.available: return self._sensor.value return None
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_sensor", ".", "value", "is", "not", "None", "and", "self", ".", "_sensor", ".", "available", ":", "return", "self", ".", "_sensor", ".", "value", "return", "None" ]
[ 97, 4 ]
[ 101, 19 ]
python
en
['en', 'en', 'en']
True
KWBSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._sensor.unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_sensor", ".", "unit_of_measurement" ]
[ 104, 4 ]
[ 106, 47 ]
python
en
['en', 'en', 'en']
True
async_setup_sdm_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities )
Set up the cameras.
Set up the cameras.
async def async_setup_sdm_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities ) -> None: """Set up the cameras.""" subscriber = hass.data[DOMAIN][entry.entry_id] try: device_manager = await subscriber.async_get_device_manager() except GoogleNestException as err: r...
[ "async", "def", "async_setup_sdm_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "subscriber", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]...
[ 29, 0 ]
[ 49, 32 ]
python
en
['en', 'pt', 'en']
True
NestCamera.__init__
(self, device: Device)
Initialize the camera.
Initialize the camera.
def __init__(self, device: Device): """Initialize the camera.""" super().__init__() self._device = device self._device_info = DeviceInfo(device) self._stream = None self._stream_refresh_unsub = None
[ "def", "__init__", "(", "self", ",", "device", ":", "Device", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_device", "=", "device", "self", ".", "_device_info", "=", "DeviceInfo", "(", "device", ")", "self", ".", "_stream", "...
[ 55, 4 ]
[ 61, 41 ]
python
en
['en', 'en', 'en']
True
NestCamera.should_poll
(self)
Disable polling since entities have state pushed via pubsub.
Disable polling since entities have state pushed via pubsub.
def should_poll(self) -> bool: """Disable polling since entities have state pushed via pubsub.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 64, 4 ]
[ 66, 20 ]
python
en
['en', 'en', 'en']
True
NestCamera.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> Optional[str]: """Return a unique ID.""" # The API "name" field is a unique device identifier. return f"{self._device.name}-camera"
[ "def", "unique_id", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "# The API \"name\" field is a unique device identifier.", "return", "f\"{self._device.name}-camera\"" ]
[ 69, 4 ]
[ 72, 44 ]
python
ca
['fr', 'ca', 'en']
False
NestCamera.name
(self)
Return the name of the camera.
Return the name of the camera.
def name(self): """Return the name of the camera.""" return self._device_info.device_name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_device_info", ".", "device_name" ]
[ 75, 4 ]
[ 77, 44 ]
python
en
['en', 'en', 'en']
True
NestCamera.device_info
(self)
Return device specific attributes.
Return device specific attributes.
def device_info(self): """Return device specific attributes.""" return self._device_info.device_info
[ "def", "device_info", "(", "self", ")", ":", "return", "self", ".", "_device_info", ".", "device_info" ]
[ 80, 4 ]
[ 82, 44 ]
python
en
['fr', 'it', 'en']
False
NestCamera.brand
(self)
Return the camera brand.
Return the camera brand.
def brand(self): """Return the camera brand.""" return self._device_info.device_brand
[ "def", "brand", "(", "self", ")", ":", "return", "self", ".", "_device_info", ".", "device_brand" ]
[ 85, 4 ]
[ 87, 45 ]
python
en
['en', 'bs', 'en']
True
NestCamera.model
(self)
Return the camera model.
Return the camera model.
def model(self): """Return the camera model.""" return self._device_info.device_model
[ "def", "model", "(", "self", ")", ":", "return", "self", ".", "_device_info", ".", "device_model" ]
[ 90, 4 ]
[ 92, 45 ]
python
en
['en', 'co', 'en']
True
NestCamera.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" if CameraLiveStreamTrait.NAME in self._device.traits: return SUPPORT_STREAM return 0
[ "def", "supported_features", "(", "self", ")", ":", "if", "CameraLiveStreamTrait", ".", "NAME", "in", "self", ".", "_device", ".", "traits", ":", "return", "SUPPORT_STREAM", "return", "0" ]
[ 95, 4 ]
[ 99, 16 ]
python
en
['da', 'en', 'en']
True
NestCamera.stream_source
(self)
Return the source of the stream.
Return the source of the stream.
async def stream_source(self): """Return the source of the stream.""" if CameraLiveStreamTrait.NAME not in self._device.traits: return None trait = self._device.traits[CameraLiveStreamTrait.NAME] if not self._stream: _LOGGER.debug("Fetching stream url") ...
[ "async", "def", "stream_source", "(", "self", ")", ":", "if", "CameraLiveStreamTrait", ".", "NAME", "not", "in", "self", ".", "_device", ".", "traits", ":", "return", "None", "trait", "=", "self", ".", "_device", ".", "traits", "[", "CameraLiveStreamTrait", ...
[ 101, 4 ]
[ 112, 43 ]
python
en
['en', 'en', 'en']
True
NestCamera._schedule_stream_refresh
(self)
Schedules an alarm to refresh the stream url before expiration.
Schedules an alarm to refresh the stream url before expiration.
def _schedule_stream_refresh(self): """Schedules an alarm to refresh the stream url before expiration.""" _LOGGER.debug("New stream url expires at %s", self._stream.expires_at) refresh_time = self._stream.expires_at - STREAM_EXPIRATION_BUFFER # Schedule an alarm to extend the stream ...
[ "def", "_schedule_stream_refresh", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"New stream url expires at %s\"", ",", "self", ".", "_stream", ".", "expires_at", ")", "refresh_time", "=", "self", ".", "_stream", ".", "expires_at", "-", "STREAM_EXPIRATION...
[ 114, 4 ]
[ 126, 9 ]
python
en
['en', 'en', 'en']
True
NestCamera._handle_stream_refresh
(self, now)
Alarm that fires to check if the stream should be refreshed.
Alarm that fires to check if the stream should be refreshed.
async def _handle_stream_refresh(self, now): """Alarm that fires to check if the stream should be refreshed.""" if not self._stream: return _LOGGER.debug("Extending stream url") self._stream_refresh_unsub = None try: self._stream = await self._stream.exten...
[ "async", "def", "_handle_stream_refresh", "(", "self", ",", "now", ")", ":", "if", "not", "self", ".", "_stream", ":", "return", "_LOGGER", ".", "debug", "(", "\"Extending stream url\"", ")", "self", ".", "_stream_refresh_unsub", "=", "None", "try", ":", "se...
[ 128, 4 ]
[ 141, 39 ]
python
en
['en', 'en', 'en']
True
NestCamera.async_will_remove_from_hass
(self)
Invalidates the RTSP token when unloaded.
Invalidates the RTSP token when unloaded.
async def async_will_remove_from_hass(self): """Invalidates the RTSP token when unloaded.""" if self._stream: _LOGGER.debug("Invalidating stream") await self._stream.stop_rtsp_stream() if self._stream_refresh_unsub: self._stream_refresh_unsub()
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", ":", "if", "self", ".", "_stream", ":", "_LOGGER", ".", "debug", "(", "\"Invalidating stream\"", ")", "await", "self", ".", "_stream", ".", "stop_rtsp_stream", "(", ")", "if", "self", ".", "_st...
[ 143, 4 ]
[ 149, 40 ]
python
en
['en', 'en', 'en']
True
NestCamera.async_added_to_hass
(self)
Run when entity is added to register update signal handler.
Run when entity is added to register update signal handler.
async def async_added_to_hass(self): """Run when entity is added to register update signal handler.""" # Event messages trigger the SIGNAL_NEST_UPDATE, which is intercepted # here to re-fresh the signals from _device. Unregister this callback # when the entity is removed. self.a...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "# Event messages trigger the SIGNAL_NEST_UPDATE, which is intercepted", "# here to re-fresh the signals from _device. Unregister this callback", "# when the entity is removed.", "self", ".", "async_on_remove", "(", "async_di...
[ 151, 4 ]
[ 160, 9 ]
python
en
['en', 'en', 'en']
True
NestCamera.async_camera_image
(self)
Return bytes of camera image.
Return bytes of camera image.
async def async_camera_image(self): """Return bytes of camera image.""" stream_url = await self.stream_source() if not stream_url: return None return await async_get_image(self.hass, stream_url, output_format=IMAGE_JPEG)
[ "async", "def", "async_camera_image", "(", "self", ")", ":", "stream_url", "=", "await", "self", ".", "stream_source", "(", ")", "if", "not", "stream_url", ":", "return", "None", "return", "await", "async_get_image", "(", "self", ".", "hass", ",", "stream_ur...
[ 162, 4 ]
[ 167, 85 ]
python
en
['en', 'zu', 'en']
True
SPOSEvolution.update_search_space
(self, search_space)
Handle the initialization/update event of search space.
Handle the initialization/update event of search space.
def update_search_space(self, search_space): """ Handle the initialization/update event of search space. """ self._search_space = search_space self._next_round()
[ "def", "update_search_space", "(", "self", ",", "search_space", ")", ":", "self", ".", "_search_space", "=", "search_space", "self", ".", "_next_round", "(", ")" ]
[ 61, 4 ]
[ 66, 26 ]
python
en
['en', 'error', 'th']
False
SPOSEvolution._bind_and_send_parameters
(self)
There are two types of resources: parameter ids and candidates. This function is called at necessary times to bind these resources to send new trials with st_callback.
There are two types of resources: parameter ids and candidates. This function is called at necessary times to bind these resources to send new trials with st_callback.
def _bind_and_send_parameters(self): """ There are two types of resources: parameter ids and candidates. This function is called at necessary times to bind these resources to send new trials with st_callback. """ result = [] while self._sending_parameter_queue and self._t...
[ "def", "_bind_and_send_parameters", "(", "self", ")", ":", "result", "=", "[", "]", "while", "self", ".", "_sending_parameter_queue", "and", "self", ".", "_to_evaluate_queue", ":", "parameter_id", "=", "self", ".", "_sending_parameter_queue", ".", "popleft", "(", ...
[ 160, 4 ]
[ 174, 21 ]
python
en
['en', 'error', 'th']
False
SPOSEvolution.generate_multiple_parameters
(self, parameter_id_list, **kwargs)
Callback function necessary to implement a tuner. This will put more parameter ids into the parameter id queue.
Callback function necessary to implement a tuner. This will put more parameter ids into the parameter id queue.
def generate_multiple_parameters(self, parameter_id_list, **kwargs): """ Callback function necessary to implement a tuner. This will put more parameter ids into the parameter id queue. """ if "st_callback" in kwargs and self._st_callback is None: self._st_callback = k...
[ "def", "generate_multiple_parameters", "(", "self", ",", "parameter_id_list", ",", "*", "*", "kwargs", ")", ":", "if", "\"st_callback\"", "in", "kwargs", "and", "self", ".", "_st_callback", "is", "None", ":", "self", ".", "_st_callback", "=", "kwargs", "[", ...
[ 176, 4 ]
[ 186, 17 ]
python
en
['en', 'error', 'th']
False
SPOSEvolution.receive_trial_result
(self, parameter_id, parameters, value, **kwargs)
Callback function. Receive a trial result.
Callback function. Receive a trial result.
def receive_trial_result(self, parameter_id, parameters, value, **kwargs): """ Callback function. Receive a trial result. """ _logger.info("Candidate %d, reported reward %f", parameter_id, value) self._reward_dict[self._hashcode(self._id2candidate[parameter_id])] = value
[ "def", "receive_trial_result", "(", "self", ",", "parameter_id", ",", "parameters", ",", "value", ",", "*", "*", "kwargs", ")", ":", "_logger", ".", "info", "(", "\"Candidate %d, reported reward %f\"", ",", "parameter_id", ",", "value", ")", "self", ".", "_rew...
[ 188, 4 ]
[ 193, 83 ]
python
en
['en', 'error', 'th']
False
SPOSEvolution.trial_end
(self, parameter_id, success, **kwargs)
Callback function when a trial is ended and resource is released.
Callback function when a trial is ended and resource is released.
def trial_end(self, parameter_id, success, **kwargs): """ Callback function when a trial is ended and resource is released. """ self._pending_result_ids.remove(parameter_id) if not self._pending_result_ids and not self._to_evaluate_queue: # a new epoch now ...
[ "def", "trial_end", "(", "self", ",", "parameter_id", ",", "success", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_pending_result_ids", ".", "remove", "(", "parameter_id", ")", "if", "not", "self", ".", "_pending_result_ids", "and", "not", "self", "."...
[ 195, 4 ]
[ 204, 44 ]
python
en
['en', 'error', 'th']
False
SPOSEvolution.export_results
(self, result)
Export a number of candidates to `checkpoints` dir. Parameters ---------- result : dict Chosen architectures to be exported.
Export a number of candidates to `checkpoints` dir.
def export_results(self, result): """ Export a number of candidates to `checkpoints` dir. Parameters ---------- result : dict Chosen architectures to be exported. """ os.makedirs("checkpoints", exist_ok=True) for i, cand in enumerate(result): ...
[ "def", "export_results", "(", "self", ",", "result", ")", ":", "os", ".", "makedirs", "(", "\"checkpoints\"", ",", "exist_ok", "=", "True", ")", "for", "i", ",", "cand", "in", "enumerate", "(", "result", ")", ":", "converted", "=", "dict", "(", ")", ...
[ 206, 4 ]
[ 222, 40 ]
python
en
['en', 'error', 'th']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Opple light platform.
Set up the Opple light platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Opple light platform.""" name = config[CONF_NAME] host = config[CONF_HOST] entity = OppleLight(name, host) add_entities([entity]) _LOGGER.debug("Init light %s %s", host, entity.unique_id)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", "[", "CONF_NAME", "]", "host", "=", "config", "[", "CONF_HOST", "]", "entity", "=", "OppleLight", "(", "name", ...
[ 33, 0 ]
[ 41, 61 ]
python
en
['en', 'da', 'en']
True
OppleLight.__init__
(self, name, host)
Initialize an Opple light.
Initialize an Opple light.
def __init__(self, name, host): """Initialize an Opple light.""" self._device = OppleLightDevice(host) self._name = name self._is_on = None self._brightness = None self._color_temp = None
[ "def", "__init__", "(", "self", ",", "name", ",", "host", ")", ":", "self", ".", "_device", "=", "OppleLightDevice", "(", "host", ")", "self", ".", "_name", "=", "name", "self", ".", "_is_on", "=", "None", "self", ".", "_brightness", "=", "None", "se...
[ 47, 4 ]
[ 55, 31 ]
python
en
['en', 'en', 'nl']
True
OppleLight.available
(self)
Return True if light is available.
Return True if light is available.
def available(self): """Return True if light is available.""" return self._device.is_online
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "is_online" ]
[ 58, 4 ]
[ 60, 37 ]
python
en
['en', 'en', 'en']
True
OppleLight.unique_id
(self)
Return unique ID for light.
Return unique ID for light.
def unique_id(self): """Return unique ID for light.""" return self._device.mac
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "mac" ]
[ 63, 4 ]
[ 65, 31 ]
python
en
['fr', 'la', 'en']
False
OppleLight.name
(self)
Return the display name of this light.
Return the display name of this light.
def name(self): """Return the display name of this light.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 68, 4 ]
[ 70, 25 ]
python
en
['en', 'en', 'en']
True
OppleLight.is_on
(self)
Return true if light is on.
Return true if light is on.
def is_on(self): """Return true if light is on.""" return self._is_on
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_is_on" ]
[ 73, 4 ]
[ 75, 26 ]
python
en
['en', 'et', 'en']
True
OppleLight.brightness
(self)
Return the brightness of the light.
Return the brightness of the light.
def brightness(self): """Return the brightness of the light.""" return self._brightness
[ "def", "brightness", "(", "self", ")", ":", "return", "self", ".", "_brightness" ]
[ 78, 4 ]
[ 80, 31 ]
python
en
['en', 'no', 'en']
True
OppleLight.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.""" return kelvin_to_mired(self._color_temp)
[ "def", "color_temp", "(", "self", ")", ":", "return", "kelvin_to_mired", "(", "self", ".", "_color_temp", ")" ]
[ 83, 4 ]
[ 85, 48 ]
python
en
['en', 'en', 'en']
True
OppleLight.min_mireds
(self)
Return minimum supported color temperature.
Return minimum supported color temperature.
def min_mireds(self): """Return minimum supported color temperature.""" return 175
[ "def", "min_mireds", "(", "self", ")", ":", "return", "175" ]
[ 88, 4 ]
[ 90, 18 ]
python
en
['ro', 'la', 'en']
False
OppleLight.max_mireds
(self)
Return maximum supported color temperature.
Return maximum supported color temperature.
def max_mireds(self): """Return maximum supported color temperature.""" return 333
[ "def", "max_mireds", "(", "self", ")", ":", "return", "333" ]
[ 93, 4 ]
[ 95, 18 ]
python
en
['ro', 'la', 'en']
False
OppleLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_BRIGHTNESS", "|", "SUPPORT_COLOR_TEMP" ]
[ 98, 4 ]
[ 100, 54 ]
python
en
['da', 'en', 'en']
True
OppleLight.turn_on
(self, **kwargs)
Instruct the light to turn on.
Instruct the light to turn on.
def turn_on(self, **kwargs): """Instruct the light to turn on.""" _LOGGER.debug("Turn on light %s %s", self._device.ip, kwargs) if not self.is_on: self._device.power_on = True if ATTR_BRIGHTNESS in kwargs and self.brightness != kwargs[ATTR_BRIGHTNESS]: self._devi...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Turn on light %s %s\"", ",", "self", ".", "_device", ".", "ip", ",", "kwargs", ")", "if", "not", "self", ".", "is_on", ":", "self", ".", "_device", "."...
[ 102, 4 ]
[ 113, 55 ]
python
en
['en', 'en', 'en']
True
OppleLight.turn_off
(self, **kwargs)
Instruct the light to turn off.
Instruct the light to turn off.
def turn_off(self, **kwargs): """Instruct the light to turn off.""" self._device.power_on = False _LOGGER.debug("Turn off light %s", self._device.ip)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_device", ".", "power_on", "=", "False", "_LOGGER", ".", "debug", "(", "\"Turn off light %s\"", ",", "self", ".", "_device", ".", "ip", ")" ]
[ 115, 4 ]
[ 118, 59 ]
python
en
['en', 'en', 'en']
True
OppleLight.update
(self)
Synchronize state with light.
Synchronize state with light.
def update(self): """Synchronize state with light.""" prev_available = self.available self._device.update() if ( prev_available == self.available and self._is_on == self._device.power_on and self._brightness == self._device.brightness and ...
[ "def", "update", "(", "self", ")", ":", "prev_available", "=", "self", ".", "available", "self", ".", "_device", ".", "update", "(", ")", "if", "(", "prev_available", "==", "self", ".", "available", "and", "self", ".", "_is_on", "==", "self", ".", "_de...
[ 120, 4 ]
[ 150, 13 ]
python
en
['en', 'en', 'en']
True
recursive_flatten
(prefix: Any, data: Dict)
Return a flattened representation of dict data.
Return a flattened representation of dict data.
def recursive_flatten(prefix: Any, data: Dict) -> Dict[str, Any]: """Return a flattened representation of dict data.""" output = {} for key, value in data.items(): if isinstance(value, dict): output.update(recursive_flatten(f"{prefix}{key}.", value)) else: output[f"{p...
[ "def", "recursive_flatten", "(", "prefix", ":", "Any", ",", "data", ":", "Dict", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "output", "=", "{", "}", "for", "key", ",", "value", "in", "data", ".", "items", "(", ")", ":", "if", "isinstanc...
[ 26, 0 ]
[ 34, 17 ]
python
en
['en', 'id', 'en']
True
component_translation_path
( component: str, language: str, integration: Integration )
Return the translation json file location for a component. For component: - components/hue/translations/nl.json For platform: - components/hue/translations/light.nl.json If component is just a single file, will return None.
Return the translation json file location for a component.
def component_translation_path( component: str, language: str, integration: Integration ) -> Optional[str]: """Return the translation json file location for a component. For component: - components/hue/translations/nl.json For platform: - components/hue/translations/light.nl.json If com...
[ "def", "component_translation_path", "(", "component", ":", "str", ",", "language", ":", "str", ",", "integration", ":", "Integration", ")", "->", "Optional", "[", "str", "]", ":", "parts", "=", "component", ".", "split", "(", "\".\"", ")", "domain", "=", ...
[ 38, 0 ]
[ 67, 43 ]
python
en
['en', 'en', 'en']
True
load_translations_files
( translation_files: Dict[str, str] )
Load and parse translation.json files.
Load and parse translation.json files.
def load_translations_files( translation_files: Dict[str, str] ) -> Dict[str, Dict[str, Any]]: """Load and parse translation.json files.""" loaded = {} for component, translation_file in translation_files.items(): loaded_json = load_json(translation_file) if not isinstance(loaded_json, ...
[ "def", "load_translations_files", "(", "translation_files", ":", "Dict", "[", "str", ",", "str", "]", ")", "->", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ":", "loaded", "=", "{", "}", "for", "component", ",", "translation_file...
[ 70, 0 ]
[ 88, 17 ]
python
en
['en', 'en', 'en']
True
_merge_resources
( translation_strings: Dict[str, Dict[str, Any]], components: Set[str], category: str, )
Build and merge the resources response for the given components and platforms.
Build and merge the resources response for the given components and platforms.
def _merge_resources( translation_strings: Dict[str, Dict[str, Any]], components: Set[str], category: str, ) -> Dict[str, Dict[str, Any]]: """Build and merge the resources response for the given components and platforms.""" # Build response resources: Dict[str, Dict[str, Any]] = {} for compo...
[ "def", "_merge_resources", "(", "translation_strings", ":", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ",", "components", ":", "Set", "[", "str", "]", ",", "category", ":", "str", ",", ")", "->", "Dict", "[", "str", ",", "Di...
[ 91, 0 ]
[ 129, 20 ]
python
en
['en', 'en', 'en']
True
_build_resources
( translation_strings: Dict[str, Dict[str, Any]], components: Set[str], category: str, )
Build the resources response for the given components.
Build the resources response for the given components.
def _build_resources( translation_strings: Dict[str, Dict[str, Any]], components: Set[str], category: str, ) -> Dict[str, Dict[str, Any]]: """Build the resources response for the given components.""" # Build response return { component: translation_strings[component][category] fo...
[ "def", "_build_resources", "(", "translation_strings", ":", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ",", "components", ":", "Set", "[", "str", "]", ",", "category", ":", "str", ",", ")", "->", "Dict", "[", "str", ",", "Di...
[ 132, 0 ]
[ 144, 5 ]
python
en
['en', 'en', 'en']
True
async_get_component_strings
( hass: HomeAssistantType, language: str, components: Set[str] )
Load translations.
Load translations.
async def async_get_component_strings( hass: HomeAssistantType, language: str, components: Set[str] ) -> Dict[str, Any]: """Load translations.""" domains = list({loaded.split(".")[-1] for loaded in components}) integrations = dict( zip( domains, await gather_with_concurre...
[ "async", "def", "async_get_component_strings", "(", "hass", ":", "HomeAssistantType", ",", "language", ":", "str", ",", "components", ":", "Set", "[", "str", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "domains", "=", "list", "(", "{", "l...
[ 147, 0 ]
[ 198, 23 ]
python
en
['en', 'bg', 'en']
False
async_get_translations
( hass: HomeAssistantType, language: str, category: str, integration: Optional[str] = None, config_flow: Optional[bool] = None, )
Return all backend translations. If integration specified, load it for that one. Otherwise default to loaded intgrations combined with config flow integrations if config_flow is true.
Return all backend translations.
async def async_get_translations( hass: HomeAssistantType, language: str, category: str, integration: Optional[str] = None, config_flow: Optional[bool] = None, ) -> Dict[str, Any]: """Return all backend translations. If integration specified, load it for that one. Otherwise default to l...
[ "async", "def", "async_get_translations", "(", "hass", ":", "HomeAssistantType", ",", "language", ":", "str", ",", "category", ":", "str", ",", "integration", ":", "Optional", "[", "str", "]", "=", "None", ",", "config_flow", ":", "Optional", "[", "bool", ...
[ 281, 0 ]
[ 312, 34 ]
python
en
['en', 'cy', 'en']
True
_TranslationCache.__init__
(self, hass: HomeAssistantType)
Initialize the cache.
Initialize the cache.
def __init__(self, hass: HomeAssistantType) -> None: """Initialize the cache.""" self.hass = hass self.loaded: Dict[str, Set[str]] = {} self.cache: Dict[str, Dict[str, Dict[str, Any]]] = {}
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistantType", ")", "->", "None", ":", "self", ".", "hass", "=", "hass", "self", ".", "loaded", ":", "Dict", "[", "str", ",", "Set", "[", "str", "]", "]", "=", "{", "}", "self", ".", "cache"...
[ 204, 4 ]
[ 208, 61 ]
python
en
['en', 'en', 'en']
True
_TranslationCache.async_fetch
( self, language: str, category: str, components: Set, )
Load resources into the cache.
Load resources into the cache.
async def async_fetch( self, language: str, category: str, components: Set, ) -> List[Dict[str, Dict[str, Any]]]: """Load resources into the cache.""" components_to_load = components - self.loaded.setdefault(language, set()) if components_to_load: ...
[ "async", "def", "async_fetch", "(", "self", ",", "language", ":", "str", ",", "category", ":", "str", ",", "components", ":", "Set", ",", ")", "->", "List", "[", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", "]", ":", "compon...
[ 210, 4 ]
[ 224, 88 ]
python
en
['en', 'en', 'en']
True
_TranslationCache._async_load
(self, language: str, components: Set)
Populate the cache for a given set of components.
Populate the cache for a given set of components.
async def _async_load(self, language: str, components: Set) -> None: """Populate the cache for a given set of components.""" _LOGGER.debug( "Cache miss for %s: %s", language, ", ".join(components), ) # Fetch the English resources, as a fallback for mis...
[ "async", "def", "_async_load", "(", "self", ",", "language", ":", "str", ",", "components", ":", "Set", ")", "->", "None", ":", "_LOGGER", ".", "debug", "(", "\"Cache miss for %s: %s\"", ",", "language", ",", "\", \"", ".", "join", "(", "components", ")", ...
[ 226, 4 ]
[ 243, 48 ]
python
en
['en', 'en', 'en']
True
_TranslationCache._build_category_cache
( self, language: str, components: Set, translation_strings: Dict[str, Dict[str, Any]], )
Extract resources into the cache.
Extract resources into the cache.
def _build_category_cache( self, language: str, components: Set, translation_strings: Dict[str, Dict[str, Any]], ) -> None: """Extract resources into the cache.""" cached = self.cache.setdefault(language, {}) categories: Set[str] = set() for resource i...
[ "def", "_build_category_cache", "(", "self", ",", "language", ":", "str", ",", "components", ":", "Set", ",", "translation_strings", ":", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ",", ")", "->", "None", ":", "cached", "=", "...
[ 246, 4 ]
[ 277, 82 ]
python
en
['en', 'en', 'en']
True
RestData.__init__
( self, method, resource, auth, headers, params, data, verify_ssl, timeout=DEFAULT_TIMEOUT, )
Initialize the data object.
Initialize the data object.
def __init__( self, method, resource, auth, headers, params, data, verify_ssl, timeout=DEFAULT_TIMEOUT, ): """Initialize the data object.""" self._method = method self._resource = resource self._auth = auth ...
[ "def", "__init__", "(", "self", ",", "method", ",", "resource", ",", "auth", ",", "headers", ",", "params", ",", "data", ",", "verify_ssl", ",", "timeout", "=", "DEFAULT_TIMEOUT", ",", ")", ":", "self", ".", "_method", "=", "method", "self", ".", "_res...
[ 13, 4 ]
[ 35, 27 ]
python
en
['en', 'en', 'en']
True
RestData.async_remove
(self)
Destroy the http session on destroy.
Destroy the http session on destroy.
async def async_remove(self): """Destroy the http session on destroy.""" if self._async_client: await self._async_client.aclose()
[ "async", "def", "async_remove", "(", "self", ")", ":", "if", "self", ".", "_async_client", ":", "await", "self", ".", "_async_client", ".", "aclose", "(", ")" ]
[ 37, 4 ]
[ 40, 45 ]
python
en
['en', 'da', 'en']
True
RestData.async_update
(self)
Get the latest data from REST service with provided method.
Get the latest data from REST service with provided method.
async def async_update(self): """Get the latest data from REST service with provided method.""" if not self._async_client: self._async_client = httpx.AsyncClient(verify=self._verify_ssl) _LOGGER.debug("Updating from %s", self._resource) try: response = await self...
[ "async", "def", "async_update", "(", "self", ")", ":", "if", "not", "self", ".", "_async_client", ":", "self", ".", "_async_client", "=", "httpx", ".", "AsyncClient", "(", "verify", "=", "self", ".", "_verify_ssl", ")", "_LOGGER", ".", "debug", "(", "\"U...
[ 46, 4 ]
[ 67, 31 ]
python
en
['en', 'en', 'en']
True
test_user_flow
(hass)
Test that config flow works.
Test that config flow works.
async def test_user_flow(hass): """Test that config flow works.""" with patch( "homeassistant.components.hvv_departures.hub.GTI.init", return_value=FIXTURE_INIT, ), patch( "homeassistant.components.hvv_departures.hub.GTI.checkName", return_value=FIXTURE_CHECK_NAME, ), pa...
[ "async", "def", "test_user_flow", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.hvv_departures.hub.GTI.init\"", ",", "return_value", "=", "FIXTURE_INIT", ",", ")", ",", "patch", "(", "\"homeassistant.components.hvv_departures.hub.GTI.checkName\"", ...
[ 28, 0 ]
[ 91, 9 ]
python
en
['en', 'en', 'en']
True
test_user_flow_no_results
(hass)
Test that config flow works when there are no results.
Test that config flow works when there are no results.
async def test_user_flow_no_results(hass): """Test that config flow works when there are no results.""" with patch( "homeassistant.components.hvv_departures.hub.GTI.init", return_value=FIXTURE_INIT, ), patch( "homeassistant.components.hvv_departures.hub.GTI.checkName", retur...
[ "async", "def", "test_user_flow_no_results", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.hvv_departures.hub.GTI.init\"", ",", "return_value", "=", "FIXTURE_INIT", ",", ")", ",", "patch", "(", "\"homeassistant.components.hvv_departures.hub.GTI.chec...
[ 94, 0 ]
[ 131, 63 ]
python
en
['en', 'en', 'en']
True
test_user_flow_invalid_auth
(hass)
Test that config flow handles invalid auth.
Test that config flow handles invalid auth.
async def test_user_flow_invalid_auth(hass): """Test that config flow handles invalid auth.""" with patch( "homeassistant.components.hvv_departures.hub.GTI.init", side_effect=InvalidAuth( "ERROR_TEXT", "Bei der Verarbeitung der Anfrage ist ein technisches Problem aufgetr...
[ "async", "def", "test_user_flow_invalid_auth", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.hvv_departures.hub.GTI.init\"", ",", "side_effect", "=", "InvalidAuth", "(", "\"ERROR_TEXT\"", ",", "\"Bei der Verarbeitung der Anfrage ist ein technisches Prob...
[ 134, 0 ]
[ 158, 64 ]
python
en
['en', 'en', 'en']
True
test_user_flow_cannot_connect
(hass)
Test that config flow handles connection errors.
Test that config flow handles connection errors.
async def test_user_flow_cannot_connect(hass): """Test that config flow handles connection errors.""" with patch( "homeassistant.components.hvv_departures.hub.GTI.init", side_effect=CannotConnect(), ): # step: user result_user = await hass.config_entries.flow.async_init( ...
[ "async", "def", "test_user_flow_cannot_connect", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.hvv_departures.hub.GTI.init\"", ",", "side_effect", "=", "CannotConnect", "(", ")", ",", ")", ":", "# step: user", "result_user", "=", "await", "h...
[ 161, 0 ]
[ 181, 66 ]
python
en
['en', 'en', 'en']
True
test_user_flow_station
(hass)
Test that config flow handles empty data on step station.
Test that config flow handles empty data on step station.
async def test_user_flow_station(hass): """Test that config flow handles empty data on step station.""" with patch( "homeassistant.components.hvv_departures.hub.GTI.init", return_value=True, ), patch( "homeassistant.components.hvv_departures.hub.GTI.checkName", return_value=...
[ "async", "def", "test_user_flow_station", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.hvv_departures.hub.GTI.init\"", ",", "return_value", "=", "True", ",", ")", ",", "patch", "(", "\"homeassistant.components.hvv_departures.hub.GTI.checkName\"", ...
[ 184, 0 ]
[ 215, 53 ]
python
en
['en', 'en', 'en']
True
test_user_flow_station_select
(hass)
Test that config flow handles empty data on step station_select.
Test that config flow handles empty data on step station_select.
async def test_user_flow_station_select(hass): """Test that config flow handles empty data on step station_select.""" with patch( "homeassistant.components.hvv_departures.hub.GTI.init", return_value=True, ), patch( "homeassistant.components.hvv_departures.hub.GTI.checkName", ...
[ "async", "def", "test_user_flow_station_select", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.hvv_departures.hub.GTI.init\"", ",", "return_value", "=", "True", ",", ")", ",", "patch", "(", "\"homeassistant.components.hvv_departures.hub.GTI.checkNam...
[ 218, 0 ]
[ 250, 67 ]
python
en
['en', 'en', 'en']
True
test_options_flow
(hass)
Test that options flow works.
Test that options flow works.
async def test_options_flow(hass): """Test that options flow works.""" config_entry = MockConfigEntry( version=1, domain=DOMAIN, title="Wartenau", data=FIXTURE_CONFIG_ENTRY, source="user", connection_class=CONN_CLASS_CLOUD_POLL, system_options={"disable_n...
[ "async", "def", "test_options_flow", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "version", "=", "1", ",", "domain", "=", "DOMAIN", ",", "title", "=", "\"Wartenau\"", ",", "data", "=", "FIXTURE_CONFIG_ENTRY", ",", "source", "=", "\"us...
[ 253, 0 ]
[ 301, 9 ]
python
en
['en', 'en', 'en']
True
test_options_flow_invalid_auth
(hass)
Test that options flow works.
Test that options flow works.
async def test_options_flow_invalid_auth(hass): """Test that options flow works.""" config_entry = MockConfigEntry( version=1, domain=DOMAIN, title="Wartenau", data=FIXTURE_CONFIG_ENTRY, source="user", connection_class=CONN_CLASS_CLOUD_POLL, system_option...
[ "async", "def", "test_options_flow_invalid_auth", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "version", "=", "1", ",", "domain", "=", "DOMAIN", ",", "title", "=", "\"Wartenau\"", ",", "data", "=", "FIXTURE_CONFIG_ENTRY", ",", "source", ...
[ 304, 0 ]
[ 342, 59 ]
python
en
['en', 'en', 'en']
True
test_options_flow_cannot_connect
(hass)
Test that options flow works.
Test that options flow works.
async def test_options_flow_cannot_connect(hass): """Test that options flow works.""" config_entry = MockConfigEntry( version=1, domain=DOMAIN, title="Wartenau", data=FIXTURE_CONFIG_ENTRY, source="user", connection_class=CONN_CLASS_CLOUD_POLL, system_opti...
[ "async", "def", "test_options_flow_cannot_connect", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "version", "=", "1", ",", "domain", "=", "DOMAIN", ",", "title", "=", "\"Wartenau\"", ",", "data", "=", "FIXTURE_CONFIG_ENTRY", ",", "source",...
[ 345, 0 ]
[ 379, 61 ]
python
en
['en', 'en', 'en']
True
query_nb101_trial_stats
(arch, num_epochs, isomorphism=True, reduction=None, include_intermediates=False)
Query trial stats of NAS-Bench-101 given conditions. Parameters ---------- arch : dict or None If a dict, it is in the format that is described in :class:`nni.nas.benchmark.nasbench101.Nb101TrialConfig`. Only trial stats matched will be returned. If none, all architectures in t...
Query trial stats of NAS-Bench-101 given conditions.
def query_nb101_trial_stats(arch, num_epochs, isomorphism=True, reduction=None, include_intermediates=False): """ Query trial stats of NAS-Bench-101 given conditions. Parameters ---------- arch : dict or None If a dict, it is in the format that is described in :class:`nni.nas.benchm...
[ "def", "query_nb101_trial_stats", "(", "arch", ",", "num_epochs", ",", "isomorphism", "=", "True", ",", "reduction", "=", "None", ",", "include_intermediates", "=", "False", ")", ":", "fields", "=", "[", "]", "if", "reduction", "==", "'none'", ":", "reductio...
[ 8, 0 ]
[ 69, 38 ]
python
en
['en', 'error', 'th']
False
async_setup
(hass, config)
Set up the iperf3 component.
Set up the iperf3 component.
async def async_setup(hass, config): """Set up the iperf3 component.""" hass.data[DOMAIN] = {} conf = config[DOMAIN] for host in conf[CONF_HOSTS]: data = hass.data[DOMAIN][host[CONF_HOST]] = Iperf3Data(hass, host) if not conf[CONF_MANUAL]: async_track_time_interval(hass, da...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "conf", "=", "config", "[", "DOMAIN", "]", "for", "host", "in", "conf", "[", "CONF_HOSTS", "]", ":", "data", "=", "hass", ...
[ 80, 0 ]
[ 108, 15 ]
python
en
['en', 'en', 'en']
True
Iperf3Data.__init__
(self, hass, host)
Initialize the data object.
Initialize the data object.
def __init__(self, hass, host): """Initialize the data object.""" self._hass = hass self._host = host self.data = {ATTR_DOWNLOAD: None, ATTR_UPLOAD: None, ATTR_VERSION: None}
[ "def", "__init__", "(", "self", ",", "hass", ",", "host", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_host", "=", "host", "self", ".", "data", "=", "{", "ATTR_DOWNLOAD", ":", "None", ",", "ATTR_UPLOAD", ":", "None", ",", "ATTR_VERSION...
[ 114, 4 ]
[ 118, 80 ]
python
en
['en', 'en', 'en']
True
Iperf3Data.create_client
(self)
Create a new iperf3 client to use for measurement.
Create a new iperf3 client to use for measurement.
def create_client(self): """Create a new iperf3 client to use for measurement.""" client = iperf3.Client() client.duration = self._host[CONF_DURATION] client.server_hostname = self._host[CONF_HOST] client.port = self._host[CONF_PORT] client.num_streams = self._host[CONF_P...
[ "def", "create_client", "(", "self", ")", ":", "client", "=", "iperf3", ".", "Client", "(", ")", "client", ".", "duration", "=", "self", ".", "_host", "[", "CONF_DURATION", "]", "client", ".", "server_hostname", "=", "self", ".", "_host", "[", "CONF_HOST...
[ 120, 4 ]
[ 129, 21 ]
python
en
['en', 'en', 'en']
True
Iperf3Data.protocol
(self)
Return the protocol used for this connection.
Return the protocol used for this connection.
def protocol(self): """Return the protocol used for this connection.""" return self._host[CONF_PROTOCOL]
[ "def", "protocol", "(", "self", ")", ":", "return", "self", ".", "_host", "[", "CONF_PROTOCOL", "]" ]
[ 132, 4 ]
[ 134, 40 ]
python
en
['en', 'en', 'en']
True
Iperf3Data.host
(self)
Return the host connected to.
Return the host connected to.
def host(self): """Return the host connected to.""" return self._host[CONF_HOST]
[ "def", "host", "(", "self", ")", ":", "return", "self", ".", "_host", "[", "CONF_HOST", "]" ]
[ 137, 4 ]
[ 139, 36 ]
python
en
['en', 'en', 'en']
True
Iperf3Data.port
(self)
Return the port on the host connected to.
Return the port on the host connected to.
def port(self): """Return the port on the host connected to.""" return self._host[CONF_PORT]
[ "def", "port", "(", "self", ")", ":", "return", "self", ".", "_host", "[", "CONF_PORT", "]" ]
[ 142, 4 ]
[ 144, 36 ]
python
en
['en', 'en', 'en']
True
Iperf3Data.update
(self, now=None)
Get the latest data from iperf3.
Get the latest data from iperf3.
def update(self, now=None): """Get the latest data from iperf3.""" if self.protocol == "udp": # UDP only have 1 way attribute result = self._run_test(ATTR_DOWNLOAD) self.data[ATTR_DOWNLOAD] = self.data[ATTR_UPLOAD] = getattr( result, "Mbps", None ...
[ "def", "update", "(", "self", ",", "now", "=", "None", ")", ":", "if", "self", ".", "protocol", "==", "\"udp\"", ":", "# UDP only have 1 way attribute", "result", "=", "self", ".", "_run_test", "(", "ATTR_DOWNLOAD", ")", "self", ".", "data", "[", "ATTR_DOW...
[ 146, 4 ]
[ 163, 60 ]
python
en
['en', 'en', 'en']
True
Iperf3Data._run_test
(self, test_type)
Run and return the iperf3 data.
Run and return the iperf3 data.
def _run_test(self, test_type): """Run and return the iperf3 data.""" client = self.create_client() client.reverse = test_type == ATTR_DOWNLOAD try: result = client.run() except (AttributeError, OSError, ValueError) as error: _LOGGER.error("Iperf3 error: %...
[ "def", "_run_test", "(", "self", ",", "test_type", ")", ":", "client", "=", "self", ".", "create_client", "(", ")", "client", ".", "reverse", "=", "test_type", "==", "ATTR_DOWNLOAD", "try", ":", "result", "=", "client", ".", "run", "(", ")", "except", ...
[ 165, 4 ]
[ 179, 21 ]
python
en
['en', 'sn', 'en']
True
number
(value: Any)
Coerce a value to number without losing precision.
Coerce a value to number without losing precision.
def number(value: Any) -> Union[int, float]: """Coerce a value to number without losing precision.""" if isinstance(value, int): return value if isinstance(value, str): try: value = int(value) return value except (TypeError, ValueError): pass ...
[ "def", "number", "(", "value", ":", "Any", ")", "->", "Union", "[", "int", ",", "float", "]", ":", "if", "isinstance", "(", "value", ",", "int", ")", ":", "return", "value", "if", "isinstance", "(", "value", ",", "str", ")", ":", "try", ":", "val...
[ 46, 0 ]
[ 62, 61 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Modbus sensors.
Set up the Modbus sensors.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Modbus sensors.""" sensors = [] for register in config[CONF_REGISTERS]: if register[CONF_DATA_TYPE] == DATA_TYPE_STRING: structure = str(register[CONF_COUNT] * 2) + "s" elif register[CONF_DATA_TYP...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "sensors", "=", "[", "]", "for", "register", "in", "config", "[", "CONF_REGISTERS", "]", ":", "if", "register", "[", "CONF_DATA_TYPE", "...
[ 99, 0 ]
[ 155, 25 ]
python
en
['en', 'sq', 'en']
True
ModbusRegisterSensor.__init__
( self, hub, name, slave, register, register_type, unit_of_measurement, count, reverse_order, scale, offset, structure, precision, data_type, device_class, )
Initialize the modbus register sensor.
Initialize the modbus register sensor.
def __init__( self, hub, name, slave, register, register_type, unit_of_measurement, count, reverse_order, scale, offset, structure, precision, data_type, device_class, ): """Initialize the...
[ "def", "__init__", "(", "self", ",", "hub", ",", "name", ",", "slave", ",", "register", ",", "register_type", ",", "unit_of_measurement", ",", "count", ",", "reverse_order", ",", "scale", ",", "offset", ",", "structure", ",", "precision", ",", "data_type", ...
[ 161, 4 ]
[ 194, 30 ]
python
en
['en', 'pt', 'en']
True
ModbusRegisterSensor.async_added_to_hass
(self)
Handle entity which will be added.
Handle entity which will be added.
async def async_added_to_hass(self): """Handle entity which will be added.""" state = await self.async_get_last_state() if not state: return self._value = state.state
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "state", "=", "await", "self", ".", "async_get_last_state", "(", ")", "if", "not", "state", ":", "return", "self", ".", "_value", "=", "state", ".", "state" ]
[ 196, 4 ]
[ 201, 33 ]
python
en
['en', 'en', 'en']
True
ModbusRegisterSensor.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._value
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_value" ]
[ 204, 4 ]
[ 206, 26 ]
python
en
['en', 'en', 'en']
True
ModbusRegisterSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 209, 4 ]
[ 211, 25 ]
python
en
['en', 'mi', 'en']
True
ModbusRegisterSensor.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 214, 4 ]
[ 216, 40 ]
python
en
['en', 'la', 'en']
True
ModbusRegisterSensor.device_class
(self)
Return the device class of the sensor.
Return the device class of the sensor.
def device_class(self) -> Optional[str]: """Return the device class of the sensor.""" return self._device_class
[ "def", "device_class", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "_device_class" ]
[ 219, 4 ]
[ 221, 33 ]
python
en
['en', 'en', 'en']
True
ModbusRegisterSensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_available" ]
[ 224, 4 ]
[ 226, 30 ]
python
en
['en', 'en', 'en']
True
ModbusRegisterSensor.update
(self)
Update the state of the sensor.
Update the state of the sensor.
def update(self): """Update the state of the sensor.""" try: if self._register_type == CALL_TYPE_REGISTER_INPUT: result = self._hub.read_input_registers( self._slave, self._register, self._count ) else: result = ...
[ "def", "update", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_register_type", "==", "CALL_TYPE_REGISTER_INPUT", ":", "result", "=", "self", ".", "_hub", ".", "read_input_registers", "(", "self", ".", "_slave", ",", "self", ".", "_register", ",",...
[ 228, 4 ]
[ 264, 30 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discover_info=None)
Set up the AVR platform.
Set up the AVR platform.
def setup_platform(hass, config, add_entities, discover_info=None): """Set up the AVR platform.""" name = config[CONF_NAME] host = config[CONF_HOST] port = config[CONF_PORT] avr = hkavr.HkAVR(host, port, name) avr_device = HkAvrDevice(avr) add_entities([avr_device], True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discover_info", "=", "None", ")", ":", "name", "=", "config", "[", "CONF_NAME", "]", "host", "=", "config", "[", "CONF_HOST", "]", "port", "=", "config", "[", "CONF_PORT", "]...
[ 35, 0 ]
[ 44, 36 ]
python
en
['en', 'da', 'en']
True
HkAvrDevice.__init__
(self, avr)
Initialize a new HarmanKardonAVR.
Initialize a new HarmanKardonAVR.
def __init__(self, avr): """Initialize a new HarmanKardonAVR.""" self._avr = avr self._name = avr.name self._host = avr.host self._port = avr.port self._source_list = avr.sources self._state = None self._muted = avr.muted self._current_source = ...
[ "def", "__init__", "(", "self", ",", "avr", ")", ":", "self", ".", "_avr", "=", "avr", "self", ".", "_name", "=", "avr", ".", "name", "self", ".", "_host", "=", "avr", ".", "host", "self", ".", "_port", "=", "avr", ".", "port", "self", ".", "_s...
[ 50, 4 ]
[ 62, 49 ]
python
en
['en', 'pl', 'en']
True
HkAvrDevice.update
(self)
Update the state of this media_player.
Update the state of this media_player.
def update(self): """Update the state of this media_player.""" if self._avr.is_on(): self._state = STATE_ON elif self._avr.is_off(): self._state = STATE_OFF else: self._state = None self._muted = self._avr.muted self._current_source = ...
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "_avr", ".", "is_on", "(", ")", ":", "self", ".", "_state", "=", "STATE_ON", "elif", "self", ".", "_avr", ".", "is_off", "(", ")", ":", "self", ".", "_state", "=", "STATE_OFF", "else", ":...
[ 64, 4 ]
[ 74, 55 ]
python
en
['en', 'en', 'en']
True
HkAvrDevice.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 77, 4 ]
[ 79, 25 ]
python
en
['en', 'en', 'en']
True
HkAvrDevice.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 82, 4 ]
[ 84, 26 ]
python
en
['en', 'en', 'en']
True
HkAvrDevice.is_volume_muted
(self)
Muted status not available.
Muted status not available.
def is_volume_muted(self): """Muted status not available.""" return self._muted
[ "def", "is_volume_muted", "(", "self", ")", ":", "return", "self", ".", "_muted" ]
[ 87, 4 ]
[ 89, 26 ]
python
en
['en', 'en', 'en']
True
HkAvrDevice.source
(self)
Return the current input source.
Return the current input source.
def source(self): """Return the current input source.""" return self._current_source
[ "def", "source", "(", "self", ")", ":", "return", "self", ".", "_current_source" ]
[ 92, 4 ]
[ 94, 35 ]
python
en
['en', 'en', 'en']
True
HkAvrDevice.source_list
(self)
Available sources.
Available sources.
def source_list(self): """Available sources.""" return self._source_list
[ "def", "source_list", "(", "self", ")", ":", "return", "self", ".", "_source_list" ]
[ 97, 4 ]
[ 99, 32 ]
python
en
['fr', 'en', 'en']
False
HkAvrDevice.supported_features
(self)
Flag media player features that are supported.
Flag media player features that are supported.
def supported_features(self): """Flag media player features that are supported.""" return SUPPORT_HARMAN_KARDON_AVR
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_HARMAN_KARDON_AVR" ]
[ 102, 4 ]
[ 104, 40 ]
python
en
['en', 'en', 'en']
True
HkAvrDevice.turn_on
(self)
Turn the AVR on.
Turn the AVR on.
def turn_on(self): """Turn the AVR on.""" self._avr.power_on()
[ "def", "turn_on", "(", "self", ")", ":", "self", ".", "_avr", ".", "power_on", "(", ")" ]
[ 106, 4 ]
[ 108, 28 ]
python
en
['en', 'en', 'en']
True
HkAvrDevice.turn_off
(self)
Turn off the AVR.
Turn off the AVR.
def turn_off(self): """Turn off the AVR.""" self._avr.power_off()
[ "def", "turn_off", "(", "self", ")", ":", "self", ".", "_avr", ".", "power_off", "(", ")" ]
[ 110, 4 ]
[ 112, 29 ]
python
en
['en', 'en', 'en']
True
HkAvrDevice.select_source
(self, source)
Select input source.
Select input source.
def select_source(self, source): """Select input source.""" return self._avr.select_source(source)
[ "def", "select_source", "(", "self", ",", "source", ")", ":", "return", "self", ".", "_avr", ".", "select_source", "(", "source", ")" ]
[ 114, 4 ]
[ 116, 46 ]
python
en
['fr', 'su', 'en']
False
HkAvrDevice.volume_up
(self)
Volume up the AVR.
Volume up the AVR.
def volume_up(self): """Volume up the AVR.""" return self._avr.volume_up()
[ "def", "volume_up", "(", "self", ")", ":", "return", "self", ".", "_avr", ".", "volume_up", "(", ")" ]
[ 118, 4 ]
[ 120, 36 ]
python
en
['en', 'en', 'en']
True
HkAvrDevice.volume_down
(self)
Volume down AVR.
Volume down AVR.
def volume_down(self): """Volume down AVR.""" return self._avr.volume_down()
[ "def", "volume_down", "(", "self", ")", ":", "return", "self", ".", "_avr", ".", "volume_down", "(", ")" ]
[ 122, 4 ]
[ 124, 38 ]
python
en
['en', 'kk', 'en']
True
HkAvrDevice.mute_volume
(self, mute)
Send mute command.
Send mute command.
def mute_volume(self, mute): """Send mute command.""" return self._avr.mute(mute)
[ "def", "mute_volume", "(", "self", ",", "mute", ")", ":", "return", "self", ".", "_avr", ".", "mute", "(", "mute", ")" ]
[ 126, 4 ]
[ 128, 35 ]
python
en
['en', 'co', 'en']
True
test_imperial_metric
( hass, units, result_observation, result_forecast, mock_simple_nws )
Test with imperial and metric units.
Test with imperial and metric units.
async def test_imperial_metric( hass, units, result_observation, result_forecast, mock_simple_nws ): """Test with imperial and metric units.""" # enable the hourly entity registry = await hass.helpers.entity_registry.async_get_registry() registry.async_get_or_create( WEATHER_DOMAIN, ...
[ "async", "def", "test_imperial_metric", "(", "hass", ",", "units", ",", "result_observation", ",", "result_forecast", ",", "mock_simple_nws", ")", ":", "# enable the hourly entity", "registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "asyn...
[ 37, 0 ]
[ 84, 44 ]
python
en
['en', 'en', 'en']
True
test_none_values
(hass, mock_simple_nws)
Test with none values in observation and forecast dicts.
Test with none values in observation and forecast dicts.
async def test_none_values(hass, mock_simple_nws): """Test with none values in observation and forecast dicts.""" instance = mock_simple_nws.return_value instance.observation = NONE_OBSERVATION instance.forecast = NONE_FORECAST entry = MockConfigEntry( domain=nws.DOMAIN, data=NWS_CO...
[ "async", "def", "test_none_values", "(", "hass", ",", "mock_simple_nws", ")", ":", "instance", "=", "mock_simple_nws", ".", "return_value", "instance", ".", "observation", "=", "NONE_OBSERVATION", "instance", ".", "forecast", "=", "NONE_FORECAST", "entry", "=", "M...
[ 87, 0 ]
[ 109, 43 ]
python
en
['en', 'en', 'en']
True
test_none
(hass, mock_simple_nws)
Test with None as observation and forecast.
Test with None as observation and forecast.
async def test_none(hass, mock_simple_nws): """Test with None as observation and forecast.""" instance = mock_simple_nws.return_value instance.observation = None instance.forecast = None entry = MockConfigEntry( domain=nws.DOMAIN, data=NWS_CONFIG, ) entry.add_to_hass(hass) ...
[ "async", "def", "test_none", "(", "hass", ",", "mock_simple_nws", ")", ":", "instance", "=", "mock_simple_nws", ".", "return_value", "instance", ".", "observation", "=", "None", "instance", ".", "forecast", "=", "None", "entry", "=", "MockConfigEntry", "(", "d...
[ 112, 0 ]
[ 135, 27 ]
python
en
['en', 'en', 'en']
True
test_error_station
(hass, mock_simple_nws)
Test error in setting station.
Test error in setting station.
async def test_error_station(hass, mock_simple_nws): """Test error in setting station.""" instance = mock_simple_nws.return_value instance.set_station.side_effect = aiohttp.ClientError entry = MockConfigEntry( domain=nws.DOMAIN, data=NWS_CONFIG, ) entry.add_to_hass(hass) aw...
[ "async", "def", "test_error_station", "(", "hass", ",", "mock_simple_nws", ")", ":", "instance", "=", "mock_simple_nws", ".", "return_value", "instance", ".", "set_station", ".", "side_effect", "=", "aiohttp", ".", "ClientError", "entry", "=", "MockConfigEntry", "...
[ 138, 0 ]
[ 153, 58 ]
python
de
['de', 'no', 'en']
False
test_entity_refresh
(hass, mock_simple_nws)
Test manual refresh.
Test manual refresh.
async def test_entity_refresh(hass, mock_simple_nws): """Test manual refresh.""" instance = mock_simple_nws.return_value await async_setup_component(hass, "homeassistant", {}) entry = MockConfigEntry( domain=nws.DOMAIN, data=NWS_CONFIG, ) entry.add_to_hass(hass) await hass....
[ "async", "def", "test_entity_refresh", "(", "hass", ",", "mock_simple_nws", ")", ":", "instance", "=", "mock_simple_nws", ".", "return_value", "await", "async_setup_component", "(", "hass", ",", "\"homeassistant\"", ",", "{", "}", ")", "entry", "=", "MockConfigEnt...
[ 156, 0 ]
[ 182, 56 ]
python
en
['en', 'cy', 'en']
True