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
DenonDevice.source_list
(self)
Return a list of available input sources.
Return a list of available input sources.
def source_list(self): """Return a list of available input sources.""" return self._source_list
[ "def", "source_list", "(", "self", ")", ":", "return", "self", ".", "_source_list" ]
[ 214, 4 ]
[ 216, 32 ]
python
en
['en', 'en', 'en']
True
DenonDevice.sound_mode
(self)
Return the current matched sound mode.
Return the current matched sound mode.
def sound_mode(self): """Return the current matched sound mode.""" return self._sound_mode
[ "def", "sound_mode", "(", "self", ")", ":", "return", "self", ".", "_sound_mode" ]
[ 219, 4 ]
[ 221, 31 ]
python
en
['en', 'en', 'en']
True
DenonDevice.sound_mode_list
(self)
Return a list of available sound modes.
Return a list of available sound modes.
def sound_mode_list(self): """Return a list of available sound modes.""" return self._sound_mode_list
[ "def", "sound_mode_list", "(", "self", ")", ":", "return", "self", ".", "_sound_mode_list" ]
[ 224, 4 ]
[ 226, 36 ]
python
en
['en', 'en', 'en']
True
DenonDevice.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.""" if self._current_source in self._receiver.netaudio_func_list: return self._supported_features_base | SUPPORT_MEDIA_MODES return self._supported_features_base
[ "def", "supported_features", "(", "self", ")", ":", "if", "self", ".", "_current_source", "in", "self", ".", "_receiver", ".", "netaudio_func_list", ":", "return", "self", ".", "_supported_features_base", "|", "SUPPORT_MEDIA_MODES", "return", "self", ".", "_suppor...
[ 229, 4 ]
[ 233, 44 ]
python
en
['en', 'en', 'en']
True
DenonDevice.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 None
[ "def", "media_content_id", "(", "self", ")", ":", "return", "None" ]
[ 236, 4 ]
[ 238, 19 ]
python
en
['en', 'en', 'en']
True
DenonDevice.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.""" if self._state == STATE_PLAYING or self._state == STATE_PAUSED: return MEDIA_TYPE_MUSIC return MEDIA_TYPE_CHANNEL
[ "def", "media_content_type", "(", "self", ")", ":", "if", "self", ".", "_state", "==", "STATE_PLAYING", "or", "self", ".", "_state", "==", "STATE_PAUSED", ":", "return", "MEDIA_TYPE_MUSIC", "return", "MEDIA_TYPE_CHANNEL" ]
[ 241, 4 ]
[ 245, 33 ]
python
en
['en', 'en', 'en']
True
DenonDevice.media_duration
(self)
Duration of current playing media in seconds.
Duration of current playing media in seconds.
def media_duration(self): """Duration of current playing media in seconds.""" return None
[ "def", "media_duration", "(", "self", ")", ":", "return", "None" ]
[ 248, 4 ]
[ 250, 19 ]
python
en
['en', 'en', 'en']
True
DenonDevice.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._current_source in self._receiver.playing_func_list: return self._media_image_url return None
[ "def", "media_image_url", "(", "self", ")", ":", "if", "self", ".", "_current_source", "in", "self", ".", "_receiver", ".", "playing_func_list", ":", "return", "self", ".", "_media_image_url", "return", "None" ]
[ 253, 4 ]
[ 257, 19 ]
python
en
['en', 'en', 'en']
True
DenonDevice.media_title
(self)
Title of current playing media.
Title of current playing media.
def media_title(self): """Title of current playing media.""" if self._current_source not in self._receiver.playing_func_list: return self._current_source if self._title is not None: return self._title return self._frequency
[ "def", "media_title", "(", "self", ")", ":", "if", "self", ".", "_current_source", "not", "in", "self", ".", "_receiver", ".", "playing_func_list", ":", "return", "self", ".", "_current_source", "if", "self", ".", "_title", "is", "not", "None", ":", "retur...
[ 260, 4 ]
[ 266, 30 ]
python
en
['en', 'en', 'en']
True
DenonDevice.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.""" if self._artist is not None: return self._artist return self._band
[ "def", "media_artist", "(", "self", ")", ":", "if", "self", ".", "_artist", "is", "not", "None", ":", "return", "self", ".", "_artist", "return", "self", ".", "_band" ]
[ 269, 4 ]
[ 273, 25 ]
python
en
['en', 'en', 'en']
True
DenonDevice.media_album_name
(self)
Album name of current playing media, music track only.
Album name of current playing media, music track only.
def media_album_name(self): """Album name of current playing media, music track only.""" if self._album is not None: return self._album return self._station
[ "def", "media_album_name", "(", "self", ")", ":", "if", "self", ".", "_album", "is", "not", "None", ":", "return", "self", ".", "_album", "return", "self", ".", "_station" ]
[ 276, 4 ]
[ 280, 28 ]
python
en
['en', 'en', 'en']
True
DenonDevice.media_album_artist
(self)
Album artist of current playing media, music track only.
Album artist of current playing media, music track only.
def media_album_artist(self): """Album artist of current playing media, music track only.""" return None
[ "def", "media_album_artist", "(", "self", ")", ":", "return", "None" ]
[ 283, 4 ]
[ 285, 19 ]
python
en
['en', 'en', 'en']
True
DenonDevice.media_track
(self)
Track number of current playing media, music track only.
Track number of current playing media, music track only.
def media_track(self): """Track number of current playing media, music track only.""" return None
[ "def", "media_track", "(", "self", ")", ":", "return", "None" ]
[ 288, 4 ]
[ 290, 19 ]
python
en
['en', 'en', 'en']
True
DenonDevice.media_series_title
(self)
Title of series of current playing media, TV show only.
Title of series of current playing media, TV show only.
def media_series_title(self): """Title of series of current playing media, TV show only.""" return None
[ "def", "media_series_title", "(", "self", ")", ":", "return", "None" ]
[ 293, 4 ]
[ 295, 19 ]
python
en
['en', 'en', 'en']
True
DenonDevice.media_season
(self)
Season of current playing media, TV show only.
Season of current playing media, TV show only.
def media_season(self): """Season of current playing media, TV show only.""" return None
[ "def", "media_season", "(", "self", ")", ":", "return", "None" ]
[ 298, 4 ]
[ 300, 19 ]
python
en
['en', 'en', 'en']
True
DenonDevice.media_episode
(self)
Episode of current playing media, TV show only.
Episode of current playing media, TV show only.
def media_episode(self): """Episode of current playing media, TV show only.""" return None
[ "def", "media_episode", "(", "self", ")", ":", "return", "None" ]
[ 303, 4 ]
[ 305, 19 ]
python
en
['en', 'en', 'en']
True
DenonDevice.device_state_attributes
(self)
Return device specific state attributes.
Return device specific state attributes.
def device_state_attributes(self): """Return device specific state attributes.""" if ( self._sound_mode_raw is not None and self._sound_mode_support and self._power == "ON" ): return {ATTR_SOUND_MODE_RAW: self._sound_mode_raw} return {}
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "(", "self", ".", "_sound_mode_raw", "is", "not", "None", "and", "self", ".", "_sound_mode_support", "and", "self", ".", "_power", "==", "\"ON\"", ")", ":", "return", "{", "ATTR_SOUND_MODE_RAW", ...
[ 308, 4 ]
[ 316, 17 ]
python
en
['fr', 'en', 'en']
True
DenonDevice.media_play_pause
(self)
Play or pause the media player.
Play or pause the media player.
def media_play_pause(self): """Play or pause the media player.""" return self._receiver.toggle_play_pause()
[ "def", "media_play_pause", "(", "self", ")", ":", "return", "self", ".", "_receiver", ".", "toggle_play_pause", "(", ")" ]
[ 318, 4 ]
[ 320, 49 ]
python
en
['en', 'en', 'en']
True
DenonDevice.media_play
(self)
Send play command.
Send play command.
def media_play(self): """Send play command.""" return self._receiver.play()
[ "def", "media_play", "(", "self", ")", ":", "return", "self", ".", "_receiver", ".", "play", "(", ")" ]
[ 322, 4 ]
[ 324, 36 ]
python
en
['en', 'en', 'en']
True
DenonDevice.media_pause
(self)
Send pause command.
Send pause command.
def media_pause(self): """Send pause command.""" return self._receiver.pause()
[ "def", "media_pause", "(", "self", ")", ":", "return", "self", ".", "_receiver", ".", "pause", "(", ")" ]
[ 326, 4 ]
[ 328, 37 ]
python
en
['en', 'en', 'en']
True
DenonDevice.media_previous_track
(self)
Send previous track command.
Send previous track command.
def media_previous_track(self): """Send previous track command.""" return self._receiver.previous_track()
[ "def", "media_previous_track", "(", "self", ")", ":", "return", "self", ".", "_receiver", ".", "previous_track", "(", ")" ]
[ 330, 4 ]
[ 332, 46 ]
python
en
['en', 'it', 'en']
True
DenonDevice.media_next_track
(self)
Send next track command.
Send next track command.
def media_next_track(self): """Send next track command.""" return self._receiver.next_track()
[ "def", "media_next_track", "(", "self", ")", ":", "return", "self", ".", "_receiver", ".", "next_track", "(", ")" ]
[ 334, 4 ]
[ 336, 42 ]
python
en
['en', 'pt', 'en']
True
DenonDevice.select_source
(self, source)
Select input source.
Select input source.
def select_source(self, source): """Select input source.""" return self._receiver.set_input_func(source)
[ "def", "select_source", "(", "self", ",", "source", ")", ":", "return", "self", ".", "_receiver", ".", "set_input_func", "(", "source", ")" ]
[ 338, 4 ]
[ 340, 52 ]
python
en
['fr', 'su', 'en']
False
DenonDevice.select_sound_mode
(self, sound_mode)
Select sound mode.
Select sound mode.
def select_sound_mode(self, sound_mode): """Select sound mode.""" return self._receiver.set_sound_mode(sound_mode)
[ "def", "select_sound_mode", "(", "self", ",", "sound_mode", ")", ":", "return", "self", ".", "_receiver", ".", "set_sound_mode", "(", "sound_mode", ")" ]
[ 342, 4 ]
[ 344, 56 ]
python
en
['en', 'mk', 'en']
True
DenonDevice.turn_on
(self)
Turn on media player.
Turn on media player.
def turn_on(self): """Turn on media player.""" if self._receiver.power_on(): self._state = STATE_ON
[ "def", "turn_on", "(", "self", ")", ":", "if", "self", ".", "_receiver", ".", "power_on", "(", ")", ":", "self", ".", "_state", "=", "STATE_ON" ]
[ 346, 4 ]
[ 349, 34 ]
python
en
['en', 'et', 'en']
True
DenonDevice.turn_off
(self)
Turn off media player.
Turn off media player.
def turn_off(self): """Turn off media player.""" if self._receiver.power_off(): self._state = STATE_OFF
[ "def", "turn_off", "(", "self", ")", ":", "if", "self", ".", "_receiver", ".", "power_off", "(", ")", ":", "self", ".", "_state", "=", "STATE_OFF" ]
[ 351, 4 ]
[ 354, 35 ]
python
en
['en', 'en', 'en']
True
DenonDevice.volume_up
(self)
Volume up the media player.
Volume up the media player.
def volume_up(self): """Volume up the media player.""" return self._receiver.volume_up()
[ "def", "volume_up", "(", "self", ")", ":", "return", "self", ".", "_receiver", ".", "volume_up", "(", ")" ]
[ 356, 4 ]
[ 358, 41 ]
python
en
['en', 'en', 'en']
True
DenonDevice.volume_down
(self)
Volume down media player.
Volume down media player.
def volume_down(self): """Volume down media player.""" return self._receiver.volume_down()
[ "def", "volume_down", "(", "self", ")", ":", "return", "self", ".", "_receiver", ".", "volume_down", "(", ")" ]
[ 360, 4 ]
[ 362, 43 ]
python
en
['en', 'sl', 'en']
True
DenonDevice.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 has to be sent in a format like -50.0. Minimum is -80.0, # maximum is 18.0 volume_denon = float((volume * 100) - 80) if volume_denon > 18: volume_denon = float(18) try: ...
[ "def", "set_volume_level", "(", "self", ",", "volume", ")", ":", "# Volume has to be sent in a format like -50.0. Minimum is -80.0,", "# maximum is 18.0", "volume_denon", "=", "float", "(", "(", "volume", "*", "100", ")", "-", "80", ")", "if", "volume_denon", ">", "...
[ 364, 4 ]
[ 375, 16 ]
python
en
['fr', 'zu', 'en']
False
DenonDevice.mute_volume
(self, mute)
Send mute command.
Send mute command.
def mute_volume(self, mute): """Send mute command.""" return self._receiver.mute(mute)
[ "def", "mute_volume", "(", "self", ",", "mute", ")", ":", "return", "self", ".", "_receiver", ".", "mute", "(", "mute", ")" ]
[ 377, 4 ]
[ 379, 40 ]
python
en
['en', 'co', 'en']
True
DenonDevice.get_command
(self, command, **kwargs)
Send generic command.
Send generic command.
def get_command(self, command, **kwargs): """Send generic command.""" self._receiver.send_get_command(command)
[ "def", "get_command", "(", "self", ",", "command", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_receiver", ".", "send_get_command", "(", "command", ")" ]
[ 381, 4 ]
[ 383, 48 ]
python
en
['en', 'zh', 'en']
True
patch_connect
(success)
Mock the `adb_shell.adb_device_async.AdbDeviceTcpAsync` and `ClientAsync` classes.
Mock the `adb_shell.adb_device_async.AdbDeviceTcpAsync` and `ClientAsync` classes.
def patch_connect(success): """Mock the `adb_shell.adb_device_async.AdbDeviceTcpAsync` and `ClientAsync` classes.""" async def connect_success_python(self, *args, **kwargs): """Mock the `AdbDeviceTcpAsyncFake.connect` method when it succeeds.""" self.available = True async def connect_fail...
[ "def", "patch_connect", "(", "success", ")", ":", "async", "def", "connect_success_python", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Mock the `AdbDeviceTcpAsyncFake.connect` method when it succeeds.\"\"\"", "self", ".", "available", "="...
[ 70, 0 ]
[ 99, 5 ]
python
en
['en', 'hmn', 'en']
True
patch_shell
(response=None, error=False)
Mock the `AdbDeviceTcpAsyncFake.shell` and `DeviceAsyncFake.shell` methods.
Mock the `AdbDeviceTcpAsyncFake.shell` and `DeviceAsyncFake.shell` methods.
def patch_shell(response=None, error=False): """Mock the `AdbDeviceTcpAsyncFake.shell` and `DeviceAsyncFake.shell` methods.""" async def shell_success(self, cmd, *args, **kwargs): """Mock the `AdbDeviceTcpAsyncFake.shell` and `DeviceAsyncFake.shell` methods when they are successful.""" self.she...
[ "def", "patch_shell", "(", "response", "=", "None", ",", "error", "=", "False", ")", ":", "async", "def", "shell_success", "(", "self", ",", "cmd", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Mock the `AdbDeviceTcpAsyncFake.shell` and `DeviceAs...
[ 102, 0 ]
[ 132, 5 ]
python
en
['en', 'en', 'en']
True
isfile
(filepath)
Mock `os.path.isfile`.
Mock `os.path.isfile`.
def isfile(filepath): """Mock `os.path.isfile`.""" return filepath.endswith("adbkey")
[ "def", "isfile", "(", "filepath", ")", ":", "return", "filepath", ".", "endswith", "(", "\"adbkey\"", ")" ]
[ 148, 0 ]
[ 150, 38 ]
python
en
['en', 'sm', 'en']
False
patch_firetv_update
(state, current_app, running_apps, hdmi_input)
Patch the `FireTV.update()` method.
Patch the `FireTV.update()` method.
def patch_firetv_update(state, current_app, running_apps, hdmi_input): """Patch the `FireTV.update()` method.""" return patch( "androidtv.firetv.firetv_async.FireTVAsync.update", return_value=(state, current_app, running_apps, hdmi_input), )
[ "def", "patch_firetv_update", "(", "state", ",", "current_app", ",", "running_apps", ",", "hdmi_input", ")", ":", "return", "patch", "(", "\"androidtv.firetv.firetv_async.FireTVAsync.update\"", ",", "return_value", "=", "(", "state", ",", "current_app", ",", "running_...
[ 157, 0 ]
[ 162, 5 ]
python
en
['en', 'zh', 'en']
True
patch_androidtv_update
( state, current_app, running_apps, device, is_volume_muted, volume_level, hdmi_input )
Patch the `AndroidTV.update()` method.
Patch the `AndroidTV.update()` method.
def patch_androidtv_update( state, current_app, running_apps, device, is_volume_muted, volume_level, hdmi_input ): """Patch the `AndroidTV.update()` method.""" return patch( "androidtv.androidtv.androidtv_async.AndroidTVAsync.update", return_value=( state, current_app...
[ "def", "patch_androidtv_update", "(", "state", ",", "current_app", ",", "running_apps", ",", "device", ",", "is_volume_muted", ",", "volume_level", ",", "hdmi_input", ")", ":", "return", "patch", "(", "\"androidtv.androidtv.androidtv_async.AndroidTVAsync.update\"", ",", ...
[ 165, 0 ]
[ 180, 5 ]
python
en
['en', 'en', 'en']
True
AdbDeviceTcpAsyncFake.__init__
(self, *args, **kwargs)
Initialize a fake `adb_shell.adb_device_async.AdbDeviceTcpAsync` instance.
Initialize a fake `adb_shell.adb_device_async.AdbDeviceTcpAsync` instance.
def __init__(self, *args, **kwargs): """Initialize a fake `adb_shell.adb_device_async.AdbDeviceTcpAsync` instance.""" self.available = False
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "available", "=", "False" ]
[ 14, 4 ]
[ 16, 30 ]
python
en
['en', 'pl', 'en']
True
AdbDeviceTcpAsyncFake.close
(self)
Close the socket connection.
Close the socket connection.
async def close(self): """Close the socket connection.""" self.available = False
[ "async", "def", "close", "(", "self", ")", ":", "self", ".", "available", "=", "False" ]
[ 18, 4 ]
[ 20, 30 ]
python
en
['en', 'en', 'en']
True
AdbDeviceTcpAsyncFake.connect
(self, *args, **kwargs)
Try to connect to a device.
Try to connect to a device.
async def connect(self, *args, **kwargs): """Try to connect to a device.""" raise NotImplementedError
[ "async", "def", "connect", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "raise", "NotImplementedError" ]
[ 22, 4 ]
[ 24, 33 ]
python
en
['en', 'en', 'en']
True
AdbDeviceTcpAsyncFake.shell
(self, cmd, *args, **kwargs)
Send an ADB shell command.
Send an ADB shell command.
async def shell(self, cmd, *args, **kwargs): """Send an ADB shell command.""" return None
[ "async", "def", "shell", "(", "self", ",", "cmd", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "None" ]
[ 26, 4 ]
[ 28, 19 ]
python
en
['en', 'lb', 'en']
True
ClientAsyncFakeSuccess.__init__
(self, host="127.0.0.1", port=5037)
Initialize a `ClientAsyncFakeSuccess` instance.
Initialize a `ClientAsyncFakeSuccess` instance.
def __init__(self, host="127.0.0.1", port=5037): """Initialize a `ClientAsyncFakeSuccess` instance.""" self._devices = []
[ "def", "__init__", "(", "self", ",", "host", "=", "\"127.0.0.1\"", ",", "port", "=", "5037", ")", ":", "self", ".", "_devices", "=", "[", "]" ]
[ 34, 4 ]
[ 36, 26 ]
python
en
['en', 'fr', 'it']
False
ClientAsyncFakeSuccess.device
(self, serial)
Mock the `ClientAsync.device` method when the device is connected via ADB.
Mock the `ClientAsync.device` method when the device is connected via ADB.
async def device(self, serial): """Mock the `ClientAsync.device` method when the device is connected via ADB.""" device = DeviceAsyncFake(serial) self._devices.append(device) return device
[ "async", "def", "device", "(", "self", ",", "serial", ")", ":", "device", "=", "DeviceAsyncFake", "(", "serial", ")", "self", ".", "_devices", ".", "append", "(", "device", ")", "return", "device" ]
[ 38, 4 ]
[ 42, 21 ]
python
en
['en', 'en', 'en']
True
ClientAsyncFakeFail.__init__
(self, host="127.0.0.1", port=5037)
Initialize a `ClientAsyncFakeFail` instance.
Initialize a `ClientAsyncFakeFail` instance.
def __init__(self, host="127.0.0.1", port=5037): """Initialize a `ClientAsyncFakeFail` instance.""" self._devices = []
[ "def", "__init__", "(", "self", ",", "host", "=", "\"127.0.0.1\"", ",", "port", "=", "5037", ")", ":", "self", ".", "_devices", "=", "[", "]" ]
[ 48, 4 ]
[ 50, 26 ]
python
en
['en', 'fr', 'it']
False
ClientAsyncFakeFail.device
(self, serial)
Mock the `ClientAsync.device` method when the device is not connected via ADB.
Mock the `ClientAsync.device` method when the device is not connected via ADB.
async def device(self, serial): """Mock the `ClientAsync.device` method when the device is not connected via ADB.""" self._devices = [] return None
[ "async", "def", "device", "(", "self", ",", "serial", ")", ":", "self", ".", "_devices", "=", "[", "]", "return", "None" ]
[ 52, 4 ]
[ 55, 19 ]
python
en
['en', 'en', 'en']
True
DeviceAsyncFake.__init__
(self, host)
Initialize a `DeviceAsyncFake` instance.
Initialize a `DeviceAsyncFake` instance.
def __init__(self, host): """Initialize a `DeviceAsyncFake` instance.""" self.host = host
[ "def", "__init__", "(", "self", ",", "host", ")", ":", "self", ".", "host", "=", "host" ]
[ 61, 4 ]
[ 63, 24 ]
python
en
['en', 'en', 'it']
True
DeviceAsyncFake.shell
(self, cmd)
Send an ADB shell command.
Send an ADB shell command.
async def shell(self, cmd): """Send an ADB shell command.""" raise NotImplementedError
[ "async", "def", "shell", "(", "self", ",", "cmd", ")", ":", "raise", "NotImplementedError" ]
[ 65, 4 ]
[ 67, 33 ]
python
en
['en', 'lb', 'en']
True
handle_set
(hass, hass_config, msg)
Handle a mysensors set message.
Handle a mysensors set message.
async def handle_set(hass, hass_config, msg): """Handle a mysensors set message.""" validated = validate_set_msg(msg) _handle_child_update(hass, hass_config, validated)
[ "async", "def", "handle_set", "(", "hass", ",", "hass_config", ",", "msg", ")", ":", "validated", "=", "validate_set_msg", "(", "msg", ")", "_handle_child_update", "(", "hass", ",", "hass_config", ",", "validated", ")" ]
[ 13, 0 ]
[ 16, 54 ]
python
en
['en', 'da', 'en']
True
handle_internal
(hass, hass_config, msg)
Handle a mysensors internal message.
Handle a mysensors internal message.
async def handle_internal(hass, hass_config, msg): """Handle a mysensors internal message.""" internal = msg.gateway.const.Internal(msg.sub_type) handler = HANDLERS.get(internal.name) if handler is None: return await handler(hass, hass_config, msg)
[ "async", "def", "handle_internal", "(", "hass", ",", "hass_config", ",", "msg", ")", ":", "internal", "=", "msg", ".", "gateway", ".", "const", ".", "Internal", "(", "msg", ".", "sub_type", ")", "handler", "=", "HANDLERS", ".", "get", "(", "internal", ...
[ 20, 0 ]
[ 26, 41 ]
python
en
['en', 'en', 'en']
True
handle_battery_level
(hass, hass_config, msg)
Handle an internal battery level message.
Handle an internal battery level message.
async def handle_battery_level(hass, hass_config, msg): """Handle an internal battery level message.""" _handle_node_update(hass, msg)
[ "async", "def", "handle_battery_level", "(", "hass", ",", "hass_config", ",", "msg", ")", ":", "_handle_node_update", "(", "hass", ",", "msg", ")" ]
[ 30, 0 ]
[ 32, 34 ]
python
en
['en', 'lb', 'en']
True
handle_heartbeat
(hass, hass_config, msg)
Handle an heartbeat.
Handle an heartbeat.
async def handle_heartbeat(hass, hass_config, msg): """Handle an heartbeat.""" _handle_node_update(hass, msg)
[ "async", "def", "handle_heartbeat", "(", "hass", ",", "hass_config", ",", "msg", ")", ":", "_handle_node_update", "(", "hass", ",", "msg", ")" ]
[ 36, 0 ]
[ 38, 34 ]
python
br
['br', 'haw', 'en']
False
handle_sketch_name
(hass, hass_config, msg)
Handle an internal sketch name message.
Handle an internal sketch name message.
async def handle_sketch_name(hass, hass_config, msg): """Handle an internal sketch name message.""" _handle_node_update(hass, msg)
[ "async", "def", "handle_sketch_name", "(", "hass", ",", "hass_config", ",", "msg", ")", ":", "_handle_node_update", "(", "hass", ",", "msg", ")" ]
[ 42, 0 ]
[ 44, 34 ]
python
en
['en', 'en', 'en']
True
handle_sketch_version
(hass, hass_config, msg)
Handle an internal sketch version message.
Handle an internal sketch version message.
async def handle_sketch_version(hass, hass_config, msg): """Handle an internal sketch version message.""" _handle_node_update(hass, msg)
[ "async", "def", "handle_sketch_version", "(", "hass", ",", "hass_config", ",", "msg", ")", ":", "_handle_node_update", "(", "hass", ",", "msg", ")" ]
[ 48, 0 ]
[ 50, 34 ]
python
en
['en', 'lb', 'en']
True
handle_gateway_ready
(hass, hass_config, msg)
Handle an internal gateway ready message. Set asyncio future result if gateway is ready.
Handle an internal gateway ready message.
async def handle_gateway_ready(hass, hass_config, msg): """Handle an internal gateway ready message. Set asyncio future result if gateway is ready. """ gateway_ready = hass.data.get(MYSENSORS_GATEWAY_READY.format(id(msg.gateway))) if gateway_ready is None or gateway_ready.cancelled(): retur...
[ "async", "def", "handle_gateway_ready", "(", "hass", ",", "hass_config", ",", "msg", ")", ":", "gateway_ready", "=", "hass", ".", "data", ".", "get", "(", "MYSENSORS_GATEWAY_READY", ".", "format", "(", "id", "(", "msg", ".", "gateway", ")", ")", ")", "if...
[ 54, 0 ]
[ 62, 34 ]
python
en
['en', 'lb', 'en']
True
_handle_child_update
(hass, hass_config, validated)
Handle a child update.
Handle a child update.
def _handle_child_update(hass, hass_config, validated): """Handle a child update.""" signals = [] # Update all platforms for the device via dispatcher. # Add/update entity for validated children. for platform, dev_ids in validated.items(): devices = get_mysensors_devices(hass, platform) ...
[ "def", "_handle_child_update", "(", "hass", ",", "hass_config", ",", "validated", ")", ":", "signals", "=", "[", "]", "# Update all platforms for the device via dispatcher.", "# Add/update entity for validated children.", "for", "platform", ",", "dev_ids", "in", "validated"...
[ 66, 0 ]
[ 85, 43 ]
python
en
['en', 'en', 'en']
True
_handle_node_update
(hass, msg)
Handle a node update.
Handle a node update.
def _handle_node_update(hass, msg): """Handle a node update.""" signal = NODE_CALLBACK.format(id(msg.gateway), msg.node_id) async_dispatcher_send(hass, signal)
[ "def", "_handle_node_update", "(", "hass", ",", "msg", ")", ":", "signal", "=", "NODE_CALLBACK", ".", "format", "(", "id", "(", "msg", ".", "gateway", ")", ",", "msg", ".", "node_id", ")", "async_dispatcher_send", "(", "hass", ",", "signal", ")" ]
[ 89, 0 ]
[ 92, 39 ]
python
en
['en', 'lb', 'en']
True
channels_mock
(zha_device_mock)
Channels mock factory.
Channels mock factory.
def channels_mock(zha_device_mock): """Channels mock factory.""" def _mock( endpoints, ieee="00:11:22:33:44:55:66:77", manufacturer="mock manufacturer", model="mock model", node_desc=b"\x02@\x807\x10\x7fd\x00\x00*d\x00\x00", patch_cluster=False, ): zh...
[ "def", "channels_mock", "(", "zha_device_mock", ")", ":", "def", "_mock", "(", "endpoints", ",", "ieee", "=", "\"00:11:22:33:44:55:66:77\"", ",", "manufacturer", "=", "\"mock manufacturer\"", ",", "model", "=", "\"mock model\"", ",", "node_desc", "=", "b\"\\x02@\\x8...
[ 38, 0 ]
[ 55, 16 ]
python
en
['en', 'fy', 'en']
True
test_devices
( device, hass_disable_services, zigpy_device_mock, zha_device_joined_restored, )
Test device discovery.
Test device discovery.
async def test_devices( device, hass_disable_services, zigpy_device_mock, zha_device_joined_restored, ): """Test device discovery.""" entity_registry = await homeassistant.helpers.entity_registry.async_get_registry( hass_disable_services ) zigpy_device = zigpy_device_mock( ...
[ "async", "def", "test_devices", "(", "device", ",", "hass_disable_services", ",", "zigpy_device_mock", ",", "zha_device_joined_restored", ",", ")", ":", "entity_registry", "=", "await", "homeassistant", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", ...
[ 63, 0 ]
[ 139, 69 ]
python
en
['fr', 'en', 'en']
True
test_discover_entities
(m1, m2)
Test discover endpoint class method.
Test discover endpoint class method.
def test_discover_entities(m1, m2): """Test discover endpoint class method.""" ep_channels = mock.MagicMock() disc.PROBE.discover_entities(ep_channels) assert m1.call_count == 1 assert m1.call_args[0][0] is ep_channels assert m2.call_count == 1 assert m2.call_args[0][0] is ep_channels
[ "def", "test_discover_entities", "(", "m1", ",", "m2", ")", ":", "ep_channels", "=", "mock", ".", "MagicMock", "(", ")", "disc", ".", "PROBE", ".", "discover_entities", "(", "ep_channels", ")", "assert", "m1", ".", "call_count", "==", "1", "assert", "m1", ...
[ 154, 0 ]
[ 161, 44 ]
python
en
['da', 'en', 'en']
True
test_discover_by_device_type
(device_type, component, hit)
Test entity discovery by device type.
Test entity discovery by device type.
def test_discover_by_device_type(device_type, component, hit): """Test entity discovery by device type.""" ep_channels = mock.MagicMock(spec_set=zha_channels.ChannelPool) ep_mock = mock.PropertyMock() ep_mock.return_value.profile_id = 0x0104 ep_mock.return_value.device_type = device_type type(e...
[ "def", "test_discover_by_device_type", "(", "device_type", ",", "component", ",", "hit", ")", ":", "ep_channels", "=", "mock", ".", "MagicMock", "(", "spec_set", "=", "zha_channels", ".", "ChannelPool", ")", "ep_mock", "=", "mock", ".", "PropertyMock", "(", ")...
[ 173, 0 ]
[ 196, 87 ]
python
en
['en', 'en', 'en']
True
test_discover_by_device_type_override
()
Test entity discovery by device type overriding.
Test entity discovery by device type overriding.
def test_discover_by_device_type_override(): """Test entity discovery by device type overriding.""" ep_channels = mock.MagicMock(spec_set=zha_channels.ChannelPool) ep_mock = mock.PropertyMock() ep_mock.return_value.profile_id = 0x0104 ep_mock.return_value.device_type = 0x0100 type(ep_channels)....
[ "def", "test_discover_by_device_type_override", "(", ")", ":", "ep_channels", "=", "mock", ".", "MagicMock", "(", "spec_set", "=", "zha_channels", ".", "ChannelPool", ")", "ep_mock", "=", "mock", ".", "PropertyMock", "(", ")", "ep_mock", ".", "return_value", "."...
[ 199, 0 ]
[ 225, 13 ]
python
en
['en', 'en', 'en']
True
test_discover_probe_single_cluster
()
Test entity discovery by single cluster.
Test entity discovery by single cluster.
def test_discover_probe_single_cluster(): """Test entity discovery by single cluster.""" ep_channels = mock.MagicMock(spec_set=zha_channels.ChannelPool) ep_mock = mock.PropertyMock() ep_mock.return_value.profile_id = 0x0104 ep_mock.return_value.device_type = 0x0100 type(ep_channels).endpoint = ...
[ "def", "test_discover_probe_single_cluster", "(", ")", ":", "ep_channels", "=", "mock", ".", "MagicMock", "(", "spec_set", "=", "zha_channels", ".", "ChannelPool", ")", "ep_mock", "=", "mock", ".", "PropertyMock", "(", ")", "ep_mock", ".", "return_value", ".", ...
[ 228, 0 ]
[ 253, 80 ]
python
en
['en', 'en', 'en']
True
test_discover_endpoint
(device_info, channels_mock, hass)
Test device discovery.
Test device discovery.
async def test_discover_endpoint(device_info, channels_mock, hass): """Test device discovery.""" with mock.patch( "homeassistant.components.zha.core.channels.Channels.async_new_entity" ) as new_ent: channels = channels_mock( device_info["endpoints"], manufacturer=dev...
[ "async", "def", "test_discover_endpoint", "(", "device_info", ",", "channels_mock", ",", "hass", ")", ":", "with", "mock", ".", "patch", "(", "\"homeassistant.components.zha.core.channels.Channels.async_new_entity\"", ")", "as", "new_ent", ":", "channels", "=", "channel...
[ 257, 0 ]
[ 288, 62 ]
python
en
['fr', 'en', 'en']
True
_ch_mock
(cluster)
Return mock of a channel with a cluster.
Return mock of a channel with a cluster.
def _ch_mock(cluster): """Return mock of a channel with a cluster.""" channel = mock.MagicMock() type(channel).cluster = mock.PropertyMock(return_value=cluster(mock.MagicMock())) return channel
[ "def", "_ch_mock", "(", "cluster", ")", ":", "channel", "=", "mock", ".", "MagicMock", "(", ")", "type", "(", "channel", ")", ".", "cluster", "=", "mock", ".", "PropertyMock", "(", "return_value", "=", "cluster", "(", "mock", ".", "MagicMock", "(", ")"...
[ 291, 0 ]
[ 295, 18 ]
python
en
['en', 'en', 'en']
True
_test_single_input_cluster_device_class
(probe_mock)
Test SINGLE_INPUT_CLUSTER_DEVICE_CLASS matching by cluster id or class.
Test SINGLE_INPUT_CLUSTER_DEVICE_CLASS matching by cluster id or class.
def _test_single_input_cluster_device_class(probe_mock): """Test SINGLE_INPUT_CLUSTER_DEVICE_CLASS matching by cluster id or class.""" door_ch = _ch_mock(zigpy.zcl.clusters.closures.DoorLock) cover_ch = _ch_mock(zigpy.zcl.clusters.closures.WindowCovering) multistate_ch = _ch_mock(zigpy.zcl.clusters.gen...
[ "def", "_test_single_input_cluster_device_class", "(", "probe_mock", ")", ":", "door_ch", "=", "_ch_mock", "(", "zigpy", ".", "zcl", ".", "clusters", ".", "closures", ".", "DoorLock", ")", "cover_ch", "=", "_ch_mock", "(", "zigpy", ".", "zcl", ".", "clusters",...
[ 306, 0 ]
[ 344, 31 ]
python
en
['en', 'en', 'en']
True
test_single_input_cluster_device_class
()
Test SINGLE_INPUT_CLUSTER_DEVICE_CLASS matching by cluster id or class.
Test SINGLE_INPUT_CLUSTER_DEVICE_CLASS matching by cluster id or class.
def test_single_input_cluster_device_class(): """Test SINGLE_INPUT_CLUSTER_DEVICE_CLASS matching by cluster id or class.""" _test_single_input_cluster_device_class()
[ "def", "test_single_input_cluster_device_class", "(", ")", ":", "_test_single_input_cluster_device_class", "(", ")" ]
[ 347, 0 ]
[ 349, 45 ]
python
en
['en', 'en', 'en']
True
test_single_input_cluster_device_class_by_cluster_class
()
Test SINGLE_INPUT_CLUSTER_DEVICE_CLASS matching by cluster id or class.
Test SINGLE_INPUT_CLUSTER_DEVICE_CLASS matching by cluster id or class.
def test_single_input_cluster_device_class_by_cluster_class(): """Test SINGLE_INPUT_CLUSTER_DEVICE_CLASS matching by cluster id or class.""" mock_reg = { zigpy.zcl.clusters.closures.DoorLock.cluster_id: zha_const.LOCK, zigpy.zcl.clusters.closures.WindowCovering.cluster_id: zha_const.COVER, ...
[ "def", "test_single_input_cluster_device_class_by_cluster_class", "(", ")", ":", "mock_reg", "=", "{", "zigpy", ".", "zcl", ".", "clusters", ".", "closures", ".", "DoorLock", ".", "cluster_id", ":", "zha_const", ".", "LOCK", ",", "zigpy", ".", "zcl", ".", "clu...
[ 352, 0 ]
[ 365, 49 ]
python
en
['en', 'en', 'en']
True
test_device_override
( hass_disable_services, zigpy_device_mock, setup_zha, override, entity_id )
Test device discovery override.
Test device discovery override.
async def test_device_override( hass_disable_services, zigpy_device_mock, setup_zha, override, entity_id ): """Test device discovery override.""" zigpy_device = zigpy_device_mock( { 1: { "device_type": zigpy.profiles.zha.DeviceType.COLOR_DIMMABLE_LIGHT, "...
[ "async", "def", "test_device_override", "(", "hass_disable_services", ",", "zigpy_device_mock", ",", "setup_zha", ",", "override", ",", "entity_id", ")", ":", "zigpy_device", "=", "zigpy_device_mock", "(", "{", "1", ":", "{", "\"device_type\"", ":", "zigpy", ".", ...
[ 375, 0 ]
[ 404, 66 ]
python
en
['fr', 'en', 'en']
True
test_group_probe_cleanup_called
( hass_disable_services, setup_zha, config_entry )
Test cleanup happens when zha is unloaded.
Test cleanup happens when zha is unloaded.
async def test_group_probe_cleanup_called( hass_disable_services, setup_zha, config_entry ): """Test cleanup happens when zha is unloaded.""" await setup_zha() disc.GROUP_PROBE.cleanup = mock.Mock(wraps=disc.GROUP_PROBE.cleanup) await config_entry.async_unload(hass_disable_services) await hass_d...
[ "async", "def", "test_group_probe_cleanup_called", "(", "hass_disable_services", ",", "setup_zha", ",", "config_entry", ")", ":", "await", "setup_zha", "(", ")", "disc", ".", "GROUP_PROBE", ".", "cleanup", "=", "mock", ".", "Mock", "(", "wraps", "=", "disc", "...
[ 407, 0 ]
[ 415, 44 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the ComfoConnect fan platform.
Set up the ComfoConnect fan platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the ComfoConnect fan platform.""" ccb = hass.data[DOMAIN] add_entities([ComfoConnectFan(ccb.name, ccb)], True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "ccb", "=", "hass", ".", "data", "[", "DOMAIN", "]", "add_entities", "(", "[", "ComfoConnectFan", "(", "ccb", ".", "name", ",", "ccb",...
[ 28, 0 ]
[ 32, 56 ]
python
en
['en', 'fr', 'en']
True
ComfoConnectFan.__init__
(self, name, ccb: ComfoConnectBridge)
Initialize the ComfoConnect fan.
Initialize the ComfoConnect fan.
def __init__(self, name, ccb: ComfoConnectBridge) -> None: """Initialize the ComfoConnect fan.""" self._ccb = ccb self._name = name
[ "def", "__init__", "(", "self", ",", "name", ",", "ccb", ":", "ComfoConnectBridge", ")", "->", "None", ":", "self", ".", "_ccb", "=", "ccb", "self", ".", "_name", "=", "name" ]
[ 38, 4 ]
[ 41, 25 ]
python
en
['en', 'en', 'en']
True
ComfoConnectFan.async_added_to_hass
(self)
Register for sensor updates.
Register for sensor updates.
async def async_added_to_hass(self): """Register for sensor updates.""" _LOGGER.debug("Registering for fan speed") self.async_on_remove( async_dispatcher_connect( self.hass, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED.format(SENSOR_FAN_SPEED_MODE), ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Registering for fan speed\"", ")", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "SIGNAL_COMFOCONNECT_UPDATE_RECEIVED", "."...
[ 43, 4 ]
[ 55, 9 ]
python
da
['da', 'no', 'en']
False
ComfoConnectFan._handle_update
(self, value)
Handle update callbacks.
Handle update callbacks.
def _handle_update(self, value): """Handle update callbacks.""" _LOGGER.debug( "Handle update for fan speed (%d): %s", SENSOR_FAN_SPEED_MODE, value ) self._ccb.data[SENSOR_FAN_SPEED_MODE] = value self.schedule_update_ha_state()
[ "def", "_handle_update", "(", "self", ",", "value", ")", ":", "_LOGGER", ".", "debug", "(", "\"Handle update for fan speed (%d): %s\"", ",", "SENSOR_FAN_SPEED_MODE", ",", "value", ")", "self", ".", "_ccb", ".", "data", "[", "SENSOR_FAN_SPEED_MODE", "]", "=", "va...
[ 57, 4 ]
[ 63, 39 ]
python
en
['en', 'xh', 'en']
True
ComfoConnectFan.should_poll
(self)
Do not poll.
Do not poll.
def should_poll(self) -> bool: """Do not poll.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 66, 4 ]
[ 68, 20 ]
python
en
['en', 'lb', 'en']
True
ComfoConnectFan.unique_id
(self)
Return a unique_id for this entity.
Return a unique_id for this entity.
def unique_id(self): """Return a unique_id for this entity.""" return self._ccb.unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_ccb", ".", "unique_id" ]
[ 71, 4 ]
[ 73, 34 ]
python
en
['en', 'en', 'en']
True
ComfoConnectFan.name
(self)
Return the name of the fan.
Return the name of the fan.
def name(self): """Return the name of the fan.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 76, 4 ]
[ 78, 25 ]
python
en
['en', 'en', 'en']
True
ComfoConnectFan.icon
(self)
Return the icon to use in the frontend.
Return the icon to use in the frontend.
def icon(self): """Return the icon to use in the frontend.""" return "mdi:air-conditioner"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:air-conditioner\"" ]
[ 81, 4 ]
[ 83, 36 ]
python
en
['en', 'en', 'en']
True
ComfoConnectFan.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self) -> int: """Flag supported features.""" return SUPPORT_SET_SPEED
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_SET_SPEED" ]
[ 86, 4 ]
[ 88, 32 ]
python
en
['da', 'en', 'en']
True
ComfoConnectFan.speed
(self)
Return the current fan mode.
Return the current fan mode.
def speed(self): """Return the current fan mode.""" try: speed = self._ccb.data[SENSOR_FAN_SPEED_MODE] return SPEED_MAPPING[speed] except KeyError: return None
[ "def", "speed", "(", "self", ")", ":", "try", ":", "speed", "=", "self", ".", "_ccb", ".", "data", "[", "SENSOR_FAN_SPEED_MODE", "]", "return", "SPEED_MAPPING", "[", "speed", "]", "except", "KeyError", ":", "return", "None" ]
[ 91, 4 ]
[ 97, 23 ]
python
en
['en', 'en', 'en']
True
ComfoConnectFan.speed_list
(self)
List of available fan modes.
List of available fan modes.
def speed_list(self): """List of available fan modes.""" return [SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
[ "def", "speed_list", "(", "self", ")", ":", "return", "[", "SPEED_OFF", ",", "SPEED_LOW", ",", "SPEED_MEDIUM", ",", "SPEED_HIGH", "]" ]
[ 100, 4 ]
[ 102, 63 ]
python
en
['en', 'en', 'en']
True
ComfoConnectFan.turn_on
(self, speed: str = None, **kwargs)
Turn on the fan.
Turn on the fan.
def turn_on(self, speed: str = None, **kwargs) -> None: """Turn on the fan.""" if speed is None: speed = SPEED_LOW self.set_speed(speed)
[ "def", "turn_on", "(", "self", ",", "speed", ":", "str", "=", "None", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "speed", "is", "None", ":", "speed", "=", "SPEED_LOW", "self", ".", "set_speed", "(", "speed", ")" ]
[ 104, 4 ]
[ 108, 29 ]
python
en
['en', 'fy', 'en']
True
ComfoConnectFan.turn_off
(self, **kwargs)
Turn off the fan (to away).
Turn off the fan (to away).
def turn_off(self, **kwargs) -> None: """Turn off the fan (to away).""" self.set_speed(SPEED_OFF)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "self", ".", "set_speed", "(", "SPEED_OFF", ")" ]
[ 110, 4 ]
[ 112, 33 ]
python
en
['en', 'en', 'en']
True
ComfoConnectFan.set_speed
(self, speed: str)
Set fan speed.
Set fan speed.
def set_speed(self, speed: str): """Set fan speed.""" _LOGGER.debug("Changing fan speed to %s", speed) if speed == SPEED_OFF: self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_AWAY) elif speed == SPEED_LOW: self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_LO...
[ "def", "set_speed", "(", "self", ",", "speed", ":", "str", ")", ":", "_LOGGER", ".", "debug", "(", "\"Changing fan speed to %s\"", ",", "speed", ")", "if", "speed", "==", "SPEED_OFF", ":", "self", ".", "_ccb", ".", "comfoconnect", ".", "cmd_rmi_request", "...
[ 114, 4 ]
[ 128, 39 ]
python
fy
['sv', 'fy', 'ur']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Set up WeMo binary sensors.
Set up WeMo binary sensors.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up WeMo binary sensors.""" async def _discovered_wemo(device): """Handle a discovered Wemo device.""" async_add_entities([WemoBinarySensor(device)]) async_dispatcher_connect(hass, f"{WEMO_DOMAIN}.binary_sensor", _d...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "async", "def", "_discovered_wemo", "(", "device", ")", ":", "\"\"\"Handle a discovered Wemo device.\"\"\"", "async_add_entities", "(", "[", "WemoBinarySensor", "...
[ 15, 0 ]
[ 29, 5 ]
python
en
['en', 'bs', 'en']
True
WemoBinarySensor.__init__
(self, device)
Initialize the WeMo sensor.
Initialize the WeMo sensor.
def __init__(self, device): """Initialize the WeMo sensor.""" self.wemo = device self._state = None self._available = True self._update_lock = None self._model_name = self.wemo.model_name self._name = self.wemo.name self._serial_number = self.wemo.serialnu...
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "self", ".", "wemo", "=", "device", "self", ".", "_state", "=", "None", "self", ".", "_available", "=", "True", "self", ".", "_update_lock", "=", "None", "self", ".", "_model_name", "=", "self", ...
[ 35, 4 ]
[ 43, 52 ]
python
en
['en', 'pt', 'en']
True
WemoBinarySensor._subscription_callback
(self, _device, _type, _params)
Update the state by the Wemo sensor.
Update the state by the Wemo sensor.
def _subscription_callback(self, _device, _type, _params): """Update the state by the Wemo sensor.""" _LOGGER.debug("Subscription update for %s", self.name) updated = self.wemo.subscription_update(_type, _params) self.hass.add_job(self._async_locked_subscription_callback(not updated))
[ "def", "_subscription_callback", "(", "self", ",", "_device", ",", "_type", ",", "_params", ")", ":", "_LOGGER", ".", "debug", "(", "\"Subscription update for %s\"", ",", "self", ".", "name", ")", "updated", "=", "self", ".", "wemo", ".", "subscription_update"...
[ 45, 4 ]
[ 49, 80 ]
python
en
['en', 'en', 'en']
True
WemoBinarySensor._async_locked_subscription_callback
(self, force_update)
Handle an update from a subscription.
Handle an update from a subscription.
async def _async_locked_subscription_callback(self, force_update): """Handle an update from a subscription.""" # If an update is in progress, we don't do anything if self._update_lock.locked(): return await self._async_locked_update(force_update) self.async_write_ha_...
[ "async", "def", "_async_locked_subscription_callback", "(", "self", ",", "force_update", ")", ":", "# If an update is in progress, we don't do anything", "if", "self", ".", "_update_lock", ".", "locked", "(", ")", ":", "return", "await", "self", ".", "_async_locked_upda...
[ 51, 4 ]
[ 58, 35 ]
python
en
['en', 'en', 'en']
True
WemoBinarySensor.async_added_to_hass
(self)
Wemo sensor added to Home Assistant.
Wemo sensor added to Home Assistant.
async def async_added_to_hass(self): """Wemo sensor added to Home Assistant.""" # Define inside async context so we know our event loop self._update_lock = asyncio.Lock() registry = self.hass.data[WEMO_DOMAIN]["registry"] await self.hass.async_add_executor_job(registry.register,...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "# Define inside async context so we know our event loop", "self", ".", "_update_lock", "=", "asyncio", ".", "Lock", "(", ")", "registry", "=", "self", ".", "hass", ".", "data", "[", "WEMO_DOMAIN", "]",...
[ 60, 4 ]
[ 67, 65 ]
python
en
['en', 'en', 'en']
True
WemoBinarySensor.async_update
(self)
Update WeMo state. Wemo has an aggressive retry logic that sometimes can take over a minute to return. If we don't get a state after 5 seconds, assume the Wemo sensor is unreachable. If update goes through, it will be made available again.
Update WeMo state.
async def async_update(self): """Update WeMo state. Wemo has an aggressive retry logic that sometimes can take over a minute to return. If we don't get a state after 5 seconds, assume the Wemo sensor is unreachable. If update goes through, it will be made available again. ...
[ "async", "def", "async_update", "(", "self", ")", ":", "# If an update is in progress, we don't do anything", "if", "self", ".", "_update_lock", ".", "locked", "(", ")", ":", "return", "try", ":", "with", "async_timeout", ".", "timeout", "(", "5", ")", ":", "a...
[ 69, 4 ]
[ 86, 35 ]
python
en
['en', 'sn', 'en']
True
WemoBinarySensor._async_locked_update
(self, force_update)
Try updating within an async lock.
Try updating within an async lock.
async def _async_locked_update(self, force_update): """Try updating within an async lock.""" async with self._update_lock: await self.hass.async_add_executor_job(self._update, force_update)
[ "async", "def", "_async_locked_update", "(", "self", ",", "force_update", ")", ":", "async", "with", "self", ".", "_update_lock", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_update", ",", "force_update", ")" ]
[ 88, 4 ]
[ 91, 78 ]
python
en
['en', 'en', 'en']
True
WemoBinarySensor._update
(self, force_update=True)
Update the sensor state.
Update the sensor state.
def _update(self, force_update=True): """Update the sensor state.""" try: self._state = self.wemo.get_state(force_update) if not self._available: _LOGGER.info("Reconnected to %s", self.name) self._available = True except (AttributeError, A...
[ "def", "_update", "(", "self", ",", "force_update", "=", "True", ")", ":", "try", ":", "self", ".", "_state", "=", "self", ".", "wemo", ".", "get_state", "(", "force_update", ")", "if", "not", "self", ".", "_available", ":", "_LOGGER", ".", "info", "...
[ 93, 4 ]
[ 104, 45 ]
python
en
['en', 'co', 'en']
True
WemoBinarySensor.unique_id
(self)
Return the id of this WeMo sensor.
Return the id of this WeMo sensor.
def unique_id(self): """Return the id of this WeMo sensor.""" return self._serial_number
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_serial_number" ]
[ 107, 4 ]
[ 109, 34 ]
python
en
['en', 'ja', 'en']
True
WemoBinarySensor.name
(self)
Return the name of the service if any.
Return the name of the service if any.
def name(self): """Return the name of the service if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 112, 4 ]
[ 114, 25 ]
python
en
['en', 'en', 'en']
True
WemoBinarySensor.is_on
(self)
Return true if sensor is on.
Return true if sensor is on.
def is_on(self): """Return true if sensor is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 117, 4 ]
[ 119, 26 ]
python
en
['en', 'et', 'en']
True
WemoBinarySensor.available
(self)
Return true if sensor is available.
Return true if sensor is available.
def available(self): """Return true if sensor is available.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 122, 4 ]
[ 124, 30 ]
python
en
['en', 'en', 'en']
True
WemoBinarySensor.device_info
(self)
Return the device info.
Return the device info.
def device_info(self): """Return the device info.""" return { "name": self._name, "identifiers": {(WEMO_DOMAIN, self._serial_number)}, "model": self._model_name, "manufacturer": "Belkin", }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"name\"", ":", "self", ".", "_name", ",", "\"identifiers\"", ":", "{", "(", "WEMO_DOMAIN", ",", "self", ".", "_serial_number", ")", "}", ",", "\"model\"", ":", "self", ".", "_model_name", ",",...
[ 127, 4 ]
[ 134, 9 ]
python
en
['en', 'en', 'en']
True
pty_input
(data)
write to the child pty. The pty sees this as if you are typing in a real terminal.
write to the child pty. The pty sees this as if you are typing in a real terminal.
def pty_input(data): """write to the child pty. The pty sees this as if you are typing in a real terminal. """ if app.config["fd"]: os.write(app.config["fd"], data["input"].encode())
[ "def", "pty_input", "(", "data", ")", ":", "if", "app", ".", "config", "[", "\"fd\"", "]", ":", "os", ".", "write", "(", "app", ".", "config", "[", "\"fd\"", "]", ",", "data", "[", "\"input\"", "]", ".", "encode", "(", ")", ")" ]
[ 72, 0 ]
[ 77, 58 ]
python
en
['en', 'en', 'en']
True
connect
()
new client connected
new client connected
def connect(): """new client connected""" if app.config["child_pid"]: # already started child process, don't start another return # create child process attached to a pty we can read from and write to (child_pid, fd) = pty.fork() if child_pid == 0: subprocess.run(app.config...
[ "def", "connect", "(", ")", ":", "if", "app", ".", "config", "[", "\"child_pid\"", "]", ":", "# already started child process, don't start another", "return", "# create child process attached to a pty we can read from and write to", "(", "child_pid", ",", "fd", ")", "=", ...
[ 87, 0 ]
[ 111, 29 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up Z-Wave Light from Config Entry.
Set up Z-Wave Light from Config Entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up Z-Wave Light from Config Entry.""" @callback def async_add_light(values): """Add Z-Wave Light.""" light = ZwaveLight(values) async_add_entities([light]) hass.data[DOMAIN][config_entry.entry_id][DATA...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "@", "callback", "def", "async_add_light", "(", "values", ")", ":", "\"\"\"Add Z-Wave Light.\"\"\"", "light", "=", "ZwaveLight", "(", "values", ")", "async_...
[ 34, 0 ]
[ 46, 5 ]
python
en
['en', 'en', 'en']
True
byte_to_zwave_brightness
(value)
Convert brightness in 0-255 scale to 0-99 scale. `value` -- (int) Brightness byte value from 0-255.
Convert brightness in 0-255 scale to 0-99 scale.
def byte_to_zwave_brightness(value): """Convert brightness in 0-255 scale to 0-99 scale. `value` -- (int) Brightness byte value from 0-255. """ if value > 0: return max(1, round((value / 255) * 99)) return 0
[ "def", "byte_to_zwave_brightness", "(", "value", ")", ":", "if", "value", ">", "0", ":", "return", "max", "(", "1", ",", "round", "(", "(", "value", "/", "255", ")", "*", "99", ")", ")", "return", "0" ]
[ 49, 0 ]
[ 56, 12 ]
python
en
['en', 'en', 'en']
True
ZwaveLight.__init__
(self, values)
Initialize the light.
Initialize the light.
def __init__(self, values): """Initialize the light.""" super().__init__(values) self._color_channels = None self._hs = None self._white = None self._ct = None self._supported_features = SUPPORT_BRIGHTNESS self._min_mireds = 153 # 6500K as a safe default ...
[ "def", "__init__", "(", "self", ",", "values", ")", ":", "super", "(", ")", ".", "__init__", "(", "values", ")", "self", ".", "_color_channels", "=", "None", "self", ".", "_hs", "=", "None", "self", ".", "_white", "=", "None", "self", ".", "_ct", "...
[ 62, 4 ]
[ 74, 30 ]
python
en
['en', 'en', 'en']
True