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
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a Notion config entry.
Unload a Notion config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a Notion config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, platform) for platform in PLATFORMS ]...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_fo...
[ 112, 0 ]
[ 125, 20 ]
python
en
['en', 'en', 'en']
True
async_register_new_bridge
( hass: HomeAssistant, bridge: dict, entry: ConfigEntry )
Register a new bridge.
Register a new bridge.
async def async_register_new_bridge( hass: HomeAssistant, bridge: dict, entry: ConfigEntry ): """Register a new bridge.""" device_registry = await dr.async_get_registry(hass) device_registry.async_get_or_create( config_entry_id=entry.entry_id, identifiers={(DOMAIN, bridge["hardware_id"])...
[ "async", "def", "async_register_new_bridge", "(", "hass", ":", "HomeAssistant", ",", "bridge", ":", "dict", ",", "entry", ":", "ConfigEntry", ")", ":", "device_registry", "=", "await", "dr", ".", "async_get_registry", "(", "hass", ")", "device_registry", ".", ...
[ 128, 0 ]
[ 140, 5 ]
python
en
['en', 'ca', 'en']
True
NotionEntity.__init__
( self, coordinator: DataUpdateCoordinator, task_id: str, sensor_id: str, bridge_id: str, system_id: str, name: str, device_class: str, )
Initialize the entity.
Initialize the entity.
def __init__( self, coordinator: DataUpdateCoordinator, task_id: str, sensor_id: str, bridge_id: str, system_id: str, name: str, device_class: str, ): """Initialize the entity.""" super().__init__(coordinator) self._attrs = {ATT...
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "DataUpdateCoordinator", ",", "task_id", ":", "str", ",", "sensor_id", ":", "str", ",", "bridge_id", ":", "str", ",", "system_id", ":", "str", ",", "name", ":", "str", ",", "device_class", ":", "st...
[ 146, 4 ]
[ 165, 31 ]
python
en
['en', 'en', 'en']
True
NotionEntity.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return ( self.coordinator.last_update_success and self._task_id in self.coordinator.data["tasks"] )
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "(", "self", ".", "coordinator", ".", "last_update_success", "and", "self", ".", "_task_id", "in", "self", ".", "coordinator", ".", "data", "[", "\"tasks\"", "]", ")" ]
[ 168, 4 ]
[ 173, 9 ]
python
en
['en', 'en', 'en']
True
NotionEntity.device_class
(self)
Return the device class.
Return the device class.
def device_class(self) -> str: """Return the device class.""" return self._device_class
[ "def", "device_class", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_device_class" ]
[ 176, 4 ]
[ 178, 33 ]
python
en
['en', 'en', 'en']
True
NotionEntity.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self) -> dict: """Return the state attributes.""" return self._attrs
[ "def", "device_state_attributes", "(", "self", ")", "->", "dict", ":", "return", "self", ".", "_attrs" ]
[ 181, 4 ]
[ 183, 26 ]
python
en
['en', 'en', 'en']
True
NotionEntity.device_info
(self)
Return device registry information for this entity.
Return device registry information for this entity.
def device_info(self) -> dict: """Return device registry information for this entity.""" bridge = self.coordinator.data["bridges"].get(self._bridge_id, {}) sensor = self.coordinator.data["sensors"][self._sensor_id] return { "identifiers": {(DOMAIN, sensor["hardware_id"])}, ...
[ "def", "device_info", "(", "self", ")", "->", "dict", ":", "bridge", "=", "self", ".", "coordinator", ".", "data", "[", "\"bridges\"", "]", ".", "get", "(", "self", ".", "_bridge_id", ",", "{", "}", ")", "sensor", "=", "self", ".", "coordinator", "."...
[ 186, 4 ]
[ 198, 9 ]
python
en
['en', 'en', 'en']
True
NotionEntity.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self) -> str: """Return the name of the entity.""" sensor = self.coordinator.data["sensors"][self._sensor_id] return f'{sensor["name"]}: {self._name}'
[ "def", "name", "(", "self", ")", "->", "str", ":", "sensor", "=", "self", ".", "coordinator", ".", "data", "[", "\"sensors\"", "]", "[", "self", ".", "_sensor_id", "]", "return", "f'{sensor[\"name\"]}: {self._name}'" ]
[ 201, 4 ]
[ 204, 48 ]
python
en
['en', 'en', 'en']
True
NotionEntity.unique_id
(self)
Return a unique, unchanging string that represents this entity.
Return a unique, unchanging string that represents this entity.
def unique_id(self) -> str: """Return a unique, unchanging string that represents this entity.""" task = self.coordinator.data["tasks"][self._task_id] return f'{self._sensor_id}_{task["task_type"]}'
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "task", "=", "self", ".", "coordinator", ".", "data", "[", "\"tasks\"", "]", "[", "self", ".", "_task_id", "]", "return", "f'{self._sensor_id}_{task[\"task_type\"]}'" ]
[ 207, 4 ]
[ 210, 55 ]
python
en
['en', 'en', 'en']
True
NotionEntity._async_update_bridge_id
(self)
Update the entity's bridge ID if it has changed. Sensors can move to other bridges based on signal strength, etc.
Update the entity's bridge ID if it has changed.
async def _async_update_bridge_id(self) -> None: """Update the entity's bridge ID if it has changed. Sensors can move to other bridges based on signal strength, etc. """ sensor = self.coordinator.data["sensors"][self._sensor_id] # If the sensor's bridge ID is the same as what w...
[ "async", "def", "_async_update_bridge_id", "(", "self", ")", "->", "None", ":", "sensor", "=", "self", ".", "coordinator", ".", "data", "[", "\"sensors\"", "]", "[", "self", ".", "_sensor_id", "]", "# If the sensor's bridge ID is the same as what we had before or if i...
[ 212, 4 ]
[ 241, 9 ]
python
en
['en', 'en', 'en']
True
NotionEntity._async_update_from_latest_data
(self)
Update the entity from the latest data.
Update the entity from the latest data.
def _async_update_from_latest_data(self) -> None: """Update the entity from the latest data.""" raise NotImplementedError
[ "def", "_async_update_from_latest_data", "(", "self", ")", "->", "None", ":", "raise", "NotImplementedError" ]
[ 244, 4 ]
[ 246, 33 ]
python
en
['en', 'en', 'en']
True
NotionEntity._handle_coordinator_update
(self)
Respond to a DataUpdateCoordinator update.
Respond to a DataUpdateCoordinator update.
def _handle_coordinator_update(self): """Respond to a DataUpdateCoordinator update.""" self.hass.async_create_task(self._async_update_bridge_id()) self._async_update_from_latest_data() self.async_write_ha_state()
[ "def", "_handle_coordinator_update", "(", "self", ")", ":", "self", ".", "hass", ".", "async_create_task", "(", "self", ".", "_async_update_bridge_id", "(", ")", ")", "self", ".", "_async_update_from_latest_data", "(", ")", "self", ".", "async_write_ha_state", "("...
[ 249, 4 ]
[ 253, 35 ]
python
en
['en', 'de', 'en']
True
NotionEntity.async_added_to_hass
(self)
Handle entity which will be added.
Handle entity which will be added.
async def async_added_to_hass(self): """Handle entity which will be added.""" await super().async_added_to_hass() self._async_update_from_latest_data()
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "self", ".", "_async_update_from_latest_data", "(", ")" ]
[ 255, 4 ]
[ 258, 45 ]
python
en
['en', 'en', 'en']
True
init_integration
(hass, forecast=False)
Set up the Airly integration in Home Assistant.
Set up the Airly integration in Home Assistant.
async def init_integration(hass, forecast=False) -> MockConfigEntry: """Set up the Airly integration in Home Assistant.""" entry = MockConfigEntry( domain=DOMAIN, title="Home", unique_id="55.55-122.12", data={ "api_key": "foo", "latitude": 55.55, ...
[ "async", "def", "init_integration", "(", "hass", ",", "forecast", "=", "False", ")", "->", "MockConfigEntry", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "title", "=", "\"Home\"", ",", "unique_id", "=", "\"55.55-122.12\"", ",", "...
[ 9, 0 ]
[ 31, 16 ]
python
en
['en', 'en', 'en']
True
MaskedLinear.__init__
( self, in_features: int, out_features: int, bias: bool = True, mask_init: str = "constant", mask_scale: float = 0.0, pruning_method: str = "topK", )
Args: in_features (`int`) Size of each input sample out_features (`int`) Size of each output sample bias (`bool`) If set to ``False``, the layer will not learn an additive bias. Default: ``True`` mas...
Args: in_features (`int`) Size of each input sample out_features (`int`) Size of each output sample bias (`bool`) If set to ``False``, the layer will not learn an additive bias. Default: ``True`` mas...
def __init__( self, in_features: int, out_features: int, bias: bool = True, mask_init: str = "constant", mask_scale: float = 0.0, pruning_method: str = "topK", ): """ Args: in_features (`int`) Size of each input samp...
[ "def", "__init__", "(", "self", ",", "in_features", ":", "int", ",", "out_features", ":", "int", ",", "bias", ":", "bool", "=", "True", ",", "mask_init", ":", "str", "=", "\"constant\"", ",", "mask_scale", ":", "float", "=", "0.0", ",", "pruning_method",...
[ 37, 4 ]
[ 75, 28 ]
python
en
['en', 'error', 'th']
False
test_maybe_schedule_update
(hass, mock_openzwave)
Test maybe schedule update.
Test maybe schedule update.
async def test_maybe_schedule_update(hass, mock_openzwave): """Test maybe schedule update.""" base_entity = node_entity.ZWaveBaseEntity() base_entity.entity_id = "zwave.bla" base_entity.hass = hass with patch.object(hass.loop, "call_later") as mock_call_later: base_entity._schedule_update()...
[ "async", "def", "test_maybe_schedule_update", "(", "hass", ",", "mock_openzwave", ")", ":", "base_entity", "=", "node_entity", ".", "ZWaveBaseEntity", "(", ")", "base_entity", ".", "entity_id", "=", "\"zwave.bla\"", "base_entity", ".", "hass", "=", "hass", "with",...
[ 8, 0 ]
[ 28, 51 ]
python
de
['de', 'de', 'en']
True
test_node_event_activated
(hass, mock_openzwave)
Test Node event activated event.
Test Node event activated event.
async def test_node_event_activated(hass, mock_openzwave): """Test Node event activated event.""" mock_receivers = [] def mock_connect(receiver, signal, *args, **kwargs): if signal == mock_zwave.MockNetwork.SIGNAL_NODE_EVENT: mock_receivers.append(receiver) node = mock_zwave.MockNo...
[ "async", "def", "test_node_event_activated", "(", "hass", ",", "mock_openzwave", ")", ":", "mock_receivers", "=", "[", "]", "def", "mock_connect", "(", "receiver", ",", "signal", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "signal", "==", ...
[ 31, 0 ]
[ 70, 58 ]
python
en
['en', 'en', 'en']
True
test_scene_activated
(hass, mock_openzwave)
Test scene activated event.
Test scene activated event.
async def test_scene_activated(hass, mock_openzwave): """Test scene activated event.""" mock_receivers = [] def mock_connect(receiver, signal, *args, **kwargs): if signal == mock_zwave.MockNetwork.SIGNAL_SCENE_EVENT: mock_receivers.append(receiver) node = mock_zwave.MockNode(node_i...
[ "async", "def", "test_scene_activated", "(", "hass", ",", "mock_openzwave", ")", ":", "mock_receivers", "=", "[", "]", "def", "mock_connect", "(", "receiver", ",", "signal", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "signal", "==", "mock...
[ 73, 0 ]
[ 112, 58 ]
python
en
['en', 'en', 'en']
True
test_central_scene_activated
(hass, mock_openzwave)
Test central scene activated event.
Test central scene activated event.
async def test_central_scene_activated(hass, mock_openzwave): """Test central scene activated event.""" mock_receivers = [] def mock_connect(receiver, signal, *args, **kwargs): if signal == mock_zwave.MockNetwork.SIGNAL_VALUE_CHANGED: mock_receivers.append(receiver) node = mock_zwa...
[ "async", "def", "test_central_scene_activated", "(", "hass", ",", "mock_openzwave", ")", ":", "mock_receivers", "=", "[", "]", "def", "mock_connect", "(", "receiver", ",", "signal", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "signal", "==",...
[ 115, 0 ]
[ 163, 62 ]
python
en
['en', 'en', 'en']
True
test_application_version
(hass, mock_openzwave)
Test application version.
Test application version.
async def test_application_version(hass, mock_openzwave): """Test application version.""" mock_receivers = {} signal_mocks = [ mock_zwave.MockNetwork.SIGNAL_VALUE_CHANGED, mock_zwave.MockNetwork.SIGNAL_VALUE_ADDED, ] def mock_connect(receiver, signal, *args, **kwargs): if s...
[ "async", "def", "test_application_version", "(", "hass", ",", "mock_openzwave", ")", ":", "mock_receivers", "=", "{", "}", "signal_mocks", "=", "[", "mock_zwave", ".", "MockNetwork", ".", "SIGNAL_VALUE_CHANGED", ",", "mock_zwave", ".", "MockNetwork", ".", "SIGNAL_...
[ 166, 0 ]
[ 230, 5 ]
python
en
['en', 'da', 'en']
True
test_network_node_changed_from_value
(hass, mock_openzwave)
Test for network_node_changed.
Test for network_node_changed.
async def test_network_node_changed_from_value(hass, mock_openzwave): """Test for network_node_changed.""" zwave_network = MagicMock() node = mock_zwave.MockNode() entity = node_entity.ZWaveNodeEntity(node, zwave_network) value = mock_zwave.MockValue(node=node) with patch.object(entity, "maybe_s...
[ "async", "def", "test_network_node_changed_from_value", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", ")", "entity", "=", "node_entity", ".", "ZWaveNodeEntity", "(", "n...
[ 233, 0 ]
[ 241, 38 ]
python
en
['en', 'en', 'en']
True
test_network_node_changed_from_node
(hass, mock_openzwave)
Test for network_node_changed.
Test for network_node_changed.
async def test_network_node_changed_from_node(hass, mock_openzwave): """Test for network_node_changed.""" zwave_network = MagicMock() node = mock_zwave.MockNode() entity = node_entity.ZWaveNodeEntity(node, zwave_network) with patch.object(entity, "maybe_schedule_update") as mock: mock_zwave....
[ "async", "def", "test_network_node_changed_from_node", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", ")", "entity", "=", "node_entity", ".", "ZWaveNodeEntity", "(", "no...
[ 244, 0 ]
[ 251, 38 ]
python
en
['en', 'en', 'en']
True
test_network_node_changed_from_another_node
(hass, mock_openzwave)
Test for network_node_changed.
Test for network_node_changed.
async def test_network_node_changed_from_another_node(hass, mock_openzwave): """Test for network_node_changed.""" zwave_network = MagicMock() node = mock_zwave.MockNode() entity = node_entity.ZWaveNodeEntity(node, zwave_network) with patch.object(entity, "maybe_schedule_update") as mock: ano...
[ "async", "def", "test_network_node_changed_from_another_node", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", ")", "entity", "=", "node_entity", ".", "ZWaveNodeEntity", "(...
[ 254, 0 ]
[ 262, 30 ]
python
en
['en', 'en', 'en']
True
test_network_node_changed_from_notification
(hass, mock_openzwave)
Test for network_node_changed.
Test for network_node_changed.
async def test_network_node_changed_from_notification(hass, mock_openzwave): """Test for network_node_changed.""" zwave_network = MagicMock() node = mock_zwave.MockNode() entity = node_entity.ZWaveNodeEntity(node, zwave_network) with patch.object(entity, "maybe_schedule_update") as mock: moc...
[ "async", "def", "test_network_node_changed_from_notification", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", ")", "entity", "=", "node_entity", ".", "ZWaveNodeEntity", "(...
[ 265, 0 ]
[ 272, 38 ]
python
en
['en', 'en', 'en']
True
test_network_node_changed_from_another_notification
(hass, mock_openzwave)
Test for network_node_changed.
Test for network_node_changed.
async def test_network_node_changed_from_another_notification(hass, mock_openzwave): """Test for network_node_changed.""" zwave_network = MagicMock() node = mock_zwave.MockNode() entity = node_entity.ZWaveNodeEntity(node, zwave_network) with patch.object(entity, "maybe_schedule_update") as mock: ...
[ "async", "def", "test_network_node_changed_from_another_notification", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", ")", "entity", "=", "node_entity", ".", "ZWaveNodeEntit...
[ 275, 0 ]
[ 282, 30 ]
python
en
['en', 'en', 'en']
True
test_node_changed
(hass, mock_openzwave)
Test node_changed function.
Test node_changed function.
async def test_node_changed(hass, mock_openzwave): """Test node_changed function.""" zwave_network = MagicMock() node = mock_zwave.MockNode( query_stage="Dynamic", is_awake=True, is_ready=False, is_failed=False, is_info_received=True, max_baud_rate=40000, ...
[ "async", "def", "test_node_changed", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", "query_stage", "=", "\"Dynamic\"", ",", "is_awake", "=", "True", ",", "is_ready", ...
[ 285, 0 ]
[ 622, 67 ]
python
en
['en', 'en', 'en']
True
test_name
(hass, mock_openzwave)
Test name property.
Test name property.
async def test_name(hass, mock_openzwave): """Test name property.""" zwave_network = MagicMock() node = mock_zwave.MockNode() entity = node_entity.ZWaveNodeEntity(node, zwave_network) assert entity.name == "Mock Node"
[ "async", "def", "test_name", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", ")", "entity", "=", "node_entity", ".", "ZWaveNodeEntity", "(", "node", ",", "zwave_netwo...
[ 625, 0 ]
[ 630, 37 ]
python
en
['en', 'en', 'en']
True
test_state_before_update
(hass, mock_openzwave)
Test state before update was called.
Test state before update was called.
async def test_state_before_update(hass, mock_openzwave): """Test state before update was called.""" zwave_network = MagicMock() node = mock_zwave.MockNode() entity = node_entity.ZWaveNodeEntity(node, zwave_network) assert entity.state is None
[ "async", "def", "test_state_before_update", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", ")", "entity", "=", "node_entity", ".", "ZWaveNodeEntity", "(", "node", ",",...
[ 633, 0 ]
[ 638, 31 ]
python
en
['en', 'en', 'en']
True
test_state_not_ready
(hass, mock_openzwave)
Test state property.
Test state property.
async def test_state_not_ready(hass, mock_openzwave): """Test state property.""" zwave_network = MagicMock() node = mock_zwave.MockNode( query_stage="Dynamic", is_awake=True, is_ready=False, is_failed=False, is_info_received=True, ) entity = node_entity.ZWaveN...
[ "async", "def", "test_state_not_ready", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", "query_stage", "=", "\"Dynamic\"", ",", "is_awake", "=", "True", ",", "is_ready"...
[ 641, 0 ]
[ 665, 37 ]
python
en
['en', 'en', 'en']
True
test_state_ready
(hass, mock_openzwave)
Test state property.
Test state property.
async def test_state_ready(hass, mock_openzwave): """Test state property.""" zwave_network = MagicMock() node = mock_zwave.MockNode( query_stage="Dynamic", is_awake=True, is_ready=False, is_failed=False, is_info_received=True, ) entity = node_entity.ZWaveNodeE...
[ "async", "def", "test_state_ready", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", "query_stage", "=", "\"Dynamic\"", ",", "is_awake", "=", "True", ",", "is_ready", ...
[ 668, 0 ]
[ 693, 37 ]
python
en
['en', 'en', 'en']
True
test_not_polled
(hass, mock_openzwave)
Test should_poll property.
Test should_poll property.
async def test_not_polled(hass, mock_openzwave): """Test should_poll property.""" zwave_network = MagicMock() node = mock_zwave.MockNode() entity = node_entity.ZWaveNodeEntity(node, zwave_network) assert not entity.should_poll
[ "async", "def", "test_not_polled", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", ")", "entity", "=", "node_entity", ".", "ZWaveNodeEntity", "(", "node", ",", "zwave...
[ 696, 0 ]
[ 701, 33 ]
python
en
['en', 'en', 'en']
True
test_unique_id
(hass, mock_openzwave)
Test unique_id.
Test unique_id.
async def test_unique_id(hass, mock_openzwave): """Test unique_id.""" zwave_network = MagicMock() node = mock_zwave.MockNode() entity = node_entity.ZWaveNodeEntity(node, zwave_network) assert entity.unique_id == "node-567"
[ "async", "def", "test_unique_id", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", ")", "entity", "=", "node_entity", ".", "ZWaveNodeEntity", "(", "node", ",", "zwave_...
[ 704, 0 ]
[ 709, 41 ]
python
en
['fr', 'la', 'en']
False
test_unique_id_missing_data
(hass, mock_openzwave)
Test unique_id.
Test unique_id.
async def test_unique_id_missing_data(hass, mock_openzwave): """Test unique_id.""" zwave_network = MagicMock() node = mock_zwave.MockNode() node.manufacturer_name = None node.name = None node.is_ready = False entity = node_entity.ZWaveNodeEntity(node, zwave_network) assert entity.unique...
[ "async", "def", "test_unique_id_missing_data", "(", "hass", ",", "mock_openzwave", ")", ":", "zwave_network", "=", "MagicMock", "(", ")", "node", "=", "mock_zwave", ".", "MockNode", "(", ")", "node", ".", "manufacturer_name", "=", "None", "node", ".", "name", ...
[ 712, 0 ]
[ 721, 35 ]
python
en
['fr', 'la', 'en']
False
new_simple_controller_config
( config: dict = None, options: dict = None, config_source=ConfigSource.CONFIG_FLOW, serial_number="1111", devices: Tuple[pv.VeraDevice, ...] = (), scenes: Tuple[pv.VeraScene, ...] = (), setup_callback: SetupCallback = None, legacy_entity_unique_id=False, )
Create simple contorller config.
Create simple contorller config.
def new_simple_controller_config( config: dict = None, options: dict = None, config_source=ConfigSource.CONFIG_FLOW, serial_number="1111", devices: Tuple[pv.VeraDevice, ...] = (), scenes: Tuple[pv.VeraScene, ...] = (), setup_callback: SetupCallback = None, legacy_entity_unique_id=False, ...
[ "def", "new_simple_controller_config", "(", "config", ":", "dict", "=", "None", ",", "options", ":", "dict", "=", "None", ",", "config_source", "=", "ConfigSource", ".", "CONFIG_FLOW", ",", "serial_number", "=", "\"1111\"", ",", "devices", ":", "Tuple", "[", ...
[ 55, 0 ]
[ 75, 5 ]
python
da
['da', 'gl', 'en']
False
ComponentFactory.__init__
(self, vera_controller_class_mock)
Initialize the factory.
Initialize the factory.
def __init__(self, vera_controller_class_mock): """Initialize the factory.""" self.vera_controller_class_mock = vera_controller_class_mock
[ "def", "__init__", "(", "self", ",", "vera_controller_class_mock", ")", ":", "self", ".", "vera_controller_class_mock", "=", "vera_controller_class_mock" ]
[ 81, 4 ]
[ 83, 68 ]
python
en
['en', 'en', 'en']
True
ComponentFactory.configure_component
( self, hass: HomeAssistant, controller_config: ControllerConfig = None, controller_configs: Tuple[ControllerConfig] = (), )
Configure the component with multiple specific mock data.
Configure the component with multiple specific mock data.
async def configure_component( self, hass: HomeAssistant, controller_config: ControllerConfig = None, controller_configs: Tuple[ControllerConfig] = (), ) -> ComponentData: """Configure the component with multiple specific mock data.""" configs = list(controller_config...
[ "async", "def", "configure_component", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "controller_config", ":", "ControllerConfig", "=", "None", ",", "controller_configs", ":", "Tuple", "[", "ControllerConfig", "]", "=", "(", ")", ",", ")", "->", "Compon...
[ 85, 4 ]
[ 104, 9 ]
python
en
['en', 'en', 'en']
True
ComponentFactory._configure_component
( self, hass: HomeAssistant, controller_config: ControllerConfig )
Configure the component with specific mock data.
Configure the component with specific mock data.
async def _configure_component( self, hass: HomeAssistant, controller_config: ControllerConfig ) -> ControllerData: """Configure the component with specific mock data.""" component_config = { **(controller_config.config or {}), **(controller_config.options or {}), ...
[ "async", "def", "_configure_component", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "controller_config", ":", "ControllerConfig", ")", "->", "ControllerData", ":", "component_config", "=", "{", "*", "*", "(", "controller_config", ".", "config", "or", "{...
[ 106, 4 ]
[ 178, 85 ]
python
en
['en', 'en', 'en']
True
test_open_cover_intent
(hass)
Test HassOpenCover intent.
Test HassOpenCover intent.
async def test_open_cover_intent(hass): """Test HassOpenCover intent.""" await cover_intent.async_setup_intents(hass) hass.states.async_set("cover.garage_door", "closed") calls = async_mock_service(hass, "cover", SERVICE_OPEN_COVER) response = await intent.async_handle( hass, "test", "Hass...
[ "async", "def", "test_open_cover_intent", "(", "hass", ")", ":", "await", "cover_intent", ".", "async_setup_intents", "(", "hass", ")", "hass", ".", "states", ".", "async_set", "(", "\"cover.garage_door\"", ",", "\"closed\"", ")", "calls", "=", "async_mock_service...
[ 12, 0 ]
[ 29, 58 ]
python
en
['en', 'en', 'en']
True
test_close_cover_intent
(hass)
Test HassCloseCover intent.
Test HassCloseCover intent.
async def test_close_cover_intent(hass): """Test HassCloseCover intent.""" await cover_intent.async_setup_intents(hass) hass.states.async_set("cover.garage_door", "open") calls = async_mock_service(hass, "cover", SERVICE_CLOSE_COVER) response = await intent.async_handle( hass, "test", "Has...
[ "async", "def", "test_close_cover_intent", "(", "hass", ")", ":", "await", "cover_intent", ".", "async_setup_intents", "(", "hass", ")", "hass", ".", "states", ".", "async_set", "(", "\"cover.garage_door\"", ",", "\"open\"", ")", "calls", "=", "async_mock_service"...
[ 32, 0 ]
[ 49, 58 ]
python
en
['en', 'en', 'en']
True
async_get_actions
(hass: HomeAssistant, device_id: str)
List device actions for Cover devices.
List device actions for Cover devices.
async def async_get_actions(hass: HomeAssistant, device_id: str) -> List[dict]: """List device actions for Cover devices.""" registry = await entity_registry.async_get_registry(hass) actions = [] # Get all the integrations entities for this device for entry in entity_registry.async_entries_for_devi...
[ "async", "def", "async_get_actions", "(", "hass", ":", "HomeAssistant", ",", "device_id", ":", "str", ")", "->", "List", "[", "dict", "]", ":", "registry", "=", "await", "entity_registry", ".", "async_get_registry", "(", "hass", ")", "actions", "=", "[", "...
[ 58, 0 ]
[ 142, 18 ]
python
en
['fr', 'en', 'en']
True
async_get_action_capabilities
(hass: HomeAssistant, config: dict)
List action capabilities.
List action capabilities.
async def async_get_action_capabilities(hass: HomeAssistant, config: dict) -> dict: """List action capabilities.""" if config[CONF_TYPE] not in POSITION_ACTION_TYPES: return {} return { "extra_fields": vol.Schema( { vol.Optional("position", default=0): vol.All( ...
[ "async", "def", "async_get_action_capabilities", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ")", "->", "dict", ":", "if", "config", "[", "CONF_TYPE", "]", "not", "in", "POSITION_ACTION_TYPES", ":", "return", "{", "}", "return", "{", "\"ex...
[ 145, 0 ]
[ 158, 5 ]
python
en
['ro', 'ga', 'en']
False
async_call_action_from_config
( hass: HomeAssistant, config: dict, variables: dict, context: Optional[Context] )
Execute a device action.
Execute a device action.
async def async_call_action_from_config( hass: HomeAssistant, config: dict, variables: dict, context: Optional[Context] ) -> None: """Execute a device action.""" config = ACTION_SCHEMA(config) service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]} if config[CONF_TYPE] == "open": service =...
[ "async", "def", "async_call_action_from_config", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ",", "variables", ":", "dict", ",", "context", ":", "Optional", "[", "Context", "]", ")", "->", "None", ":", "config", "=", "ACTION_SCHEMA", "(", ...
[ 161, 0 ]
[ 188, 5 ]
python
en
['ro', 'en', 'en']
True
_assert_tensors_equal
(a, b, atol=1e-12, prefix="")
If tensors not close, or a and b arent both tensors, raise a nice Assertion error.
If tensors not close, or a and b arent both tensors, raise a nice Assertion error.
def _assert_tensors_equal(a, b, atol=1e-12, prefix=""): """If tensors not close, or a and b arent both tensors, raise a nice Assertion error.""" if a is None and b is None: return True try: if tf.debugging.assert_near(a, b, atol=atol): return True raise except Excepti...
[ "def", "_assert_tensors_equal", "(", "a", ",", "b", ",", "atol", "=", "1e-12", ",", "prefix", "=", "\"\"", ")", ":", "if", "a", "is", "None", "and", "b", "is", "None", ":", "return", "True", "try", ":", "if", "tf", ".", "debugging", ".", "assert_ne...
[ 373, 0 ]
[ 385, 33 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the iTunes platform.
Set up the iTunes platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the iTunes platform.""" add_entities( [ ItunesDevice( config.get(CONF_NAME), config.get(CONF_HOST), config.get(CONF_PORT), config[CONF_SSL], ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "add_entities", "(", "[", "ItunesDevice", "(", "config", ".", "get", "(", "CONF_NAME", ")", ",", "config", ".", "get", "(", "CONF_HOST",...
[ 188, 0 ]
[ 200, 5 ]
python
en
['en', 'lb', 'en']
True
Itunes.__init__
(self, host, port, use_ssl)
Initialize the iTunes device.
Initialize the iTunes device.
def __init__(self, host, port, use_ssl): """Initialize the iTunes device.""" self.host = host self.port = port self.use_ssl = use_ssl
[ "def", "__init__", "(", "self", ",", "host", ",", "port", ",", "use_ssl", ")", ":", "self", ".", "host", "=", "host", "self", ".", "port", "=", "port", "self", ".", "use_ssl", "=", "use_ssl" ]
[ 67, 4 ]
[ 71, 30 ]
python
en
['en', 'en', 'en']
True
Itunes._base_url
(self)
Return the base URL for endpoints.
Return the base URL for endpoints.
def _base_url(self): """Return the base URL for endpoints.""" if self.use_ssl: uri_scheme = "https://" else: uri_scheme = "http://" if self.port: return f"{uri_scheme}{self.host}:{self.port}" return f"{uri_scheme}{self.host}"
[ "def", "_base_url", "(", "self", ")", ":", "if", "self", ".", "use_ssl", ":", "uri_scheme", "=", "\"https://\"", "else", ":", "uri_scheme", "=", "\"http://\"", "if", "self", ".", "port", ":", "return", "f\"{uri_scheme}{self.host}:{self.port}\"", "return", "f\"{u...
[ 74, 4 ]
[ 84, 41 ]
python
en
['en', 'en', 'en']
True
Itunes._request
(self, method, path, params=None)
Make the actual request and return the parsed response.
Make the actual request and return the parsed response.
def _request(self, method, path, params=None): """Make the actual request and return the parsed response.""" url = f"{self._base_url}{path}" try: if method == "GET": response = requests.get(url, timeout=DEFAULT_TIMEOUT) elif method == "POST": ...
[ "def", "_request", "(", "self", ",", "method", ",", "path", ",", "params", "=", "None", ")", ":", "url", "=", "f\"{self._base_url}{path}\"", "try", ":", "if", "method", "==", "\"GET\"", ":", "response", "=", "requests", ".", "get", "(", "url", ",", "ti...
[ 86, 4 ]
[ 104, 46 ]
python
en
['en', 'en', 'en']
True
Itunes._command
(self, named_command)
Make a request for a controlling command.
Make a request for a controlling command.
def _command(self, named_command): """Make a request for a controlling command.""" return self._request("PUT", f"/{named_command}")
[ "def", "_command", "(", "self", ",", "named_command", ")", ":", "return", "self", ".", "_request", "(", "\"PUT\"", ",", "f\"/{named_command}\"", ")" ]
[ 106, 4 ]
[ 108, 56 ]
python
en
['en', 'en', 'en']
True
Itunes.now_playing
(self)
Return the current state.
Return the current state.
def now_playing(self): """Return the current state.""" return self._request("GET", "/now_playing")
[ "def", "now_playing", "(", "self", ")", ":", "return", "self", ".", "_request", "(", "\"GET\"", ",", "\"/now_playing\"", ")" ]
[ 110, 4 ]
[ 112, 51 ]
python
en
['en', 'en', 'en']
True
Itunes.set_volume
(self, level)
Set the volume and returns the current state, level 0-100.
Set the volume and returns the current state, level 0-100.
def set_volume(self, level): """Set the volume and returns the current state, level 0-100.""" return self._request("PUT", "/volume", {"level": level})
[ "def", "set_volume", "(", "self", ",", "level", ")", ":", "return", "self", ".", "_request", "(", "\"PUT\"", ",", "\"/volume\"", ",", "{", "\"level\"", ":", "level", "}", ")" ]
[ 114, 4 ]
[ 116, 64 ]
python
en
['en', 'en', 'en']
True
Itunes.set_muted
(self, muted)
Mute and returns the current state, muted True or False.
Mute and returns the current state, muted True or False.
def set_muted(self, muted): """Mute and returns the current state, muted True or False.""" return self._request("PUT", "/mute", {"muted": muted})
[ "def", "set_muted", "(", "self", ",", "muted", ")", ":", "return", "self", ".", "_request", "(", "\"PUT\"", ",", "\"/mute\"", ",", "{", "\"muted\"", ":", "muted", "}", ")" ]
[ 118, 4 ]
[ 120, 62 ]
python
en
['en', 'en', 'en']
True
Itunes.set_shuffle
(self, shuffle)
Set the shuffle mode, shuffle True or False.
Set the shuffle mode, shuffle True or False.
def set_shuffle(self, shuffle): """Set the shuffle mode, shuffle True or False.""" return self._request( "PUT", "/shuffle", {"mode": ("songs" if shuffle else "off")} )
[ "def", "set_shuffle", "(", "self", ",", "shuffle", ")", ":", "return", "self", ".", "_request", "(", "\"PUT\"", ",", "\"/shuffle\"", ",", "{", "\"mode\"", ":", "(", "\"songs\"", "if", "shuffle", "else", "\"off\"", ")", "}", ")" ]
[ 122, 4 ]
[ 126, 9 ]
python
en
['en', 'zh-Latn', 'en']
True
Itunes.play
(self)
Set playback to play and returns the current state.
Set playback to play and returns the current state.
def play(self): """Set playback to play and returns the current state.""" return self._command("play")
[ "def", "play", "(", "self", ")", ":", "return", "self", ".", "_command", "(", "\"play\"", ")" ]
[ 128, 4 ]
[ 130, 36 ]
python
en
['en', 'en', 'en']
True
Itunes.pause
(self)
Set playback to paused and returns the current state.
Set playback to paused and returns the current state.
def pause(self): """Set playback to paused and returns the current state.""" return self._command("pause")
[ "def", "pause", "(", "self", ")", ":", "return", "self", ".", "_command", "(", "\"pause\"", ")" ]
[ 132, 4 ]
[ 134, 37 ]
python
en
['en', 'en', 'en']
True
Itunes.next
(self)
Skip to the next track and returns the current state.
Skip to the next track and returns the current state.
def next(self): """Skip to the next track and returns the current state.""" return self._command("next")
[ "def", "next", "(", "self", ")", ":", "return", "self", ".", "_command", "(", "\"next\"", ")" ]
[ 136, 4 ]
[ 138, 36 ]
python
en
['en', 'en', 'en']
True
Itunes.previous
(self)
Skip back and returns the current state.
Skip back and returns the current state.
def previous(self): """Skip back and returns the current state.""" return self._command("previous")
[ "def", "previous", "(", "self", ")", ":", "return", "self", ".", "_command", "(", "\"previous\"", ")" ]
[ 140, 4 ]
[ 142, 40 ]
python
en
['en', 'en', 'en']
True
Itunes.stop
(self)
Stop playback and return the current state.
Stop playback and return the current state.
def stop(self): """Stop playback and return the current state.""" return self._command("stop")
[ "def", "stop", "(", "self", ")", ":", "return", "self", ".", "_command", "(", "\"stop\"", ")" ]
[ 144, 4 ]
[ 146, 36 ]
python
en
['en', 'en', 'en']
True
Itunes.play_playlist
(self, playlist_id_or_name)
Set a playlist to be current and returns the current state.
Set a playlist to be current and returns the current state.
def play_playlist(self, playlist_id_or_name): """Set a playlist to be current and returns the current state.""" response = self._request("GET", "/playlists") playlists = response.get("playlists", []) found_playlists = [ playlist for playlist in playlists ...
[ "def", "play_playlist", "(", "self", ",", "playlist_id_or_name", ")", ":", "response", "=", "self", ".", "_request", "(", "\"GET\"", ",", "\"/playlists\"", ")", "playlists", "=", "response", ".", "get", "(", "\"playlists\"", ",", "[", "]", ")", "found_playli...
[ 148, 4 ]
[ 162, 45 ]
python
en
['en', 'en', 'en']
True
Itunes.artwork_url
(self)
Return a URL of the current track's album art.
Return a URL of the current track's album art.
def artwork_url(self): """Return a URL of the current track's album art.""" return f"{self._base_url}/artwork"
[ "def", "artwork_url", "(", "self", ")", ":", "return", "f\"{self._base_url}/artwork\"" ]
[ 164, 4 ]
[ 166, 42 ]
python
en
['en', 'en', 'en']
True
Itunes.airplay_devices
(self)
Return a list of AirPlay devices.
Return a list of AirPlay devices.
def airplay_devices(self): """Return a list of AirPlay devices.""" return self._request("GET", "/airplay_devices")
[ "def", "airplay_devices", "(", "self", ")", ":", "return", "self", ".", "_request", "(", "\"GET\"", ",", "\"/airplay_devices\"", ")" ]
[ 168, 4 ]
[ 170, 55 ]
python
en
['en', 'en', 'en']
True
Itunes.airplay_device
(self, device_id)
Return an AirPlay device.
Return an AirPlay device.
def airplay_device(self, device_id): """Return an AirPlay device.""" return self._request("GET", f"/airplay_devices/{device_id}")
[ "def", "airplay_device", "(", "self", ",", "device_id", ")", ":", "return", "self", ".", "_request", "(", "\"GET\"", ",", "f\"/airplay_devices/{device_id}\"", ")" ]
[ 172, 4 ]
[ 174, 68 ]
python
en
['en', 'tg', 'en']
True
Itunes.toggle_airplay_device
(self, device_id, toggle)
Toggle airplay device on or off, id, toggle True or False.
Toggle airplay device on or off, id, toggle True or False.
def toggle_airplay_device(self, device_id, toggle): """Toggle airplay device on or off, id, toggle True or False.""" command = "on" if toggle else "off" path = f"/airplay_devices/{device_id}/{command}" return self._request("PUT", path)
[ "def", "toggle_airplay_device", "(", "self", ",", "device_id", ",", "toggle", ")", ":", "command", "=", "\"on\"", "if", "toggle", "else", "\"off\"", "path", "=", "f\"/airplay_devices/{device_id}/{command}\"", "return", "self", ".", "_request", "(", "\"PUT\"", ",",...
[ 176, 4 ]
[ 180, 41 ]
python
en
['en', 'en', 'en']
True
Itunes.set_volume_airplay_device
(self, device_id, level)
Set volume, returns current state of device, id,level 0-100.
Set volume, returns current state of device, id,level 0-100.
def set_volume_airplay_device(self, device_id, level): """Set volume, returns current state of device, id,level 0-100.""" path = f"/airplay_devices/{device_id}/volume" return self._request("PUT", path, {"level": level})
[ "def", "set_volume_airplay_device", "(", "self", ",", "device_id", ",", "level", ")", ":", "path", "=", "f\"/airplay_devices/{device_id}/volume\"", "return", "self", ".", "_request", "(", "\"PUT\"", ",", "path", ",", "{", "\"level\"", ":", "level", "}", ")" ]
[ 182, 4 ]
[ 185, 59 ]
python
en
['nl', 'en', 'en']
True
ItunesDevice.__init__
(self, name, host, port, use_ssl, add_entities)
Initialize the iTunes device.
Initialize the iTunes device.
def __init__(self, name, host, port, use_ssl, add_entities): """Initialize the iTunes device.""" self._name = name self._host = host self._port = port self._use_ssl = use_ssl self._add_entities = add_entities self.client = Itunes(self._host, self._port, self._use...
[ "def", "__init__", "(", "self", ",", "name", ",", "host", ",", "port", ",", "use_ssl", ",", "add_entities", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_host", "=", "host", "self", ".", "_port", "=", "port", "self", ".", "_use_ssl", ...
[ 206, 4 ]
[ 229, 21 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.update_state
(self, state_hash)
Update all the state properties with the passed in dictionary.
Update all the state properties with the passed in dictionary.
def update_state(self, state_hash): """Update all the state properties with the passed in dictionary.""" self.player_state = state_hash.get("player_state", None) self.current_volume = state_hash.get("volume", 0) self.muted = state_hash.get("muted", None) self.current_title = sta...
[ "def", "update_state", "(", "self", ",", "state_hash", ")", ":", "self", ".", "player_state", "=", "state_hash", ".", "get", "(", "\"player_state\"", ",", "None", ")", "self", ".", "current_volume", "=", "state_hash", ".", "get", "(", "\"volume\"", ",", "0...
[ 231, 4 ]
[ 244, 43 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.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" ]
[ 247, 4 ]
[ 249, 25 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" if self.player_state == "offline" or self.player_state is None: return "offline" if self.player_state == "error": return "error" if self.player_state == "stopped": return STATE_IDLE if s...
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "player_state", "==", "\"offline\"", "or", "self", ".", "player_state", "is", "None", ":", "return", "\"offline\"", "if", "self", ".", "player_state", "==", "\"error\"", ":", "return", "\"error\"", ...
[ 252, 4 ]
[ 266, 28 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.update
(self)
Retrieve latest state.
Retrieve latest state.
def update(self): """Retrieve latest state.""" now_playing = self.client.now_playing() self.update_state(now_playing) found_devices = self.client.airplay_devices() found_devices = found_devices.get("airplay_devices", []) new_devices = [] for device_data in foun...
[ "def", "update", "(", "self", ")", ":", "now_playing", "=", "self", ".", "client", ".", "now_playing", "(", ")", "self", ".", "update_state", "(", "now_playing", ")", "found_devices", "=", "self", ".", "client", ".", "airplay_devices", "(", ")", "found_dev...
[ 268, 4 ]
[ 293, 43 ]
python
en
['es', 'sk', 'en']
False
ItunesDevice.is_volume_muted
(self)
Boolean if volume is currently muted.
Boolean if volume is currently muted.
def is_volume_muted(self): """Boolean if volume is currently muted.""" return self.muted
[ "def", "is_volume_muted", "(", "self", ")", ":", "return", "self", ".", "muted" ]
[ 296, 4 ]
[ 298, 25 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.volume_level
(self)
Volume level of the media player (0..1).
Volume level of the media player (0..1).
def volume_level(self): """Volume level of the media player (0..1).""" return self.current_volume / 100.0
[ "def", "volume_level", "(", "self", ")", ":", "return", "self", ".", "current_volume", "/", "100.0" ]
[ 301, 4 ]
[ 303, 42 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.media_content_id
(self)
Content ID of current playing media.
Content ID of current playing media.
def media_content_id(self): """Content ID of current playing media.""" return self.content_id
[ "def", "media_content_id", "(", "self", ")", ":", "return", "self", ".", "content_id" ]
[ 306, 4 ]
[ 308, 30 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.media_content_type
(self)
Content type of current playing media.
Content type of current playing media.
def media_content_type(self): """Content type of current playing media.""" return MEDIA_TYPE_MUSIC
[ "def", "media_content_type", "(", "self", ")", ":", "return", "MEDIA_TYPE_MUSIC" ]
[ 311, 4 ]
[ 313, 31 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.media_image_url
(self)
Image url of current playing media.
Image url of current playing media.
def media_image_url(self): """Image url of current playing media.""" if ( self.player_state in (STATE_PLAYING, STATE_IDLE, STATE_PAUSED) and self.current_title is not None ): return f"{self.client.artwork_url()}?id={self.content_id}" return ( ...
[ "def", "media_image_url", "(", "self", ")", ":", "if", "(", "self", ".", "player_state", "in", "(", "STATE_PLAYING", ",", "STATE_IDLE", ",", "STATE_PAUSED", ")", "and", "self", ".", "current_title", "is", "not", "None", ")", ":", "return", "f\"{self.client.a...
[ 316, 4 ]
[ 327, 9 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.media_title
(self)
Title of current playing media.
Title of current playing media.
def media_title(self): """Title of current playing media.""" return self.current_title
[ "def", "media_title", "(", "self", ")", ":", "return", "self", ".", "current_title" ]
[ 330, 4 ]
[ 332, 33 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.media_artist
(self)
Artist of current playing media (Music track only).
Artist of current playing media (Music track only).
def media_artist(self): """Artist of current playing media (Music track only).""" return self.current_artist
[ "def", "media_artist", "(", "self", ")", ":", "return", "self", ".", "current_artist" ]
[ 335, 4 ]
[ 337, 34 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.media_album_name
(self)
Album of current playing media (Music track only).
Album of current playing media (Music track only).
def media_album_name(self): """Album of current playing media (Music track only).""" return self.current_album
[ "def", "media_album_name", "(", "self", ")", ":", "return", "self", ".", "current_album" ]
[ 340, 4 ]
[ 342, 33 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.media_playlist
(self)
Title of the currently playing playlist.
Title of the currently playing playlist.
def media_playlist(self): """Title of the currently playing playlist.""" return self.current_playlist
[ "def", "media_playlist", "(", "self", ")", ":", "return", "self", ".", "current_playlist" ]
[ 345, 4 ]
[ 347, 36 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.shuffle
(self)
Boolean if shuffle is enabled.
Boolean if shuffle is enabled.
def shuffle(self): """Boolean if shuffle is enabled.""" return self.shuffled
[ "def", "shuffle", "(", "self", ")", ":", "return", "self", ".", "shuffled" ]
[ 350, 4 ]
[ 352, 28 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.supported_features
(self)
Flag media player features that are supported.
Flag media player features that are supported.
def supported_features(self): """Flag media player features that are supported.""" return SUPPORT_ITUNES
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_ITUNES" ]
[ 355, 4 ]
[ 357, 29 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.set_volume_level
(self, volume)
Set volume level, range 0..1.
Set volume level, range 0..1.
def set_volume_level(self, volume): """Set volume level, range 0..1.""" response = self.client.set_volume(int(volume * 100)) self.update_state(response)
[ "def", "set_volume_level", "(", "self", ",", "volume", ")", ":", "response", "=", "self", ".", "client", ".", "set_volume", "(", "int", "(", "volume", "*", "100", ")", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 359, 4 ]
[ 362, 35 ]
python
en
['fr', 'zu', 'en']
False
ItunesDevice.mute_volume
(self, mute)
Mute (true) or unmute (false) media player.
Mute (true) or unmute (false) media player.
def mute_volume(self, mute): """Mute (true) or unmute (false) media player.""" response = self.client.set_muted(mute) self.update_state(response)
[ "def", "mute_volume", "(", "self", ",", "mute", ")", ":", "response", "=", "self", ".", "client", ".", "set_muted", "(", "mute", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 364, 4 ]
[ 367, 35 ]
python
en
['en', 'la', 'it']
False
ItunesDevice.set_shuffle
(self, shuffle)
Shuffle (true) or no shuffle (false) media player.
Shuffle (true) or no shuffle (false) media player.
def set_shuffle(self, shuffle): """Shuffle (true) or no shuffle (false) media player.""" response = self.client.set_shuffle(shuffle) self.update_state(response)
[ "def", "set_shuffle", "(", "self", ",", "shuffle", ")", ":", "response", "=", "self", ".", "client", ".", "set_shuffle", "(", "shuffle", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 369, 4 ]
[ 372, 35 ]
python
en
['en', 'zh-Latn', 'en']
True
ItunesDevice.media_play
(self)
Send media_play command to media player.
Send media_play command to media player.
def media_play(self): """Send media_play command to media player.""" response = self.client.play() self.update_state(response)
[ "def", "media_play", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "play", "(", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 374, 4 ]
[ 377, 35 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.media_pause
(self)
Send media_pause command to media player.
Send media_pause command to media player.
def media_pause(self): """Send media_pause command to media player.""" response = self.client.pause() self.update_state(response)
[ "def", "media_pause", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "pause", "(", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 379, 4 ]
[ 382, 35 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.media_next_track
(self)
Send media_next command to media player.
Send media_next command to media player.
def media_next_track(self): """Send media_next command to media player.""" response = self.client.next() # pylint: disable=not-callable self.update_state(response)
[ "def", "media_next_track", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "next", "(", ")", "# pylint: disable=not-callable", "self", ".", "update_state", "(", "response", ")" ]
[ 384, 4 ]
[ 387, 35 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.media_previous_track
(self)
Send media_previous command media player.
Send media_previous command media player.
def media_previous_track(self): """Send media_previous command media player.""" response = self.client.previous() self.update_state(response)
[ "def", "media_previous_track", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "previous", "(", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 389, 4 ]
[ 392, 35 ]
python
en
['en', 'pt', 'en']
True
ItunesDevice.play_media
(self, media_type, media_id, **kwargs)
Send the play_media command to the media player.
Send the play_media command to the media player.
def play_media(self, media_type, media_id, **kwargs): """Send the play_media command to the media player.""" if media_type == MEDIA_TYPE_PLAYLIST: response = self.client.play_playlist(media_id) self.update_state(response)
[ "def", "play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "if", "media_type", "==", "MEDIA_TYPE_PLAYLIST", ":", "response", "=", "self", ".", "client", ".", "play_playlist", "(", "media_id", ")", "self", ".", ...
[ 394, 4 ]
[ 398, 39 ]
python
en
['en', 'en', 'en']
True
ItunesDevice.turn_off
(self)
Turn the media player off.
Turn the media player off.
def turn_off(self): """Turn the media player off.""" response = self.client.stop() self.update_state(response)
[ "def", "turn_off", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "stop", "(", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 400, 4 ]
[ 403, 35 ]
python
en
['en', 'en', 'en']
True
AirPlayDevice.__init__
(self, device_id, client)
Initialize the AirPlay device.
Initialize the AirPlay device.
def __init__(self, device_id, client): """Initialize the AirPlay device.""" self._id = device_id self.client = client self.device_name = "AirPlay" self.kind = None self.active = False self.selected = False self.volume = 0 self.supports_audio = Fals...
[ "def", "__init__", "(", "self", ",", "device_id", ",", "client", ")", ":", "self", ".", "_id", "=", "device_id", "self", ".", "client", "=", "client", "self", ".", "device_name", "=", "\"AirPlay\"", "self", ".", "kind", "=", "None", "self", ".", "activ...
[ 409, 4 ]
[ 420, 32 ]
python
en
['en', 'en', 'en']
True
AirPlayDevice.update_state
(self, state_hash)
Update all the state properties with the passed in dictionary.
Update all the state properties with the passed in dictionary.
def update_state(self, state_hash): """Update all the state properties with the passed in dictionary.""" if "player_state" in state_hash: self.player_state = state_hash.get("player_state", None) if "name" in state_hash: name = state_hash.get("name", "") self....
[ "def", "update_state", "(", "self", ",", "state_hash", ")", ":", "if", "\"player_state\"", "in", "state_hash", ":", "self", ".", "player_state", "=", "state_hash", ".", "get", "(", "\"player_state\"", ",", "None", ")", "if", "\"name\"", "in", "state_hash", "...
[ 422, 4 ]
[ 447, 72 ]
python
en
['en', 'en', 'en']
True
AirPlayDevice.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.device_name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "device_name" ]
[ 450, 4 ]
[ 452, 31 ]
python
en
['en', 'en', 'en']
True
AirPlayDevice.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.""" if self.selected is True: return "mdi:volume-high" return "mdi:volume-off"
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "selected", "is", "True", ":", "return", "\"mdi:volume-high\"", "return", "\"mdi:volume-off\"" ]
[ 455, 4 ]
[ 460, 31 ]
python
en
['en', 'en', 'en']
True
AirPlayDevice.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" if self.selected is True: return STATE_ON return STATE_OFF
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "selected", "is", "True", ":", "return", "STATE_ON", "return", "STATE_OFF" ]
[ 463, 4 ]
[ 468, 24 ]
python
en
['en', 'en', 'en']
True
AirPlayDevice.update
(self)
Retrieve latest state.
Retrieve latest state.
def update(self): """Retrieve latest state."""
[ "def", "update", "(", "self", ")", ":" ]
[ 470, 4 ]
[ 471, 36 ]
python
en
['es', 'sk', 'en']
False
AirPlayDevice.volume_level
(self)
Return the volume.
Return the volume.
def volume_level(self): """Return the volume.""" return float(self.volume) / 100.0
[ "def", "volume_level", "(", "self", ")", ":", "return", "float", "(", "self", ".", "volume", ")", "/", "100.0" ]
[ 474, 4 ]
[ 476, 41 ]
python
en
['en', 'no', 'en']
True
AirPlayDevice.media_content_type
(self)
Flag of media content that is supported.
Flag of media content that is supported.
def media_content_type(self): """Flag of media content that is supported.""" return MEDIA_TYPE_MUSIC
[ "def", "media_content_type", "(", "self", ")", ":", "return", "MEDIA_TYPE_MUSIC" ]
[ 479, 4 ]
[ 481, 31 ]
python
en
['en', 'en', 'en']
True
AirPlayDevice.supported_features
(self)
Flag media player features that are supported.
Flag media player features that are supported.
def supported_features(self): """Flag media player features that are supported.""" return SUPPORT_AIRPLAY
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_AIRPLAY" ]
[ 484, 4 ]
[ 486, 30 ]
python
en
['en', 'en', 'en']
True
AirPlayDevice.set_volume_level
(self, volume)
Set volume level, range 0..1.
Set volume level, range 0..1.
def set_volume_level(self, volume): """Set volume level, range 0..1.""" volume = int(volume * 100) response = self.client.set_volume_airplay_device(self._id, volume) self.update_state(response)
[ "def", "set_volume_level", "(", "self", ",", "volume", ")", ":", "volume", "=", "int", "(", "volume", "*", "100", ")", "response", "=", "self", ".", "client", ".", "set_volume_airplay_device", "(", "self", ".", "_id", ",", "volume", ")", "self", ".", "...
[ 488, 4 ]
[ 492, 35 ]
python
en
['fr', 'zu', 'en']
False
AirPlayDevice.turn_on
(self)
Select AirPlay.
Select AirPlay.
def turn_on(self): """Select AirPlay.""" self.update_state({"selected": True}) self.schedule_update_ha_state() response = self.client.toggle_airplay_device(self._id, True) self.update_state(response)
[ "def", "turn_on", "(", "self", ")", ":", "self", ".", "update_state", "(", "{", "\"selected\"", ":", "True", "}", ")", "self", ".", "schedule_update_ha_state", "(", ")", "response", "=", "self", ".", "client", ".", "toggle_airplay_device", "(", "self", "."...
[ 494, 4 ]
[ 499, 35 ]
python
en
['en', 'en', 'en']
False
AirPlayDevice.turn_off
(self)
Deselect AirPlay.
Deselect AirPlay.
def turn_off(self): """Deselect AirPlay.""" self.update_state({"selected": False}) self.schedule_update_ha_state() response = self.client.toggle_airplay_device(self._id, False) self.update_state(response)
[ "def", "turn_off", "(", "self", ")", ":", "self", ".", "update_state", "(", "{", "\"selected\"", ":", "False", "}", ")", "self", ".", "schedule_update_ha_state", "(", ")", "response", "=", "self", ".", "client", ".", "toggle_airplay_device", "(", "self", "...
[ 501, 4 ]
[ 506, 35 ]
python
en
['en', 'en', 'en']
False