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
UniversalMediaPlayer.async_media_stop
(self)
Send stop command.
Send stop command.
async def async_media_stop(self): """Send stop command.""" await self._async_call_service(SERVICE_MEDIA_STOP)
[ "async", "def", "async_media_stop", "(", "self", ")", ":", "await", "self", ".", "_async_call_service", "(", "SERVICE_MEDIA_STOP", ")" ]
[ 470, 4 ]
[ 472, 58 ]
python
en
['en', 'en', 'en']
True
UniversalMediaPlayer.async_media_previous_track
(self)
Send previous track command.
Send previous track command.
async def async_media_previous_track(self): """Send previous track command.""" await self._async_call_service(SERVICE_MEDIA_PREVIOUS_TRACK)
[ "async", "def", "async_media_previous_track", "(", "self", ")", ":", "await", "self", ".", "_async_call_service", "(", "SERVICE_MEDIA_PREVIOUS_TRACK", ")" ]
[ 474, 4 ]
[ 476, 68 ]
python
en
['en', 'it', 'en']
True
UniversalMediaPlayer.async_media_next_track
(self)
Send next track command.
Send next track command.
async def async_media_next_track(self): """Send next track command.""" await self._async_call_service(SERVICE_MEDIA_NEXT_TRACK)
[ "async", "def", "async_media_next_track", "(", "self", ")", ":", "await", "self", ".", "_async_call_service", "(", "SERVICE_MEDIA_NEXT_TRACK", ")" ]
[ 478, 4 ]
[ 480, 64 ]
python
en
['en', 'pt', 'en']
True
UniversalMediaPlayer.async_media_seek
(self, position)
Send seek command.
Send seek command.
async def async_media_seek(self, position): """Send seek command.""" data = {ATTR_MEDIA_SEEK_POSITION: position} await self._async_call_service(SERVICE_MEDIA_SEEK, data)
[ "async", "def", "async_media_seek", "(", "self", ",", "position", ")", ":", "data", "=", "{", "ATTR_MEDIA_SEEK_POSITION", ":", "position", "}", "await", "self", ".", "_async_call_service", "(", "SERVICE_MEDIA_SEEK", ",", "data", ")" ]
[ 482, 4 ]
[ 485, 64 ]
python
en
['en', 'ig', 'en']
True
UniversalMediaPlayer.async_play_media
(self, media_type, media_id, **kwargs)
Play a piece of media.
Play a piece of media.
async def async_play_media(self, media_type, media_id, **kwargs): """Play a piece of media.""" data = {ATTR_MEDIA_CONTENT_TYPE: media_type, ATTR_MEDIA_CONTENT_ID: media_id} await self._async_call_service(SERVICE_PLAY_MEDIA, data)
[ "async", "def", "async_play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "ATTR_MEDIA_CONTENT_TYPE", ":", "media_type", ",", "ATTR_MEDIA_CONTENT_ID", ":", "media_id", "}", "await", "self", ".", ...
[ 487, 4 ]
[ 490, 64 ]
python
en
['en', 'en', 'en']
True
UniversalMediaPlayer.async_volume_up
(self)
Turn volume up for media player.
Turn volume up for media player.
async def async_volume_up(self): """Turn volume up for media player.""" await self._async_call_service(SERVICE_VOLUME_UP, allow_override=True)
[ "async", "def", "async_volume_up", "(", "self", ")", ":", "await", "self", ".", "_async_call_service", "(", "SERVICE_VOLUME_UP", ",", "allow_override", "=", "True", ")" ]
[ 492, 4 ]
[ 494, 78 ]
python
en
['en', 'no', 'en']
True
UniversalMediaPlayer.async_volume_down
(self)
Turn volume down for media player.
Turn volume down for media player.
async def async_volume_down(self): """Turn volume down for media player.""" await self._async_call_service(SERVICE_VOLUME_DOWN, allow_override=True)
[ "async", "def", "async_volume_down", "(", "self", ")", ":", "await", "self", ".", "_async_call_service", "(", "SERVICE_VOLUME_DOWN", ",", "allow_override", "=", "True", ")" ]
[ 496, 4 ]
[ 498, 80 ]
python
en
['en', 'en', 'en']
True
UniversalMediaPlayer.async_media_play_pause
(self)
Play or pause the media player.
Play or pause the media player.
async def async_media_play_pause(self): """Play or pause the media player.""" await self._async_call_service(SERVICE_MEDIA_PLAY_PAUSE)
[ "async", "def", "async_media_play_pause", "(", "self", ")", ":", "await", "self", ".", "_async_call_service", "(", "SERVICE_MEDIA_PLAY_PAUSE", ")" ]
[ 500, 4 ]
[ 502, 64 ]
python
en
['en', 'en', 'en']
True
UniversalMediaPlayer.async_select_source
(self, source)
Set the input source.
Set the input source.
async def async_select_source(self, source): """Set the input source.""" data = {ATTR_INPUT_SOURCE: source} await self._async_call_service(SERVICE_SELECT_SOURCE, data, allow_override=True)
[ "async", "def", "async_select_source", "(", "self", ",", "source", ")", ":", "data", "=", "{", "ATTR_INPUT_SOURCE", ":", "source", "}", "await", "self", ".", "_async_call_service", "(", "SERVICE_SELECT_SOURCE", ",", "data", ",", "allow_override", "=", "True", ...
[ 504, 4 ]
[ 507, 88 ]
python
en
['en', 'su', 'en']
True
UniversalMediaPlayer.async_clear_playlist
(self)
Clear players playlist.
Clear players playlist.
async def async_clear_playlist(self): """Clear players playlist.""" await self._async_call_service(SERVICE_CLEAR_PLAYLIST)
[ "async", "def", "async_clear_playlist", "(", "self", ")", ":", "await", "self", ".", "_async_call_service", "(", "SERVICE_CLEAR_PLAYLIST", ")" ]
[ 509, 4 ]
[ 511, 62 ]
python
en
['fr', 'en', 'en']
True
UniversalMediaPlayer.async_set_shuffle
(self, shuffle)
Enable/disable shuffling.
Enable/disable shuffling.
async def async_set_shuffle(self, shuffle): """Enable/disable shuffling.""" data = {ATTR_MEDIA_SHUFFLE: shuffle} await self._async_call_service(SERVICE_SHUFFLE_SET, data, allow_override=True)
[ "async", "def", "async_set_shuffle", "(", "self", ",", "shuffle", ")", ":", "data", "=", "{", "ATTR_MEDIA_SHUFFLE", ":", "shuffle", "}", "await", "self", ".", "_async_call_service", "(", "SERVICE_SHUFFLE_SET", ",", "data", ",", "allow_override", "=", "True", "...
[ 513, 4 ]
[ 516, 86 ]
python
en
['de', 'en', 'en']
False
UniversalMediaPlayer.async_update
(self)
Update state in HA.
Update state in HA.
async def async_update(self): """Update state in HA.""" for child_name in self._children: child_state = self.hass.states.get(child_name) if child_state and child_state.state not in OFF_STATES: self._child_state = child_state return self._ch...
[ "async", "def", "async_update", "(", "self", ")", ":", "for", "child_name", "in", "self", ".", "_children", ":", "child_state", "=", "self", ".", "hass", ".", "states", ".", "get", "(", "child_name", ")", "if", "child_state", "and", "child_state", ".", "...
[ 518, 4 ]
[ 525, 32 ]
python
en
['en', 'co', 'en']
True
setup
(hass, config)
Set up the opnsense component.
Set up the opnsense component.
def setup(hass, config): """Set up the opnsense component.""" conf = config[DOMAIN] url = conf[CONF_URL] api_key = conf[CONF_API_KEY] api_secret = conf[CONF_API_SECRET] verify_ssl = conf[CONF_VERIFY_SSL] tracker_interfaces = conf[CONF_TRACKER_INTERFACE] interfaces_client = diagnostics....
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", "[", "DOMAIN", "]", "url", "=", "conf", "[", "CONF_URL", "]", "api_key", "=", "conf", "[", "CONF_API_KEY", "]", "api_secret", "=", "conf", "[", "CONF_API_SECRET", "]", "verify...
[ 38, 0 ]
[ 76, 15 ]
python
en
['en', 'en', 'en']
True
test_platform_manually_configured
(hass)
Test that we do not discover anything or try to set up a controller.
Test that we do not discover anything or try to set up a controller.
async def test_platform_manually_configured(hass): """Test that we do not discover anything or try to set up a controller.""" assert ( await async_setup_component( hass, SWITCH_DOMAIN, {SWITCH_DOMAIN: {"platform": UNIFI_DOMAIN}} ) is True ) assert UNIFI_DOMAIN not in ...
[ "async", "def", "test_platform_manually_configured", "(", "hass", ")", ":", "assert", "(", "await", "async_setup_component", "(", "hass", ",", "SWITCH_DOMAIN", ",", "{", "SWITCH_DOMAIN", ":", "{", "\"platform\"", ":", "UNIFI_DOMAIN", "}", "}", ")", "is", "True",...
[ 284, 0 ]
[ 292, 40 ]
python
en
['en', 'en', 'en']
True
test_no_clients
(hass)
Test the update_clients function when no clients are found.
Test the update_clients function when no clients are found.
async def test_no_clients(hass): """Test the update_clients function when no clients are found.""" controller = await setup_unifi_integration( hass, options={ CONF_TRACK_CLIENTS: False, CONF_TRACK_DEVICES: False, CONF_DPI_RESTRICTIONS: False, }, ) ...
[ "async", "def", "test_no_clients", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ",", "options", "=", "{", "CONF_TRACK_CLIENTS", ":", "False", ",", "CONF_TRACK_DEVICES", ":", "False", ",", "CONF_DPI_RESTRICTIONS", ":", ...
[ 295, 0 ]
[ 307, 64 ]
python
en
['en', 'en', 'en']
True
test_controller_not_client
(hass)
Test that the controller doesn't become a switch.
Test that the controller doesn't become a switch.
async def test_controller_not_client(hass): """Test that the controller doesn't become a switch.""" controller = await setup_unifi_integration( hass, options={CONF_TRACK_CLIENTS: False, CONF_TRACK_DEVICES: False}, clients_response=[CONTROLLER_HOST], devices_response=[DEVICE_1], ...
[ "async", "def", "test_controller_not_client", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ",", "options", "=", "{", "CONF_TRACK_CLIENTS", ":", "False", ",", "CONF_TRACK_DEVICES", ":", "False", "}", ",", "clients_respo...
[ 310, 0 ]
[ 322, 27 ]
python
en
['en', 'en', 'en']
True
test_not_admin
(hass)
Test that switch platform only work on an admin account.
Test that switch platform only work on an admin account.
async def test_not_admin(hass): """Test that switch platform only work on an admin account.""" description = deepcopy(DESCRIPTION) description[0]["site_role"] = "not admin" controller = await setup_unifi_integration( hass, options={CONF_TRACK_CLIENTS: False, CONF_TRACK_DEVICES: False}, ...
[ "async", "def", "test_not_admin", "(", "hass", ")", ":", "description", "=", "deepcopy", "(", "DESCRIPTION", ")", "description", "[", "0", "]", "[", "\"site_role\"", "]", "=", "\"not admin\"", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ...
[ 325, 0 ]
[ 338, 64 ]
python
en
['en', 'en', 'en']
True
test_switches
(hass)
Test the update_items function with some clients.
Test the update_items function with some clients.
async def test_switches(hass): """Test the update_items function with some clients.""" controller = await setup_unifi_integration( hass, options={ CONF_BLOCK_CLIENT: [BLOCKED["mac"], UNBLOCKED["mac"]], CONF_TRACK_CLIENTS: False, CONF_TRACK_DEVICES: False, ...
[ "async", "def", "test_switches", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ",", "options", "=", "{", "CONF_BLOCK_CLIENT", ":", "[", "BLOCKED", "[", "\"mac\"", "]", ",", "UNBLOCKED", "[", "\"mac\"", "]", "]", ...
[ 341, 0 ]
[ 427, 5 ]
python
en
['en', 'en', 'en']
True
test_remove_switches
(hass)
Test the update_items function with some clients.
Test the update_items function with some clients.
async def test_remove_switches(hass): """Test the update_items function with some clients.""" controller = await setup_unifi_integration( hass, options={CONF_BLOCK_CLIENT: [UNBLOCKED["mac"]]}, clients_response=[CLIENT_1, UNBLOCKED], devices_response=[DEVICE_1], ) assert l...
[ "async", "def", "test_remove_switches", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ",", "options", "=", "{", "CONF_BLOCK_CLIENT", ":", "[", "UNBLOCKED", "[", "\"mac\"", "]", "]", "}", ",", "clients_response", "="...
[ 430, 0 ]
[ 459, 31 ]
python
en
['en', 'en', 'en']
True
test_block_switches
(hass)
Test the update_items function with some clients.
Test the update_items function with some clients.
async def test_block_switches(hass): """Test the update_items function with some clients.""" controller = await setup_unifi_integration( hass, options={ CONF_BLOCK_CLIENT: [BLOCKED["mac"], UNBLOCKED["mac"]], CONF_TRACK_CLIENTS: False, CONF_TRACK_DEVICES: False...
[ "async", "def", "test_block_switches", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ",", "options", "=", "{", "CONF_BLOCK_CLIENT", ":", "[", "BLOCKED", "[", "\"mac\"", "]", ",", "UNBLOCKED", "[", "\"mac\"", "]", ...
[ 462, 0 ]
[ 527, 5 ]
python
en
['en', 'en', 'en']
True
test_new_client_discovered_on_block_control
(hass)
Test if 2nd update has a new client.
Test if 2nd update has a new client.
async def test_new_client_discovered_on_block_control(hass): """Test if 2nd update has a new client.""" controller = await setup_unifi_integration( hass, options={ CONF_BLOCK_CLIENT: [BLOCKED["mac"]], CONF_TRACK_CLIENTS: False, CONF_TRACK_DEVICES: False, ...
[ "async", "def", "test_new_client_discovered_on_block_control", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ",", "options", "=", "{", "CONF_BLOCK_CLIENT", ":", "[", "BLOCKED", "[", "\"mac\"", "]", "]", ",", "CONF_TRACK...
[ 530, 0 ]
[ 566, 30 ]
python
en
['en', 'en', 'en']
True
test_option_block_clients
(hass)
Test the changes to option reflects accordingly.
Test the changes to option reflects accordingly.
async def test_option_block_clients(hass): """Test the changes to option reflects accordingly.""" controller = await setup_unifi_integration( hass, options={CONF_BLOCK_CLIENT: [BLOCKED["mac"]]}, clients_all_response=[BLOCKED, UNBLOCKED], ) assert len(hass.states.async_entity_ids(...
[ "async", "def", "test_option_block_clients", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ",", "options", "=", "{", "CONF_BLOCK_CLIENT", ":", "[", "BLOCKED", "[", "\"mac\"", "]", "]", "}", ",", "clients_all_response"...
[ 569, 0 ]
[ 608, 64 ]
python
en
['en', 'en', 'en']
True
test_option_remove_switches
(hass)
Test removal of DPI switch when options updated.
Test removal of DPI switch when options updated.
async def test_option_remove_switches(hass): """Test removal of DPI switch when options updated.""" controller = await setup_unifi_integration( hass, options={ CONF_TRACK_CLIENTS: False, CONF_TRACK_DEVICES: False, }, clients_response=[CLIENT_1], de...
[ "async", "def", "test_option_remove_switches", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ",", "options", "=", "{", "CONF_TRACK_CLIENTS", ":", "False", ",", "CONF_TRACK_DEVICES", ":", "False", ",", "}", ",", "clien...
[ 611, 0 ]
[ 632, 64 ]
python
en
['en', 'en', 'en']
True
test_new_client_discovered_on_poe_control
(hass)
Test if 2nd update has a new client.
Test if 2nd update has a new client.
async def test_new_client_discovered_on_poe_control(hass): """Test if 2nd update has a new client.""" controller = await setup_unifi_integration( hass, options={CONF_TRACK_CLIENTS: False, CONF_TRACK_DEVICES: False}, clients_response=[CLIENT_1], devices_response=[DEVICE_1], ) ...
[ "async", "def", "test_new_client_discovered_on_poe_control", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ",", "options", "=", "{", "CONF_TRACK_CLIENTS", ":", "False", ",", "CONF_TRACK_DEVICES", ":", "False", "}", ",", ...
[ 635, 0 ]
[ 692, 5 ]
python
en
['en', 'en', 'en']
True
test_ignore_multiple_poe_clients_on_same_port
(hass)
Ignore when there are multiple POE driven clients on same port. If there is a non-UniFi switch powered by POE, clients will be transparently marked as having POE as well.
Ignore when there are multiple POE driven clients on same port.
async def test_ignore_multiple_poe_clients_on_same_port(hass): """Ignore when there are multiple POE driven clients on same port. If there is a non-UniFi switch powered by POE, clients will be transparently marked as having POE as well. """ controller = await setup_unifi_integration( hass, ...
[ "async", "def", "test_ignore_multiple_poe_clients_on_same_port", "(", "hass", ")", ":", "controller", "=", "await", "setup_unifi_integration", "(", "hass", ",", "clients_response", "=", "POE_SWITCH_CLIENTS", ",", "devices_response", "=", "[", "DEVICE_1", "]", ",", ")"...
[ 695, 0 ]
[ 713, 27 ]
python
en
['en', 'en', 'en']
True
test_restoring_client
(hass)
Test the update_items function with some clients.
Test the update_items function with some clients.
async def test_restoring_client(hass): """Test the update_items function with some clients.""" config_entry = config_entries.ConfigEntry( version=1, domain=UNIFI_DOMAIN, title="Mock Title", data=ENTRY_CONFIG, source="test", connection_class=config_entries.CONN_CLA...
[ "async", "def", "test_restoring_client", "(", "hass", ")", ":", "config_entry", "=", "config_entries", ".", "ConfigEntry", "(", "version", "=", "1", ",", "domain", "=", "UNIFI_DOMAIN", ",", "title", "=", "\"Mock Title\"", ",", "data", "=", "ENTRY_CONFIG", ",",...
[ 716, 0 ]
[ 762, 31 ]
python
en
['en', 'en', 'en']
True
get_crd
(hass, update_interval)
Make coordinator mocks.
Make coordinator mocks.
def get_crd(hass, update_interval): """Make coordinator mocks.""" calls = 0 async def refresh() -> int: nonlocal calls calls += 1 return calls crd = update_coordinator.DataUpdateCoordinator[int]( hass, _LOGGER, name="test", update_method=refresh,...
[ "def", "get_crd", "(", "hass", ",", "update_interval", ")", ":", "calls", "=", "0", "async", "def", "refresh", "(", ")", "->", "int", ":", "nonlocal", "calls", "calls", "+=", "1", "return", "calls", "crd", "=", "update_coordinator", ".", "DataUpdateCoordin...
[ 19, 0 ]
[ 35, 14 ]
python
en
['en', 'et', 'en']
True
crd
(hass)
Coordinator mock with default update interval.
Coordinator mock with default update interval.
def crd(hass): """Coordinator mock with default update interval.""" return get_crd(hass, DEFAULT_UPDATE_INTERVAL)
[ "def", "crd", "(", "hass", ")", ":", "return", "get_crd", "(", "hass", ",", "DEFAULT_UPDATE_INTERVAL", ")" ]
[ 42, 0 ]
[ 44, 49 ]
python
en
['en', 'nl', 'en']
True
crd_without_update_interval
(hass)
Coordinator mock that never automatically updates.
Coordinator mock that never automatically updates.
def crd_without_update_interval(hass): """Coordinator mock that never automatically updates.""" return get_crd(hass, None)
[ "def", "crd_without_update_interval", "(", "hass", ")", ":", "return", "get_crd", "(", "hass", ",", "None", ")" ]
[ 48, 0 ]
[ 50, 30 ]
python
en
['en', 'en', 'en']
True
test_async_refresh
(crd)
Test async_refresh for update coordinator.
Test async_refresh for update coordinator.
async def test_async_refresh(crd): """Test async_refresh for update coordinator.""" assert crd.data is None await crd.async_refresh() assert crd.data == 1 assert crd.last_update_success is True # Make sure we didn't schedule a refresh because we have 0 listeners assert crd._unsub_refresh is ...
[ "async", "def", "test_async_refresh", "(", "crd", ")", ":", "assert", "crd", ".", "data", "is", "None", "await", "crd", ".", "async_refresh", "(", ")", "assert", "crd", ".", "data", "==", "1", "assert", "crd", ".", "last_update_success", "is", "True", "#...
[ 53, 0 ]
[ 81, 25 ]
python
en
['en', 'de', 'en']
True
test_request_refresh
(crd)
Test request refresh for update coordinator.
Test request refresh for update coordinator.
async def test_request_refresh(crd): """Test request refresh for update coordinator.""" assert crd.data is None await crd.async_request_refresh() assert crd.data == 1 assert crd.last_update_success is True # Second time we hit the debonuce await crd.async_request_refresh() assert crd.da...
[ "async", "def", "test_request_refresh", "(", "crd", ")", ":", "assert", "crd", ".", "data", "is", "None", "await", "crd", ".", "async_request_refresh", "(", ")", "assert", "crd", ".", "data", "==", "1", "assert", "crd", ".", "last_update_success", "is", "T...
[ 84, 0 ]
[ 94, 42 ]
python
en
['en', 'de', 'en']
True
test_request_refresh_no_auto_update
(crd_without_update_interval)
Test request refresh for update coordinator without automatic update.
Test request refresh for update coordinator without automatic update.
async def test_request_refresh_no_auto_update(crd_without_update_interval): """Test request refresh for update coordinator without automatic update.""" crd = crd_without_update_interval assert crd.data is None await crd.async_request_refresh() assert crd.data == 1 assert crd.last_update_success ...
[ "async", "def", "test_request_refresh_no_auto_update", "(", "crd_without_update_interval", ")", ":", "crd", "=", "crd_without_update_interval", "assert", "crd", ".", "data", "is", "None", "await", "crd", ".", "async_request_refresh", "(", ")", "assert", "crd", ".", ...
[ 97, 0 ]
[ 108, 42 ]
python
en
['en', 'en', 'en']
True
test_refresh_known_errors
(err_msg, crd, caplog)
Test raising known errors.
Test raising known errors.
async def test_refresh_known_errors(err_msg, crd, caplog): """Test raising known errors.""" crd.update_method = AsyncMock(side_effect=err_msg[0]) await crd.async_refresh() assert crd.data is None assert crd.last_update_success is False assert err_msg[1] in caplog.text
[ "async", "def", "test_refresh_known_errors", "(", "err_msg", ",", "crd", ",", "caplog", ")", ":", "crd", ".", "update_method", "=", "AsyncMock", "(", "side_effect", "=", "err_msg", "[", "0", "]", ")", "await", "crd", ".", "async_refresh", "(", ")", "assert...
[ 123, 0 ]
[ 131, 36 ]
python
en
['en', 'de', 'en']
True
test_refresh_fail_unknown
(crd, caplog)
Test raising unknown error.
Test raising unknown error.
async def test_refresh_fail_unknown(crd, caplog): """Test raising unknown error.""" await crd.async_refresh() crd.update_method = AsyncMock(side_effect=ValueError) await crd.async_refresh() assert crd.data == 1 # value from previous fetch assert crd.last_update_success is False assert "U...
[ "async", "def", "test_refresh_fail_unknown", "(", "crd", ",", "caplog", ")", ":", "await", "crd", ".", "async_refresh", "(", ")", "crd", ".", "update_method", "=", "AsyncMock", "(", "side_effect", "=", "ValueError", ")", "await", "crd", ".", "async_refresh", ...
[ 134, 0 ]
[ 144, 63 ]
python
en
['en', 'de', 'en']
True
test_refresh_no_update_method
(crd)
Test raising error is no update method is provided.
Test raising error is no update method is provided.
async def test_refresh_no_update_method(crd): """Test raising error is no update method is provided.""" await crd.async_refresh() crd.update_method = None with pytest.raises(NotImplementedError): await crd.async_refresh()
[ "async", "def", "test_refresh_no_update_method", "(", "crd", ")", ":", "await", "crd", ".", "async_refresh", "(", ")", "crd", ".", "update_method", "=", "None", "with", "pytest", ".", "raises", "(", "NotImplementedError", ")", ":", "await", "crd", ".", "asyn...
[ 147, 0 ]
[ 154, 33 ]
python
en
['en', 'en', 'en']
True
test_update_interval
(hass, crd)
Test update interval works.
Test update interval works.
async def test_update_interval(hass, crd): """Test update interval works.""" # Test we don't update without subscriber async_fire_time_changed(hass, utcnow() + crd.update_interval) await hass.async_block_till_done() assert crd.data is None # Add subscriber update_callback = Mock() crd.a...
[ "async", "def", "test_update_interval", "(", "hass", ",", "crd", ")", ":", "# Test we don't update without subscriber", "async_fire_time_changed", "(", "hass", ",", "utcnow", "(", ")", "+", "crd", ".", "update_interval", ")", "await", "hass", ".", "async_block_till_...
[ 157, 0 ]
[ 184, 24 ]
python
de
['nl', 'de', 'en']
False
test_update_interval_not_present
(hass, crd_without_update_interval)
Test update never happens with no update interval.
Test update never happens with no update interval.
async def test_update_interval_not_present(hass, crd_without_update_interval): """Test update never happens with no update interval.""" crd = crd_without_update_interval # Test we don't update without subscriber with no update interval async_fire_time_changed(hass, utcnow() + DEFAULT_UPDATE_INTERVAL) ...
[ "async", "def", "test_update_interval_not_present", "(", "hass", ",", "crd_without_update_interval", ")", ":", "crd", "=", "crd_without_update_interval", "# Test we don't update without subscriber with no update interval", "async_fire_time_changed", "(", "hass", ",", "utcnow", "(...
[ 187, 0 ]
[ 215, 27 ]
python
en
['en', 'en', 'en']
True
test_refresh_recover
(crd, caplog)
Test recovery of freshing data.
Test recovery of freshing data.
async def test_refresh_recover(crd, caplog): """Test recovery of freshing data.""" crd.last_update_success = False await crd.async_refresh() assert crd.last_update_success is True assert "Fetching test data recovered" in caplog.text
[ "async", "def", "test_refresh_recover", "(", "crd", ",", "caplog", ")", ":", "crd", ".", "last_update_success", "=", "False", "await", "crd", ".", "async_refresh", "(", ")", "assert", "crd", ".", "last_update_success", "is", "True", "assert", "\"Fetching test da...
[ 218, 0 ]
[ 225, 56 ]
python
en
['en', 'en', 'en']
True
test_coordinator_entity
(crd)
Test the CoordinatorEntity class.
Test the CoordinatorEntity class.
async def test_coordinator_entity(crd): """Test the CoordinatorEntity class.""" entity = update_coordinator.CoordinatorEntity(crd) assert entity.should_poll is False crd.last_update_success = False assert entity.available is False await entity.async_update() assert entity.available is Tru...
[ "async", "def", "test_coordinator_entity", "(", "crd", ")", ":", "entity", "=", "update_coordinator", ".", "CoordinatorEntity", "(", "crd", ")", "assert", "entity", ".", "should_poll", "is", "False", "crd", ".", "last_update_success", "=", "False", "assert", "en...
[ 228, 0 ]
[ 251, 36 ]
python
en
['en', 'zh', 'en']
True
test_async_set_updated_data
(crd)
Test async_set_updated_data for update coordinator.
Test async_set_updated_data for update coordinator.
async def test_async_set_updated_data(crd): """Test async_set_updated_data for update coordinator.""" assert crd.data is None with patch.object(crd._debounced_refresh, "async_cancel") as mock_cancel: crd.async_set_updated_data(100) # Test we cancel any pending refresh assert len(mo...
[ "async", "def", "test_async_set_updated_data", "(", "crd", ")", ":", "assert", "crd", ".", "data", "is", "None", "with", "patch", ".", "object", "(", "crd", ".", "_debounced_refresh", ",", "\"async_cancel\"", ")", "as", "mock_cancel", ":", "crd", ".", "async...
[ 254, 0 ]
[ 285, 48 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the IP Webcam component.
Set up the IP Webcam component.
async def async_setup(hass, config): """Set up the IP Webcam component.""" webcams = hass.data[DATA_IP_WEBCAM] = {} websession = async_get_clientsession(hass) async def async_setup_ipcamera(cam_config): """Set up an IP camera.""" host = cam_config[CONF_HOST] username = cam_conf...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "webcams", "=", "hass", ".", "data", "[", "DATA_IP_WEBCAM", "]", "=", "{", "}", "websession", "=", "async_get_clientsession", "(", "hass", ")", "async", "def", "async_setup_ipcamera", "(", ...
[ 185, 0 ]
[ 287, 15 ]
python
en
['en', 'da', 'en']
True
AndroidIPCamEntity.__init__
(self, host, ipcam)
Initialize the data object.
Initialize the data object.
def __init__(self, host, ipcam): """Initialize the data object.""" self._host = host self._ipcam = ipcam
[ "def", "__init__", "(", "self", ",", "host", ",", "ipcam", ")", ":", "self", ".", "_host", "=", "host", "self", ".", "_ipcam", "=", "ipcam" ]
[ 293, 4 ]
[ 296, 27 ]
python
en
['en', 'en', 'en']
True
AndroidIPCamEntity.async_added_to_hass
(self)
Register update dispatcher.
Register update dispatcher.
async def async_added_to_hass(self): """Register update dispatcher.""" @callback def async_ipcam_update(host): """Update callback.""" if self._host != host: return self.async_schedule_update_ha_state(True) self.async_on_remove( ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "@", "callback", "def", "async_ipcam_update", "(", "host", ")", ":", "\"\"\"Update callback.\"\"\"", "if", "self", ".", "_host", "!=", "host", ":", "return", "self", ".", "async_schedule_update_ha_state...
[ 298, 4 ]
[ 310, 9 ]
python
de
['it', 'de', 'en']
False
AndroidIPCamEntity.should_poll
(self)
Return True if entity has to be polled for state.
Return True if entity has to be polled for state.
def should_poll(self): """Return True if entity has to be polled for state.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 313, 4 ]
[ 315, 20 ]
python
en
['en', 'en', 'en']
True
AndroidIPCamEntity.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._ipcam.available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_ipcam", ".", "available" ]
[ 318, 4 ]
[ 320, 36 ]
python
en
['en', 'en', 'en']
True
AndroidIPCamEntity.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" state_attr = {ATTR_HOST: self._host} if self._ipcam.status_data is None: return state_attr state_attr[ATTR_VID_CONNS] = self._ipcam.status_data.get("video_connections") state_attr[ATTR_AUD_CONNS] =...
[ "def", "device_state_attributes", "(", "self", ")", ":", "state_attr", "=", "{", "ATTR_HOST", ":", "self", ".", "_host", "}", "if", "self", ".", "_ipcam", ".", "status_data", "is", "None", ":", "return", "state_attr", "state_attr", "[", "ATTR_VID_CONNS", "]"...
[ 323, 4 ]
[ 332, 25 ]
python
en
['en', 'en', 'en']
True
test_setup_entry
(hass, config_entry, aioclient_mock_fixture)
Test migration of config entry from v1.
Test migration of config entry from v1.
async def test_setup_entry(hass, config_entry, aioclient_mock_fixture): """Test migration of config entry from v1.""" config_entry.add_to_hass(hass) assert await async_setup_component( hass, FLO_DOMAIN, {CONF_USERNAME: TEST_USER_ID, CONF_PASSWORD: TEST_PASSWORD} ) await hass.async_block_till...
[ "async", "def", "test_setup_entry", "(", "hass", ",", "config_entry", ",", "aioclient_mock_fixture", ")", ":", "config_entry", ".", "add_to_hass", "(", "hass", ")", "assert", "await", "async_setup_component", "(", "hass", ",", "FLO_DOMAIN", ",", "{", "CONF_USERNAM...
[ 8, 0 ]
[ 17, 72 ]
python
en
['en', 'en', 'en']
True
test_flow_user
(hass)
Test user initialized flow.
Test user initialized flow.
async def test_flow_user(hass): """Test user initialized flow.""" mocked_yeti = await _create_mocked_yeti() with _patch_config_flow_yeti(mocked_yeti), _patch_setup(): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, ) ...
[ "async", "def", "test_flow_user", "(", "hass", ")", ":", "mocked_yeti", "=", "await", "_create_mocked_yeti", "(", ")", "with", "_patch_config_flow_yeti", "(", "mocked_yeti", ")", ",", "_patch_setup", "(", ")", ":", "result", "=", "await", "hass", ".", "config_...
[ 40, 0 ]
[ 54, 42 ]
python
da
['da', 'pl', 'en']
False
test_flow_user_already_configured
(hass)
Test user initialized flow with duplicate server.
Test user initialized flow with duplicate server.
async def test_flow_user_already_configured(hass): """Test user initialized flow with duplicate server.""" entry = MockConfigEntry( domain=DOMAIN, data={CONF_HOST: "1.2.3.4", CONF_NAME: "Yeti"}, ) entry.add_to_hass(hass) service_info = { "host": "1.2.3.4", "name": "...
[ "async", "def", "test_flow_user_already_configured", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "CONF_HOST", ":", "\"1.2.3.4\"", ",", "CONF_NAME", ":", "\"Yeti\"", "}", ",", ")", "entry", ".",...
[ 57, 0 ]
[ 75, 51 ]
python
en
['en', 'en', 'en']
True
test_flow_user_cannot_connect
(hass)
Test user initialized flow with unreachable server.
Test user initialized flow with unreachable server.
async def test_flow_user_cannot_connect(hass): """Test user initialized flow with unreachable server.""" mocked_yeti = await _create_mocked_yeti(True) with _patch_config_flow_yeti(mocked_yeti) as yetimock: yetimock.side_effect = exceptions.ConnectError result = await hass.config_entries.flow...
[ "async", "def", "test_flow_user_cannot_connect", "(", "hass", ")", ":", "mocked_yeti", "=", "await", "_create_mocked_yeti", "(", "True", ")", "with", "_patch_config_flow_yeti", "(", "mocked_yeti", ")", "as", "yetimock", ":", "yetimock", ".", "side_effect", "=", "e...
[ 78, 0 ]
[ 88, 61 ]
python
en
['en', 'en', 'en']
True
test_flow_user_invalid_host
(hass)
Test user initialized flow with invalid server.
Test user initialized flow with invalid server.
async def test_flow_user_invalid_host(hass): """Test user initialized flow with invalid server.""" mocked_yeti = await _create_mocked_yeti(True) with _patch_config_flow_yeti(mocked_yeti) as yetimock: yetimock.side_effect = exceptions.InvalidHost result = await hass.config_entries.flow.async_...
[ "async", "def", "test_flow_user_invalid_host", "(", "hass", ")", ":", "mocked_yeti", "=", "await", "_create_mocked_yeti", "(", "True", ")", "with", "_patch_config_flow_yeti", "(", "mocked_yeti", ")", "as", "yetimock", ":", "yetimock", ".", "side_effect", "=", "exc...
[ 91, 0 ]
[ 101, 59 ]
python
en
['en', 'en', 'en']
True
test_flow_user_unknown_error
(hass)
Test user initialized flow with unreachable server.
Test user initialized flow with unreachable server.
async def test_flow_user_unknown_error(hass): """Test user initialized flow with unreachable server.""" mocked_yeti = await _create_mocked_yeti(True) with _patch_config_flow_yeti(mocked_yeti) as yetimock: yetimock.side_effect = Exception result = await hass.config_entries.flow.async_init( ...
[ "async", "def", "test_flow_user_unknown_error", "(", "hass", ")", ":", "mocked_yeti", "=", "await", "_create_mocked_yeti", "(", "True", ")", "with", "_patch_config_flow_yeti", "(", "mocked_yeti", ")", "as", "yetimock", ":", "yetimock", ".", "side_effect", "=", "Ex...
[ 104, 0 ]
[ 114, 54 ]
python
en
['en', 'en', 'en']
True
_transitions_config_parser
(transitions)
Parse transitions config into initialized objects.
Parse transitions config into initialized objects.
def _transitions_config_parser(transitions): """Parse transitions config into initialized objects.""" transition_objects = [] for transition_config in transitions: transition, params = list(transition_config.items())[0] transition_objects.append(getattr(yeelight, transition)(*params)) r...
[ "def", "_transitions_config_parser", "(", "transitions", ")", ":", "transition_objects", "=", "[", "]", "for", "transition_config", "in", "transitions", ":", "transition", ",", "params", "=", "list", "(", "transition_config", ".", "items", "(", ")", ")", "[", ...
[ 185, 0 ]
[ 192, 29 ]
python
en
['en', 'en', 'en']
True
_cmd
(func)
Define a wrapper to catch exceptions from the bulb.
Define a wrapper to catch exceptions from the bulb.
def _cmd(func): """Define a wrapper to catch exceptions from the bulb.""" def _wrap(self, *args, **kwargs): try: _LOGGER.debug("Calling %s with %s %s", func, args, kwargs) return func(self, *args, **kwargs) except BulbException as ex: _LOGGER.error("Error whe...
[ "def", "_cmd", "(", "func", ")", ":", "def", "_wrap", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "_LOGGER", ".", "debug", "(", "\"Calling %s with %s %s\"", ",", "func", ",", "args", ",", "kwargs", ")", "return", "...
[ 212, 0 ]
[ 222, 16 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities )
Set up Yeelight from a config entry.
Set up Yeelight from a config entry.
async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up Yeelight from a config entry.""" custom_effects = _parse_custom_effects(hass.data[DOMAIN][DATA_CUSTOM_EFFECTS]) device = hass.data[DOMAIN][DATA_CONFIG_ENTRIES][config_entry.entry_id][DA...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "custom_effects", "=", "_parse_custom_effects", "(", "hass", ".", "data", "[", "DOMAIN", "]", "[",...
[ 225, 0 ]
[ 274, 31 ]
python
en
['en', 'en', 'en']
True
_async_setup_services
(hass: HomeAssistant)
Set up custom services.
Set up custom services.
def _async_setup_services(hass: HomeAssistant): """Set up custom services.""" async def _async_start_flow(entity, service_call): params = {**service_call.data} params.pop(ATTR_ENTITY_ID) params[ATTR_TRANSITIONS] = _transitions_config_parser(params[ATTR_TRANSITIONS]) await hass.a...
[ "def", "_async_setup_services", "(", "hass", ":", "HomeAssistant", ")", ":", "async", "def", "_async_start_flow", "(", "entity", ",", "service_call", ")", ":", "params", "=", "{", "*", "*", "service_call", ".", "data", "}", "params", ".", "pop", "(", "ATTR...
[ 278, 0 ]
[ 377, 5 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.__init__
(self, device, entry, custom_effects=None)
Initialize the Yeelight light.
Initialize the Yeelight light.
def __init__(self, device, entry, custom_effects=None): """Initialize the Yeelight light.""" super().__init__(device, entry) self.config = device.config self._brightness = None self._color_temp = None self._hs = None self._effect = None model_specs = se...
[ "def", "__init__", "(", "self", ",", "device", ",", "entry", ",", "custom_effects", "=", "None", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "entry", ")", "self", ".", "config", "=", "device", ".", "config", "self", ".", "_brigh...
[ 383, 4 ]
[ 403, 37 ]
python
en
['en', 'xh', 'en']
True
YeelightGenericLight.async_added_to_hass
(self)
Handle entity which will be added.
Handle entity which will be added.
async def async_added_to_hass(self): """Handle entity which will be added.""" self.async_on_remove( async_dispatcher_connect( self.hass, DATA_UPDATED.format(self._device.host), self._schedule_immediate_update, ) )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "DATA_UPDATED", ".", "format", "(", "self", ".", "_device", ".", "host", ")", ",", "self", ".", "_...
[ 409, 4 ]
[ 417, 9 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self) -> int: """Flag supported features.""" return SUPPORT_YEELIGHT
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_YEELIGHT" ]
[ 420, 4 ]
[ 422, 31 ]
python
en
['da', 'en', 'en']
True
YeelightGenericLight.effect_list
(self)
Return the list of supported effects.
Return the list of supported effects.
def effect_list(self): """Return the list of supported effects.""" return self._predefined_effects + self.custom_effects_names
[ "def", "effect_list", "(", "self", ")", ":", "return", "self", ".", "_predefined_effects", "+", "self", ".", "custom_effects_names" ]
[ 425, 4 ]
[ 427, 67 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.color_temp
(self)
Return the color temperature.
Return the color temperature.
def color_temp(self) -> int: """Return the color temperature.""" temp_in_k = self._get_property("ct") if temp_in_k: self._color_temp = kelvin_to_mired(int(temp_in_k)) return self._color_temp
[ "def", "color_temp", "(", "self", ")", "->", "int", ":", "temp_in_k", "=", "self", ".", "_get_property", "(", "\"ct\"", ")", "if", "temp_in_k", ":", "self", ".", "_color_temp", "=", "kelvin_to_mired", "(", "int", "(", "temp_in_k", ")", ")", "return", "se...
[ 430, 4 ]
[ 435, 31 ]
python
en
['en', 'la', 'en']
True
YeelightGenericLight.name
(self)
Return the name of the device if any.
Return the name of the device if any.
def name(self) -> str: """Return the name of the device if any.""" return self.device.name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "device", ".", "name" ]
[ 438, 4 ]
[ 440, 31 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self) -> bool: """Return true if device is on.""" return self._get_property(self._power_property) == "on"
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_get_property", "(", "self", ".", "_power_property", ")", "==", "\"on\"" ]
[ 443, 4 ]
[ 445, 63 ]
python
en
['en', 'fy', 'en']
True
YeelightGenericLight.brightness
(self)
Return the brightness of this light between 1..255.
Return the brightness of this light between 1..255.
def brightness(self) -> int: """Return the brightness of this light between 1..255.""" temp = self._get_property(self._brightness_property) if temp: self._brightness = temp return round(255 * (int(self._brightness) / 100))
[ "def", "brightness", "(", "self", ")", "->", "int", ":", "temp", "=", "self", ".", "_get_property", "(", "self", ".", "_brightness_property", ")", "if", "temp", ":", "self", ".", "_brightness", "=", "temp", "return", "round", "(", "255", "*", "(", "int...
[ 448, 4 ]
[ 453, 57 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.min_mireds
(self)
Return minimum supported color temperature.
Return minimum supported color temperature.
def min_mireds(self): """Return minimum supported color temperature.""" return self._min_mireds
[ "def", "min_mireds", "(", "self", ")", ":", "return", "self", ".", "_min_mireds" ]
[ 456, 4 ]
[ 458, 31 ]
python
en
['ro', 'la', 'en']
False
YeelightGenericLight.max_mireds
(self)
Return maximum supported color temperature.
Return maximum supported color temperature.
def max_mireds(self): """Return maximum supported color temperature.""" return self._max_mireds
[ "def", "max_mireds", "(", "self", ")", ":", "return", "self", ".", "_max_mireds" ]
[ 461, 4 ]
[ 463, 31 ]
python
en
['ro', 'la', 'en']
False
YeelightGenericLight.custom_effects
(self)
Return dict with custom effects.
Return dict with custom effects.
def custom_effects(self): """Return dict with custom effects.""" return self._custom_effects
[ "def", "custom_effects", "(", "self", ")", ":", "return", "self", ".", "_custom_effects" ]
[ 466, 4 ]
[ 468, 35 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.custom_effects_names
(self)
Return list with custom effects names.
Return list with custom effects names.
def custom_effects_names(self): """Return list with custom effects names.""" return list(self.custom_effects)
[ "def", "custom_effects_names", "(", "self", ")", ":", "return", "list", "(", "self", ".", "custom_effects", ")" ]
[ 471, 4 ]
[ 473, 40 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.light_type
(self)
Return light type.
Return light type.
def light_type(self): """Return light type.""" return self._light_type
[ "def", "light_type", "(", "self", ")", ":", "return", "self", ".", "_light_type" ]
[ 476, 4 ]
[ 478, 31 ]
python
en
['es', 'no', 'en']
False
YeelightGenericLight.hs_color
(self)
Return the color property.
Return the color property.
def hs_color(self) -> tuple: """Return the color property.""" return self._hs
[ "def", "hs_color", "(", "self", ")", "->", "tuple", ":", "return", "self", ".", "_hs" ]
[ 481, 4 ]
[ 483, 23 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.effect
(self)
Return the current effect.
Return the current effect.
def effect(self): """Return the current effect.""" return self._effect
[ "def", "effect", "(", "self", ")", ":", "return", "self", ".", "_effect" ]
[ 486, 4 ]
[ 488, 27 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.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.""" attributes = {"flowing": self.device.is_color_flow_enabled} if self.device.is_nightlight_supported: attributes["night_light"] = self.device.is_nightlight_enabled return attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "attributes", "=", "{", "\"flowing\"", ":", "self", ".", "device", ".", "is_color_flow_enabled", "}", "if", "self", ".", "device", ".", "is_nightlight_supported", ":", "attributes", "[", "\"night_light\"", ...
[ 521, 4 ]
[ 528, 25 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.device
(self)
Return yeelight device.
Return yeelight device.
def device(self): """Return yeelight device.""" return self._device
[ "def", "device", "(", "self", ")", ":", "return", "self", ".", "_device" ]
[ 531, 4 ]
[ 533, 27 ]
python
en
['en', 'tr', 'en']
True
YeelightGenericLight.update
(self)
Update light properties.
Update light properties.
def update(self): """Update light properties.""" self._hs = self._get_hs_from_properties() if not self.device.is_color_flow_enabled: self._effect = None
[ "def", "update", "(", "self", ")", ":", "self", ".", "_hs", "=", "self", ".", "_get_hs_from_properties", "(", ")", "if", "not", "self", ".", "device", ".", "is_color_flow_enabled", ":", "self", ".", "_effect", "=", "None" ]
[ 535, 4 ]
[ 539, 31 ]
python
en
['it', 'lb', 'en']
False
YeelightGenericLight.set_music_mode
(self, mode)
Set the music mode on or off.
Set the music mode on or off.
def set_music_mode(self, mode) -> None: """Set the music mode on or off.""" if mode: self._bulb.start_music() else: self._bulb.stop_music()
[ "def", "set_music_mode", "(", "self", ",", "mode", ")", "->", "None", ":", "if", "mode", ":", "self", ".", "_bulb", ".", "start_music", "(", ")", "else", ":", "self", ".", "_bulb", ".", "stop_music", "(", ")" ]
[ 565, 4 ]
[ 570, 35 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.set_brightness
(self, brightness, duration)
Set bulb brightness.
Set bulb brightness.
def set_brightness(self, brightness, duration) -> None: """Set bulb brightness.""" if brightness: _LOGGER.debug("Setting brightness: %s", brightness) self._bulb.set_brightness( brightness / 255 * 100, duration=duration, light_type=self.light_type )
[ "def", "set_brightness", "(", "self", ",", "brightness", ",", "duration", ")", "->", "None", ":", "if", "brightness", ":", "_LOGGER", ".", "debug", "(", "\"Setting brightness: %s\"", ",", "brightness", ")", "self", ".", "_bulb", ".", "set_brightness", "(", "...
[ 573, 4 ]
[ 579, 13 ]
python
bg
['nl', 'bg', 'en']
False
YeelightGenericLight.set_rgb
(self, rgb, duration)
Set bulb's color.
Set bulb's color.
def set_rgb(self, rgb, duration) -> None: """Set bulb's color.""" if rgb and self.supported_features & SUPPORT_COLOR: _LOGGER.debug("Setting RGB: %s", rgb) self._bulb.set_rgb( rgb[0], rgb[1], rgb[2], duration=duration, light_type=self.light_type )
[ "def", "set_rgb", "(", "self", ",", "rgb", ",", "duration", ")", "->", "None", ":", "if", "rgb", "and", "self", ".", "supported_features", "&", "SUPPORT_COLOR", ":", "_LOGGER", ".", "debug", "(", "\"Setting RGB: %s\"", ",", "rgb", ")", "self", ".", "_bul...
[ 582, 4 ]
[ 588, 13 ]
python
en
['en', 'fr', 'en']
True
YeelightGenericLight.set_colortemp
(self, colortemp, duration)
Set bulb's color temperature.
Set bulb's color temperature.
def set_colortemp(self, colortemp, duration) -> None: """Set bulb's color temperature.""" if colortemp and self.supported_features & SUPPORT_COLOR_TEMP: temp_in_k = mired_to_kelvin(colortemp) _LOGGER.debug("Setting color temp: %s K", temp_in_k) self._bulb.set_color_t...
[ "def", "set_colortemp", "(", "self", ",", "colortemp", ",", "duration", ")", "->", "None", ":", "if", "colortemp", "and", "self", ".", "supported_features", "&", "SUPPORT_COLOR_TEMP", ":", "temp_in_k", "=", "mired_to_kelvin", "(", "colortemp", ")", "_LOGGER", ...
[ 591, 4 ]
[ 599, 13 ]
python
en
['en', 'ca', 'en']
True
YeelightGenericLight.set_default
(self)
Set current options as default.
Set current options as default.
def set_default(self) -> None: """Set current options as default.""" self._bulb.set_default()
[ "def", "set_default", "(", "self", ")", "->", "None", ":", "self", ".", "_bulb", ".", "set_default", "(", ")" ]
[ 602, 4 ]
[ 604, 32 ]
python
en
['en', 'da', 'en']
True
YeelightGenericLight.set_flash
(self, flash)
Activate flash.
Activate flash.
def set_flash(self, flash) -> None: """Activate flash.""" if flash: if int(self._bulb.last_properties["color_mode"]) != 1: _LOGGER.error("Flash supported currently only in RGB mode") return transition = int(self.config[CONF_TRANSITION]) ...
[ "def", "set_flash", "(", "self", ",", "flash", ")", "->", "None", ":", "if", "flash", ":", "if", "int", "(", "self", ".", "_bulb", ".", "last_properties", "[", "\"color_mode\"", "]", ")", "!=", "1", ":", "_LOGGER", ".", "error", "(", "\"Flash supported...
[ 607, 4 ]
[ 639, 60 ]
python
en
['en', 'la', 'en']
False
YeelightGenericLight.set_effect
(self, effect)
Activate effect.
Activate effect.
def set_effect(self, effect) -> None: """Activate effect.""" if not effect: return if effect == EFFECT_STOP: self._bulb.stop_flow(light_type=self.light_type) return if effect in self.custom_effects_names: flow = Flow(**self.custom_effects...
[ "def", "set_effect", "(", "self", ",", "effect", ")", "->", "None", ":", "if", "not", "effect", ":", "return", "if", "effect", "==", "EFFECT_STOP", ":", "self", ".", "_bulb", ".", "stop_flow", "(", "light_type", "=", "self", ".", "light_type", ")", "re...
[ 642, 4 ]
[ 670, 57 ]
python
en
['es', 'en', 'en']
False
YeelightGenericLight.turn_on
(self, **kwargs)
Turn the bulb on.
Turn the bulb on.
def turn_on(self, **kwargs) -> None: """Turn the bulb on.""" brightness = kwargs.get(ATTR_BRIGHTNESS) colortemp = kwargs.get(ATTR_COLOR_TEMP) hs_color = kwargs.get(ATTR_HS_COLOR) rgb = color_util.color_hs_to_RGB(*hs_color) if hs_color else None flash = kwargs.get(ATTR_FLA...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "brightness", "=", "kwargs", ".", "get", "(", "ATTR_BRIGHTNESS", ")", "colortemp", "=", "kwargs", ".", "get", "(", "ATTR_COLOR_TEMP", ")", "hs_color", "=", "kwargs", ".", "...
[ 672, 4 ]
[ 717, 28 ]
python
en
['en', 'ga', 'en']
True
YeelightGenericLight.set_mode
(self, mode: str)
Set a power mode.
Set a power mode.
def set_mode(self, mode: str): """Set a power mode.""" try: self._bulb.set_power_mode(PowerMode[mode.upper()]) self.device.update() except BulbException as ex: _LOGGER.error("Unable to set the power mode: %s", ex)
[ "def", "set_mode", "(", "self", ",", "mode", ":", "str", ")", ":", "try", ":", "self", ".", "_bulb", ".", "set_power_mode", "(", "PowerMode", "[", "mode", ".", "upper", "(", ")", "]", ")", "self", ".", "device", ".", "update", "(", ")", "except", ...
[ 728, 4 ]
[ 734, 65 ]
python
en
['en', 'lb', 'en']
True
YeelightGenericLight.start_flow
(self, transitions, count=0, action=ACTION_RECOVER)
Start flow.
Start flow.
def start_flow(self, transitions, count=0, action=ACTION_RECOVER): """Start flow.""" try: flow = Flow( count=count, action=Flow.actions[action], transitions=transitions ) self._bulb.start_flow(flow, light_type=self.light_type) self.device....
[ "def", "start_flow", "(", "self", ",", "transitions", ",", "count", "=", "0", ",", "action", "=", "ACTION_RECOVER", ")", ":", "try", ":", "flow", "=", "Flow", "(", "count", "=", "count", ",", "action", "=", "Flow", ".", "actions", "[", "action", "]",...
[ 736, 4 ]
[ 746, 57 ]
python
en
['en', 'de', 'en']
False
YeelightGenericLight.set_scene
(self, scene_class, *args)
Set the light directly to the specified state. If the light is off, it will first be turned on.
Set the light directly to the specified state.
def set_scene(self, scene_class, *args): """ Set the light directly to the specified state. If the light is off, it will first be turned on. """ try: self._bulb.set_scene(scene_class, *args) self.device.update() except BulbException as ex: ...
[ "def", "set_scene", "(", "self", ",", "scene_class", ",", "*", "args", ")", ":", "try", ":", "self", ".", "_bulb", ".", "set_scene", "(", "scene_class", ",", "*", "args", ")", "self", ".", "device", ".", "update", "(", ")", "except", "BulbException", ...
[ 748, 4 ]
[ 758, 56 ]
python
en
['en', 'error', 'th']
False
YeelightColorLightSupport.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self) -> int: """Flag supported features.""" return SUPPORT_YEELIGHT_RGB
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_YEELIGHT_RGB" ]
[ 765, 4 ]
[ 767, 35 ]
python
en
['da', 'en', 'en']
True
YeelightWhiteTempLightSupport.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self) -> int: """Flag supported features.""" return SUPPORT_YEELIGHT_WHITE_TEMP
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_YEELIGHT_WHITE_TEMP" ]
[ 778, 4 ]
[ 780, 42 ]
python
en
['da', 'en', 'en']
True
YeelightColorLightWithNightlightSwitch.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self) -> bool: """Return true if device is on.""" return super().is_on and not self.device.is_nightlight_enabled
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "super", "(", ")", ".", "is_on", "and", "not", "self", ".", "device", ".", "is_nightlight_enabled" ]
[ 814, 4 ]
[ 816, 70 ]
python
en
['en', 'fy', 'en']
True
YeelightWithNightLight.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self) -> bool: """Return true if device is on.""" return super().is_on and not self.device.is_nightlight_enabled
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "super", "(", ")", ".", "is_on", "and", "not", "self", ".", "device", ".", "is_nightlight_enabled" ]
[ 838, 4 ]
[ 840, 70 ]
python
en
['en', 'fy', 'en']
True
YeelightNightLightMode.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" unique = super().unique_id return f"{unique}-nightlight"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "unique", "=", "super", "(", ")", ".", "unique_id", "return", "f\"{unique}-nightlight\"" ]
[ 847, 4 ]
[ 850, 37 ]
python
ca
['fr', 'ca', 'en']
False
YeelightNightLightMode.name
(self)
Return the name of the device if any.
Return the name of the device if any.
def name(self) -> str: """Return the name of the device if any.""" return f"{self.device.name} nightlight"
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "f\"{self.device.name} nightlight\"" ]
[ 853, 4 ]
[ 855, 47 ]
python
en
['en', 'en', 'en']
True
YeelightNightLightMode.icon
(self)
Return the icon to use in the frontend, if any.
Return the icon to use in the frontend, if any.
def icon(self): """Return the icon to use in the frontend, if any.""" return "mdi:weather-night"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:weather-night\"" ]
[ 858, 4 ]
[ 860, 34 ]
python
en
['en', 'en', 'en']
True
YeelightNightLightMode.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self) -> bool: """Return true if device is on.""" return super().is_on and self.device.is_nightlight_enabled
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "super", "(", ")", ".", "is_on", "and", "self", ".", "device", ".", "is_nightlight_enabled" ]
[ 863, 4 ]
[ 865, 66 ]
python
en
['en', 'fy', 'en']
True
YeelightNightLightModeWithWithoutBrightnessControl.supported_features
(self)
Flag no supported features.
Flag no supported features.
def supported_features(self): """Flag no supported features.""" return 0
[ "def", "supported_features", "(", "self", ")", ":", "return", "0" ]
[ 895, 4 ]
[ 897, 16 ]
python
en
['en', 'en', 'en']
True
YeelightAmbientLight.__init__
(self, *args, **kwargs)
Initialize the Yeelight Ambient light.
Initialize the Yeelight Ambient light.
def __init__(self, *args, **kwargs): """Initialize the Yeelight Ambient light.""" super().__init__(*args, **kwargs) self._min_mireds = kelvin_to_mired(6500) self._max_mireds = kelvin_to_mired(1700) self._light_type = LightType.Ambient
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init__", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "_min_mireds", "=", "kelvin_to_mired", "(", "6500", ")", "self", ...
[ 927, 4 ]
[ 933, 44 ]
python
en
['en', 'en', 'en']
True
YeelightAmbientLight.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" unique = super().unique_id return f"{unique}-ambilight"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "unique", "=", "super", "(", ")", ".", "unique_id", "return", "f\"{unique}-ambilight\"" ]
[ 936, 4 ]
[ 939, 36 ]
python
ca
['fr', 'ca', 'en']
False
YeelightAmbientLight.name
(self)
Return the name of the device if any.
Return the name of the device if any.
def name(self) -> str: """Return the name of the device if any.""" return f"{self.device.name} ambilight"
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "f\"{self.device.name} ambilight\"" ]
[ 942, 4 ]
[ 944, 46 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Lutron Caseta fan platform. Adds fan controllers from the Caseta bridge associated with the config_entry as fan entities.
Set up the Lutron Caseta fan platform.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Lutron Caseta fan platform. Adds fan controllers from the Caseta bridge associated with the config_entry as fan entities. """ entities = [] bridge = hass.data[CASETA_DOMAIN][config_entry.entry_id] fan_device...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "entities", "=", "[", "]", "bridge", "=", "hass", ".", "data", "[", "CASETA_DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "fan_devices", "=...
[ 38, 0 ]
[ 53, 38 ]
python
en
['en', 'fr', 'en']
True
LutronCasetaFan.speed
(self)
Return the current speed.
Return the current speed.
def speed(self) -> str: """Return the current speed.""" return VALUE_TO_SPEED[self._device["fan_speed"]]
[ "def", "speed", "(", "self", ")", "->", "str", ":", "return", "VALUE_TO_SPEED", "[", "self", ".", "_device", "[", "\"fan_speed\"", "]", "]" ]
[ 60, 4 ]
[ 62, 56 ]
python
en
['en', 'en', 'en']
True
LutronCasetaFan.speed_list
(self)
Get the list of available speeds.
Get the list of available speeds.
def speed_list(self) -> list: """Get the list of available speeds.""" return FAN_SPEEDS
[ "def", "speed_list", "(", "self", ")", "->", "list", ":", "return", "FAN_SPEEDS" ]
[ 65, 4 ]
[ 67, 25 ]
python
en
['en', 'en', 'en']
True