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
RoombaConfigFlow.async_step_link
(self, user_input=None)
Attempt to link with the Roomba. Given a configured host, will ask the user to press the home and target buttons to connect to the device.
Attempt to link with the Roomba.
async def async_step_link(self, user_input=None): """Attempt to link with the Roomba. Given a configured host, will ask the user to press the home and target buttons to connect to the device. """ if user_input is None: return self.async_show_form( ste...
[ "async", "def", "async_step_link", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "None", ":", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"link\"", ",", "description_placeholders", "=", "{", "CONF_NAME", ...
[ 195, 4 ]
[ 232, 68 ]
python
en
['en', 'en', 'en']
True
RoombaConfigFlow.async_step_link_manual
(self, user_input=None)
Handle manual linking.
Handle manual linking.
async def async_step_link_manual(self, user_input=None): """Handle manual linking.""" errors = {} if user_input is not None: config = { CONF_HOST: self.host, CONF_BLID: self.blid, CONF_PASSWORD: user_input[CONF_PASSWORD], ...
[ "async", "def", "async_step_link_manual", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "config", "=", "{", "CONF_HOST", ":", "self", ".", "host", ",", "CONF_BLID", ":", "s...
[ 234, 4 ]
[ 258, 9 ]
python
en
['fr', 'fil', 'en']
False
OptionsFlowHandler.__init__
(self, config_entry)
Initialize options flow.
Initialize options flow.
def __init__(self, config_entry): """Initialize options flow.""" self.config_entry = config_entry
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 264, 4 ]
[ 266, 40 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.async_step_init
(self, user_input=None)
Manage the options.
Manage the options.
async def async_step_init(self, user_input=None): """Manage the options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) return self.async_show_form( step_id="init", data_schema=vol.Schema( { ...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "user_input", ")", "return", ...
[ 268, 4 ]
[ 291, 9 ]
python
en
['en', 'en', 'en']
True
_lookup_domain
( perm_lookup: PermissionLookup, domains_dict: SubCategoryDict, entity_id: str )
Look up entity permissions by domain.
Look up entity permissions by domain.
def _lookup_domain( perm_lookup: PermissionLookup, domains_dict: SubCategoryDict, entity_id: str ) -> ValueType | None: """Look up entity permissions by domain.""" return domains_dict.get(entity_id.split(".", 1)[0])
[ "def", "_lookup_domain", "(", "perm_lookup", ":", "PermissionLookup", ",", "domains_dict", ":", "SubCategoryDict", ",", "entity_id", ":", "str", ")", "->", "ValueType", "|", "None", ":", "return", "domains_dict", ".", "get", "(", "entity_id", ".", "split", "("...
[ 45, 0 ]
[ 49, 55 ]
python
en
['en', 'en', 'en']
True
_lookup_area
( perm_lookup: PermissionLookup, area_dict: SubCategoryDict, entity_id: str )
Look up entity permissions by area.
Look up entity permissions by area.
def _lookup_area( perm_lookup: PermissionLookup, area_dict: SubCategoryDict, entity_id: str ) -> ValueType | None: """Look up entity permissions by area.""" entity_entry = perm_lookup.entity_registry.async_get(entity_id) if entity_entry is None or entity_entry.device_id is None: return None ...
[ "def", "_lookup_area", "(", "perm_lookup", ":", "PermissionLookup", ",", "area_dict", ":", "SubCategoryDict", ",", "entity_id", ":", "str", ")", "->", "ValueType", "|", "None", ":", "entity_entry", "=", "perm_lookup", ".", "entity_registry", ".", "async_get", "(...
[ 52, 0 ]
[ 66, 46 ]
python
en
['en', 'en', 'en']
True
_lookup_device
( perm_lookup: PermissionLookup, devices_dict: SubCategoryDict, entity_id: str )
Look up entity permissions by device.
Look up entity permissions by device.
def _lookup_device( perm_lookup: PermissionLookup, devices_dict: SubCategoryDict, entity_id: str ) -> ValueType | None: """Look up entity permissions by device.""" entity_entry = perm_lookup.entity_registry.async_get(entity_id) if entity_entry is None or entity_entry.device_id is None: return N...
[ "def", "_lookup_device", "(", "perm_lookup", ":", "PermissionLookup", ",", "devices_dict", ":", "SubCategoryDict", ",", "entity_id", ":", "str", ")", "->", "ValueType", "|", "None", ":", "entity_entry", "=", "perm_lookup", ".", "entity_registry", ".", "async_get",...
[ 69, 0 ]
[ 78, 51 ]
python
en
['en', 'en', 'en']
True
_lookup_entity_id
( perm_lookup: PermissionLookup, entities_dict: SubCategoryDict, entity_id: str )
Look up entity permission by entity id.
Look up entity permission by entity id.
def _lookup_entity_id( perm_lookup: PermissionLookup, entities_dict: SubCategoryDict, entity_id: str ) -> ValueType | None: """Look up entity permission by entity id.""" return entities_dict.get(entity_id)
[ "def", "_lookup_entity_id", "(", "perm_lookup", ":", "PermissionLookup", ",", "entities_dict", ":", "SubCategoryDict", ",", "entity_id", ":", "str", ")", "->", "ValueType", "|", "None", ":", "return", "entities_dict", ".", "get", "(", "entity_id", ")" ]
[ 81, 0 ]
[ 85, 39 ]
python
en
['en', 'cy', 'en']
True
compile_entities
( policy: CategoryType, perm_lookup: PermissionLookup )
Compile policy into a function that tests policy.
Compile policy into a function that tests policy.
def compile_entities( policy: CategoryType, perm_lookup: PermissionLookup ) -> Callable[[str, str], bool]: """Compile policy into a function that tests policy.""" subcategories: SubCatLookupType = OrderedDict() subcategories[ENTITY_ENTITY_IDS] = _lookup_entity_id subcategories[ENTITY_DEVICE_IDS] = _...
[ "def", "compile_entities", "(", "policy", ":", "CategoryType", ",", "perm_lookup", ":", "PermissionLookup", ")", "->", "Callable", "[", "[", "str", ",", "str", "]", ",", "bool", "]", ":", "subcategories", ":", "SubCatLookupType", "=", "OrderedDict", "(", ")"...
[ 88, 0 ]
[ 99, 61 ]
python
en
['en', 'en', 'en']
True
create_lcn_scene_entity
( hass: HomeAssistant, entity_config: ConfigType, config_entry: ConfigEntry )
Set up an entity for this domain.
Set up an entity for this domain.
def create_lcn_scene_entity( hass: HomeAssistant, entity_config: ConfigType, config_entry: ConfigEntry ) -> LcnEntity: """Set up an entity for this domain.""" device_connection = get_device_connection( hass, entity_config[CONF_ADDRESS], config_entry ) return LcnScene(entity_config, config_e...
[ "def", "create_lcn_scene_entity", "(", "hass", ":", "HomeAssistant", ",", "entity_config", ":", "ConfigType", ",", "config_entry", ":", "ConfigEntry", ")", "->", "LcnEntity", ":", "device_connection", "=", "get_device_connection", "(", "hass", ",", "entity_config", ...
[ 27, 0 ]
[ 35, 76 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback, )
Set up LCN switch entities from a config entry.
Set up LCN switch entities from a config entry.
async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: """Set up LCN switch entities from a config entry.""" entities = [] for entity_config in config_entry.data[CONF_ENTITIES]: if entity_config[CONF_DOMAIN] == DO...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "AddEntitiesCallback", ",", ")", "->", "None", ":", "entities", "=", "[", "]", "for", "entity_config", "in", "config_...
[ 38, 0 ]
[ 50, 32 ]
python
en
['en', 'en', 'en']
True
LcnScene.__init__
( self, config: ConfigType, entry_id: str, device_connection: DeviceConnectionType )
Initialize the LCN scene.
Initialize the LCN scene.
def __init__( self, config: ConfigType, entry_id: str, device_connection: DeviceConnectionType ) -> None: """Initialize the LCN scene.""" super().__init__(config, entry_id, device_connection) self.register_id = config[CONF_DOMAIN_DATA][CONF_REGISTER] self.scene_id = config[C...
[ "def", "__init__", "(", "self", ",", "config", ":", "ConfigType", ",", "entry_id", ":", "str", ",", "device_connection", ":", "DeviceConnectionType", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "config", ",", "entry_id", ",", "device_c...
[ 56, 4 ]
[ 78, 13 ]
python
en
['en', 'fy', 'en']
True
LcnScene.async_activate
(self, **kwargs: Any)
Activate scene.
Activate scene.
async def async_activate(self, **kwargs: Any) -> None: """Activate scene.""" await self.device_connection.activate_scene( self.register_id, self.scene_id, self.output_ports, self.relay_ports, self.transition, )
[ "async", "def", "async_activate", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "await", "self", ".", "device_connection", ".", "activate_scene", "(", "self", ".", "register_id", ",", "self", ".", "scene_id", ",", "self", ".",...
[ 80, 4 ]
[ 88, 9 ]
python
en
['it', 'la', 'en']
False
is_on
(hass: HomeAssistant, entity_id: str)
Test if input_boolean is True.
Test if input_boolean is True.
def is_on(hass: HomeAssistant, entity_id: str) -> bool: """Test if input_boolean is True.""" return hass.states.is_state(entity_id, STATE_ON)
[ "def", "is_on", "(", "hass", ":", "HomeAssistant", ",", "entity_id", ":", "str", ")", "->", "bool", ":", "return", "hass", ".", "states", ".", "is_state", "(", "entity_id", ",", "STATE_ON", ")" ]
[ 80, 0 ]
[ 82, 52 ]
python
en
['en', 'fy', 'en']
True
async_setup
(hass: HomeAssistant, config: ConfigType)
Set up an input boolean.
Set up an input boolean.
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up an input boolean.""" component = EntityComponent(_LOGGER, DOMAIN, hass) id_manager = collection.IDManager() yaml_collection = collection.YamlCollection( logging.getLogger(f"{__name__}.yaml_collection"), id_manager...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "component", "=", "EntityComponent", "(", "_LOGGER", ",", "DOMAIN", ",", "hass", ")", "id_manager", "=", "collection", ".", "IDManager...
[ 85, 0 ]
[ 141, 15 ]
python
en
['en', 'lb', 'en']
True
InputBooleanStorageCollection._process_create_data
(self, data: dict)
Validate the config is valid.
Validate the config is valid.
async def _process_create_data(self, data: dict) -> dict: """Validate the config is valid.""" return self.CREATE_SCHEMA(data)
[ "async", "def", "_process_create_data", "(", "self", ",", "data", ":", "dict", ")", "->", "dict", ":", "return", "self", ".", "CREATE_SCHEMA", "(", "data", ")" ]
[ 64, 4 ]
[ 66, 39 ]
python
en
['en', 'en', 'en']
True
InputBooleanStorageCollection._get_suggested_id
(self, info: dict)
Suggest an ID based on the config.
Suggest an ID based on the config.
def _get_suggested_id(self, info: dict) -> str: """Suggest an ID based on the config.""" return info[CONF_NAME]
[ "def", "_get_suggested_id", "(", "self", ",", "info", ":", "dict", ")", "->", "str", ":", "return", "info", "[", "CONF_NAME", "]" ]
[ 69, 4 ]
[ 71, 30 ]
python
en
['en', 'en', 'en']
True
InputBooleanStorageCollection._update_data
(self, data: dict, update_data: dict)
Return a new updated data object.
Return a new updated data object.
async def _update_data(self, data: dict, update_data: dict) -> dict: """Return a new updated data object.""" update_data = self.UPDATE_SCHEMA(update_data) return {**data, **update_data}
[ "async", "def", "_update_data", "(", "self", ",", "data", ":", "dict", ",", "update_data", ":", "dict", ")", "->", "dict", ":", "update_data", "=", "self", ".", "UPDATE_SCHEMA", "(", "update_data", ")", "return", "{", "*", "*", "data", ",", "*", "*", ...
[ 73, 4 ]
[ 76, 38 ]
python
en
['en', 'en', 'en']
True
InputBoolean.__init__
(self, config: ConfigType)
Initialize a boolean input.
Initialize a boolean input.
def __init__(self, config: ConfigType) -> None: """Initialize a boolean input.""" self._config = config self.editable = True self._attr_is_on = config.get(CONF_INITIAL, False) self._attr_unique_id = config[CONF_ID]
[ "def", "__init__", "(", "self", ",", "config", ":", "ConfigType", ")", "->", "None", ":", "self", ".", "_config", "=", "config", "self", ".", "editable", "=", "True", "self", ".", "_attr_is_on", "=", "config", ".", "get", "(", "CONF_INITIAL", ",", "Fal...
[ 149, 4 ]
[ 154, 46 ]
python
co
['en', 'co', 'it']
False
InputBoolean.from_yaml
(cls, config: ConfigType)
Return entity instance initialized from yaml storage.
Return entity instance initialized from yaml storage.
def from_yaml(cls, config: ConfigType) -> InputBoolean: """Return entity instance initialized from yaml storage.""" input_bool = cls(config) input_bool.entity_id = f"{DOMAIN}.{config[CONF_ID]}" input_bool.editable = False return input_bool
[ "def", "from_yaml", "(", "cls", ",", "config", ":", "ConfigType", ")", "->", "InputBoolean", ":", "input_bool", "=", "cls", "(", "config", ")", "input_bool", ".", "entity_id", "=", "f\"{DOMAIN}.{config[CONF_ID]}\"", "input_bool", ".", "editable", "=", "False", ...
[ 157, 4 ]
[ 162, 25 ]
python
en
['en', 'pl', 'en']
True
InputBoolean.name
(self)
Return name of the boolean input.
Return name of the boolean input.
def name(self) -> str | None: """Return name of the boolean input.""" return self._config.get(CONF_NAME)
[ "def", "name", "(", "self", ")", "->", "str", "|", "None", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_NAME", ")" ]
[ 165, 4 ]
[ 167, 42 ]
python
en
['en', 'ig', 'en']
True
InputBoolean.icon
(self)
Return the icon to be used for this entity.
Return the icon to be used for this entity.
def icon(self) -> str | None: """Return the icon to be used for this entity.""" return self._config.get(CONF_ICON)
[ "def", "icon", "(", "self", ")", "->", "str", "|", "None", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_ICON", ")" ]
[ 170, 4 ]
[ 172, 42 ]
python
en
['en', 'en', 'en']
True
InputBoolean.extra_state_attributes
(self)
Return the state attributes of the entity.
Return the state attributes of the entity.
def extra_state_attributes(self) -> dict[str, bool]: """Return the state attributes of the entity.""" return {ATTR_EDITABLE: self.editable}
[ "def", "extra_state_attributes", "(", "self", ")", "->", "dict", "[", "str", ",", "bool", "]", ":", "return", "{", "ATTR_EDITABLE", ":", "self", ".", "editable", "}" ]
[ 175, 4 ]
[ 177, 45 ]
python
en
['en', 'en', 'en']
True
InputBoolean.async_added_to_hass
(self)
Call when entity about to be added to hass.
Call when entity about to be added to hass.
async def async_added_to_hass(self) -> None: """Call when entity about to be added to hass.""" # Don't restore if we got an initial value. await super().async_added_to_hass() if self._config.get(CONF_INITIAL) is not None: return state = await self.async_get_last_stat...
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "# Don't restore if we got an initial value.", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "if", "self", ".", "_config", ".", "get", "(", "CONF_INITIAL", ")", "is",...
[ 179, 4 ]
[ 187, 72 ]
python
en
['en', 'en', 'en']
True
InputBoolean.async_turn_on
(self, **kwargs: Any)
Turn the entity on.
Turn the entity on.
async def async_turn_on(self, **kwargs: Any) -> None: """Turn the entity on.""" self._attr_is_on = True self.async_write_ha_state()
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "self", ".", "_attr_is_on", "=", "True", "self", ".", "async_write_ha_state", "(", ")" ]
[ 189, 4 ]
[ 192, 35 ]
python
en
['en', 'en', 'en']
True
InputBoolean.async_turn_off
(self, **kwargs: Any)
Turn the entity off.
Turn the entity off.
async def async_turn_off(self, **kwargs: Any) -> None: """Turn the entity off.""" self._attr_is_on = False self.async_write_ha_state()
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "self", ".", "_attr_is_on", "=", "False", "self", ".", "async_write_ha_state", "(", ")" ]
[ 194, 4 ]
[ 197, 35 ]
python
en
['en', 'en', 'en']
True
InputBoolean.async_update_config
(self, config: ConfigType)
Handle when the config is updated.
Handle when the config is updated.
async def async_update_config(self, config: ConfigType) -> None: """Handle when the config is updated.""" self._config = config self.async_write_ha_state()
[ "async", "def", "async_update_config", "(", "self", ",", "config", ":", "ConfigType", ")", "->", "None", ":", "self", ".", "_config", "=", "config", "self", ".", "async_write_ha_state", "(", ")" ]
[ 199, 4 ]
[ 202, 35 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities )
Set up the Firmata switches.
Set up the Firmata switches.
async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up the Firmata switches.""" new_entities = [] board = hass.data[DOMAIN][config_entry.entry_id] for switch in board.switches: pin = switch[CONF_PIN] pin_mode = switch[CON...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "new_entities", "=", "[", "]", "board", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "...
[ 16, 0 ]
[ 42, 40 ]
python
en
['en', 'en', 'en']
True
FirmataSwitch.async_added_to_hass
(self)
Set up a switch.
Set up a switch.
async def async_added_to_hass(self) -> None: """Set up a switch.""" await self._api.start_pin()
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "await", "self", ".", "_api", ".", "start_pin", "(", ")" ]
[ 48, 4 ]
[ 50, 35 ]
python
en
['en', 'en', 'en']
True
FirmataSwitch.is_on
(self)
Return true if switch is on.
Return true if switch is on.
def is_on(self) -> bool: """Return true if switch is on.""" return self._api.is_on
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_api", ".", "is_on" ]
[ 53, 4 ]
[ 55, 30 ]
python
en
['en', 'fy', 'en']
True
FirmataSwitch.async_turn_on
(self, **kwargs)
Turn on switch.
Turn on switch.
async def async_turn_on(self, **kwargs) -> None: """Turn on switch.""" await self._api.turn_on() self.async_write_ha_state()
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_api", ".", "turn_on", "(", ")", "self", ".", "async_write_ha_state", "(", ")" ]
[ 57, 4 ]
[ 60, 35 ]
python
en
['en', 'en', 'en']
True
FirmataSwitch.async_turn_off
(self, **kwargs)
Turn off switch.
Turn off switch.
async def async_turn_off(self, **kwargs) -> None: """Turn off switch.""" await self._api.turn_off() self.async_write_ha_state()
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_api", ".", "turn_off", "(", ")", "self", ".", "async_write_ha_state", "(", ")" ]
[ 62, 4 ]
[ 65, 35 ]
python
en
['en', 'en', 'en']
True
async_get_registry
(hass: HomeAssistant)
Return zha device storage instance.
Return zha device storage instance.
async def async_get_registry(hass: HomeAssistant) -> ZhaStorage: """Return zha device storage instance.""" task = hass.data.get(DATA_REGISTRY) if task is None: async def _load_reg() -> ZhaStorage: registry = ZhaStorage(hass) await registry.async_load() return re...
[ "async", "def", "async_get_registry", "(", "hass", ":", "HomeAssistant", ")", "->", "ZhaStorage", ":", "task", "=", "hass", ".", "data", ".", "get", "(", "DATA_REGISTRY", ")", "if", "task", "is", "None", ":", "async", "def", "_load_reg", "(", ")", "->", ...
[ 131, 0 ]
[ 144, 39 ]
python
br
['br', 'pl', 'en']
False
ZhaStorage.__init__
(self, hass: HomeAssistant)
Initialize the zha device storage.
Initialize the zha device storage.
def __init__(self, hass: HomeAssistant) -> None: """Initialize the zha device storage.""" self.hass: HomeAssistant = hass self.devices: MutableMapping[str, ZhaDeviceEntry] = {} self._store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "self", ".", "hass", ":", "HomeAssistant", "=", "hass", "self", ".", "devices", ":", "MutableMapping", "[", "str", ",", "ZhaDeviceEntry", "]", "=", "{", "}", "se...
[ 36, 4 ]
[ 40, 78 ]
python
br
['br', 'pl', 'en']
False
ZhaStorage.async_create_device
(self, device: ZhaDeviceType)
Create a new ZhaDeviceEntry.
Create a new ZhaDeviceEntry.
def async_create_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry: """Create a new ZhaDeviceEntry.""" device_entry: ZhaDeviceEntry = ZhaDeviceEntry( name=device.name, ieee=str(device.ieee), last_seen=device.last_seen ) self.devices[device_entry.ieee] = device_entry ...
[ "def", "async_create_device", "(", "self", ",", "device", ":", "ZhaDeviceType", ")", "->", "ZhaDeviceEntry", ":", "device_entry", ":", "ZhaDeviceEntry", "=", "ZhaDeviceEntry", "(", "name", "=", "device", ".", "name", ",", "ieee", "=", "str", "(", "device", "...
[ 43, 4 ]
[ 50, 27 ]
python
en
['en', 'en', 'en']
True
ZhaStorage.async_get_or_create_device
(self, device: ZhaDeviceType)
Create a new ZhaDeviceEntry.
Create a new ZhaDeviceEntry.
def async_get_or_create_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry: """Create a new ZhaDeviceEntry.""" ieee_str: str = str(device.ieee) if ieee_str in self.devices: return self.devices[ieee_str] return self.async_create_device(device)
[ "def", "async_get_or_create_device", "(", "self", ",", "device", ":", "ZhaDeviceType", ")", "->", "ZhaDeviceEntry", ":", "ieee_str", ":", "str", "=", "str", "(", "device", ".", "ieee", ")", "if", "ieee_str", "in", "self", ".", "devices", ":", "return", "se...
[ 53, 4 ]
[ 58, 47 ]
python
en
['en', 'en', 'en']
True
ZhaStorage.async_create_or_update_device
(self, device: ZhaDeviceType)
Create or update a ZhaDeviceEntry.
Create or update a ZhaDeviceEntry.
def async_create_or_update_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry: """Create or update a ZhaDeviceEntry.""" if str(device.ieee) in self.devices: return self.async_update_device(device) return self.async_create_device(device)
[ "def", "async_create_or_update_device", "(", "self", ",", "device", ":", "ZhaDeviceType", ")", "->", "ZhaDeviceEntry", ":", "if", "str", "(", "device", ".", "ieee", ")", "in", "self", ".", "devices", ":", "return", "self", ".", "async_update_device", "(", "d...
[ 61, 4 ]
[ 65, 47 ]
python
en
['en', 'en', 'en']
True
ZhaStorage.async_delete_device
(self, device: ZhaDeviceType)
Delete ZhaDeviceEntry.
Delete ZhaDeviceEntry.
def async_delete_device(self, device: ZhaDeviceType) -> None: """Delete ZhaDeviceEntry.""" ieee_str: str = str(device.ieee) if ieee_str in self.devices: del self.devices[ieee_str] self.async_schedule_save()
[ "def", "async_delete_device", "(", "self", ",", "device", ":", "ZhaDeviceType", ")", "->", "None", ":", "ieee_str", ":", "str", "=", "str", "(", "device", ".", "ieee", ")", "if", "ieee_str", "in", "self", ".", "devices", ":", "del", "self", ".", "devic...
[ 68, 4 ]
[ 73, 38 ]
python
en
['en', 'sr', 'pt']
False
ZhaStorage.async_update_device
(self, device: ZhaDeviceType)
Update name of ZhaDeviceEntry.
Update name of ZhaDeviceEntry.
def async_update_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry: """Update name of ZhaDeviceEntry.""" ieee_str: str = str(device.ieee) old = self.devices[ieee_str] if old is not None and device.last_seen is None: return changes = {} changes["last_seen...
[ "def", "async_update_device", "(", "self", ",", "device", ":", "ZhaDeviceType", ")", "->", "ZhaDeviceEntry", ":", "ieee_str", ":", "str", "=", "str", "(", "device", ".", "ieee", ")", "old", "=", "self", ".", "devices", "[", "ieee_str", "]", "if", "old", ...
[ 76, 4 ]
[ 89, 18 ]
python
en
['en', 'en', 'en']
True
ZhaStorage.async_load
(self)
Load the registry of zha device entries.
Load the registry of zha device entries.
async def async_load(self) -> None: """Load the registry of zha device entries.""" data = await self._store.async_load() devices: OrderedDict[str, ZhaDeviceEntry] = OrderedDict() if data is not None: for device in data["devices"]: devices[device["ieee"]] = Z...
[ "async", "def", "async_load", "(", "self", ")", "->", "None", ":", "data", "=", "await", "self", ".", "_store", ".", "async_load", "(", ")", "devices", ":", "OrderedDict", "[", "str", ",", "ZhaDeviceEntry", "]", "=", "OrderedDict", "(", ")", "if", "dat...
[ 91, 4 ]
[ 105, 30 ]
python
en
['en', 'en', 'en']
True
ZhaStorage.async_schedule_save
(self)
Schedule saving the registry of zha devices.
Schedule saving the registry of zha devices.
def async_schedule_save(self) -> None: """Schedule saving the registry of zha devices.""" self._store.async_delay_save(self._data_to_save, SAVE_DELAY)
[ "def", "async_schedule_save", "(", "self", ")", "->", "None", ":", "self", ".", "_store", ".", "async_delay_save", "(", "self", ".", "_data_to_save", ",", "SAVE_DELAY", ")" ]
[ 108, 4 ]
[ 110, 68 ]
python
en
['en', 'en', 'en']
True
ZhaStorage.async_save
(self)
Save the registry of zha devices.
Save the registry of zha devices.
async def async_save(self) -> None: """Save the registry of zha devices.""" await self._store.async_save(self._data_to_save())
[ "async", "def", "async_save", "(", "self", ")", "->", "None", ":", "await", "self", ".", "_store", ".", "async_save", "(", "self", ".", "_data_to_save", "(", ")", ")" ]
[ 112, 4 ]
[ 114, 58 ]
python
en
['en', 'en', 'en']
True
ZhaStorage._data_to_save
(self)
Return data for the registry of zha devices to store in a file.
Return data for the registry of zha devices to store in a file.
def _data_to_save(self) -> dict: """Return data for the registry of zha devices to store in a file.""" data = {} data["devices"] = [ {"name": entry.name, "ieee": entry.ieee, "last_seen": entry.last_seen} for entry in self.devices.values() if entry.last_seen a...
[ "def", "_data_to_save", "(", "self", ")", "->", "dict", ":", "data", "=", "{", "}", "data", "[", "\"devices\"", "]", "=", "[", "{", "\"name\"", ":", "entry", ".", "name", ",", "\"ieee\"", ":", "entry", ".", "ieee", ",", "\"last_seen\"", ":", "entry",...
[ 117, 4 ]
[ 127, 19 ]
python
en
['en', 'en', 'en']
True
test_setup_with_config
(hass)
Test the platform setup with configuration.
Test the platform setup with configuration.
async def test_setup_with_config(hass): """Test the platform setup with configuration.""" assert await async_setup_component(hass, "sensor", {"wsdot": config})
[ "async", "def", "test_setup_with_config", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"sensor\"", ",", "{", "\"wsdot\"", ":", "config", "}", ")" ]
[ 26, 0 ]
[ 28, 73 ]
python
en
['en', 'en', 'en']
True
test_setup
(hass, requests_mock)
Test for operational WSDOT sensor with proper attributes.
Test for operational WSDOT sensor with proper attributes.
async def test_setup(hass, requests_mock): """Test for operational WSDOT sensor with proper attributes.""" entities = [] def add_entities(new_entities, update_before_add=False): """Mock add entities.""" for entity in new_entities: entity.hass = hass if update_before_add...
[ "async", "def", "test_setup", "(", "hass", ",", "requests_mock", ")", ":", "entities", "=", "[", "]", "def", "add_entities", "(", "new_entities", ",", "update_before_add", "=", "False", ")", ":", "\"\"\"Mock add entities.\"\"\"", "for", "entity", "in", "new_enti...
[ 31, 0 ]
[ 60, 5 ]
python
en
['en', 'en', 'en']
True
sync_entity_lifecycle
( hass: HomeAssistant, domain: str, platform: str, entity_component: EntityComponent, collection: ObservableCollection, create_entity: Callable[[dict], Entity], )
Map a collection to an entity component.
Map a collection to an entity component.
def sync_entity_lifecycle( hass: HomeAssistant, domain: str, platform: str, entity_component: EntityComponent, collection: ObservableCollection, create_entity: Callable[[dict], Entity], ) -> None: """Map a collection to an entity component.""" entities = {} ent_reg = entity_registry....
[ "def", "sync_entity_lifecycle", "(", "hass", ":", "HomeAssistant", ",", "domain", ":", "str", ",", "platform", ":", "str", ",", "entity_component", ":", "EntityComponent", ",", "collection", ":", "ObservableCollection", ",", "create_entity", ":", "Callable", "[", ...
[ 322, 0 ]
[ 380, 65 ]
python
en
['en', 'en', 'en']
True
ItemNotFound.__init__
(self, item_id: str)
Initialize item not found error.
Initialize item not found error.
def __init__(self, item_id: str) -> None: """Initialize item not found error.""" super().__init__(f"Item {item_id} not found.") self.item_id = item_id
[ "def", "__init__", "(", "self", ",", "item_id", ":", "str", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "f\"Item {item_id} not found.\"", ")", "self", ".", "item_id", "=", "item_id" ]
[ 68, 4 ]
[ 71, 30 ]
python
en
['en', 'la', 'en']
True
IDManager.__init__
(self)
Initiate the ID manager.
Initiate the ID manager.
def __init__(self) -> None: """Initiate the ID manager.""" self.collections: list[dict[str, Any]] = []
[ "def", "__init__", "(", "self", ")", "->", "None", ":", "self", ".", "collections", ":", "list", "[", "dict", "[", "str", ",", "Any", "]", "]", "=", "[", "]" ]
[ 77, 4 ]
[ 79, 51 ]
python
en
['en', 'en', 'en']
True
IDManager.add_collection
(self, collection: dict[str, Any])
Add a collection to check for ID usage.
Add a collection to check for ID usage.
def add_collection(self, collection: dict[str, Any]) -> None: """Add a collection to check for ID usage.""" self.collections.append(collection)
[ "def", "add_collection", "(", "self", ",", "collection", ":", "dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "self", ".", "collections", ".", "append", "(", "collection", ")" ]
[ 81, 4 ]
[ 83, 43 ]
python
en
['en', 'en', 'en']
True
IDManager.has_id
(self, item_id: str)
Test if the ID exists.
Test if the ID exists.
def has_id(self, item_id: str) -> bool: """Test if the ID exists.""" return any(item_id in collection for collection in self.collections)
[ "def", "has_id", "(", "self", ",", "item_id", ":", "str", ")", "->", "bool", ":", "return", "any", "(", "item_id", "in", "collection", "for", "collection", "in", "self", ".", "collections", ")" ]
[ 85, 4 ]
[ 87, 76 ]
python
en
['en', 'en', 'en']
True
IDManager.generate_id
(self, suggestion: str)
Generate an ID.
Generate an ID.
def generate_id(self, suggestion: str) -> str: """Generate an ID.""" base = slugify(suggestion) proposal = base attempt = 1 while self.has_id(proposal): attempt += 1 proposal = f"{base}_{attempt}" return proposal
[ "def", "generate_id", "(", "self", ",", "suggestion", ":", "str", ")", "->", "str", ":", "base", "=", "slugify", "(", "suggestion", ")", "proposal", "=", "base", "attempt", "=", "1", "while", "self", ".", "has_id", "(", "proposal", ")", ":", "attempt",...
[ 89, 4 ]
[ 99, 23 ]
python
en
['en', 'yo', 'it']
False
ObservableCollection.__init__
( self, logger: logging.Logger, id_manager: IDManager | None = None )
Initialize the base collection.
Initialize the base collection.
def __init__( self, logger: logging.Logger, id_manager: IDManager | None = None ) -> None: """Initialize the base collection.""" self.logger = logger self.id_manager = id_manager or IDManager() self.data: dict[str, dict] = {} self.listeners: list[ChangeListener] = [] ...
[ "def", "__init__", "(", "self", ",", "logger", ":", "logging", ".", "Logger", ",", "id_manager", ":", "IDManager", "|", "None", "=", "None", ")", "->", "None", ":", "self", ".", "logger", "=", "logger", "self", ".", "id_manager", "=", "id_manager", "or...
[ 105, 4 ]
[ 115, 49 ]
python
en
['en', 'en', 'en']
True
ObservableCollection.async_items
(self)
Return list of items in collection.
Return list of items in collection.
def async_items(self) -> list[dict]: """Return list of items in collection.""" return list(self.data.values())
[ "def", "async_items", "(", "self", ")", "->", "list", "[", "dict", "]", ":", "return", "list", "(", "self", ".", "data", ".", "values", "(", ")", ")" ]
[ 118, 4 ]
[ 120, 39 ]
python
en
['en', 'en', 'en']
True
ObservableCollection.async_add_listener
(self, listener: ChangeListener)
Add a listener. Will be called with (change_type, item_id, updated_config).
Add a listener.
def async_add_listener(self, listener: ChangeListener) -> None: """Add a listener. Will be called with (change_type, item_id, updated_config). """ self.listeners.append(listener)
[ "def", "async_add_listener", "(", "self", ",", "listener", ":", "ChangeListener", ")", "->", "None", ":", "self", ".", "listeners", ".", "append", "(", "listener", ")" ]
[ 123, 4 ]
[ 128, 39 ]
python
en
['en', 'cy', 'en']
True
ObservableCollection.async_add_change_set_listener
(self, listener: ChangeSetListener)
Add a listener for a full change set. Will be called with [(change_type, item_id, updated_config), ...]
Add a listener for a full change set.
def async_add_change_set_listener(self, listener: ChangeSetListener) -> None: """Add a listener for a full change set. Will be called with [(change_type, item_id, updated_config), ...] """ self.change_set_listeners.append(listener)
[ "def", "async_add_change_set_listener", "(", "self", ",", "listener", ":", "ChangeSetListener", ")", "->", "None", ":", "self", ".", "change_set_listeners", ".", "append", "(", "listener", ")" ]
[ 131, 4 ]
[ 136, 50 ]
python
en
['en', 'en', 'en']
True
ObservableCollection.notify_changes
(self, change_sets: Iterable[CollectionChangeSet])
Notify listeners of a change.
Notify listeners of a change.
async def notify_changes(self, change_sets: Iterable[CollectionChangeSet]) -> None: """Notify listeners of a change.""" await asyncio.gather( *( listener(change_set.change_type, change_set.item_id, change_set.item) for listener in self.listeners ...
[ "async", "def", "notify_changes", "(", "self", ",", "change_sets", ":", "Iterable", "[", "CollectionChangeSet", "]", ")", "->", "None", ":", "await", "asyncio", ".", "gather", "(", "*", "(", "listener", "(", "change_set", ".", "change_type", ",", "change_set...
[ 138, 4 ]
[ 150, 9 ]
python
en
['en', 'en', 'en']
True
YamlCollection.async_load
(self, data: list[dict])
Load the YAML collection. Overrides existing data.
Load the YAML collection. Overrides existing data.
async def async_load(self, data: list[dict]) -> None: """Load the YAML collection. Overrides existing data.""" old_ids = set(self.data) change_sets = [] for item in data: item_id = item[CONF_ID] if item_id in old_ids: old_ids.remove(item_id) ...
[ "async", "def", "async_load", "(", "self", ",", "data", ":", "list", "[", "dict", "]", ")", "->", "None", ":", "old_ids", "=", "set", "(", "self", ".", "data", ")", "change_sets", "=", "[", "]", "for", "item", "in", "data", ":", "item_id", "=", "...
[ 156, 4 ]
[ 183, 50 ]
python
en
['en', 'en', 'en']
True
StorageCollection.__init__
( self, store: Store, logger: logging.Logger, id_manager: IDManager | None = None, )
Initialize the storage collection.
Initialize the storage collection.
def __init__( self, store: Store, logger: logging.Logger, id_manager: IDManager | None = None, ) -> None: """Initialize the storage collection.""" super().__init__(logger, id_manager) self.store = store
[ "def", "__init__", "(", "self", ",", "store", ":", "Store", ",", "logger", ":", "logging", ".", "Logger", ",", "id_manager", ":", "IDManager", "|", "None", "=", "None", ",", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "logger", ...
[ 189, 4 ]
[ 197, 26 ]
python
en
['en', 'en', 'en']
True
StorageCollection.hass
(self)
Home Assistant object.
Home Assistant object.
def hass(self) -> HomeAssistant: """Home Assistant object.""" return self.store.hass
[ "def", "hass", "(", "self", ")", "->", "HomeAssistant", ":", "return", "self", ".", "store", ".", "hass" ]
[ 200, 4 ]
[ 202, 30 ]
python
en
['fr', 'en', 'en']
True
StorageCollection._async_load_data
(self)
Load the data.
Load the data.
async def _async_load_data(self) -> dict | None: """Load the data.""" return cast(Optional[dict], await self.store.async_load())
[ "async", "def", "_async_load_data", "(", "self", ")", "->", "dict", "|", "None", ":", "return", "cast", "(", "Optional", "[", "dict", "]", ",", "await", "self", ".", "store", ".", "async_load", "(", ")", ")" ]
[ 204, 4 ]
[ 206, 66 ]
python
en
['en', 'en', 'en']
True
StorageCollection.async_load
(self)
Load the storage Manager.
Load the storage Manager.
async def async_load(self) -> None: """Load the storage Manager.""" raw_storage = await self._async_load_data() if raw_storage is None: raw_storage = {"items": []} for item in raw_storage["items"]: self.data[item[CONF_ID]] = item await self.notify_chang...
[ "async", "def", "async_load", "(", "self", ")", "->", "None", ":", "raw_storage", "=", "await", "self", ".", "_async_load_data", "(", ")", "if", "raw_storage", "is", "None", ":", "raw_storage", "=", "{", "\"items\"", ":", "[", "]", "}", "for", "item", ...
[ 208, 4 ]
[ 223, 9 ]
python
en
['en', 'en', 'en']
True
StorageCollection._process_create_data
(self, data: dict)
Validate the config is valid.
Validate the config is valid.
async def _process_create_data(self, data: dict) -> dict: """Validate the config is valid."""
[ "async", "def", "_process_create_data", "(", "self", ",", "data", ":", "dict", ")", "->", "dict", ":" ]
[ 226, 4 ]
[ 227, 43 ]
python
en
['en', 'en', 'en']
True
StorageCollection._get_suggested_id
(self, info: dict)
Suggest an ID based on the config.
Suggest an ID based on the config.
def _get_suggested_id(self, info: dict) -> str: """Suggest an ID based on the config."""
[ "def", "_get_suggested_id", "(", "self", ",", "info", ":", "dict", ")", "->", "str", ":" ]
[ 231, 4 ]
[ 232, 48 ]
python
en
['en', 'en', 'en']
True
StorageCollection._update_data
(self, data: dict, update_data: dict)
Return a new updated data object.
Return a new updated data object.
async def _update_data(self, data: dict, update_data: dict) -> dict: """Return a new updated data object."""
[ "async", "def", "_update_data", "(", "self", ",", "data", ":", "dict", ",", "update_data", ":", "dict", ")", "->", "dict", ":" ]
[ 235, 4 ]
[ 236, 47 ]
python
en
['en', 'en', 'en']
True
StorageCollection.async_create_item
(self, data: dict)
Create a new item.
Create a new item.
async def async_create_item(self, data: dict) -> dict: """Create a new item.""" item = await self._process_create_data(data) item[CONF_ID] = self.id_manager.generate_id(self._get_suggested_id(item)) self.data[item[CONF_ID]] = item self._async_schedule_save() await self.no...
[ "async", "def", "async_create_item", "(", "self", ",", "data", ":", "dict", ")", "->", "dict", ":", "item", "=", "await", "self", ".", "_process_create_data", "(", "data", ")", "item", "[", "CONF_ID", "]", "=", "self", ".", "id_manager", ".", "generate_i...
[ 238, 4 ]
[ 247, 19 ]
python
en
['en', 'en', 'en']
True
StorageCollection.async_update_item
(self, item_id: str, updates: dict)
Update item.
Update item.
async def async_update_item(self, item_id: str, updates: dict) -> dict: """Update item.""" if item_id not in self.data: raise ItemNotFound(item_id) if CONF_ID in updates: raise ValueError("Cannot update ID") current = self.data[item_id] updated = await ...
[ "async", "def", "async_update_item", "(", "self", ",", "item_id", ":", "str", ",", "updates", ":", "dict", ")", "->", "dict", ":", "if", "item_id", "not", "in", "self", ".", "data", ":", "raise", "ItemNotFound", "(", "item_id", ")", "if", "CONF_ID", "i...
[ 249, 4 ]
[ 268, 33 ]
python
en
['en', 'la', 'en']
False
StorageCollection.async_delete_item
(self, item_id: str)
Delete item.
Delete item.
async def async_delete_item(self, item_id: str) -> None: """Delete item.""" if item_id not in self.data: raise ItemNotFound(item_id) item = self.data.pop(item_id) self._async_schedule_save() await self.notify_changes([CollectionChangeSet(CHANGE_REMOVED, item_id, ite...
[ "async", "def", "async_delete_item", "(", "self", ",", "item_id", ":", "str", ")", "->", "None", ":", "if", "item_id", "not", "in", "self", ".", "data", ":", "raise", "ItemNotFound", "(", "item_id", ")", "item", "=", "self", ".", "data", ".", "pop", ...
[ 270, 4 ]
[ 278, 87 ]
python
en
['en', 'la', 'en']
False
StorageCollection._async_schedule_save
(self)
Schedule saving the area registry.
Schedule saving the area registry.
def _async_schedule_save(self) -> None: """Schedule saving the area registry.""" self.store.async_delay_save(self._data_to_save, SAVE_DELAY)
[ "def", "_async_schedule_save", "(", "self", ")", "->", "None", ":", "self", ".", "store", ".", "async_delay_save", "(", "self", ".", "_data_to_save", ",", "SAVE_DELAY", ")" ]
[ 281, 4 ]
[ 283, 67 ]
python
en
['en', 'nl', 'en']
True
StorageCollection._data_to_save
(self)
Return data of area registry to store in a file.
Return data of area registry to store in a file.
def _data_to_save(self) -> dict: """Return data of area registry to store in a file.""" return {"items": list(self.data.values())}
[ "def", "_data_to_save", "(", "self", ")", "->", "dict", ":", "return", "{", "\"items\"", ":", "list", "(", "self", ".", "data", ".", "values", "(", ")", ")", "}" ]
[ 286, 4 ]
[ 288, 50 ]
python
en
['en', 'en', 'en']
True
IDLessCollection.async_load
(self, data: list[dict])
Load the collection. Overrides existing data.
Load the collection. Overrides existing data.
async def async_load(self, data: list[dict]) -> None: """Load the collection. Overrides existing data.""" await self.notify_changes( [ CollectionChangeSet(CHANGE_REMOVED, item_id, item) for item_id, item in list(self.data.items()) ] ) ...
[ "async", "def", "async_load", "(", "self", ",", "data", ":", "list", "[", "dict", "]", ")", "->", "None", ":", "await", "self", ".", "notify_changes", "(", "[", "CollectionChangeSet", "(", "CHANGE_REMOVED", ",", "item_id", ",", "item", ")", "for", "item_...
[ 296, 4 ]
[ 318, 9 ]
python
en
['en', 'en', 'en']
True
StorageCollectionWebsocket.__init__
( self, storage_collection: StorageCollection, api_prefix: str, model_name: str, create_schema: dict, update_schema: dict, )
Initialize a websocket CRUD.
Initialize a websocket CRUD.
def __init__( self, storage_collection: StorageCollection, api_prefix: str, model_name: str, create_schema: dict, update_schema: dict, ) -> None: """Initialize a websocket CRUD.""" self.storage_collection = storage_collection self.api_prefix = ...
[ "def", "__init__", "(", "self", ",", "storage_collection", ":", "StorageCollection", ",", "api_prefix", ":", "str", ",", "model_name", ":", "str", ",", "create_schema", ":", "dict", ",", "update_schema", ":", "dict", ",", ")", "->", "None", ":", "self", "....
[ 386, 4 ]
[ 401, 75 ]
python
en
['en', 'fy', 'it']
False
StorageCollectionWebsocket.item_id_key
(self)
Return item ID key.
Return item ID key.
def item_id_key(self) -> str: """Return item ID key.""" return f"{self.model_name}_id"
[ "def", "item_id_key", "(", "self", ")", "->", "str", ":", "return", "f\"{self.model_name}_id\"" ]
[ 404, 4 ]
[ 406, 38 ]
python
en
['en', 'mt', 'en']
True
StorageCollectionWebsocket.async_setup
( self, hass: HomeAssistant, *, create_list: bool = True, create_create: bool = True, )
Set up the websocket commands.
Set up the websocket commands.
def async_setup( self, hass: HomeAssistant, *, create_list: bool = True, create_create: bool = True, ) -> None: """Set up the websocket commands.""" if create_list: websocket_api.async_register_command( hass, f"{self...
[ "def", "async_setup", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "*", ",", "create_list", ":", "bool", "=", "True", ",", "create_create", ":", "bool", "=", "True", ",", ")", "->", "None", ":", "if", "create_list", ":", "websocket_api", ".", "...
[ 409, 4 ]
[ 469, 9 ]
python
en
['en', 'da', 'en']
True
StorageCollectionWebsocket.ws_list_item
( self, hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict )
List items.
List items.
def ws_list_item( self, hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict ) -> None: """List items.""" connection.send_result(msg["id"], self.storage_collection.async_items())
[ "def", "ws_list_item", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "connection", ":", "websocket_api", ".", "ActiveConnection", ",", "msg", ":", "dict", ")", "->", "None", ":", "connection", ".", "send_result", "(", "msg", "[", "\"id\"", "]", ",",...
[ 471, 4 ]
[ 475, 80 ]
python
en
['en', 'ga', 'en']
False
StorageCollectionWebsocket.ws_create_item
( self, hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict )
Create a item.
Create a item.
async def ws_create_item( self, hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict ) -> None: """Create a item.""" try: data = dict(msg) data.pop("id") data.pop("type") item = await self.storage_collection.async_create_i...
[ "async", "def", "ws_create_item", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "connection", ":", "websocket_api", ".", "ActiveConnection", ",", "msg", ":", "dict", ")", "->", "None", ":", "try", ":", "data", "=", "dict", "(", "msg", ")", "data",...
[ 477, 4 ]
[ 496, 13 ]
python
en
['en', 'co', 'en']
True
StorageCollectionWebsocket.ws_update_item
( self, hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict )
Update a item.
Update a item.
async def ws_update_item( self, hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict ) -> None: """Update a item.""" data = dict(msg) msg_id = data.pop("id") item_id = data.pop(self.item_id_key) data.pop("type") try: item = a...
[ "async", "def", "ws_update_item", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "connection", ":", "websocket_api", ".", "ActiveConnection", ",", "msg", ":", "dict", ")", "->", "None", ":", "data", "=", "dict", "(", "msg", ")", "msg_id", "=", "dat...
[ 498, 4 ]
[ 525, 13 ]
python
en
['en', 'co', 'en']
True
StorageCollectionWebsocket.ws_delete_item
( self, hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict )
Delete a item.
Delete a item.
async def ws_delete_item( self, hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict ) -> None: """Delete a item.""" try: await self.storage_collection.async_delete_item(msg[self.item_id_key]) except ItemNotFound: connection.send_error( ...
[ "async", "def", "ws_delete_item", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "connection", ":", "websocket_api", ".", "ActiveConnection", ",", "msg", ":", "dict", ")", "->", "None", ":", "try", ":", "await", "self", ".", "storage_collection", ".", ...
[ 527, 4 ]
[ 540, 41 ]
python
en
['en', 'ca', 'en']
True
HomematicipGenericEntity.__init__
( self, hap: HomematicipHAP, device, post: str | None = None, channel: int | None = None, is_multi_channel: bool | None = False, )
Initialize the generic entity.
Initialize the generic entity.
def __init__( self, hap: HomematicipHAP, device, post: str | None = None, channel: int | None = None, is_multi_channel: bool | None = False, ) -> None: """Initialize the generic entity.""" self._hap = hap self._home: AsyncHome = hap.home ...
[ "def", "__init__", "(", "self", ",", "hap", ":", "HomematicipHAP", ",", "device", ",", "post", ":", "str", "|", "None", "=", "None", ",", "channel", ":", "int", "|", "None", "=", "None", ",", "is_multi_channel", ":", "bool", "|", "None", "=", "False"...
[ 74, 4 ]
[ 91, 77 ]
python
en
['en', 'en', 'en']
True
HomematicipGenericEntity.device_info
(self)
Return device specific attributes.
Return device specific attributes.
def device_info(self) -> DeviceInfo | None: """Return device specific attributes.""" # Only physical devices should be HA devices. if isinstance(self._device, AsyncDevice): return { "identifiers": { # Serial numbers of Homematic IP device ...
[ "def", "device_info", "(", "self", ")", "->", "DeviceInfo", "|", "None", ":", "# Only physical devices should be HA devices.", "if", "isinstance", "(", "self", ".", "_device", ",", "AsyncDevice", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "# Serial numb...
[ 94, 4 ]
[ 110, 19 ]
python
en
['fr', 'it', 'en']
False
HomematicipGenericEntity.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self) -> None: """Register callbacks.""" self._hap.hmip_device_by_entity_id[self.entity_id] = self._device self._device.on_update(self._async_device_changed) self._device.on_remove(self._async_device_removed)
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "self", ".", "_hap", ".", "hmip_device_by_entity_id", "[", "self", ".", "entity_id", "]", "=", "self", ".", "_device", "self", ".", "_device", ".", "on_update", "(", "self", ".", ...
[ 112, 4 ]
[ 116, 58 ]
python
en
['en', 'no', 'en']
False
HomematicipGenericEntity._async_device_changed
(self, *args, **kwargs)
Handle device state changes.
Handle device state changes.
def _async_device_changed(self, *args, **kwargs) -> None: """Handle device state changes.""" # Don't update disabled entities if self.enabled: _LOGGER.debug("Event %s (%s)", self.name, self._device.modelType) self.async_write_ha_state() else: _LOGGER.d...
[ "def", "_async_device_changed", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "None", ":", "# Don't update disabled entities", "if", "self", ".", "enabled", ":", "_LOGGER", ".", "debug", "(", "\"Event %s (%s)\"", ",", "self", ".", "name"...
[ 119, 4 ]
[ 130, 13 ]
python
en
['ro', 'en', 'en']
True
HomematicipGenericEntity.async_will_remove_from_hass
(self)
Run when hmip device will be removed from hass.
Run when hmip device will be removed from hass.
async def async_will_remove_from_hass(self) -> None: """Run when hmip device will be removed from hass.""" # Only go further if the device/entity should be removed from registries # due to a removal of the HmIP device. if self.hmip_device_removed: try: del s...
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", "->", "None", ":", "# Only go further if the device/entity should be removed from registries", "# due to a removal of the HmIP device.", "if", "self", ".", "hmip_device_removed", ":", "try", ":", "del", "self", ...
[ 132, 4 ]
[ 143, 82 ]
python
en
['en', 'en', 'en']
True
HomematicipGenericEntity.async_remove_from_registries
(self)
Remove entity/device from registry.
Remove entity/device from registry.
async def async_remove_from_registries(self) -> None: """Remove entity/device from registry.""" # Remove callback from device. self._device.remove_callback(self._async_device_changed) self._device.remove_callback(self._async_device_removed) if not self.registry_entry: ...
[ "async", "def", "async_remove_from_registries", "(", "self", ")", "->", "None", ":", "# Remove callback from device.", "self", ".", "_device", ".", "remove_callback", "(", "self", ".", "_async_device_changed", ")", "self", ".", "_device", ".", "remove_callback", "("...
[ 145, 4 ]
[ 169, 59 ]
python
en
['en', 'en', 'en']
True
HomematicipGenericEntity._async_device_removed
(self, *args, **kwargs)
Handle hmip device removal.
Handle hmip device removal.
def _async_device_removed(self, *args, **kwargs) -> None: """Handle hmip device removal.""" # Set marker showing that the HmIP device hase been removed. self.hmip_device_removed = True self.hass.async_create_task(self.async_remove(force_remove=True))
[ "def", "_async_device_removed", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "None", ":", "# Set marker showing that the HmIP device hase been removed.", "self", ".", "hmip_device_removed", "=", "True", "self", ".", "hass", ".", "async_create_t...
[ 172, 4 ]
[ 176, 73 ]
python
en
['nl', 'en', 'en']
True
HomematicipGenericEntity.name
(self)
Return the name of the generic entity.
Return the name of the generic entity.
def name(self) -> str: """Return the name of the generic entity.""" name = None # Try to get a label from a channel. if hasattr(self._device, "functionalChannels"): if self._is_multi_channel: name = self._device.functionalChannels[self._channel].label ...
[ "def", "name", "(", "self", ")", "->", "str", ":", "name", "=", "None", "# Try to get a label from a channel.", "if", "hasattr", "(", "self", ".", "_device", ",", "\"functionalChannels\"", ")", ":", "if", "self", ".", "_is_multi_channel", ":", "name", "=", "...
[ 179, 4 ]
[ 203, 19 ]
python
en
['en', 'en', 'en']
True
HomematicipGenericEntity.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self) -> bool: """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 206, 4 ]
[ 208, 20 ]
python
en
['en', 'en', 'en']
True
HomematicipGenericEntity.available
(self)
Return if entity is available.
Return if entity is available.
def available(self) -> bool: """Return if entity is available.""" return not self._device.unreach
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "not", "self", ".", "_device", ".", "unreach" ]
[ 211, 4 ]
[ 213, 39 ]
python
en
['en', 'en', 'en']
True
HomematicipGenericEntity.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" unique_id = f"{self.__class__.__name__}_{self._device.id}" if self._is_multi_channel: unique_id = ( f"{self.__class__.__name__}_Channel{self._channel}_{self._device.id}" ) return unique_id
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "unique_id", "=", "f\"{self.__class__.__name__}_{self._device.id}\"", "if", "self", ".", "_is_multi_channel", ":", "unique_id", "=", "(", "f\"{self.__class__.__name__}_Channel{self._channel}_{self._device.id}\"", ")", ...
[ 216, 4 ]
[ 224, 24 ]
python
ca
['fr', 'ca', 'en']
False
HomematicipGenericEntity.icon
(self)
Return the icon.
Return the icon.
def icon(self) -> str | None: """Return the icon.""" for attr, icon in DEVICE_ATTRIBUTE_ICONS.items(): if getattr(self._device, attr, None): return icon return None
[ "def", "icon", "(", "self", ")", "->", "str", "|", "None", ":", "for", "attr", ",", "icon", "in", "DEVICE_ATTRIBUTE_ICONS", ".", "items", "(", ")", ":", "if", "getattr", "(", "self", ".", "_device", ",", "attr", ",", "None", ")", ":", "return", "ic...
[ 227, 4 ]
[ 233, 19 ]
python
en
['en', 'sr', 'en']
True
HomematicipGenericEntity.extra_state_attributes
(self)
Return the state attributes of the generic entity.
Return the state attributes of the generic entity.
def extra_state_attributes(self) -> dict[str, Any]: """Return the state attributes of the generic entity.""" state_attr = {} if isinstance(self._device, AsyncDevice): for attr, attr_key in DEVICE_ATTRIBUTES.items(): attr_value = getattr(self._device, attr, None) ...
[ "def", "extra_state_attributes", "(", "self", ")", "->", "dict", "[", "str", ",", "Any", "]", ":", "state_attr", "=", "{", "}", "if", "isinstance", "(", "self", ".", "_device", ",", "AsyncDevice", ")", ":", "for", "attr", ",", "attr_key", "in", "DEVICE...
[ 236, 4 ]
[ 256, 25 ]
python
en
['en', 'en', 'en']
True
direct_url_as_pep440_direct_reference
(direct_url, name)
Convert a DirectUrl to a pip requirement string.
Convert a DirectUrl to a pip requirement string.
def direct_url_as_pep440_direct_reference(direct_url, name): # type: (DirectUrl, str) -> str """Convert a DirectUrl to a pip requirement string.""" direct_url.validate() # if invalid, this is a pip bug requirement = name + " @ " fragments = [] if isinstance(direct_url.info, VcsInfo): re...
[ "def", "direct_url_as_pep440_direct_reference", "(", "direct_url", ",", "name", ")", ":", "# type: (DirectUrl, str) -> str", "direct_url", ".", "validate", "(", ")", "# if invalid, this is a pip bug", "requirement", "=", "name", "+", "\" @ \"", "fragments", "=", "[", "]...
[ 29, 0 ]
[ 54, 22 ]
python
en
['en', 'en', 'en']
True
dist_get_direct_url
(dist)
Obtain a DirectUrl from a pkg_resource.Distribution. Returns None if the distribution has no `direct_url.json` metadata, or if `direct_url.json` is invalid.
Obtain a DirectUrl from a pkg_resource.Distribution.
def dist_get_direct_url(dist): # type: (Distribution) -> Optional[DirectUrl] """Obtain a DirectUrl from a pkg_resource.Distribution. Returns None if the distribution has no `direct_url.json` metadata, or if `direct_url.json` is invalid. """ if not dist.has_metadata(DIRECT_URL_METADATA_NAME): ...
[ "def", "dist_get_direct_url", "(", "dist", ")", ":", "# type: (Distribution) -> Optional[DirectUrl]", "if", "not", "dist", ".", "has_metadata", "(", "DIRECT_URL_METADATA_NAME", ")", ":", "return", "None", "try", ":", "return", "DirectUrl", ".", "from_json", "(", "di...
[ 107, 0 ]
[ 129, 19 ]
python
en
['en', 'en', 'en']
True
send_request
(payload, session)
Send request to radio.
Send request to radio.
def send_request(payload, session): """Send request to radio.""" try: request = requests.post( URL, cookies={"sdi_squeezenetwork_session": session}, json=payload, timeout=5, ) except requests.exceptions.Timeout: _LOGGER.error("Timed out...
[ "def", "send_request", "(", "payload", ",", "session", ")", ":", "try", ":", "request", "=", "requests", ".", "post", "(", "URL", ",", "cookies", "=", "{", "\"sdi_squeezenetwork_session\"", ":", "session", "}", ",", "json", "=", "payload", ",", "timeout", ...
[ 54, 0 ]
[ 68, 29 ]
python
en
['en', 'de', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Logitech UE Smart Radio platform.
Set up the Logitech UE Smart Radio platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Logitech UE Smart Radio platform.""" email = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) session_request = requests.post( "https://www.uesmartradio.com/user/login", data={"email": email...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "email", "=", "config", ".", "get", "(", "CONF_USERNAME", ")", "password", "=", "config", ".", "get", "(", "CONF_PASSWORD", ")", "sessio...
[ 71, 0 ]
[ 90, 25 ]
python
en
['en', 'ky', 'en']
True
UERadioDevice.__init__
(self, session, player_id, player_name)
Initialize the Logitech UE Smart Radio device.
Initialize the Logitech UE Smart Radio device.
def __init__(self, session, player_id, player_name): """Initialize the Logitech UE Smart Radio device.""" self._session = session self._player_id = player_id self._name = player_name self._state = None self._volume = 0 self._last_volume = 0 self._media_tit...
[ "def", "__init__", "(", "self", ",", "session", ",", "player_id", ",", "player_name", ")", ":", "self", ".", "_session", "=", "session", "self", ".", "_player_id", "=", "player_id", "self", ".", "_name", "=", "player_name", "self", ".", "_state", "=", "N...
[ 96, 4 ]
[ 106, 38 ]
python
en
['en', 'pl', 'en']
True
UERadioDevice.send_command
(self, command)
Send command to radio.
Send command to radio.
def send_command(self, command): """Send command to radio.""" send_request( {"method": "slim.request", "params": [self._player_id, command]}, self._session, )
[ "def", "send_command", "(", "self", ",", "command", ")", ":", "send_request", "(", "{", "\"method\"", ":", "\"slim.request\"", ",", "\"params\"", ":", "[", "self", ".", "_player_id", ",", "command", "]", "}", ",", "self", ".", "_session", ",", ")" ]
[ 108, 4 ]
[ 113, 9 ]
python
en
['en', 'sr', 'en']
True
UERadioDevice.update
(self)
Get the latest details from the device.
Get the latest details from the device.
def update(self): """Get the latest details from the device.""" request = send_request( { "method": "slim.request", "params": [ self._player_id, ["status", "-", 1, "tags:cgABbehldiqtyrSuoKLN"], ], ...
[ "def", "update", "(", "self", ")", ":", "request", "=", "send_request", "(", "{", "\"method\"", ":", "\"slim.request\"", ",", "\"params\"", ":", "[", "self", ".", "_player_id", ",", "[", "\"status\"", ",", "\"-\"", ",", "1", ",", "\"tags:cgABbehldiqtyrSuoKLN...
[ 115, 4 ]
[ 145, 63 ]
python
en
['en', 'en', 'en']
True
UERadioDevice.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" ]
[ 148, 4 ]
[ 150, 25 ]
python
en
['en', 'en', 'en']
True
UERadioDevice.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" ]
[ 153, 4 ]
[ 155, 26 ]
python
en
['en', 'en', 'en']
True
UERadioDevice.icon
(self)
Return the icon to use in the frontend, if any.
Return the icon to use in the frontend, if any.
def icon(self): """Return the icon to use in the frontend, if any.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 158, 4 ]
[ 160, 19 ]
python
en
['en', 'en', 'en']
True