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
test_operation_value_changed_mapping_preset
(device_mapping)
Test values changed for climate device. Mapping with presets.
Test values changed for climate device. Mapping with presets.
def test_operation_value_changed_mapping_preset(device_mapping): """Test values changed for climate device. Mapping with presets.""" device = device_mapping assert device.hvac_mode == HVAC_MODE_HEAT assert device.preset_mode == PRESET_NONE device.values.primary.data = "Full Power" value_changed(...
[ "def", "test_operation_value_changed_mapping_preset", "(", "device_mapping", ")", ":", "device", "=", "device_mapping", "assert", "device", ".", "hvac_mode", "==", "HVAC_MODE_HEAT", "assert", "device", ".", "preset_mode", "==", "PRESET_NONE", "device", ".", "values", ...
[ 771, 0 ]
[ 782, 44 ]
python
en
['en', 'en', 'en']
True
test_operation_value_changed_unknown
(device_unknown)
Test preset changed for climate device. Unknown.
Test preset changed for climate device. Unknown.
def test_operation_value_changed_unknown(device_unknown): """Test preset changed for climate device. Unknown.""" device = device_unknown assert device.hvac_mode == HVAC_MODE_HEAT assert device.preset_mode == PRESET_NONE device.values.primary.data = "Abcdefg" value_changed(device.values.primary) ...
[ "def", "test_operation_value_changed_unknown", "(", "device_unknown", ")", ":", "device", "=", "device_unknown", "assert", "device", ".", "hvac_mode", "==", "HVAC_MODE_HEAT", "assert", "device", ".", "preset_mode", "==", "PRESET_NONE", "device", ".", "values", ".", ...
[ 785, 0 ]
[ 793, 42 ]
python
en
['en', 'en', 'en']
True
test_operation_value_changed_heat_cool
(device_heat_cool)
Test preset changed for climate device. Heat/Cool only.
Test preset changed for climate device. Heat/Cool only.
def test_operation_value_changed_heat_cool(device_heat_cool): """Test preset changed for climate device. Heat/Cool only.""" device = device_heat_cool assert device.hvac_mode == HVAC_MODE_HEAT assert device.preset_mode == PRESET_NONE device.values.primary.data = "Cool Eco" value_changed(device.va...
[ "def", "test_operation_value_changed_heat_cool", "(", "device_heat_cool", ")", ":", "device", "=", "device_heat_cool", "assert", "device", ".", "hvac_mode", "==", "HVAC_MODE_HEAT", "assert", "device", ".", "preset_mode", "==", "PRESET_NONE", "device", ".", "values", "...
[ 796, 0 ]
[ 808, 43 ]
python
en
['en', 'en', 'en']
True
test_fan_mode_value_changed
(device)
Test values changed for climate device.
Test values changed for climate device.
def test_fan_mode_value_changed(device): """Test values changed for climate device.""" assert device.fan_mode == "test2" device.values.fan_mode.data = "test_updated_fan" value_changed(device.values.fan_mode) assert device.fan_mode == "test_updated_fan"
[ "def", "test_fan_mode_value_changed", "(", "device", ")", ":", "assert", "device", ".", "fan_mode", "==", "\"test2\"", "device", ".", "values", ".", "fan_mode", ".", "data", "=", "\"test_updated_fan\"", "value_changed", "(", "device", ".", "values", ".", "fan_mo...
[ 811, 0 ]
[ 816, 48 ]
python
en
['en', 'en', 'en']
True
test_hvac_action_value_changed
(device)
Test values changed for climate device.
Test values changed for climate device.
def test_hvac_action_value_changed(device): """Test values changed for climate device.""" assert device.hvac_action == CURRENT_HVAC_HEAT device.values.operating_state.data = CURRENT_HVAC_COOL value_changed(device.values.operating_state) assert device.hvac_action == CURRENT_HVAC_COOL
[ "def", "test_hvac_action_value_changed", "(", "device", ")", ":", "assert", "device", ".", "hvac_action", "==", "CURRENT_HVAC_HEAT", "device", ".", "values", ".", "operating_state", ".", "data", "=", "CURRENT_HVAC_COOL", "value_changed", "(", "device", ".", "values"...
[ 819, 0 ]
[ 824, 50 ]
python
en
['en', 'en', 'en']
True
test_hvac_action_value_changed_mapping
(device_mapping)
Test values changed for climate device.
Test values changed for climate device.
def test_hvac_action_value_changed_mapping(device_mapping): """Test values changed for climate device.""" device = device_mapping assert device.hvac_action == CURRENT_HVAC_HEAT device.values.operating_state.data = "cooling" value_changed(device.values.operating_state) assert device.hvac_action =...
[ "def", "test_hvac_action_value_changed_mapping", "(", "device_mapping", ")", ":", "device", "=", "device_mapping", "assert", "device", ".", "hvac_action", "==", "CURRENT_HVAC_HEAT", "device", ".", "values", ".", "operating_state", ".", "data", "=", "\"cooling\"", "val...
[ 827, 0 ]
[ 833, 50 ]
python
en
['en', 'en', 'en']
True
test_hvac_action_value_changed_unknown
(device_unknown)
Test values changed for climate device.
Test values changed for climate device.
def test_hvac_action_value_changed_unknown(device_unknown): """Test values changed for climate device.""" device = device_unknown assert device.hvac_action == "test4" device.values.operating_state.data = "another_hvac_action" value_changed(device.values.operating_state) assert device.hvac_action...
[ "def", "test_hvac_action_value_changed_unknown", "(", "device_unknown", ")", ":", "device", "=", "device_unknown", "assert", "device", ".", "hvac_action", "==", "\"test4\"", "device", ".", "values", ".", "operating_state", ".", "data", "=", "\"another_hvac_action\"", ...
[ 836, 0 ]
[ 842, 54 ]
python
en
['en', 'en', 'en']
True
test_fan_action_value_changed
(device)
Test values changed for climate device.
Test values changed for climate device.
def test_fan_action_value_changed(device): """Test values changed for climate device.""" assert device.device_state_attributes[climate.ATTR_FAN_ACTION] == 7 device.values.fan_action.data = 9 value_changed(device.values.fan_action) assert device.device_state_attributes[climate.ATTR_FAN_ACTION] == 9
[ "def", "test_fan_action_value_changed", "(", "device", ")", ":", "assert", "device", ".", "device_state_attributes", "[", "climate", ".", "ATTR_FAN_ACTION", "]", "==", "7", "device", ".", "values", ".", "fan_action", ".", "data", "=", "9", "value_changed", "(", ...
[ 845, 0 ]
[ 850, 71 ]
python
en
['en', 'en', 'en']
True
test_aux_heat_unsupported_set
(device)
Test aux heat for climate device.
Test aux heat for climate device.
def test_aux_heat_unsupported_set(device): """Test aux heat for climate device.""" assert device.values.primary.data == HVAC_MODE_HEAT device.turn_aux_heat_on() assert device.values.primary.data == HVAC_MODE_HEAT device.turn_aux_heat_off() assert device.values.primary.data == HVAC_MODE_HEAT
[ "def", "test_aux_heat_unsupported_set", "(", "device", ")", ":", "assert", "device", ".", "values", ".", "primary", ".", "data", "==", "HVAC_MODE_HEAT", "device", ".", "turn_aux_heat_on", "(", ")", "assert", "device", ".", "values", ".", "primary", ".", "data"...
[ 853, 0 ]
[ 859, 55 ]
python
fr
['fr', 'en', 'fr']
True
test_aux_heat_unsupported_value_changed
(device)
Test aux heat for climate device.
Test aux heat for climate device.
def test_aux_heat_unsupported_value_changed(device): """Test aux heat for climate device.""" assert device.is_aux_heat is None device.values.primary.data = HVAC_MODE_HEAT value_changed(device.values.primary) assert device.is_aux_heat is None
[ "def", "test_aux_heat_unsupported_value_changed", "(", "device", ")", ":", "assert", "device", ".", "is_aux_heat", "is", "None", "device", ".", "values", ".", "primary", ".", "data", "=", "HVAC_MODE_HEAT", "value_changed", "(", "device", ".", "values", ".", "pri...
[ 862, 0 ]
[ 867, 37 ]
python
fr
['fr', 'en', 'fr']
True
test_aux_heat_set
(device_aux_heat)
Test aux heat for climate device.
Test aux heat for climate device.
def test_aux_heat_set(device_aux_heat): """Test aux heat for climate device.""" device = device_aux_heat assert device.values.primary.data == HVAC_MODE_HEAT device.turn_aux_heat_on() assert device.values.primary.data == AUX_HEAT_ZWAVE_MODE device.turn_aux_heat_off() assert device.values.prim...
[ "def", "test_aux_heat_set", "(", "device_aux_heat", ")", ":", "device", "=", "device_aux_heat", "assert", "device", ".", "values", ".", "primary", ".", "data", "==", "HVAC_MODE_HEAT", "device", ".", "turn_aux_heat_on", "(", ")", "assert", "device", ".", "values"...
[ 870, 0 ]
[ 877, 55 ]
python
fr
['fr', 'en', 'fr']
True
test_aux_heat_value_changed
(device_aux_heat)
Test aux heat for climate device.
Test aux heat for climate device.
def test_aux_heat_value_changed(device_aux_heat): """Test aux heat for climate device.""" device = device_aux_heat assert device.is_aux_heat is False device.values.primary.data = AUX_HEAT_ZWAVE_MODE value_changed(device.values.primary) assert device.is_aux_heat is True device.values.primary....
[ "def", "test_aux_heat_value_changed", "(", "device_aux_heat", ")", ":", "device", "=", "device_aux_heat", "assert", "device", ".", "is_aux_heat", "is", "False", "device", ".", "values", ".", "primary", ".", "data", "=", "AUX_HEAT_ZWAVE_MODE", "value_changed", "(", ...
[ 880, 0 ]
[ 889, 38 ]
python
fr
['fr', 'en', 'fr']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], )
Set up WLED light based on a config entry.
Set up WLED light based on a config entry.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], ) -> None: """Set up WLED light based on a config entry.""" coordinator: WLEDDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id] platform = entity_platform.c...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", "[", "[", "List", "[", "Entity", "]", ",", "bool", "]", ",", "None", "]", ",", ")", "->", "None", ":...
[ 50, 0 ]
[ 91, 21 ]
python
en
['en', 'da', 'en']
True
async_update_segments
( entry: ConfigEntry, coordinator: WLEDDataUpdateCoordinator, current: Dict[int, WLEDSegmentLight], async_add_entities, )
Update segments.
Update segments.
def async_update_segments( entry: ConfigEntry, coordinator: WLEDDataUpdateCoordinator, current: Dict[int, WLEDSegmentLight], async_add_entities, ) -> None: """Update segments.""" segment_ids = {light.segment_id for light in coordinator.data.state.segments} current_ids = set(current) # D...
[ "def", "async_update_segments", "(", "entry", ":", "ConfigEntry", ",", "coordinator", ":", "WLEDDataUpdateCoordinator", ",", "current", ":", "Dict", "[", "int", ",", "WLEDSegmentLight", "]", ",", "async_add_entities", ",", ")", "->", "None", ":", "segment_ids", ...
[ 397, 0 ]
[ 434, 9 ]
python
co
['it', 'co', 'en']
False
async_remove_entity
( index: int, coordinator: WLEDDataUpdateCoordinator, current: Dict[int, WLEDSegmentLight], )
Remove WLED segment light from Home Assistant.
Remove WLED segment light from Home Assistant.
async def async_remove_entity( index: int, coordinator: WLEDDataUpdateCoordinator, current: Dict[int, WLEDSegmentLight], ) -> None: """Remove WLED segment light from Home Assistant.""" entity = current[index] await entity.async_remove() registry = await async_get_entity_registry(coordinator....
[ "async", "def", "async_remove_entity", "(", "index", ":", "int", ",", "coordinator", ":", "WLEDDataUpdateCoordinator", ",", "current", ":", "Dict", "[", "int", ",", "WLEDSegmentLight", "]", ",", ")", "->", "None", ":", "entity", "=", "current", "[", "index",...
[ 437, 0 ]
[ 448, 22 ]
python
en
['en', 'en', 'en']
True
WLEDMasterLight.__init__
(self, entry_id: str, coordinator: WLEDDataUpdateCoordinator)
Initialize WLED master light.
Initialize WLED master light.
def __init__(self, entry_id: str, coordinator: WLEDDataUpdateCoordinator): """Initialize WLED master light.""" super().__init__( entry_id=entry_id, coordinator=coordinator, name=f"{coordinator.data.info.name} Master", icon="mdi:led-strip-variant", ...
[ "def", "__init__", "(", "self", ",", "entry_id", ":", "str", ",", "coordinator", ":", "WLEDDataUpdateCoordinator", ")", ":", "super", "(", ")", ".", "__init__", "(", "entry_id", "=", "entry_id", ",", "coordinator", "=", "coordinator", ",", "name", "=", "f\...
[ 97, 4 ]
[ 104, 9 ]
python
en
['fr', 'zu', 'en']
False
WLEDMasterLight.unique_id
(self)
Return the unique ID for this sensor.
Return the unique ID for this sensor.
def unique_id(self) -> str: """Return the unique ID for this sensor.""" return f"{self.coordinator.data.info.mac_address}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self.coordinator.data.info.mac_address}\"" ]
[ 107, 4 ]
[ 109, 58 ]
python
en
['en', 'la', 'en']
True
WLEDMasterLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self) -> int: """Flag supported features.""" return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_BRIGHTNESS", "|", "SUPPORT_TRANSITION" ]
[ 112, 4 ]
[ 114, 54 ]
python
en
['da', 'en', 'en']
True
WLEDMasterLight.brightness
(self)
Return the brightness of this light between 1..255.
Return the brightness of this light between 1..255.
def brightness(self) -> Optional[int]: """Return the brightness of this light between 1..255.""" return self.coordinator.data.state.brightness
[ "def", "brightness", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "return", "self", ".", "coordinator", ".", "data", ".", "state", ".", "brightness" ]
[ 117, 4 ]
[ 119, 53 ]
python
en
['en', 'en', 'en']
True
WLEDMasterLight.is_on
(self)
Return the state of the light.
Return the state of the light.
def is_on(self) -> bool: """Return the state of the light.""" return bool(self.coordinator.data.state.on)
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "coordinator", ".", "data", ".", "state", ".", "on", ")" ]
[ 122, 4 ]
[ 124, 51 ]
python
en
['en', 'en', 'en']
True
WLEDMasterLight.async_turn_off
(self, **kwargs: Any)
Turn off the light.
Turn off the light.
async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the light.""" data = {ATTR_ON: False} if ATTR_TRANSITION in kwargs: # WLED uses 100ms per unit, so 10 = 1 second. data[ATTR_TRANSITION] = round(kwargs[ATTR_TRANSITION] * 10) await self.coordinato...
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "data", "=", "{", "ATTR_ON", ":", "False", "}", "if", "ATTR_TRANSITION", "in", "kwargs", ":", "# WLED uses 100ms per unit, so 10 = 1 second.", "data", ...
[ 127, 4 ]
[ 135, 50 ]
python
en
['en', 'zh', 'en']
True
WLEDMasterLight.async_turn_on
(self, **kwargs: Any)
Turn on the light.
Turn on the light.
async def async_turn_on(self, **kwargs: Any) -> None: """Turn on the light.""" data = {ATTR_ON: True} if ATTR_TRANSITION in kwargs: # WLED uses 100ms per unit, so 10 = 1 second. data[ATTR_TRANSITION] = round(kwargs[ATTR_TRANSITION] * 10) if ATTR_BRIGHTNESS in kw...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "data", "=", "{", "ATTR_ON", ":", "True", "}", "if", "ATTR_TRANSITION", "in", "kwargs", ":", "# WLED uses 100ms per unit, so 10 = 1 second.", "data", "...
[ 138, 4 ]
[ 149, 50 ]
python
en
['en', 'et', 'en']
True
WLEDSegmentLight.__init__
( self, entry_id: str, coordinator: WLEDDataUpdateCoordinator, segment: int )
Initialize WLED segment light.
Initialize WLED segment light.
def __init__( self, entry_id: str, coordinator: WLEDDataUpdateCoordinator, segment: int ): """Initialize WLED segment light.""" self._rgbw = coordinator.data.info.leds.rgbw self._segment = segment # If this is the one and only segment, use a simpler name name = f"{co...
[ "def", "__init__", "(", "self", ",", "entry_id", ":", "str", ",", "coordinator", ":", "WLEDDataUpdateCoordinator", ",", "segment", ":", "int", ")", ":", "self", ".", "_rgbw", "=", "coordinator", ".", "data", ".", "info", ".", "leds", ".", "rgbw", "self",...
[ 155, 4 ]
[ 172, 9 ]
python
en
['ca', 'en', 'en']
True
WLEDSegmentLight.unique_id
(self)
Return the unique ID for this sensor.
Return the unique ID for this sensor.
def unique_id(self) -> str: """Return the unique ID for this sensor.""" return f"{self.coordinator.data.info.mac_address}_{self._segment}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self.coordinator.data.info.mac_address}_{self._segment}\"" ]
[ 175, 4 ]
[ 177, 74 ]
python
en
['en', 'la', 'en']
True
WLEDSegmentLight.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" try: self.coordinator.data.state.segments[self._segment] except IndexError: return False return super().available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "try", ":", "self", ".", "coordinator", ".", "data", ".", "state", ".", "segments", "[", "self", ".", "_segment", "]", "except", "IndexError", ":", "return", "False", "return", "super", "(", ")",...
[ 180, 4 ]
[ 187, 32 ]
python
en
['en', 'en', 'en']
True
WLEDSegmentLight.device_state_attributes
(self)
Return the state attributes of the entity.
Return the state attributes of the entity.
def device_state_attributes(self) -> Optional[Dict[str, Any]]: """Return the state attributes of the entity.""" playlist = self.coordinator.data.state.playlist if playlist == -1: playlist = None preset = self.coordinator.data.state.preset if preset == -1: ...
[ "def", "device_state_attributes", "(", "self", ")", "->", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "playlist", "=", "self", ".", "coordinator", ".", "data", ".", "state", ".", "playlist", "if", "playlist", "==", "-", "1", ":", ...
[ 190, 4 ]
[ 208, 9 ]
python
en
['en', 'en', 'en']
True
WLEDSegmentLight.hs_color
(self)
Return the hue and saturation color value [float, float].
Return the hue and saturation color value [float, float].
def hs_color(self) -> Optional[Tuple[float, float]]: """Return the hue and saturation color value [float, float].""" color = self.coordinator.data.state.segments[self._segment].color_primary return color_util.color_RGB_to_hs(*color[:3])
[ "def", "hs_color", "(", "self", ")", "->", "Optional", "[", "Tuple", "[", "float", ",", "float", "]", "]", ":", "color", "=", "self", ".", "coordinator", ".", "data", ".", "state", ".", "segments", "[", "self", ".", "_segment", "]", ".", "color_prima...
[ 211, 4 ]
[ 214, 53 ]
python
en
['en', 'en', 'en']
True
WLEDSegmentLight.effect
(self)
Return the current effect of the light.
Return the current effect of the light.
def effect(self) -> Optional[str]: """Return the current effect of the light.""" return self.coordinator.data.state.segments[self._segment].effect.name
[ "def", "effect", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "coordinator", ".", "data", ".", "state", ".", "segments", "[", "self", ".", "_segment", "]", ".", "effect", ".", "name" ]
[ 217, 4 ]
[ 219, 78 ]
python
en
['en', 'en', 'en']
True
WLEDSegmentLight.brightness
(self)
Return the brightness of this light between 1..255.
Return the brightness of this light between 1..255.
def brightness(self) -> Optional[int]: """Return the brightness of this light between 1..255.""" state = self.coordinator.data.state # If this is the one and only segment, calculate brightness based # on the master and segment brightness if len(state.segments) == 1: ...
[ "def", "brightness", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "state", "=", "self", ".", "coordinator", ".", "data", ".", "state", "# If this is the one and only segment, calculate brightness based", "# on the master and segment brightness", "if", "len"...
[ 222, 4 ]
[ 233, 55 ]
python
en
['en', 'en', 'en']
True
WLEDSegmentLight.white_value
(self)
Return the white value of this light between 0..255.
Return the white value of this light between 0..255.
def white_value(self) -> Optional[int]: """Return the white value of this light between 0..255.""" color = self.coordinator.data.state.segments[self._segment].color_primary return color[-1] if self._rgbw else None
[ "def", "white_value", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "color", "=", "self", ".", "coordinator", ".", "data", ".", "state", ".", "segments", "[", "self", ".", "_segment", "]", ".", "color_primary", "return", "color", "[", "-", ...
[ 236, 4 ]
[ 239, 48 ]
python
en
['en', 'en', 'en']
True
WLEDSegmentLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self) -> int: """Flag supported features.""" flags = ( SUPPORT_BRIGHTNESS | SUPPORT_COLOR | SUPPORT_COLOR_TEMP | SUPPORT_EFFECT | SUPPORT_TRANSITION ) if self._rgbw: flags |= SUPPORT_WHITE_VAL...
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "flags", "=", "(", "SUPPORT_BRIGHTNESS", "|", "SUPPORT_COLOR", "|", "SUPPORT_COLOR_TEMP", "|", "SUPPORT_EFFECT", "|", "SUPPORT_TRANSITION", ")", "if", "self", ".", "_rgbw", ":", "flags", "|=", "S...
[ 242, 4 ]
[ 255, 20 ]
python
en
['da', 'en', 'en']
True
WLEDSegmentLight.effect_list
(self)
Return the list of supported effects.
Return the list of supported effects.
def effect_list(self) -> List[str]: """Return the list of supported effects.""" return [effect.name for effect in self.coordinator.data.effects]
[ "def", "effect_list", "(", "self", ")", "->", "List", "[", "str", "]", ":", "return", "[", "effect", ".", "name", "for", "effect", "in", "self", ".", "coordinator", ".", "data", ".", "effects", "]" ]
[ 258, 4 ]
[ 260, 72 ]
python
en
['en', 'en', 'en']
True
WLEDSegmentLight.is_on
(self)
Return the state of the light.
Return the state of the light.
def is_on(self) -> bool: """Return the state of the light.""" state = self.coordinator.data.state # If there is a single segment, take master into account if len(state.segments) == 1 and not state.on: return False return bool(state.segments[self._segment].on)
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "state", "=", "self", ".", "coordinator", ".", "data", ".", "state", "# If there is a single segment, take master into account", "if", "len", "(", "state", ".", "segments", ")", "==", "1", "and", "not", "s...
[ 263, 4 ]
[ 271, 53 ]
python
en
['en', 'en', 'en']
True
WLEDSegmentLight.async_turn_off
(self, **kwargs: Any)
Turn off the light.
Turn off the light.
async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the light.""" data = {ATTR_ON: False} if ATTR_TRANSITION in kwargs: # WLED uses 100ms per unit, so 10 = 1 second. data[ATTR_TRANSITION] = round(kwargs[ATTR_TRANSITION] * 10) # If there is a singl...
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "data", "=", "{", "ATTR_ON", ":", "False", "}", "if", "ATTR_TRANSITION", "in", "kwargs", ":", "# WLED uses 100ms per unit, so 10 = 1 second.", "data", ...
[ 274, 4 ]
[ 288, 51 ]
python
en
['en', 'zh', 'en']
True
WLEDSegmentLight.async_turn_on
(self, **kwargs: Any)
Turn on the light.
Turn on the light.
async def async_turn_on(self, **kwargs: Any) -> None: """Turn on the light.""" data = {ATTR_ON: True, ATTR_SEGMENT_ID: self._segment} if ATTR_COLOR_TEMP in kwargs: mireds = color_util.color_temperature_kelvin_to_mired( kwargs[ATTR_COLOR_TEMP] ) ...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "data", "=", "{", "ATTR_ON", ":", "True", ",", "ATTR_SEGMENT_ID", ":", "self", ".", "_segment", "}", "if", "ATTR_COLOR_TEMP", "in", "kwargs", ":"...
[ 291, 4 ]
[ 354, 51 ]
python
en
['en', 'et', 'en']
True
WLEDSegmentLight.async_effect
( self, effect: Optional[Union[int, str]] = None, intensity: Optional[int] = None, palette: Optional[Union[int, str]] = None, reverse: Optional[bool] = None, speed: Optional[int] = None, )
Set the effect of a WLED light.
Set the effect of a WLED light.
async def async_effect( self, effect: Optional[Union[int, str]] = None, intensity: Optional[int] = None, palette: Optional[Union[int, str]] = None, reverse: Optional[bool] = None, speed: Optional[int] = None, ) -> None: """Set the effect of a WLED light.""" ...
[ "async", "def", "async_effect", "(", "self", ",", "effect", ":", "Optional", "[", "Union", "[", "int", ",", "str", "]", "]", "=", "None", ",", "intensity", ":", "Optional", "[", "int", "]", "=", "None", ",", "palette", ":", "Optional", "[", "Union", ...
[ 357, 4 ]
[ 383, 51 ]
python
en
['en', 'en', 'en']
True
WLEDSegmentLight.async_preset
( self, preset: int, )
Set a WLED light to a saved preset.
Set a WLED light to a saved preset.
async def async_preset( self, preset: int, ) -> None: """Set a WLED light to a saved preset.""" data = {ATTR_PRESET: preset} await self.coordinator.wled.preset(**data)
[ "async", "def", "async_preset", "(", "self", ",", "preset", ":", "int", ",", ")", "->", "None", ":", "data", "=", "{", "ATTR_PRESET", ":", "preset", "}", "await", "self", ".", "coordinator", ".", "wled", ".", "preset", "(", "*", "*", "data", ")" ]
[ 386, 4 ]
[ 393, 50 ]
python
en
['en', 'su', 'en']
True
met_setup_fixture
()
Patch met setup entry.
Patch met setup entry.
def met_setup_fixture(): """Patch met setup entry.""" with patch("homeassistant.components.met.async_setup_entry", return_value=True): yield
[ "def", "met_setup_fixture", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.met.async_setup_entry\"", ",", "return_value", "=", "True", ")", ":", "yield" ]
[ 11, 0 ]
[ 14, 13 ]
python
en
['en', 'en', 'en']
True
test_show_config_form
(hass)
Test show configuration form.
Test show configuration form.
async def test_show_config_form(hass): """Test show configuration form.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "user"} ) assert result["type"] == "form" assert result["step_id"] == "user"
[ "async", "def", "test_show_config_form", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"user\"", "}", ")", "assert", "result", "["...
[ 17, 0 ]
[ 24, 38 ]
python
en
['en', 'fr', 'en']
True
test_flow_with_home_location
(hass)
Test config flow. Test the flow when a default location is configured. Then it should return a form with default values.
Test config flow.
async def test_flow_with_home_location(hass): """Test config flow. Test the flow when a default location is configured. Then it should return a form with default values. """ hass.config.latitude = 1 hass.config.longitude = 2 hass.config.elevation = 3 result = await hass.config_entries....
[ "async", "def", "test_flow_with_home_location", "(", "hass", ")", ":", "hass", ".", "config", ".", "latitude", "=", "1", "hass", ".", "config", ".", "longitude", "=", "2", "hass", ".", "config", ".", "elevation", "=", "3", "result", "=", "await", "hass",...
[ 27, 0 ]
[ 48, 41 ]
python
da
['de', 'da', 'en']
False
test_create_entry
(hass)
Test create entry from user input.
Test create entry from user input.
async def test_create_entry(hass): """Test create entry from user input.""" test_data = { "name": "home", CONF_LONGITUDE: 0, CONF_LATITUDE: 0, CONF_ELEVATION: 0, } result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "user"}, data=test_d...
[ "async", "def", "test_create_entry", "(", "hass", ")", ":", "test_data", "=", "{", "\"name\"", ":", "\"home\"", ",", "CONF_LONGITUDE", ":", "0", ",", "CONF_LATITUDE", ":", "0", ",", "CONF_ELEVATION", ":", "0", ",", "}", "result", "=", "await", "hass", "....
[ 51, 0 ]
[ 66, 38 ]
python
en
['en', 'en', 'en']
True
test_flow_entry_already_exists
(hass)
Test user input for config_entry that already exists. Test when the form should show when user puts existing location in the config gui. Then the form should show with error.
Test user input for config_entry that already exists.
async def test_flow_entry_already_exists(hass): """Test user input for config_entry that already exists. Test when the form should show when user puts existing location in the config gui. Then the form should show with error. """ first_entry = MockConfigEntry( domain="met", data={"n...
[ "async", "def", "test_flow_entry_already_exists", "(", "hass", ")", ":", "first_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"met\"", ",", "data", "=", "{", "\"name\"", ":", "\"home\"", ",", "CONF_LATITUDE", ":", "0", ",", "CONF_LONGITUDE", ":", "0", ...
[ 69, 0 ]
[ 93, 59 ]
python
en
['en', 'en', 'en']
True
test_onboarding_step
(hass)
Test initializing via onboarding step.
Test initializing via onboarding step.
async def test_onboarding_step(hass): """Test initializing via onboarding step.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "onboarding"}, data={} ) assert result["type"] == "create_entry" assert result["title"] == HOME_LOCATION_NAME assert result["...
[ "async", "def", "test_onboarding_step", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"onboarding\"", "}", ",", "data", "=", "{", ...
[ 96, 0 ]
[ 104, 49 ]
python
en
['nl', 'en', 'en']
True
test_import_step
(hass)
Test initializing via import step.
Test initializing via import step.
async def test_import_step(hass): """Test initializing via import step.""" test_data = { "name": "home", CONF_LONGITUDE: None, CONF_LATITUDE: None, CONF_ELEVATION: 0, "track_home": True, } result = await hass.config_entries.flow.async_init( DOMAIN, context...
[ "async", "def", "test_import_step", "(", "hass", ")", ":", "test_data", "=", "{", "\"name\"", ":", "\"home\"", ",", "CONF_LONGITUDE", ":", "None", ",", "CONF_LATITUDE", ":", "None", ",", "CONF_ELEVATION", ":", "0", ",", "\"track_home\"", ":", "True", ",", ...
[ 107, 0 ]
[ 122, 38 ]
python
en
['nl', 'zu', 'en']
False
get_arguments
()
Get parsed passed in arguments.
Get parsed passed in arguments.
def get_arguments() -> argparse.Namespace: """Get parsed passed in arguments.""" return util.get_base_arg_parser().parse_known_args()[0]
[ "def", "get_arguments", "(", ")", "->", "argparse", ".", "Namespace", ":", "return", "util", ".", "get_base_arg_parser", "(", ")", ".", "parse_known_args", "(", ")", "[", "0", "]" ]
[ 9, 0 ]
[ 11, 59 ]
python
en
['en', 'la', 'en']
True
main
()
Run a translation script.
Run a translation script.
def main(): """Run a translation script.""" if not Path("requirements_all.txt").is_file(): print("Run from project root") return 1 args = get_arguments() module = importlib.import_module(f".{args.action}", "script.translations") return module.run()
[ "def", "main", "(", ")", ":", "if", "not", "Path", "(", "\"requirements_all.txt\"", ")", ".", "is_file", "(", ")", ":", "print", "(", "\"Run from project root\"", ")", "return", "1", "args", "=", "get_arguments", "(", ")", "module", "=", "importlib", ".", ...
[ 14, 0 ]
[ 23, 23 ]
python
co
['ro', 'co', 'en']
False
create_air_quality_sensor_service
(accessory)
Define temperature characteristics.
Define temperature characteristics.
def create_air_quality_sensor_service(accessory): """Define temperature characteristics.""" service = accessory.add_service(ServicesTypes.AIR_QUALITY_SENSOR) cur_state = service.add_char(CharacteristicsTypes.AIR_QUALITY) cur_state.value = 5 cur_state = service.add_char(CharacteristicsTypes.DENSITY...
[ "def", "create_air_quality_sensor_service", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "AIR_QUALITY_SENSOR", ")", "cur_state", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "AIR_QUALITY"...
[ 7, 0 ]
[ 30, 26 ]
python
en
['en', 'ca', 'en']
True
test_air_quality_sensor_read_state
(hass, utcnow)
Test reading the state of a HomeKit temperature sensor accessory.
Test reading the state of a HomeKit temperature sensor accessory.
async def test_air_quality_sensor_read_state(hass, utcnow): """Test reading the state of a HomeKit temperature sensor accessory.""" helper = await setup_test_component(hass, create_air_quality_sensor_service) state = await helper.poll_and_get_state() assert state.state == "4444" assert state.attri...
[ "async", "def", "test_air_quality_sensor_read_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_air_quality_sensor_service", ")", "state", "=", "await", "helper", ".", "poll_and_get_state", "(", "...
[ 33, 0 ]
[ 46, 65 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities )
Set up Toon sensors based on a config entry.
Set up Toon sensors based on a config entry.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None: """Set up Toon sensors based on a config entry.""" coordinator = hass.data[DOMAIN][entry.entry_id] sensors = [ ToonElectricityMeterDeviceSensor(coordinator, key=key) for key in ( ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "coordinator", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "s...
[ 29, 0 ]
[ 108, 37 ]
python
en
['en', 'en', 'en']
True
ToonSensor.__init__
(self, coordinator: ToonDataUpdateCoordinator, *, key: str)
Initialize the Toon sensor.
Initialize the Toon sensor.
def __init__(self, coordinator: ToonDataUpdateCoordinator, *, key: str) -> None: """Initialize the Toon sensor.""" self.key = key super().__init__( coordinator, enabled_default=SENSOR_ENTITIES[key][ATTR_DEFAULT_ENABLED], icon=SENSOR_ENTITIES[key][ATTR_ICON], ...
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "ToonDataUpdateCoordinator", ",", "*", ",", "key", ":", "str", ")", "->", "None", ":", "self", ".", "key", "=", "key", "super", "(", ")", ".", "__init__", "(", "coordinator", ",", "enabled_default"...
[ 114, 4 ]
[ 123, 9 ]
python
en
['en', 'en', 'en']
True
ToonSensor.unique_id
(self)
Return the unique ID for this sensor.
Return the unique ID for this sensor.
def unique_id(self) -> str: """Return the unique ID for this sensor.""" agreement_id = self.coordinator.data.agreement.agreement_id # This unique ID is a bit ugly and contains unneeded information. # It is here for legacy / backward compatible reasons. return f"{DOMAIN}_{agreemen...
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "agreement_id", "=", "self", ".", "coordinator", ".", "data", ".", "agreement", ".", "agreement_id", "# This unique ID is a bit ugly and contains unneeded information.", "# It is here for legacy / backward compatible rea...
[ 126, 4 ]
[ 131, 59 ]
python
en
['en', 'la', 'en']
True
ToonSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self) -> Optional[str]: """Return the state of the sensor.""" section = getattr( self.coordinator.data, SENSOR_ENTITIES[self.key][ATTR_SECTION] ) return getattr(section, SENSOR_ENTITIES[self.key][ATTR_MEASUREMENT])
[ "def", "state", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "section", "=", "getattr", "(", "self", ".", "coordinator", ".", "data", ",", "SENSOR_ENTITIES", "[", "self", ".", "key", "]", "[", "ATTR_SECTION", "]", ")", "return", "getattr",...
[ 134, 4 ]
[ 139, 76 ]
python
en
['en', 'en', 'en']
True
ToonSensor.unit_of_measurement
(self)
Return the unit this state is expressed in.
Return the unit this state is expressed in.
def unit_of_measurement(self) -> Optional[str]: """Return the unit this state is expressed in.""" return SENSOR_ENTITIES[self.key][ATTR_UNIT_OF_MEASUREMENT]
[ "def", "unit_of_measurement", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "SENSOR_ENTITIES", "[", "self", ".", "key", "]", "[", "ATTR_UNIT_OF_MEASUREMENT", "]" ]
[ 142, 4 ]
[ 144, 66 ]
python
en
['en', 'en', 'en']
True
ToonSensor.device_class
(self)
Return the device class.
Return the device class.
def device_class(self) -> Optional[str]: """Return the device class.""" return SENSOR_ENTITIES[self.key][ATTR_DEVICE_CLASS]
[ "def", "device_class", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "SENSOR_ENTITIES", "[", "self", ".", "key", "]", "[", "ATTR_DEVICE_CLASS", "]" ]
[ 147, 4 ]
[ 149, 59 ]
python
en
['en', 'en', 'en']
True
init_integration
( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, rgbw: bool = False, skip_setup: bool = False, )
Set up the Atag integration in Home Assistant.
Set up the Atag integration in Home Assistant.
async def init_integration( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, rgbw: bool = False, skip_setup: bool = False, ) -> MockConfigEntry: """Set up the Atag integration in Home Assistant.""" aioclient_mock.post( "http://127.0.0.1:10000/retrieve", json=RECEIVE_REP...
[ "async", "def", "init_integration", "(", "hass", ":", "HomeAssistant", ",", "aioclient_mock", ":", "AiohttpClientMocker", ",", "rgbw", ":", "bool", "=", "False", ",", "skip_setup", ":", "bool", "=", "False", ",", ")", "->", "MockConfigEntry", ":", "aioclient_m...
[ 53, 0 ]
[ 84, 16 ]
python
en
['en', 'en', 'en']
True
json_message_response
(message: str, message_code: int)
Produce common json output.
Produce common json output.
def json_message_response(message: str, message_code: int) -> Response: """Produce common json output.""" return HomeAssistantView.json({"message": message, "code": message_code}, 200)
[ "def", "json_message_response", "(", "message", ":", "str", ",", "message_code", ":", "int", ")", "->", "Response", ":", "return", "HomeAssistantView", ".", "json", "(", "{", "\"message\"", ":", "message", ",", "\"code\"", ":", "message_code", "}", ",", "200...
[ 505, 0 ]
[ 507, 82 ]
python
en
['fi', 'fr', 'en']
False
get_attribute_unique_id
(attribute: WithingsAttribute, user_id: int)
Get a entity unique id for a user's attribute.
Get a entity unique id for a user's attribute.
def get_attribute_unique_id(attribute: WithingsAttribute, user_id: int) -> str: """Get a entity unique id for a user's attribute.""" return f"withings_{user_id}_{attribute.measurement.value}"
[ "def", "get_attribute_unique_id", "(", "attribute", ":", "WithingsAttribute", ",", "user_id", ":", "int", ")", "->", "str", ":", "return", "f\"withings_{user_id}_{attribute.measurement.value}\"" ]
[ 902, 0 ]
[ 904, 62 ]
python
en
['en', 'en', 'en']
True
async_get_entity_id
( hass: HomeAssistant, attribute: WithingsAttribute, user_id: int )
Get an entity id for a user's attribute.
Get an entity id for a user's attribute.
async def async_get_entity_id( hass: HomeAssistant, attribute: WithingsAttribute, user_id: int ) -> Optional[str]: """Get an entity id for a user's attribute.""" entity_registry: EntityRegistry = ( await hass.helpers.entity_registry.async_get_registry() ) unique_id = get_attribute_unique_id(...
[ "async", "def", "async_get_entity_id", "(", "hass", ":", "HomeAssistant", ",", "attribute", ":", "WithingsAttribute", ",", "user_id", ":", "int", ")", "->", "Optional", "[", "str", "]", ":", "entity_registry", ":", "EntityRegistry", "=", "(", "await", "hass", ...
[ 907, 0 ]
[ 924, 20 ]
python
en
['en', 'en', 'en']
True
async_get_data_manager
( hass: HomeAssistant, config_entry: ConfigEntry )
Get the data manager for a config entry.
Get the data manager for a config entry.
async def async_get_data_manager( hass: HomeAssistant, config_entry: ConfigEntry ) -> DataManager: """Get the data manager for a config entry.""" hass.data.setdefault(const.DOMAIN, {}) hass.data[const.DOMAIN].setdefault(config_entry.entry_id, {}) config_entry_data = hass.data[const.DOMAIN][config_en...
[ "async", "def", "async_get_data_manager", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ")", "->", "DataManager", ":", "hass", ".", "data", ".", "setdefault", "(", "const", ".", "DOMAIN", ",", "{", "}", ")", "hass", ".", "data...
[ 1020, 0 ]
[ 1050, 48 ]
python
en
['en', 'en', 'en']
True
get_data_manager_by_webhook_id
( hass: HomeAssistant, webhook_id: str )
Get a data manager by it's webhook id.
Get a data manager by it's webhook id.
def get_data_manager_by_webhook_id( hass: HomeAssistant, webhook_id: str ) -> Optional[DataManager]: """Get a data manager by it's webhook id.""" return next( iter( [ data_manager for data_manager in get_all_data_managers(hass) if data_mana...
[ "def", "get_data_manager_by_webhook_id", "(", "hass", ":", "HomeAssistant", ",", "webhook_id", ":", "str", ")", "->", "Optional", "[", "DataManager", "]", ":", "return", "next", "(", "iter", "(", "[", "data_manager", "for", "data_manager", "in", "get_all_data_ma...
[ 1053, 0 ]
[ 1066, 5 ]
python
en
['en', 'en', 'en']
True
get_all_data_managers
(hass: HomeAssistant)
Get all configured data managers.
Get all configured data managers.
def get_all_data_managers(hass: HomeAssistant) -> Tuple[DataManager, ...]: """Get all configured data managers.""" return tuple( [ config_entry_data[const.DATA_MANAGER] for config_entry_data in hass.data[const.DOMAIN].values() if const.DATA_MANAGER in config_entry_dat...
[ "def", "get_all_data_managers", "(", "hass", ":", "HomeAssistant", ")", "->", "Tuple", "[", "DataManager", ",", "...", "]", ":", "return", "tuple", "(", "[", "config_entry_data", "[", "const", ".", "DATA_MANAGER", "]", "for", "config_entry_data", "in", "hass",...
[ 1069, 0 ]
[ 1077, 5 ]
python
en
['en', 'en', 'en']
True
async_remove_data_manager
(hass: HomeAssistant, config_entry: ConfigEntry)
Remove a data manager for a config entry.
Remove a data manager for a config entry.
def async_remove_data_manager(hass: HomeAssistant, config_entry: ConfigEntry) -> None: """Remove a data manager for a config entry.""" del hass.data[const.DOMAIN][config_entry.entry_id][const.DATA_MANAGER]
[ "def", "async_remove_data_manager", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ")", "->", "None", ":", "del", "hass", ".", "data", "[", "const", ".", "DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "[", "const", "...
[ 1080, 0 ]
[ 1082, 74 ]
python
en
['en', 'en', 'en']
True
async_create_entities
( hass: HomeAssistant, entry: ConfigEntry, create_func: Callable[[DataManager, WithingsAttribute], Entity], platform: str, )
Create withings entities from config entry.
Create withings entities from config entry.
async def async_create_entities( hass: HomeAssistant, entry: ConfigEntry, create_func: Callable[[DataManager, WithingsAttribute], Entity], platform: str, ) -> List[Entity]: """Create withings entities from config entry.""" data_manager = await async_get_data_manager(hass, entry) return [ ...
[ "async", "def", "async_create_entities", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "create_func", ":", "Callable", "[", "[", "DataManager", ",", "WithingsAttribute", "]", ",", "Entity", "]", ",", "platform", ":", "str", ",", "...
[ 1085, 0 ]
[ 1097, 5 ]
python
en
['en', 'en', 'en']
True
get_platform_attributes
(platform: str)
Get withings attributes used for a specific platform.
Get withings attributes used for a specific platform.
def get_platform_attributes(platform: str) -> Tuple[WithingsAttribute, ...]: """Get withings attributes used for a specific platform.""" return tuple( [ attribute for attribute in WITHINGS_ATTRIBUTES if attribute.platform == platform ] )
[ "def", "get_platform_attributes", "(", "platform", ":", "str", ")", "->", "Tuple", "[", "WithingsAttribute", ",", "...", "]", ":", "return", "tuple", "(", "[", "attribute", "for", "attribute", "in", "WITHINGS_ATTRIBUTES", "if", "attribute", ".", "platform", "=...
[ 1100, 0 ]
[ 1108, 5 ]
python
en
['en', 'en', 'en']
True
ConfigEntryWithingsApi.__init__
( self, hass: HomeAssistant, config_entry: ConfigEntry, implementation: AbstractOAuth2Implementation, )
Initialize object.
Initialize object.
def __init__( self, hass: HomeAssistant, config_entry: ConfigEntry, implementation: AbstractOAuth2Implementation, ): """Initialize object.""" self._hass = hass self._config_entry = config_entry self._implementation = implementation self.session...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ",", "implementation", ":", "AbstractOAuth2Implementation", ",", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_config_entry", "=", "config...
[ 475, 4 ]
[ 485, 72 ]
python
en
['en', 'en', 'it']
False
ConfigEntryWithingsApi._request
( self, path: str, params: Dict[str, Any], method: str = "GET" )
Perform an async request.
Perform an async request.
def _request( self, path: str, params: Dict[str, Any], method: str = "GET" ) -> Dict[str, Any]: """Perform an async request.""" asyncio.run_coroutine_threadsafe( self.session.async_ensure_token_valid(), self._hass.loop ) access_token = self._config_entry.data["to...
[ "def", "_request", "(", "self", ",", "path", ":", "str", ",", "params", ":", "Dict", "[", "str", ",", "Any", "]", ",", "method", ":", "str", "=", "\"GET\"", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "asyncio", ".", "run_coroutine_threads...
[ 487, 4 ]
[ 502, 30 ]
python
en
['en', 'en', 'en']
True
WebhookUpdateCoordinator.__init__
(self, hass: HomeAssistant, user_id: int)
Initialize the object.
Initialize the object.
def __init__(self, hass: HomeAssistant, user_id: int) -> None: """Initialize the object.""" self._hass = hass self._user_id = user_id self._listeners: List[CALLBACK_TYPE] = [] self.data: MeasurementData = {}
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "user_id", ":", "int", ")", "->", "None", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_user_id", "=", "user_id", "self", ".", "_listeners", ":", "List", "[", "CALLBACK_TY...
[ 522, 4 ]
[ 527, 39 ]
python
en
['en', 'en', 'en']
True
WebhookUpdateCoordinator.async_add_listener
(self, listener: CALLBACK_TYPE)
Add a listener.
Add a listener.
def async_add_listener(self, listener: CALLBACK_TYPE) -> Callable[[], None]: """Add a listener.""" self._listeners.append(listener) @callback def remove_listener() -> None: self.async_remove_listener(listener) return remove_listener
[ "def", "async_add_listener", "(", "self", ",", "listener", ":", "CALLBACK_TYPE", ")", "->", "Callable", "[", "[", "]", ",", "None", "]", ":", "self", ".", "_listeners", ".", "append", "(", "listener", ")", "@", "callback", "def", "remove_listener", "(", ...
[ 529, 4 ]
[ 537, 30 ]
python
en
['en', 'cy', 'en']
True
WebhookUpdateCoordinator.async_remove_listener
(self, listener: CALLBACK_TYPE)
Remove a listener.
Remove a listener.
def async_remove_listener(self, listener: CALLBACK_TYPE) -> None: """Remove a listener.""" self._listeners.remove(listener)
[ "def", "async_remove_listener", "(", "self", ",", "listener", ":", "CALLBACK_TYPE", ")", "->", "None", ":", "self", ".", "_listeners", ".", "remove", "(", "listener", ")" ]
[ 539, 4 ]
[ 541, 40 ]
python
en
['es', 'it', 'en']
False
WebhookUpdateCoordinator.update_data
(self, measurement: Measurement, value: Any)
Update the data object and notify listeners the data has changed.
Update the data object and notify listeners the data has changed.
def update_data(self, measurement: Measurement, value: Any) -> None: """Update the data object and notify listeners the data has changed.""" self.data[measurement] = value self.notify_data_changed()
[ "def", "update_data", "(", "self", ",", "measurement", ":", "Measurement", ",", "value", ":", "Any", ")", "->", "None", ":", "self", ".", "data", "[", "measurement", "]", "=", "value", "self", ".", "notify_data_changed", "(", ")" ]
[ 543, 4 ]
[ 546, 34 ]
python
en
['en', 'en', 'en']
True
WebhookUpdateCoordinator.notify_data_changed
(self)
Notify all listeners the data has changed.
Notify all listeners the data has changed.
def notify_data_changed(self) -> None: """Notify all listeners the data has changed.""" for listener in self._listeners: listener()
[ "def", "notify_data_changed", "(", "self", ")", "->", "None", ":", "for", "listener", "in", "self", ".", "_listeners", ":", "listener", "(", ")" ]
[ 548, 4 ]
[ 551, 22 ]
python
en
['en', 'en', 'en']
True
DataManager.__init__
( self, hass: HomeAssistant, profile: str, api: ConfigEntryWithingsApi, user_id: int, webhook_config: WebhookConfig, )
Initialize the data manager.
Initialize the data manager.
def __init__( self, hass: HomeAssistant, profile: str, api: ConfigEntryWithingsApi, user_id: int, webhook_config: WebhookConfig, ): """Initialize the data manager.""" self._hass = hass self._api = api self._user_id = user_id sel...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "profile", ":", "str", ",", "api", ":", "ConfigEntryWithingsApi", ",", "user_id", ":", "int", ",", "webhook_config", ":", "WebhookConfig", ",", ")", ":", "self", ".", "_hass", "=", "...
[ 557, 4 ]
[ 603, 45 ]
python
en
['en', 'en', 'en']
True
DataManager.webhook_config
(self)
Get the webhook config.
Get the webhook config.
def webhook_config(self) -> WebhookConfig: """Get the webhook config.""" return self._webhook_config
[ "def", "webhook_config", "(", "self", ")", "->", "WebhookConfig", ":", "return", "self", ".", "_webhook_config" ]
[ 606, 4 ]
[ 608, 35 ]
python
en
['en', 'en', 'en']
True
DataManager.user_id
(self)
Get the user_id of the authenticated user.
Get the user_id of the authenticated user.
def user_id(self) -> int: """Get the user_id of the authenticated user.""" return self._user_id
[ "def", "user_id", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_user_id" ]
[ 611, 4 ]
[ 613, 28 ]
python
en
['en', 'en', 'en']
True
DataManager.profile
(self)
Get the profile.
Get the profile.
def profile(self) -> str: """Get the profile.""" return self._profile
[ "def", "profile", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_profile" ]
[ 616, 4 ]
[ 618, 28 ]
python
en
['en', 'en', 'en']
True
DataManager.async_start_polling_webhook_subscriptions
(self)
Start polling webhook subscriptions (if enabled) to reconcile their setup.
Start polling webhook subscriptions (if enabled) to reconcile their setup.
def async_start_polling_webhook_subscriptions(self) -> None: """Start polling webhook subscriptions (if enabled) to reconcile their setup.""" self.async_stop_polling_webhook_subscriptions() def empty_listener() -> None: pass self._cancel_subscription_update = ( ...
[ "def", "async_start_polling_webhook_subscriptions", "(", "self", ")", "->", "None", ":", "self", ".", "async_stop_polling_webhook_subscriptions", "(", ")", "def", "empty_listener", "(", ")", "->", "None", ":", "pass", "self", ".", "_cancel_subscription_update", "=", ...
[ 620, 4 ]
[ 629, 9 ]
python
en
['en', 'en', 'en']
True
DataManager.async_stop_polling_webhook_subscriptions
(self)
Stop polling webhook subscriptions.
Stop polling webhook subscriptions.
def async_stop_polling_webhook_subscriptions(self) -> None: """Stop polling webhook subscriptions.""" if self._cancel_subscription_update: self._cancel_subscription_update() self._cancel_subscription_update = None
[ "def", "async_stop_polling_webhook_subscriptions", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_cancel_subscription_update", ":", "self", ".", "_cancel_subscription_update", "(", ")", "self", ".", "_cancel_subscription_update", "=", "None" ]
[ 631, 4 ]
[ 635, 51 ]
python
en
['en', 'en', 'en']
True
DataManager._do_retry
(self, func, attempts=3)
Retry a function call. Withings' API occasionally and incorrectly throws errors. Retrying the call tends to work.
Retry a function call.
async def _do_retry(self, func, attempts=3) -> Any: """Retry a function call. Withings' API occasionally and incorrectly throws errors. Retrying the call tends to work. """ exception = None for attempt in range(1, attempts + 1): _LOGGER.debug("Attempt %s of %s", atte...
[ "async", "def", "_do_retry", "(", "self", ",", "func", ",", "attempts", "=", "3", ")", "->", "Any", ":", "exception", "=", "None", "for", "attempt", "in", "range", "(", "1", ",", "attempts", "+", "1", ")", ":", "_LOGGER", ".", "debug", "(", "\"Atte...
[ 637, 4 ]
[ 653, 27 ]
python
en
['en', 'en', 'en']
True
DataManager.async_subscribe_webhook
(self)
Subscribe the webhook to withings data updates.
Subscribe the webhook to withings data updates.
async def async_subscribe_webhook(self) -> None: """Subscribe the webhook to withings data updates.""" return await self._do_retry(self._async_subscribe_webhook)
[ "async", "def", "async_subscribe_webhook", "(", "self", ")", "->", "None", ":", "return", "await", "self", ".", "_do_retry", "(", "self", ".", "_async_subscribe_webhook", ")" ]
[ 655, 4 ]
[ 657, 66 ]
python
en
['en', 'en', 'en']
True
DataManager.async_unsubscribe_webhook
(self)
Unsubscribe webhook from withings data updates.
Unsubscribe webhook from withings data updates.
async def async_unsubscribe_webhook(self) -> None: """Unsubscribe webhook from withings data updates.""" return await self._do_retry(self._async_unsubscribe_webhook)
[ "async", "def", "async_unsubscribe_webhook", "(", "self", ")", "->", "None", ":", "return", "await", "self", ".", "_do_retry", "(", "self", ".", "_async_unsubscribe_webhook", ")" ]
[ 707, 4 ]
[ 709, 68 ]
python
en
['en', 'en', 'en']
True
DataManager.async_get_all_data
(self)
Update all withings data.
Update all withings data.
async def async_get_all_data(self) -> Optional[Dict[MeasureType, Any]]: """Update all withings data.""" try: return await self._do_retry(self._async_get_all_data) except Exception as exception: # User is not authenticated. if isinstance( except...
[ "async", "def", "async_get_all_data", "(", "self", ")", "->", "Optional", "[", "Dict", "[", "MeasureType", ",", "Any", "]", "]", ":", "try", ":", "return", "await", "self", ".", "_do_retry", "(", "self", ".", "_async_get_all_data", ")", "except", "Exceptio...
[ 730, 4 ]
[ 764, 27 ]
python
en
['en', 'en', 'en']
True
DataManager.async_get_measures
(self)
Get the measures data.
Get the measures data.
async def async_get_measures(self) -> Dict[MeasureType, Any]: """Get the measures data.""" _LOGGER.debug("Updating withings measures") response = await self._hass.async_add_executor_job(self._api.measure_get_meas) # Sort from oldest to newest. groups = sorted( query...
[ "async", "def", "async_get_measures", "(", "self", ")", "->", "Dict", "[", "MeasureType", ",", "Any", "]", ":", "_LOGGER", ".", "debug", "(", "\"Updating withings measures\"", ")", "response", "=", "await", "self", ".", "_hass", ".", "async_add_executor_job", ...
[ 773, 4 ]
[ 794, 9 ]
python
en
['en', 'en', 'en']
True
DataManager.async_get_sleep_summary
(self)
Get the sleep summary data.
Get the sleep summary data.
async def async_get_sleep_summary(self) -> Dict[MeasureType, Any]: """Get the sleep summary data.""" _LOGGER.debug("Updating withing sleep summary") now = dt.utcnow() yesterday = now - datetime.timedelta(days=1) yesterday_noon = datetime.datetime( yesterday.year, ...
[ "async", "def", "async_get_sleep_summary", "(", "self", ")", "->", "Dict", "[", "MeasureType", ",", "Any", "]", ":", "_LOGGER", ".", "debug", "(", "\"Updating withing sleep summary\"", ")", "now", "=", "dt", ".", "utcnow", "(", ")", "yesterday", "=", "now", ...
[ 796, 4 ]
[ 884, 9 ]
python
en
['en', 'ga', 'en']
True
DataManager.async_webhook_data_updated
(self, data_category: NotifyAppli)
Handle scenario when data is updated from a webook.
Handle scenario when data is updated from a webook.
async def async_webhook_data_updated(self, data_category: NotifyAppli) -> None: """Handle scenario when data is updated from a webook.""" _LOGGER.debug("Withings webhook triggered") if data_category in { NotifyAppli.WEIGHT, NotifyAppli.CIRCULATORY, NotifyAppli...
[ "async", "def", "async_webhook_data_updated", "(", "self", ",", "data_category", ":", "NotifyAppli", ")", "->", "None", ":", "_LOGGER", ".", "debug", "(", "\"Withings webhook triggered\"", ")", "if", "data_category", "in", "{", "NotifyAppli", ".", "WEIGHT", ",", ...
[ 886, 4 ]
[ 899, 13 ]
python
en
['en', 'en', 'en']
True
BaseWithingsSensor.__init__
(self, data_manager: DataManager, attribute: WithingsAttribute)
Initialize the Withings sensor.
Initialize the Withings sensor.
def __init__(self, data_manager: DataManager, attribute: WithingsAttribute) -> None: """Initialize the Withings sensor.""" self._data_manager = data_manager self._attribute = attribute self._profile = self._data_manager.profile self._user_id = self._data_manager.user_id s...
[ "def", "__init__", "(", "self", ",", "data_manager", ":", "DataManager", ",", "attribute", ":", "WithingsAttribute", ")", "->", "None", ":", "self", ".", "_data_manager", "=", "data_manager", "self", ".", "_attribute", "=", "attribute", "self", ".", "_profile"...
[ 930, 4 ]
[ 938, 46 ]
python
en
['en', 'en', 'en']
True
BaseWithingsSensor.should_poll
(self)
Return False to indicate HA should not poll for changes.
Return False to indicate HA should not poll for changes.
def should_poll(self) -> bool: """Return False to indicate HA should not poll for changes.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 941, 4 ]
[ 943, 20 ]
python
en
['en', 'en', 'en']
True
BaseWithingsSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self) -> str: """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_name" ]
[ 946, 4 ]
[ 948, 25 ]
python
en
['en', 'mi', 'en']
True
BaseWithingsSensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" if self._attribute.update_type == UpdateType.POLL: return self._data_manager.poll_data_update_coordinator.last_update_success if self._attribute.update_type == UpdateType.WEBHOOK: return self._data_ma...
[ "def", "available", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "_attribute", ".", "update_type", "==", "UpdateType", ".", "POLL", ":", "return", "self", ".", "_data_manager", ".", "poll_data_update_coordinator", ".", "last_update_success", "if", "...
[ 951, 4 ]
[ 962, 19 ]
python
en
['en', 'en', 'en']
True
BaseWithingsSensor.unique_id
(self)
Return a unique, Home Assistant friendly identifier for this entity.
Return a unique, Home Assistant friendly identifier for this entity.
def unique_id(self) -> str: """Return a unique, Home Assistant friendly identifier for this entity.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_unique_id" ]
[ 965, 4 ]
[ 967, 30 ]
python
en
['en', 'en', 'en']
True
BaseWithingsSensor.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) -> str: """Return the unit of measurement of this entity, if any.""" return self._attribute.unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_attribute", ".", "unit_of_measurement" ]
[ 970, 4 ]
[ 972, 50 ]
python
en
['en', 'en', 'en']
True
BaseWithingsSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self) -> str: """Icon to use in the frontend, if any.""" return self._attribute.icon
[ "def", "icon", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_attribute", ".", "icon" ]
[ 975, 4 ]
[ 977, 35 ]
python
en
['en', 'en', 'en']
True
BaseWithingsSensor.entity_registry_enabled_default
(self)
Return if the entity should be enabled when first added to the entity registry.
Return if the entity should be enabled when first added to the entity registry.
def entity_registry_enabled_default(self) -> bool: """Return if the entity should be enabled when first added to the entity registry.""" return self._attribute.enabled_by_default
[ "def", "entity_registry_enabled_default", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_attribute", ".", "enabled_by_default" ]
[ 980, 4 ]
[ 982, 49 ]
python
en
['en', 'en', 'en']
True
BaseWithingsSensor._update_state_data
(self, data: MeasurementData)
Update the state data.
Update the state data.
def _update_state_data(self, data: MeasurementData) -> None: """Update the state data.""" self._state_data = data.get(self._attribute.measurement) self.async_write_ha_state()
[ "def", "_update_state_data", "(", "self", ",", "data", ":", "MeasurementData", ")", "->", "None", ":", "self", ".", "_state_data", "=", "data", ".", "get", "(", "self", ".", "_attribute", ".", "measurement", ")", "self", ".", "async_write_ha_state", "(", "...
[ 996, 4 ]
[ 999, 35 ]
python
en
['en', 'en', 'en']
True
BaseWithingsSensor.async_added_to_hass
(self)
Register update dispatcher.
Register update dispatcher.
async def async_added_to_hass(self) -> None: """Register update dispatcher.""" if self._attribute.update_type == UpdateType.POLL: self.async_on_remove( self._data_manager.poll_data_update_coordinator.async_add_listener( self._on_poll_data_updated ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_attribute", ".", "update_type", "==", "UpdateType", ".", "POLL", ":", "self", ".", "async_on_remove", "(", "self", ".", "_data_manager", ".", "poll_data_update_coo...
[ 1001, 4 ]
[ 1017, 43 ]
python
de
['it', 'de', 'en']
False
WithingsLocalOAuth2Implementation.redirect_uri
(self)
Return the redirect uri.
Return the redirect uri.
def redirect_uri(self) -> str: """Return the redirect uri.""" url = get_url(self.hass, allow_internal=False, prefer_cloud=True) return f"{url}{AUTH_CALLBACK_PATH}"
[ "def", "redirect_uri", "(", "self", ")", "->", "str", ":", "url", "=", "get_url", "(", "self", ".", "hass", ",", "allow_internal", "=", "False", ",", "prefer_cloud", "=", "True", ")", "return", "f\"{url}{AUTH_CALLBACK_PATH}\"" ]
[ 1115, 4 ]
[ 1118, 43 ]
python
en
['en', 'hr', 'en']
True
async_setup_entry
( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], )
Set up from config entry.
Set up from config entry.
async def async_setup_entry( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], ) -> None: """Set up from config entry.""" # Grab hosts list once to examine whether the initial fetch has got some data for # us, i.e. if wlan host list is...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", "[", "[", "List", "[", "Entity", "]", ",", "bool", "]", ",", "None", "]", ",", ")", "->", "None...
[ 30, 0 ]
[ 77, 73 ]
python
en
['en', 'en', 'en']
True
async_add_new_entities
( hass: HomeAssistantType, router_url: str, async_add_entities: Callable[[List[Entity], bool], None], tracked: Set[str], )
Add new entities that are not already being tracked.
Add new entities that are not already being tracked.
def async_add_new_entities( hass: HomeAssistantType, router_url: str, async_add_entities: Callable[[List[Entity], bool], None], tracked: Set[str], ) -> None: """Add new entities that are not already being tracked.""" router = hass.data[DOMAIN].routers[router_url] try: hosts = router....
[ "def", "async_add_new_entities", "(", "hass", ":", "HomeAssistantType", ",", "router_url", ":", "str", ",", "async_add_entities", ":", "Callable", "[", "[", "List", "[", "Entity", "]", ",", "bool", "]", ",", "None", "]", ",", "tracked", ":", "Set", "[", ...
[ 81, 0 ]
[ 102, 42 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_get_options_flow
(config_entry)
Return the options flow.
Return the options flow.
def async_get_options_flow(config_entry): """Return the options flow.""" return OptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "OptionsFlowHandler", "(", "config_entry", ")" ]
[ 35, 4 ]
[ 37, 47 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.__init__
(self)
Initialize the config flow.
Initialize the config flow.
def __init__(self): """Initialize the config flow.""" self._discovered_devices = {}
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "_discovered_devices", "=", "{", "}" ]
[ 39, 4 ]
[ 41, 37 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" errors = {} if user_input is not None: if user_input.get(CONF_HOST): try: await self._async_try_connect(user_input[CONF_HOST]) return self.async_cr...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "if", "user_input", ".", "get", "(", "CONF_HOST", ")", ":", "try", ":", "await", "self", ...
[ 43, 4 ]
[ 68, 9 ]
python
en
['en', 'en', 'en']
True