Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
test_no_switches_does_not_create
(hass)
Test if there are no switches no creation.
Test if there are no switches no creation.
async def test_no_switches_does_not_create(hass): """Test if there are no switches no creation.""" with assert_setup_component(0, "switch"): assert await async_setup_component( hass, "switch", {"switch": {"platform": "template"}} ) await hass.async_block_till_done() await ha...
[ "async", "def", "test_no_switches_does_not_create", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "0", ",", "\"switch\"", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"switch\"", ",", "{", "\"switch\"", ":", "{", "\"p...
[ 315, 0 ]
[ 326, 40 ]
python
en
['en', 'en', 'en']
True
test_missing_on_does_not_create
(hass)
Test missing on.
Test missing on.
async def test_missing_on_does_not_create(hass): """Test missing on.""" with assert_setup_component(0, "switch"): assert await async_setup_component( hass, "switch", { "switch": { "platform": "template", "switche...
[ "async", "def", "test_missing_on_does_not_create", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "0", ",", "\"switch\"", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"switch\"", ",", "{", "\"switch\"", ":", "{", "\"pl...
[ 329, 0 ]
[ 359, 40 ]
python
da
['mt', 'da', 'en']
False
test_missing_off_does_not_create
(hass)
Test missing off.
Test missing off.
async def test_missing_off_does_not_create(hass): """Test missing off.""" with assert_setup_component(0, "switch"): assert await async_setup_component( hass, "switch", { "switch": { "platform": "template", "switc...
[ "async", "def", "test_missing_off_does_not_create", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "0", ",", "\"switch\"", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"switch\"", ",", "{", "\"switch\"", ":", "{", "\"p...
[ 362, 0 ]
[ 392, 40 ]
python
en
['en', 'da', 'en']
True
test_on_action
(hass, calls)
Test on action.
Test on action.
async def test_on_action(hass, calls): """Test on action.""" assert await async_setup_component( hass, "switch", { "switch": { "platform": "template", "switches": { "test_template_switch": { "value_te...
[ "async", "def", "test_on_action", "(", "hass", ",", "calls", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"switch\"", ",", "{", "\"switch\"", ":", "{", "\"platform\"", ":", "\"template\"", ",", "\"switches\"", ":", "{", "\"test_tem...
[ 395, 0 ]
[ 434, 26 ]
python
en
['en', 'en', 'en']
True
test_on_action_optimistic
(hass, calls)
Test on action in optimistic mode.
Test on action in optimistic mode.
async def test_on_action_optimistic(hass, calls): """Test on action in optimistic mode.""" assert await async_setup_component( hass, "switch", { "switch": { "platform": "template", "switches": { "test_template_switch": { ...
[ "async", "def", "test_on_action_optimistic", "(", "hass", ",", "calls", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"switch\"", ",", "{", "\"switch\"", ":", "{", "\"platform\"", ":", "\"template\"", ",", "\"switches\"", ":", "{", ...
[ 437, 0 ]
[ 476, 34 ]
python
en
['en', 'en', 'it']
True
test_off_action
(hass, calls)
Test off action.
Test off action.
async def test_off_action(hass, calls): """Test off action.""" assert await async_setup_component( hass, "switch", { "switch": { "platform": "template", "switches": { "test_template_switch": { "value_...
[ "async", "def", "test_off_action", "(", "hass", ",", "calls", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"switch\"", ",", "{", "\"switch\"", ":", "{", "\"platform\"", ":", "\"template\"", ",", "\"switches\"", ":", "{", "\"test_te...
[ 479, 0 ]
[ 518, 26 ]
python
en
['en', 'en', 'en']
True
test_off_action_optimistic
(hass, calls)
Test off action in optimistic mode.
Test off action in optimistic mode.
async def test_off_action_optimistic(hass, calls): """Test off action in optimistic mode.""" assert await async_setup_component( hass, "switch", { "switch": { "platform": "template", "switches": { "test_template_switch": { ...
[ "async", "def", "test_off_action_optimistic", "(", "hass", ",", "calls", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"switch\"", ",", "{", "\"switch\"", ":", "{", "\"platform\"", ":", "\"template\"", ",", "\"switches\"", ":", "{", ...
[ 521, 0 ]
[ 560, 35 ]
python
en
['en', 'en', 'en']
True
test_restore_state
(hass)
Test state restoration.
Test state restoration.
async def test_restore_state(hass): """Test state restoration.""" mock_restore_cache( hass, ( State("switch.s1", STATE_ON), State("switch.s2", STATE_OFF), ), ) hass.state = CoreState.starting mock_component(hass, "recorder") await async_setup_com...
[ "async", "def", "test_restore_state", "(", "hass", ")", ":", "mock_restore_cache", "(", "hass", ",", "(", "State", "(", "\"switch.s1\"", ",", "STATE_ON", ")", ",", "State", "(", "\"switch.s2\"", ",", "STATE_OFF", ")", ",", ")", ",", ")", "hass", ".", "st...
[ 563, 0 ]
[ 603, 35 ]
python
en
['en', 'de', 'en']
True
test_available_template_with_entities
(hass)
Test availability templates with values from other entities.
Test availability templates with values from other entities.
async def test_available_template_with_entities(hass): """Test availability templates with values from other entities.""" await setup.async_setup_component( hass, "switch", { "switch": { "platform": "template", "switches": { ...
[ "async", "def", "test_available_template_with_entities", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"switch\"", ",", "{", "\"switch\"", ":", "{", "\"platform\"", ":", "\"template\"", ",", "\"switches\"", ":", "{", ...
[ 606, 0 ]
[ 644, 84 ]
python
en
['en', 'en', 'en']
True
test_invalid_availability_template_keeps_component_available
(hass, caplog)
Test that an invalid availability keeps the device available.
Test that an invalid availability keeps the device available.
async def test_invalid_availability_template_keeps_component_available(hass, caplog): """Test that an invalid availability keeps the device available.""" await setup.async_setup_component( hass, "switch", { "switch": { "platform": "template", "...
[ "async", "def", "test_invalid_availability_template_keeps_component_available", "(", "hass", ",", "caplog", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"switch\"", ",", "{", "\"switch\"", ":", "{", "\"platform\"", ":", "\"template\"",...
[ 647, 0 ]
[ 678, 62 ]
python
en
['en', 'en', 'en']
True
test_unique_id
(hass)
Test unique_id option only creates one switch per id.
Test unique_id option only creates one switch per id.
async def test_unique_id(hass): """Test unique_id option only creates one switch per id.""" await setup.async_setup_component( hass, "switch", { "switch": { "platform": "template", "switches": { "test_template_switch_01": { ...
[ "async", "def", "test_unique_id", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"switch\"", ",", "{", "\"switch\"", ":", "{", "\"platform\"", ":", "\"template\"", ",", "\"switches\"", ":", "{", "\"test_template_switch...
[ 681, 0 ]
[ 723, 44 ]
python
en
['en', 'en', 'en']
True
apply_fixed_architecture
(model, fixed_arc, verbose=True)
Load architecture from `fixed_arc` and apply to model. Parameters ---------- model : torch.nn.Module Model with mutables. fixed_arc : str or dict Path to the JSON that stores the architecture, or dict that stores the exported architecture. verbose : bool Print log messa...
Load architecture from `fixed_arc` and apply to model.
def apply_fixed_architecture(model, fixed_arc, verbose=True): """ Load architecture from `fixed_arc` and apply to model. Parameters ---------- model : torch.nn.Module Model with mutables. fixed_arc : str or dict Path to the JSON that stores the architecture, or dict that stores ...
[ "def", "apply_fixed_architecture", "(", "model", ",", "fixed_arc", ",", "verbose", "=", "True", ")", ":", "if", "isinstance", "(", "fixed_arc", ",", "str", ")", ":", "with", "open", "(", "fixed_arc", ")", "as", "f", ":", "fixed_arc", "=", "json", ".", ...
[ 119, 0 ]
[ 146, 23 ]
python
en
['en', 'error', 'th']
False
FixedArchitecture.sample_search
(self)
Always returns the fixed architecture.
Always returns the fixed architecture.
def sample_search(self): """ Always returns the fixed architecture. """ return self._fixed_arc
[ "def", "sample_search", "(", "self", ")", ":", "return", "self", ".", "_fixed_arc" ]
[ 70, 4 ]
[ 74, 30 ]
python
en
['en', 'error', 'th']
False
FixedArchitecture.sample_final
(self)
Always returns the fixed architecture.
Always returns the fixed architecture.
def sample_final(self): """ Always returns the fixed architecture. """ return self._fixed_arc
[ "def", "sample_final", "(", "self", ")", ":", "return", "self", ".", "_fixed_arc" ]
[ 76, 4 ]
[ 80, 30 ]
python
en
['en', 'error', 'th']
False
FixedArchitecture.replace_layer_choice
(self, module=None, prefix="")
Replace layer choices with selected candidates. It's done with best effort. In case of weighted choices or multiple choices. if some of the choices on weighted with zero, delete them. If single choice, replace the module with a normal module. Parameters ---------- modul...
Replace layer choices with selected candidates. It's done with best effort. In case of weighted choices or multiple choices. if some of the choices on weighted with zero, delete them. If single choice, replace the module with a normal module.
def replace_layer_choice(self, module=None, prefix=""): """ Replace layer choices with selected candidates. It's done with best effort. In case of weighted choices or multiple choices. if some of the choices on weighted with zero, delete them. If single choice, replace the module with a ...
[ "def", "replace_layer_choice", "(", "self", ",", "module", "=", "None", ",", "prefix", "=", "\"\"", ")", ":", "if", "module", "is", "None", ":", "module", "=", "self", ".", "model", "for", "name", ",", "mutable", "in", "module", ".", "named_children", ...
[ 82, 4 ]
[ 116, 63 ]
python
en
['en', 'error', 'th']
False
mock_setup
()
Prevent setup.
Prevent setup.
def mock_setup(): """Prevent setup.""" with patch( "homeassistant.components.openuv.async_setup", return_value=True, ), patch( "homeassistant.components.openuv.async_setup_entry", return_value=True, ): yield
[ "def", "mock_setup", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.openuv.async_setup\"", ",", "return_value", "=", "True", ",", ")", ",", "patch", "(", "\"homeassistant.components.openuv.async_setup_entry\"", ",", "return_value", "=", "True", ",", ...
[ 19, 0 ]
[ 28, 13 ]
python
en
['en', 'pt', 'en']
False
test_duplicate_error
(hass)
Test that errors are shown when duplicates are added.
Test that errors are shown when duplicates are added.
async def test_duplicate_error(hass): """Test that errors are shown when duplicates are added.""" conf = { CONF_API_KEY: "12345abcde", CONF_ELEVATION: 59.1234, CONF_LATITUDE: 39.128712, CONF_LONGITUDE: -104.9812612, } MockConfigEntry( domain=DOMAIN, unique_id="39...
[ "async", "def", "test_duplicate_error", "(", "hass", ")", ":", "conf", "=", "{", "CONF_API_KEY", ":", "\"12345abcde\"", ",", "CONF_ELEVATION", ":", "59.1234", ",", "CONF_LATITUDE", ":", "39.128712", ",", "CONF_LONGITUDE", ":", "-", "104.9812612", ",", "}", "Mo...
[ 31, 0 ]
[ 49, 51 ]
python
en
['en', 'en', 'en']
True
test_invalid_api_key
(hass)
Test that an invalid API key throws an error.
Test that an invalid API key throws an error.
async def test_invalid_api_key(hass): """Test that an invalid API key throws an error.""" conf = { CONF_API_KEY: "12345abcde", CONF_ELEVATION: 59.1234, CONF_LATITUDE: 39.128712, CONF_LONGITUDE: -104.9812612, } with patch( "pyopenuv.client.Client.uv_index", ...
[ "async", "def", "test_invalid_api_key", "(", "hass", ")", ":", "conf", "=", "{", "CONF_API_KEY", ":", "\"12345abcde\"", ",", "CONF_ELEVATION", ":", "59.1234", ",", "CONF_LATITUDE", ":", "39.128712", ",", "CONF_LONGITUDE", ":", "-", "104.9812612", ",", "}", "wi...
[ 52, 0 ]
[ 69, 68 ]
python
en
['en', 'gd', 'en']
True
test_step_user
(hass)
Test that the user step works.
Test that the user step works.
async def test_step_user(hass): """Test that the user step works.""" conf = { CONF_API_KEY: "12345abcde", CONF_ELEVATION: 59.1234, CONF_LATITUDE: 39.128712, CONF_LONGITUDE: -104.9812612, } with patch( "homeassistant.components.airvisual.async_setup_entry", return...
[ "async", "def", "test_step_user", "(", "hass", ")", ":", "conf", "=", "{", "CONF_API_KEY", ":", "\"12345abcde\"", ",", "CONF_ELEVATION", ":", "59.1234", ",", "CONF_LATITUDE", ":", "39.128712", ",", "CONF_LONGITUDE", ":", "-", "104.9812612", ",", "}", "with", ...
[ 72, 0 ]
[ 100, 9 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Mediaroom platform.
Set up the Mediaroom platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Mediaroom platform.""" known_hosts = hass.data.get(DATA_MEDIAROOM) if known_hosts is None: known_hosts = hass.data[DATA_MEDIAROOM] = [] host = config.get(CONF_HOST) if host: async_add...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "known_hosts", "=", "hass", ".", "data", ".", "get", "(", "DATA_MEDIAROOM", ")", "if", "known_hosts", "is", "None", "...
[ 75, 0 ]
[ 125, 53 ]
python
en
['en', 'da', 'en']
True
MediaroomDevice.set_state
(self, mediaroom_state)
Map pymediaroom state to HA state.
Map pymediaroom state to HA state.
def set_state(self, mediaroom_state): """Map pymediaroom state to HA state.""" state_map = { State.OFF: STATE_OFF, State.STANDBY: STATE_STANDBY, State.PLAYING_LIVE_TV: STATE_PLAYING, State.PLAYING_RECORDED_TV: STATE_PLAYING, State.PLAYING_TIME...
[ "def", "set_state", "(", "self", ",", "mediaroom_state", ")", ":", "state_map", "=", "{", "State", ".", "OFF", ":", "STATE_OFF", ",", "State", ".", "STANDBY", ":", "STATE_STANDBY", ",", "State", ".", "PLAYING_LIVE_TV", ":", "STATE_PLAYING", ",", "State", "...
[ 131, 4 ]
[ 144, 48 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.__init__
(self, host, device_id, optimistic=False, timeout=DEFAULT_TIMEOUT)
Initialize the device.
Initialize the device.
def __init__(self, host, device_id, optimistic=False, timeout=DEFAULT_TIMEOUT): """Initialize the device.""" self.host = host self.stb = Remote(host) _LOGGER.info( "Found STB at %s%s", host, " - I'm optimistic" if optimistic else "" ) self._channel = None ...
[ "def", "__init__", "(", "self", ",", "host", ",", "device_id", ",", "optimistic", "=", "False", ",", "timeout", "=", "DEFAULT_TIMEOUT", ")", ":", "self", ".", "host", "=", "host", "self", ".", "stb", "=", "Remote", "(", "host", ")", "_LOGGER", ".", "...
[ 146, 4 ]
[ 162, 34 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 165, 4 ]
[ 167, 20 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 170, 4 ]
[ 172, 30 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.async_added_to_hass
(self)
Retrieve latest state.
Retrieve latest state.
async def async_added_to_hass(self): """Retrieve latest state.""" async def async_notify_received(notify): """Process STB state from NOTIFY message.""" stb_state = self.stb.notify_callback(notify) # stb_state is None in case the notify is not from the current stb ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "async", "def", "async_notify_received", "(", "notify", ")", ":", "\"\"\"Process STB state from NOTIFY message.\"\"\"", "stb_state", "=", "self", ".", "stb", ".", "notify_callback", "(", "notify", ")", "#...
[ 174, 4 ]
[ 192, 9 ]
python
en
['es', 'sk', 'en']
False
MediaroomDevice.async_play_media
(self, media_type, media_id, **kwargs)
Play media.
Play media.
async def async_play_media(self, media_type, media_id, **kwargs): """Play media.""" _LOGGER.debug( "STB(%s) Play media: %s (%s)", self.stb.stb_ip, media_id, media_type ) if media_type == MEDIA_TYPE_CHANNEL: if not media_id.isdigit(): _LOGGER.error...
[ "async", "def", "async_play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"STB(%s) Play media: %s (%s)\"", ",", "self", ".", "stb", ".", "stb_ip", ",", "media_id", ",", "media_type...
[ 194, 4 ]
[ 220, 35 ]
python
en
['en', 'sv', 'en']
False
MediaroomDevice.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 223, 4 ]
[ 225, 30 ]
python
ca
['fr', 'ca', 'en']
False
MediaroomDevice.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" ]
[ 228, 4 ]
[ 230, 25 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.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" ]
[ 233, 4 ]
[ 235, 26 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.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_MEDIAROOM
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_MEDIAROOM" ]
[ 238, 4 ]
[ 240, 32 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.media_content_type
(self)
Return the content type of current playing media.
Return the content type of current playing media.
def media_content_type(self): """Return the content type of current playing media.""" return MEDIA_TYPE_CHANNEL
[ "def", "media_content_type", "(", "self", ")", ":", "return", "MEDIA_TYPE_CHANNEL" ]
[ 243, 4 ]
[ 245, 33 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.media_channel
(self)
Channel currently playing.
Channel currently playing.
def media_channel(self): """Channel currently playing.""" return self._channel
[ "def", "media_channel", "(", "self", ")", ":", "return", "self", ".", "_channel" ]
[ 248, 4 ]
[ 250, 28 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.async_turn_on
(self)
Turn on the receiver.
Turn on the receiver.
async def async_turn_on(self): """Turn on the receiver.""" try: self.set_state(await self.stb.turn_on()) if self._optimistic: self._state = STATE_PLAYING self._available = True except PyMediaroomError: self._available = False ...
[ "async", "def", "async_turn_on", "(", "self", ")", ":", "try", ":", "self", ".", "set_state", "(", "await", "self", ".", "stb", ".", "turn_on", "(", ")", ")", "if", "self", ".", "_optimistic", ":", "self", ".", "_state", "=", "STATE_PLAYING", "self", ...
[ 252, 4 ]
[ 262, 35 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.async_turn_off
(self)
Turn off the receiver.
Turn off the receiver.
async def async_turn_off(self): """Turn off the receiver.""" try: self.set_state(await self.stb.turn_off()) if self._optimistic: self._state = STATE_STANDBY self._available = True except PyMediaroomError: self._available = False ...
[ "async", "def", "async_turn_off", "(", "self", ")", ":", "try", ":", "self", ".", "set_state", "(", "await", "self", ".", "stb", ".", "turn_off", "(", ")", ")", "if", "self", ".", "_optimistic", ":", "self", ".", "_state", "=", "STATE_STANDBY", "self",...
[ 264, 4 ]
[ 274, 35 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.async_media_play
(self)
Send play command.
Send play command.
async def async_media_play(self): """Send play command.""" try: _LOGGER.debug("media_play()") await self.stb.send_cmd("PlayPause") if self._optimistic: self._state = STATE_PLAYING self._available = True except PyMediaroomError: ...
[ "async", "def", "async_media_play", "(", "self", ")", ":", "try", ":", "_LOGGER", ".", "debug", "(", "\"media_play()\"", ")", "await", "self", ".", "stb", ".", "send_cmd", "(", "\"PlayPause\"", ")", "if", "self", ".", "_optimistic", ":", "self", ".", "_s...
[ 276, 4 ]
[ 287, 35 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.async_media_pause
(self)
Send pause command.
Send pause command.
async def async_media_pause(self): """Send pause command.""" try: await self.stb.send_cmd("PlayPause") if self._optimistic: self._state = STATE_PAUSED self._available = True except PyMediaroomError: self._available = False ...
[ "async", "def", "async_media_pause", "(", "self", ")", ":", "try", ":", "await", "self", ".", "stb", ".", "send_cmd", "(", "\"PlayPause\"", ")", "if", "self", ".", "_optimistic", ":", "self", ".", "_state", "=", "STATE_PAUSED", "self", ".", "_available", ...
[ 289, 4 ]
[ 299, 35 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.async_media_stop
(self)
Send stop command.
Send stop command.
async def async_media_stop(self): """Send stop command.""" try: await self.stb.send_cmd("Stop") if self._optimistic: self._state = STATE_PAUSED self._available = True except PyMediaroomError: self._available = False self.as...
[ "async", "def", "async_media_stop", "(", "self", ")", ":", "try", ":", "await", "self", ".", "stb", ".", "send_cmd", "(", "\"Stop\"", ")", "if", "self", ".", "_optimistic", ":", "self", ".", "_state", "=", "STATE_PAUSED", "self", ".", "_available", "=", ...
[ 301, 4 ]
[ 311, 35 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.async_media_previous_track
(self)
Send Program Down command.
Send Program Down command.
async def async_media_previous_track(self): """Send Program Down command.""" try: await self.stb.send_cmd("ProgDown") if self._optimistic: self._state = STATE_PLAYING self._available = True except PyMediaroomError: self._available ...
[ "async", "def", "async_media_previous_track", "(", "self", ")", ":", "try", ":", "await", "self", ".", "stb", ".", "send_cmd", "(", "\"ProgDown\"", ")", "if", "self", ".", "_optimistic", ":", "self", ".", "_state", "=", "STATE_PLAYING", "self", ".", "_avai...
[ 313, 4 ]
[ 323, 35 ]
python
en
['en', 'it', 'en']
True
MediaroomDevice.async_media_next_track
(self)
Send Program Up command.
Send Program Up command.
async def async_media_next_track(self): """Send Program Up command.""" try: await self.stb.send_cmd("ProgUp") if self._optimistic: self._state = STATE_PLAYING self._available = True except PyMediaroomError: self._available = False ...
[ "async", "def", "async_media_next_track", "(", "self", ")", ":", "try", ":", "await", "self", ".", "stb", ".", "send_cmd", "(", "\"ProgUp\"", ")", "if", "self", ".", "_optimistic", ":", "self", ".", "_state", "=", "STATE_PLAYING", "self", ".", "_available"...
[ 325, 4 ]
[ 335, 35 ]
python
en
['en', 'pt', 'en']
True
MediaroomDevice.async_volume_up
(self)
Send volume up command.
Send volume up command.
async def async_volume_up(self): """Send volume up command.""" try: await self.stb.send_cmd("VolUp") self._available = True except PyMediaroomError: self._available = False self.async_write_ha_state()
[ "async", "def", "async_volume_up", "(", "self", ")", ":", "try", ":", "await", "self", ".", "stb", ".", "send_cmd", "(", "\"VolUp\"", ")", "self", ".", "_available", "=", "True", "except", "PyMediaroomError", ":", "self", ".", "_available", "=", "False", ...
[ 337, 4 ]
[ 345, 35 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.async_volume_down
(self)
Send volume up command.
Send volume up command.
async def async_volume_down(self): """Send volume up command.""" try: await self.stb.send_cmd("VolDown") except PyMediaroomError: self._available = False self.async_write_ha_state()
[ "async", "def", "async_volume_down", "(", "self", ")", ":", "try", ":", "await", "self", ".", "stb", ".", "send_cmd", "(", "\"VolDown\"", ")", "except", "PyMediaroomError", ":", "self", ".", "_available", "=", "False", "self", ".", "async_write_ha_state", "(...
[ 347, 4 ]
[ 354, 35 ]
python
en
['en', 'en', 'en']
True
MediaroomDevice.async_mute_volume
(self, mute)
Send mute command.
Send mute command.
async def async_mute_volume(self, mute): """Send mute command.""" try: await self.stb.send_cmd("Mute") except PyMediaroomError: self._available = False self.async_write_ha_state()
[ "async", "def", "async_mute_volume", "(", "self", ",", "mute", ")", ":", "try", ":", "await", "self", ".", "stb", ".", "send_cmd", "(", "\"Mute\"", ")", "except", "PyMediaroomError", ":", "self", ".", "_available", "=", "False", "self", ".", "async_write_h...
[ 356, 4 ]
[ 363, 35 ]
python
en
['en', 'co', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Garadget covers.
Set up the Garadget covers.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Garadget covers.""" covers = [] devices = config.get(CONF_COVERS) for device_id, device_config in devices.items(): args = { "name": device_config.get(CONF_NAME), "device_id": device_config...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "covers", "=", "[", "]", "devices", "=", "config", ".", "get", "(", "CONF_COVERS", ")", "for", "device_id", ",", "device_config", "in", ...
[ 57, 0 ]
[ 73, 24 ]
python
en
['en', 'en', 'en']
True
GaradgetCover.__init__
(self, hass, args)
Initialize the cover.
Initialize the cover.
def __init__(self, hass, args): """Initialize the cover.""" self.particle_url = "https://api.particle.io" self.hass = hass self._name = args["name"] self.device_id = args["device_id"] self.access_token = args["access_token"] self.obtained_token = False sel...
[ "def", "__init__", "(", "self", ",", "hass", ",", "args", ")", ":", "self", ".", "particle_url", "=", "\"https://api.particle.io\"", "self", ".", "hass", "=", "hass", "self", ".", "_name", "=", "args", "[", "\"name\"", "]", "self", ".", "device_id", "=",...
[ 79, 4 ]
[ 118, 35 ]
python
en
['en', 'en', 'en']
True
GaradgetCover.__del__
(self)
Try to remove token.
Try to remove token.
def __del__(self): """Try to remove token.""" if self._obtained_token is True: if self.access_token is not None: self.remove_token()
[ "def", "__del__", "(", "self", ")", ":", "if", "self", ".", "_obtained_token", "is", "True", ":", "if", "self", ".", "access_token", "is", "not", "None", ":", "self", ".", "remove_token", "(", ")" ]
[ 120, 4 ]
[ 124, 35 ]
python
en
['en', 'en', 'en']
True
GaradgetCover.name
(self)
Return the name of the cover.
Return the name of the cover.
def name(self): """Return the name of the cover.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 127, 4 ]
[ 129, 25 ]
python
en
['en', 'en', 'en']
True
GaradgetCover.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 132, 4 ]
[ 134, 30 ]
python
en
['en', 'en', 'en']
True
GaradgetCover.device_state_attributes
(self)
Return the device state attributes.
Return the device state attributes.
def device_state_attributes(self): """Return the device state attributes.""" data = {} if self.signal is not None: data[ATTR_SIGNAL_STRENGTH] = self.signal if self.time_in_state is not None: data[ATTR_TIME_IN_STATE] = self.time_in_state if self.sensor i...
[ "def", "device_state_attributes", "(", "self", ")", ":", "data", "=", "{", "}", "if", "self", ".", "signal", "is", "not", "None", ":", "data", "[", "ATTR_SIGNAL_STRENGTH", "]", "=", "self", ".", "signal", "if", "self", ".", "time_in_state", "is", "not", ...
[ 137, 4 ]
[ 153, 19 ]
python
en
['en', 'en', 'en']
True
GaradgetCover.is_closed
(self)
Return if the cover is closed.
Return if the cover is closed.
def is_closed(self): """Return if the cover is closed.""" if self._state is None: return None return self._state == STATE_CLOSED
[ "def", "is_closed", "(", "self", ")", ":", "if", "self", ".", "_state", "is", "None", ":", "return", "None", "return", "self", ".", "_state", "==", "STATE_CLOSED" ]
[ 156, 4 ]
[ 160, 42 ]
python
en
['en', 'en', 'en']
True
GaradgetCover.device_class
(self)
Return the class of this device, from component DEVICE_CLASSES.
Return the class of this device, from component DEVICE_CLASSES.
def device_class(self): """Return the class of this device, from component DEVICE_CLASSES.""" return "garage"
[ "def", "device_class", "(", "self", ")", ":", "return", "\"garage\"" ]
[ 163, 4 ]
[ 165, 23 ]
python
en
['en', 'en', 'en']
True
GaradgetCover.get_token
(self)
Get new token for usage during this session.
Get new token for usage during this session.
def get_token(self): """Get new token for usage during this session.""" args = { "grant_type": "password", "username": self._username, "password": self._password, } url = f"{self.particle_url}/oauth/token" ret = requests.post(url, auth=("partic...
[ "def", "get_token", "(", "self", ")", ":", "args", "=", "{", "\"grant_type\"", ":", "\"password\"", ",", "\"username\"", ":", "self", ".", "_username", ",", "\"password\"", ":", "self", ".", "_password", ",", "}", "url", "=", "f\"{self.particle_url}/oauth/toke...
[ 167, 4 ]
[ 180, 60 ]
python
en
['en', 'en', 'en']
True
GaradgetCover.remove_token
(self)
Remove authorization token from API.
Remove authorization token from API.
def remove_token(self): """Remove authorization token from API.""" url = f"{self.particle_url}/v1/access_tokens/{self.access_token}" ret = requests.delete(url, auth=(self._username, self._password), timeout=10) return ret.text
[ "def", "remove_token", "(", "self", ")", ":", "url", "=", "f\"{self.particle_url}/v1/access_tokens/{self.access_token}\"", "ret", "=", "requests", ".", "delete", "(", "url", ",", "auth", "=", "(", "self", ".", "_username", ",", "self", ".", "_password", ")", "...
[ 182, 4 ]
[ 186, 23 ]
python
en
['en', 'en', 'en']
True
GaradgetCover._start_watcher
(self, command)
Start watcher.
Start watcher.
def _start_watcher(self, command): """Start watcher.""" _LOGGER.debug("Starting Watcher for command: %s ", command) if self._unsub_listener_cover is None: self._unsub_listener_cover = track_utc_time_change( self.hass, self._check_state )
[ "def", "_start_watcher", "(", "self", ",", "command", ")", ":", "_LOGGER", ".", "debug", "(", "\"Starting Watcher for command: %s \"", ",", "command", ")", "if", "self", ".", "_unsub_listener_cover", "is", "None", ":", "self", ".", "_unsub_listener_cover", "=", ...
[ 188, 4 ]
[ 194, 13 ]
python
en
['en', 'de', 'en']
False
GaradgetCover._check_state
(self, now)
Check the state of the service during an operation.
Check the state of the service during an operation.
def _check_state(self, now): """Check the state of the service during an operation.""" self.schedule_update_ha_state(True)
[ "def", "_check_state", "(", "self", ",", "now", ")", ":", "self", ".", "schedule_update_ha_state", "(", "True", ")" ]
[ 196, 4 ]
[ 198, 43 ]
python
en
['en', 'en', 'en']
True
GaradgetCover.close_cover
(self, **kwargs)
Close the cover.
Close the cover.
def close_cover(self, **kwargs): """Close the cover.""" if self._state not in ["close", "closing"]: ret = self._put_command("setState", "close") self._start_watcher("close") return ret.get("return_value") == 1
[ "def", "close_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_state", "not", "in", "[", "\"close\"", ",", "\"closing\"", "]", ":", "ret", "=", "self", ".", "_put_command", "(", "\"setState\"", ",", "\"close\"", ")", "self",...
[ 200, 4 ]
[ 205, 47 ]
python
en
['en', 'en', 'en']
True
GaradgetCover.open_cover
(self, **kwargs)
Open the cover.
Open the cover.
def open_cover(self, **kwargs): """Open the cover.""" if self._state not in ["open", "opening"]: ret = self._put_command("setState", "open") self._start_watcher("open") return ret.get("return_value") == 1
[ "def", "open_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_state", "not", "in", "[", "\"open\"", ",", "\"opening\"", "]", ":", "ret", "=", "self", ".", "_put_command", "(", "\"setState\"", ",", "\"open\"", ")", "self", ...
[ 207, 4 ]
[ 212, 47 ]
python
en
['en', 'en', 'en']
True
GaradgetCover.stop_cover
(self, **kwargs)
Stop the door where it is.
Stop the door where it is.
def stop_cover(self, **kwargs): """Stop the door where it is.""" if self._state not in ["stopped"]: ret = self._put_command("setState", "stop") self._start_watcher("stop") return ret["return_value"] == 1
[ "def", "stop_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_state", "not", "in", "[", "\"stopped\"", "]", ":", "ret", "=", "self", ".", "_put_command", "(", "\"setState\"", ",", "\"stop\"", ")", "self", ".", "_start_watche...
[ 214, 4 ]
[ 219, 43 ]
python
en
['en', 'nl', 'en']
True
GaradgetCover.update
(self)
Get updated status from API.
Get updated status from API.
def update(self): """Get updated status from API.""" try: status = self._get_variable("doorStatus") _LOGGER.debug("Current Status: %s", status["status"]) self._state = STATES_MAP.get(status["status"]) self.time_in_state = status["time"] self.si...
[ "def", "update", "(", "self", ")", ":", "try", ":", "status", "=", "self", ".", "_get_variable", "(", "\"doorStatus\"", ")", "_LOGGER", ".", "debug", "(", "\"Current Status: %s\"", ",", "status", "[", "\"status\"", "]", ")", "self", ".", "_state", "=", "...
[ 221, 4 ]
[ 244, 49 ]
python
en
['en', 'en', 'en']
True
GaradgetCover._get_variable
(self, var)
Get latest status.
Get latest status.
def _get_variable(self, var): """Get latest status.""" url = f"{self.particle_url}/v1/devices/{self.device_id}/{var}?access_token={self.access_token}" ret = requests.get(url, timeout=10) result = {} for pairs in ret.json()["result"].split("|"): key = pairs.split("=") ...
[ "def", "_get_variable", "(", "self", ",", "var", ")", ":", "url", "=", "f\"{self.particle_url}/v1/devices/{self.device_id}/{var}?access_token={self.access_token}\"", "ret", "=", "requests", ".", "get", "(", "url", ",", "timeout", "=", "10", ")", "result", "=", "{", ...
[ 246, 4 ]
[ 254, 21 ]
python
en
['fr', 'la', 'en']
False
GaradgetCover._put_command
(self, func, arg=None)
Send commands to API.
Send commands to API.
def _put_command(self, func, arg=None): """Send commands to API.""" params = {"access_token": self.access_token} if arg: params["command"] = arg url = f"{self.particle_url}/v1/devices/{self.device_id}/{func}" ret = requests.post(url, data=params, timeout=10) r...
[ "def", "_put_command", "(", "self", ",", "func", ",", "arg", "=", "None", ")", ":", "params", "=", "{", "\"access_token\"", ":", "self", ".", "access_token", "}", "if", "arg", ":", "params", "[", "\"command\"", "]", "=", "arg", "url", "=", "f\"{self.pa...
[ 256, 4 ]
[ 263, 25 ]
python
en
['en', 'pt', 'en']
True
async_get_conditions
( hass: HomeAssistant, device_id: str )
List device conditions for Device tracker devices.
List device conditions for Device tracker devices.
async def async_get_conditions( hass: HomeAssistant, device_id: str ) -> List[Dict[str, str]]: """List device conditions for Device tracker devices.""" registry = await entity_registry.async_get_registry(hass) conditions = [] # Get all the integrations entities for this device for entry in enti...
[ "async", "def", "async_get_conditions", "(", "hass", ":", "HomeAssistant", ",", "device_id", ":", "str", ")", "->", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ":", "registry", "=", "await", "entity_registry", ".", "async_get_registry", "(", "ha...
[ 32, 0 ]
[ 64, 21 ]
python
en
['fr', 'en', 'en']
True
async_condition_from_config
( config: ConfigType, config_validation: bool )
Create a function to test a device condition.
Create a function to test a device condition.
def async_condition_from_config( config: ConfigType, config_validation: bool ) -> condition.ConditionCheckerType: """Create a function to test a device condition.""" if config_validation: config = CONDITION_SCHEMA(config) if config[CONF_TYPE] == "is_home": state = STATE_HOME else: ...
[ "def", "async_condition_from_config", "(", "config", ":", "ConfigType", ",", "config_validation", ":", "bool", ")", "->", "condition", ".", "ConditionCheckerType", ":", "if", "config_validation", ":", "config", "=", "CONDITION_SCHEMA", "(", "config", ")", "if", "c...
[ 68, 0 ]
[ 84, 24 ]
python
en
['en', 'en', 'en']
True
get_mysensors_devices
(hass, domain)
Return MySensors devices for a platform.
Return MySensors devices for a platform.
def get_mysensors_devices(hass, domain): """Return MySensors devices for a platform.""" if MYSENSORS_PLATFORM_DEVICES.format(domain) not in hass.data: hass.data[MYSENSORS_PLATFORM_DEVICES.format(domain)] = {} return hass.data[MYSENSORS_PLATFORM_DEVICES.format(domain)]
[ "def", "get_mysensors_devices", "(", "hass", ",", "domain", ")", ":", "if", "MYSENSORS_PLATFORM_DEVICES", ".", "format", "(", "domain", ")", "not", "in", "hass", ".", "data", ":", "hass", ".", "data", "[", "MYSENSORS_PLATFORM_DEVICES", ".", "format", "(", "d...
[ 21, 0 ]
[ 25, 63 ]
python
da
['fr', 'da', 'en']
False
MySensorsDevice.__init__
(self, gateway, node_id, child_id, name, value_type)
Set up the MySensors device.
Set up the MySensors device.
def __init__(self, gateway, node_id, child_id, name, value_type): """Set up the MySensors device.""" self.gateway = gateway self.node_id = node_id self.child_id = child_id self._name = name self.value_type = value_type child = gateway.sensors[node_id].children[chi...
[ "def", "__init__", "(", "self", ",", "gateway", ",", "node_id", ",", "child_id", ",", "name", ",", "value_type", ")", ":", "self", ".", "gateway", "=", "gateway", "self", ".", "node_id", "=", "node_id", "self", ".", "child_id", "=", "child_id", "self", ...
[ 31, 4 ]
[ 42, 24 ]
python
en
['en', 'en', 'en']
True
MySensorsDevice.name
(self)
Return the name of this entity.
Return the name of this entity.
def name(self): """Return the name of this entity.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 45, 4 ]
[ 47, 25 ]
python
en
['en', 'en', 'en']
True
MySensorsDevice.device_state_attributes
(self)
Return device specific state attributes.
Return device specific state attributes.
def device_state_attributes(self): """Return device specific state attributes.""" node = self.gateway.sensors[self.node_id] child = node.children[self.child_id] attr = { ATTR_BATTERY_LEVEL: node.battery_level, ATTR_HEARTBEAT: node.heartbeat, ATTR_CHILD...
[ "def", "device_state_attributes", "(", "self", ")", ":", "node", "=", "self", ".", "gateway", ".", "sensors", "[", "self", ".", "node_id", "]", "child", "=", "node", ".", "children", "[", "self", ".", "child_id", "]", "attr", "=", "{", "ATTR_BATTERY_LEVE...
[ 50, 4 ]
[ 68, 19 ]
python
en
['fr', 'en', 'en']
True
MySensorsDevice.async_update
(self)
Update the controller with the latest value from a sensor.
Update the controller with the latest value from a sensor.
async def async_update(self): """Update the controller with the latest value from a sensor.""" node = self.gateway.sensors[self.node_id] child = node.children[self.child_id] set_req = self.gateway.const.SetReq for value_type, value in child.values.items(): _LOGGER.deb...
[ "async", "def", "async_update", "(", "self", ")", ":", "node", "=", "self", ".", "gateway", ".", "sensors", "[", "self", ".", "node_id", "]", "child", "=", "node", ".", "children", "[", "self", ".", "child_id", "]", "set_req", "=", "self", ".", "gate...
[ 70, 4 ]
[ 92, 48 ]
python
en
['en', 'en', 'en']
True
MySensorsDevice._async_update_callback
(self)
Update the device.
Update the device.
async def _async_update_callback(self): """Update the device.""" raise NotImplementedError
[ "async", "def", "_async_update_callback", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 94, 4 ]
[ 96, 33 ]
python
en
['en', 'en', 'en']
True
MySensorsDevice.async_update_callback
(self)
Update the device after delay.
Update the device after delay.
def async_update_callback(self): """Update the device after delay.""" if self._update_scheduled: return async def update(): """Perform update.""" try: await self._async_update_callback() except Exception: # pylint: disable=broad-e...
[ "def", "async_update_callback", "(", "self", ")", ":", "if", "self", ".", "_update_scheduled", ":", "return", "async", "def", "update", "(", ")", ":", "\"\"\"Perform update.\"\"\"", "try", ":", "await", "self", ".", "_async_update_callback", "(", ")", "except", ...
[ 99, 4 ]
[ 115, 63 ]
python
en
['en', 'en', 'en']
True
MySensorsEntity.should_poll
(self)
Return the polling state. The gateway pushes its states.
Return the polling state. The gateway pushes its states.
def should_poll(self): """Return the polling state. The gateway pushes its states.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 122, 4 ]
[ 124, 20 ]
python
en
['en', 'en', 'en']
True
MySensorsEntity.available
(self)
Return true if entity is available.
Return true if entity is available.
def available(self): """Return true if entity is available.""" return self.value_type in self._values
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "value_type", "in", "self", ".", "_values" ]
[ 127, 4 ]
[ 129, 46 ]
python
en
['en', 'en', 'en']
True
MySensorsEntity._async_update_callback
(self)
Update the entity.
Update the entity.
async def _async_update_callback(self): """Update the entity.""" await self.async_update_ha_state(True)
[ "async", "def", "_async_update_callback", "(", "self", ")", ":", "await", "self", ".", "async_update_ha_state", "(", "True", ")" ]
[ 131, 4 ]
[ 133, 46 ]
python
en
['en', 'en', 'en']
True
MySensorsEntity.async_added_to_hass
(self)
Register update callback.
Register update callback.
async def async_added_to_hass(self): """Register update callback.""" gateway_id = id(self.gateway) dev_id = gateway_id, self.node_id, self.child_id, self.value_type self.async_on_remove( async_dispatcher_connect( self.hass, CHILD_CALLBACK.format(*dev_id), self...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "gateway_id", "=", "id", "(", "self", ".", "gateway", ")", "dev_id", "=", "gateway_id", ",", "self", ".", "node_id", ",", "self", ".", "child_id", ",", "self", ".", "value_type", "self", ".", ...
[ 135, 4 ]
[ 150, 9 ]
python
en
['fr', 'no', 'en']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Read in all of our configuration, and initialize the loopback switch.
Read in all of our configuration, and initialize the loopback switch.
def setup_platform(hass, config, add_entities, discovery_info=None): """Read in all of our configuration, and initialize the loopback switch.""" name = config.get(CONF_NAME) sink_name = config.get(CONF_SINK_NAME) source_name = config.get(CONF_SOURCE_NAME) host = config.get(CONF_HOST) port = conf...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "sink_name", "=", "config", ".", "get", "(", "CONF_SINK_NAME", ")", "source_na...
[ 33, 0 ]
[ 56, 80 ]
python
en
['en', 'en', 'en']
True
PALoopbackSwitch.__init__
(self, name, pa_server, sink_name, source_name)
Initialize the Pulseaudio switch.
Initialize the Pulseaudio switch.
def __init__(self, name, pa_server, sink_name, source_name): """Initialize the Pulseaudio switch.""" self._module_idx = None self._name = name self._sink_name = sink_name self._source_name = source_name self._pa_svr = pa_server
[ "def", "__init__", "(", "self", ",", "name", ",", "pa_server", ",", "sink_name", ",", "source_name", ")", ":", "self", ".", "_module_idx", "=", "None", "self", ".", "_name", "=", "name", "self", ".", "_sink_name", "=", "sink_name", "self", ".", "_source_...
[ 62, 4 ]
[ 68, 32 ]
python
en
['en', 'en', 'en']
True
PALoopbackSwitch.available
(self)
Return true when connected to server.
Return true when connected to server.
def available(self): """Return true when connected to server.""" return self._pa_svr.connected
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_pa_svr", ".", "connected" ]
[ 92, 4 ]
[ 94, 37 ]
python
en
['en', 'en', 'en']
True
PALoopbackSwitch.name
(self)
Return the name of the switch.
Return the name of the switch.
def name(self): """Return the name of the switch.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 97, 4 ]
[ 99, 25 ]
python
en
['en', 'en', 'en']
True
PALoopbackSwitch.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._module_idx is not None
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_module_idx", "is", "not", "None" ]
[ 102, 4 ]
[ 104, 43 ]
python
en
['en', 'fy', 'en']
True
PALoopbackSwitch.turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
def turn_on(self, **kwargs): """Turn the device on.""" if not self.is_on: self._pa_svr.module_load( "module-loopback", args=f"sink={self._sink_name} source={self._source_name}", ) else: _LOGGER.warning(IGNORED_SWITCH_WARN)
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "is_on", ":", "self", ".", "_pa_svr", ".", "module_load", "(", "\"module-loopback\"", ",", "args", "=", "f\"sink={self._sink_name} source={self._source_name}\"", ",", "...
[ 106, 4 ]
[ 114, 48 ]
python
en
['en', 'en', 'en']
True
PALoopbackSwitch.turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
def turn_off(self, **kwargs): """Turn the device off.""" if self.is_on: self._pa_svr.module_unload(self._module_idx) else: _LOGGER.warning(IGNORED_SWITCH_WARN)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "is_on", ":", "self", ".", "_pa_svr", ".", "module_unload", "(", "self", ".", "_module_idx", ")", "else", ":", "_LOGGER", ".", "warning", "(", "IGNORED_SWITCH_WARN", ...
[ 116, 4 ]
[ 121, 48 ]
python
en
['en', 'en', 'en']
True
PALoopbackSwitch.update
(self)
Refresh state in case an alternate process modified this data.
Refresh state in case an alternate process modified this data.
def update(self): """Refresh state in case an alternate process modified this data.""" self._module_idx = self._get_module_idx()
[ "def", "update", "(", "self", ")", ":", "self", ".", "_module_idx", "=", "self", ".", "_get_module_idx", "(", ")" ]
[ 123, 4 ]
[ 125, 49 ]
python
en
['en', 'en', 'en']
True
async_get_system_info
(hass: HomeAssistantType)
Return info about the system.
Return info about the system.
async def async_get_system_info(hass: HomeAssistantType) -> Dict[str, Any]: """Return info about the system.""" info_object = { "installation_type": "Unknown", "version": current_version, "dev": "dev" in current_version, "hassio": hass.components.hassio.is_hassio(), "virt...
[ "async", "def", "async_get_system_info", "(", "hass", ":", "HomeAssistantType", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "info_object", "=", "{", "\"installation_type\"", ":", "\"Unknown\"", ",", "\"version\"", ":", "current_version", ",", "\"dev\"",...
[ 13, 0 ]
[ 57, 22 ]
python
en
['en', 'en', 'en']
True
create_device_name
(node: OZWNode)
Generate sensible (short) default device name from a OZWNode.
Generate sensible (short) default device name from a OZWNode.
def create_device_name(node: OZWNode): """Generate sensible (short) default device name from a OZWNode.""" # Prefer custom name set by OZWAdmin if present if node.node_name: return node.node_name # Prefer short devicename from metadata if present if node.meta_data and node.meta_data.get("Nam...
[ "def", "create_device_name", "(", "node", ":", "OZWNode", ")", ":", "# Prefer custom name set by OZWAdmin if present", "if", "node", ".", "node_name", ":", "return", "node", ".", "node_name", "# Prefer short devicename from metadata if present", "if", "node", ".", "meta_d...
[ 273, 0 ]
[ 289, 28 ]
python
en
['en', 'en', 'en']
True
create_device_id
(node: OZWNode, node_instance: int = 1)
Generate unique device_id from a OZWNode.
Generate unique device_id from a OZWNode.
def create_device_id(node: OZWNode, node_instance: int = 1): """Generate unique device_id from a OZWNode.""" ozw_instance = node.parent.id dev_id = f"{ozw_instance}.{node.node_id}.{node_instance}" return dev_id
[ "def", "create_device_id", "(", "node", ":", "OZWNode", ",", "node_instance", ":", "int", "=", "1", ")", ":", "ozw_instance", "=", "node", ".", "parent", ".", "id", "dev_id", "=", "f\"{ozw_instance}.{node.node_id}.{node_instance}\"", "return", "dev_id" ]
[ 292, 0 ]
[ 296, 17 ]
python
en
['en', 'en', 'en']
True
create_value_id
(value: OZWValue)
Generate unique value_id from an OZWValue.
Generate unique value_id from an OZWValue.
def create_value_id(value: OZWValue): """Generate unique value_id from an OZWValue.""" # [OZW_INSTANCE_ID]-[NODE_ID]-[VALUE_ID_KEY] return f"{value.node.parent.id}-{value.node.id}-{value.value_id_key}"
[ "def", "create_value_id", "(", "value", ":", "OZWValue", ")", ":", "# [OZW_INSTANCE_ID]-[NODE_ID]-[VALUE_ID_KEY]", "return", "f\"{value.node.parent.id}-{value.node.id}-{value.value_id_key}\"" ]
[ 299, 0 ]
[ 302, 73 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntityValues.__init__
(self, hass, options, schema, primary_value)
Initialize the values object with the passed entity schema.
Initialize the values object with the passed entity schema.
def __init__(self, hass, options, schema, primary_value): """Initialize the values object with the passed entity schema.""" self._hass = hass self._entity_created = False self._schema = copy.deepcopy(schema) self._values = {} self.options = options # Go through v...
[ "def", "__init__", "(", "self", ",", "hass", ",", "options", ",", "schema", ",", "primary_value", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_entity_created", "=", "False", "self", ".", "_schema", "=", "copy", ".", "deepcopy", "(", "sch...
[ 33, 4 ]
[ 49, 63 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntityValues.async_setup
(self)
Set up values instance.
Set up values instance.
def async_setup(self): """Set up values instance.""" # Check values that have already been discovered for node # and see if they match the schema and need added to the entity. for value in self._node.values(): self.async_check_value(value) # Check if all the _require...
[ "def", "async_setup", "(", "self", ")", ":", "# Check values that have already been discovered for node", "# and see if they match the schema and need added to the entity.", "for", "value", "in", "self", ".", "_node", ".", "values", "(", ")", ":", "self", ".", "async_check_...
[ 51, 4 ]
[ 60, 40 ]
python
en
['en', 'fr', 'en']
True
ZWaveDeviceEntityValues.__getattr__
(self, name)
Get the specified value for this entity.
Get the specified value for this entity.
def __getattr__(self, name): """Get the specified value for this entity.""" return self._values.get(name, None)
[ "def", "__getattr__", "(", "self", ",", "name", ")", ":", "return", "self", ".", "_values", ".", "get", "(", "name", ",", "None", ")" ]
[ 62, 4 ]
[ 64, 43 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntityValues.__iter__
(self)
Allow iteration over all values.
Allow iteration over all values.
def __iter__(self): """Allow iteration over all values.""" return iter(self._values.values())
[ "def", "__iter__", "(", "self", ")", ":", "return", "iter", "(", "self", ".", "_values", ".", "values", "(", ")", ")" ]
[ 66, 4 ]
[ 68, 42 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntityValues.__contains__
(self, name)
Check if the specified name/key exists in the values.
Check if the specified name/key exists in the values.
def __contains__(self, name): """Check if the specified name/key exists in the values.""" return name in self._values
[ "def", "__contains__", "(", "self", ",", "name", ")", ":", "return", "name", "in", "self", ".", "_values" ]
[ 70, 4 ]
[ 72, 35 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntityValues.async_check_value
(self, value)
Check if the new value matches a missing value for this entity. If a match is found, it is added to the values mapping.
Check if the new value matches a missing value for this entity.
def async_check_value(self, value): """Check if the new value matches a missing value for this entity. If a match is found, it is added to the values mapping. """ # Make sure the node matches the schema for this entity. if not check_node_schema(value.node, self._schema): ...
[ "def", "async_check_value", "(", "self", ",", "value", ")", ":", "# Make sure the node matches the schema for this entity.", "if", "not", "check_node_schema", "(", "value", ".", "node", ",", "self", ".", "_schema", ")", ":", "return", "# Go through the possible values f...
[ 75, 4 ]
[ 103, 44 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntityValues._async_check_entity_ready
(self)
Check if all required values are discovered and create entity.
Check if all required values are discovered and create entity.
def _async_check_entity_ready(self): """Check if all required values are discovered and create entity.""" # Abort if the entity has already been created if self._entity_created: return # Go through values defined in the schema and abort if a required value is missing. ...
[ "def", "_async_check_entity_ready", "(", "self", ")", ":", "# Abort if the entity has already been created", "if", "self", ".", "_entity_created", ":", "return", "# Go through values defined in the schema and abort if a required value is missing.", "for", "name", ",", "disc_setting...
[ 106, 4 ]
[ 139, 80 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntityValues.values_id
(self)
Identification for this values collection.
Identification for this values collection.
def values_id(self): """Identification for this values collection.""" return create_value_id(self.primary)
[ "def", "values_id", "(", "self", ")", ":", "return", "create_value_id", "(", "self", ".", "primary", ")" ]
[ 142, 4 ]
[ 144, 44 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntity.__init__
(self, values)
Initialize a generic Z-Wave device entity.
Initialize a generic Z-Wave device entity.
def __init__(self, values): """Initialize a generic Z-Wave device entity.""" self.values = values self.options = values.options
[ "def", "__init__", "(", "self", ",", "values", ")", ":", "self", ".", "values", "=", "values", "self", ".", "options", "=", "values", ".", "options" ]
[ 150, 4 ]
[ 153, 37 ]
python
en
['en', 'pl', 'en']
True
ZWaveDeviceEntity.on_value_update
(self)
Call when a value is added/updated in the entity EntityValues Collection. To be overridden by platforms needing this event.
Call when a value is added/updated in the entity EntityValues Collection.
def on_value_update(self): """Call when a value is added/updated in the entity EntityValues Collection. To be overridden by platforms needing this event. """
[ "def", "on_value_update", "(", "self", ")", ":" ]
[ 156, 4 ]
[ 160, 11 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntity.async_added_to_hass
(self)
Call when entity is added.
Call when entity is added.
async def async_added_to_hass(self): """Call when entity is added.""" # Add dispatcher and OZW listeners callbacks. # Add to on_remove so they will be cleaned up on entity removal. self.async_on_remove( self.options.listen(EVENT_VALUE_CHANGED, self._value_changed) ) ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "# Add dispatcher and OZW listeners callbacks.", "# Add to on_remove so they will be cleaned up on entity removal.", "self", ".", "async_on_remove", "(", "self", ".", "options", ".", "listen", "(", "EVENT_VALUE_CHANG...
[ 162, 4 ]
[ 183, 9 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntity.device_info
(self)
Return device information for the device registry.
Return device information for the device registry.
def device_info(self): """Return device information for the device registry.""" node = self.values.primary.node node_instance = self.values.primary.instance dev_id = create_device_id(node, self.values.primary.instance) node_firmware = node.get_value( CommandClass.VERS...
[ "def", "device_info", "(", "self", ")", ":", "node", "=", "self", ".", "values", ".", "primary", ".", "node", "node_instance", "=", "self", ".", "values", ".", "primary", ".", "instance", "dev_id", "=", "create_device_id", "(", "node", ",", "self", ".", ...
[ 186, 4 ]
[ 208, 26 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntity.device_state_attributes
(self)
Return the device specific state attributes.
Return the device specific state attributes.
def device_state_attributes(self): """Return the device specific state attributes.""" return {const.ATTR_NODE_ID: self.values.primary.node.node_id}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "const", ".", "ATTR_NODE_ID", ":", "self", ".", "values", ".", "primary", ".", "node", ".", "node_id", "}" ]
[ 211, 4 ]
[ 213, 69 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntity.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" node = self.values.primary.node return f"{create_device_name(node)}: {self.values.primary.label}"
[ "def", "name", "(", "self", ")", ":", "node", "=", "self", ".", "values", ".", "primary", ".", "node", "return", "f\"{create_device_name(node)}: {self.values.primary.label}\"" ]
[ 216, 4 ]
[ 219, 73 ]
python
en
['en', 'en', 'en']
True
ZWaveDeviceEntity.unique_id
(self)
Return the unique_id of the entity.
Return the unique_id of the entity.
def unique_id(self): """Return the unique_id of the entity.""" return self.values.values_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "values", ".", "values_id" ]
[ 222, 4 ]
[ 224, 36 ]
python
en
['en', 'en', 'en']
True