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
TradfriCover._refresh
(self, device)
Refresh the cover data.
Refresh the cover data.
def _refresh(self, device): """Refresh the cover data.""" super()._refresh(device) self._device = device # Caching of BlindControl and cover object self._device_control = device.blind_control self._device_data = device.blind_control.blinds[0]
[ "def", "_refresh", "(", "self", ",", "device", ")", ":", "super", "(", ")", ".", "_refresh", "(", "device", ")", "self", ".", "_device", "=", "device", "# Caching of BlindControl and cover object", "self", ".", "_device_control", "=", "device", ".", "blind_con...
[ 64, 4 ]
[ 71, 58 ]
python
en
['en', 'en', 'en']
True
coerce_ip
(value)
Validate that provided value is a valid IP address.
Validate that provided value is a valid IP address.
def coerce_ip(value): """Validate that provided value is a valid IP address.""" if not value: raise vol.Invalid("Must define an IP address") try: ipaddress.IPv4Network(value) except ValueError as err: raise vol.Invalid("Not a valid IP address") from err return value
[ "def", "coerce_ip", "(", "value", ")", ":", "if", "not", "value", ":", "raise", "vol", ".", "Invalid", "(", "\"Must define an IP address\"", ")", "try", ":", "ipaddress", ".", "IPv4Network", "(", "value", ")", "except", "ValueError", "as", "err", ":", "rai...
[ 18, 0 ]
[ 26, 16 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the Hisense AEH-W4A1 integration.
Set up the Hisense AEH-W4A1 integration.
async def async_setup(hass, config): """Set up the Hisense AEH-W4A1 integration.""" conf = config.get(DOMAIN) hass.data[DOMAIN] = {} if conf is not None: devices = conf[CONF_IP_ADDRESS][:] for device in devices: try: await AehW4a1(device).check() ...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", ".", "get", "(", "DOMAIN", ")", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "if", "conf", "is", "not", "None", ":", "devices", "=", "conf", "[...
[ 45, 0 ]
[ 67, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry)
Set up a config entry for Hisense AEH-W4A1.
Set up a config entry for Hisense AEH-W4A1.
async def async_setup_entry(hass, entry): """Set up a config entry for Hisense AEH-W4A1.""" hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, CLIMATE_DOMAIN) ) return True
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "async_forward_entry_setup", "(", "entry", ",", "CLIMATE_DOMAIN", ")", ")", "return", "True" ]
[ 70, 0 ]
[ 76, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, entry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass, entry): """Unload a config entry.""" return await hass.config_entries.async_forward_entry_unload(entry, CLIMATE_DOMAIN)
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "return", "await", "hass", ".", "config_entries", ".", "async_forward_entry_unload", "(", "entry", ",", "CLIMATE_DOMAIN", ")" ]
[ 79, 0 ]
[ 81, 86 ]
python
en
['en', 'es', 'en']
True
test_humanify_homekit_changed_event
(hass, hk_driver)
Test humanifying HomeKit changed event.
Test humanifying HomeKit changed event.
async def test_humanify_homekit_changed_event(hass, hk_driver): """Test humanifying HomeKit changed event.""" hass.config.components.add("recorder") with patch("homeassistant.components.homekit.HomeKit"): assert await async_setup_component(hass, "homekit", {"homekit": {}}) assert await async_set...
[ "async", "def", "test_humanify_homekit_changed_event", "(", "hass", ",", "hk_driver", ")", ":", "hass", ".", "config", ".", "components", ".", "add", "(", "\"recorder\"", ")", "with", "patch", "(", "\"homeassistant.components.homekit.HomeKit\"", ")", ":", "assert", ...
[ 15, 0 ]
[ 58, 48 ]
python
en
['en', 'en', 'en']
True
get_engine
(hass, config, discovery_info=None)
Set up Baidu TTS component.
Set up Baidu TTS component.
def get_engine(hass, config, discovery_info=None): """Set up Baidu TTS component.""" return BaiduTTSProvider(hass, config)
[ "def", "get_engine", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "return", "BaiduTTSProvider", "(", "hass", ",", "config", ")" ]
[ 53, 0 ]
[ 55, 41 ]
python
en
['en', 'fr', 'en']
True
BaiduTTSProvider.__init__
(self, hass, conf)
Init Baidu TTS service.
Init Baidu TTS service.
def __init__(self, hass, conf): """Init Baidu TTS service.""" self.hass = hass self._lang = conf[CONF_LANG] self._codec = "mp3" self.name = "BaiduTTS" self._app_data = { "appid": conf[CONF_APP_ID], "apikey": conf[CONF_API_KEY], "secret...
[ "def", "__init__", "(", "self", ",", "hass", ",", "conf", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "_lang", "=", "conf", "[", "CONF_LANG", "]", "self", ".", "_codec", "=", "\"mp3\"", "self", ".", "name", "=", "\"BaiduTTS\"", "self", ...
[ 61, 4 ]
[ 79, 9 ]
python
en
['fr', 'mt', 'en']
False
BaiduTTSProvider.default_language
(self)
Return the default language.
Return the default language.
def default_language(self): """Return the default language.""" return self._lang
[ "def", "default_language", "(", "self", ")", ":", "return", "self", ".", "_lang" ]
[ 82, 4 ]
[ 84, 25 ]
python
en
['en', 'et', 'en']
True
BaiduTTSProvider.supported_languages
(self)
Return a list of supported languages.
Return a list of supported languages.
def supported_languages(self): """Return a list of supported languages.""" return SUPPORTED_LANGUAGES
[ "def", "supported_languages", "(", "self", ")", ":", "return", "SUPPORTED_LANGUAGES" ]
[ 87, 4 ]
[ 89, 34 ]
python
en
['en', 'en', 'en']
True
BaiduTTSProvider.default_options
(self)
Return a dict including default options.
Return a dict including default options.
def default_options(self): """Return a dict including default options.""" return { CONF_PERSON: self._speech_conf_data[_OPTIONS[CONF_PERSON]], CONF_PITCH: self._speech_conf_data[_OPTIONS[CONF_PITCH]], CONF_SPEED: self._speech_conf_data[_OPTIONS[CONF_SPEED]], ...
[ "def", "default_options", "(", "self", ")", ":", "return", "{", "CONF_PERSON", ":", "self", ".", "_speech_conf_data", "[", "_OPTIONS", "[", "CONF_PERSON", "]", "]", ",", "CONF_PITCH", ":", "self", ".", "_speech_conf_data", "[", "_OPTIONS", "[", "CONF_PITCH", ...
[ 92, 4 ]
[ 99, 9 ]
python
ca
['id', 'ca', 'en']
False
BaiduTTSProvider.supported_options
(self)
Return a list of supported options.
Return a list of supported options.
def supported_options(self): """Return a list of supported options.""" return SUPPORTED_OPTIONS
[ "def", "supported_options", "(", "self", ")", ":", "return", "SUPPORTED_OPTIONS" ]
[ 102, 4 ]
[ 104, 32 ]
python
en
['en', 'en', 'en']
True
BaiduTTSProvider.get_tts_audio
(self, message, language, options=None)
Load TTS from BaiduTTS.
Load TTS from BaiduTTS.
def get_tts_audio(self, message, language, options=None): """Load TTS from BaiduTTS.""" aip_speech = AipSpeech( self._app_data["appid"], self._app_data["apikey"], self._app_data["secretkey"], ) if options is None: result = aip_speech.synt...
[ "def", "get_tts_audio", "(", "self", ",", "message", ",", "language", ",", "options", "=", "None", ")", ":", "aip_speech", "=", "AipSpeech", "(", "self", ".", "_app_data", "[", "\"appid\"", "]", ",", "self", ".", "_app_data", "[", "\"apikey\"", "]", ",",...
[ 106, 4 ]
[ 133, 34 ]
python
en
['en', 'en', 'en']
True
mock_client
()
Define a fixture for a client creation coroutine.
Define a fixture for a client creation coroutine.
def mock_client(): """Define a fixture for a client creation coroutine.""" return AsyncMock(return_value=None)
[ "def", "mock_client", "(", ")", ":", "return", "AsyncMock", "(", "return_value", "=", "None", ")" ]
[ 14, 0 ]
[ 16, 39 ]
python
en
['en', 'fr', 'en']
True
mock_aionotion
(mock_client)
Mock the aionotion library.
Mock the aionotion library.
def mock_aionotion(mock_client): """Mock the aionotion library.""" with patch("homeassistant.components.notion.config_flow.async_get_client") as mock_: mock_.side_effect = mock_client yield mock_
[ "def", "mock_aionotion", "(", "mock_client", ")", ":", "with", "patch", "(", "\"homeassistant.components.notion.config_flow.async_get_client\"", ")", "as", "mock_", ":", "mock_", ".", "side_effect", "=", "mock_client", "yield", "mock_" ]
[ 20, 0 ]
[ 24, 19 ]
python
en
['en', 'en', 'en']
True
test_duplicate_error
(hass)
Test that errors are shown when duplicates are added.
Test that errors are shown when duplicates are added.
async def test_duplicate_error(hass): """Test that errors are shown when duplicates are added.""" conf = {CONF_USERNAME: "user@host.com", CONF_PASSWORD: "password123"} MockConfigEntry(domain=DOMAIN, unique_id="user@host.com", data=conf).add_to_hass( hass ) result = await hass.config_entrie...
[ "async", "def", "test_duplicate_error", "(", "hass", ")", ":", "conf", "=", "{", "CONF_USERNAME", ":", "\"user@host.com\"", ",", "CONF_PASSWORD", ":", "\"password123\"", "}", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "unique_id", "=", "\"user@host.com\...
[ 27, 0 ]
[ 40, 51 ]
python
en
['en', 'en', 'en']
True
test_invalid_credentials
(hass, mock_aionotion)
Test that an invalid API/App Key throws an error.
Test that an invalid API/App Key throws an error.
async def test_invalid_credentials(hass, mock_aionotion): """Test that an invalid API/App Key throws an error.""" conf = {CONF_USERNAME: "user@host.com", CONF_PASSWORD: "password123"} flow = config_flow.NotionFlowHandler() flow.hass = hass flow.context = {"source": SOURCE_USER} result = await ...
[ "async", "def", "test_invalid_credentials", "(", "hass", ",", "mock_aionotion", ")", ":", "conf", "=", "{", "CONF_USERNAME", ":", "\"user@host.com\"", ",", "CONF_PASSWORD", ":", "\"password123\"", "}", "flow", "=", "config_flow", ".", "NotionFlowHandler", "(", ")"...
[ 46, 0 ]
[ 55, 55 ]
python
en
['en', 'gd', 'en']
True
test_show_form
(hass)
Test that the form is served with no input.
Test that the form is served with no input.
async def test_show_form(hass): """Test that the form is served with no input.""" flow = config_flow.NotionFlowHandler() flow.hass = hass flow.context = {"source": SOURCE_USER} result = await flow.async_step_user(user_input=None) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM as...
[ "async", "def", "test_show_form", "(", "hass", ")", ":", "flow", "=", "config_flow", ".", "NotionFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "flow", ".", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", "result", "=", "await", "f...
[ 58, 0 ]
[ 67, 38 ]
python
en
['en', 'en', 'en']
True
test_step_user
(hass, mock_aionotion)
Test that the user step works.
Test that the user step works.
async def test_step_user(hass, mock_aionotion): """Test that the user step works.""" conf = {CONF_USERNAME: "user@host.com", CONF_PASSWORD: "password123"} flow = config_flow.NotionFlowHandler() flow.hass = hass flow.context = {"source": SOURCE_USER} result = await flow.async_step_user(user_inp...
[ "async", "def", "test_step_user", "(", "hass", ",", "mock_aionotion", ")", ":", "conf", "=", "{", "CONF_USERNAME", ":", "\"user@host.com\"", ",", "CONF_PASSWORD", ":", "\"password123\"", "}", "flow", "=", "config_flow", ".", "NotionFlowHandler", "(", ")", "flow"...
[ 70, 0 ]
[ 84, 5 ]
python
en
['en', 'en', 'en']
True
test_turbojpeg_singleton
()
Verify the instance always gives back the same.
Verify the instance always gives back the same.
def test_turbojpeg_singleton(): """Verify the instance always gives back the same.""" assert TurboJPEGSingleton.instance() == TurboJPEGSingleton.instance()
[ "def", "test_turbojpeg_singleton", "(", ")", ":", "assert", "TurboJPEGSingleton", ".", "instance", "(", ")", "==", "TurboJPEGSingleton", ".", "instance", "(", ")" ]
[ 14, 0 ]
[ 16, 73 ]
python
en
['en', 'en', 'en']
True
test_scale_jpeg_camera_image
()
Test we can scale a jpeg image.
Test we can scale a jpeg image.
def test_scale_jpeg_camera_image(): """Test we can scale a jpeg image.""" camera_image = Image("image/jpeg", EMPTY_16_12_JPEG) turbo_jpeg = mock_turbo_jpeg(first_width=16, first_height=12) with patch("turbojpeg.TurboJPEG", return_value=False): TurboJPEGSingleton() assert scale_jpeg_cam...
[ "def", "test_scale_jpeg_camera_image", "(", ")", ":", "camera_image", "=", "Image", "(", "\"image/jpeg\"", ",", "EMPTY_16_12_JPEG", ")", "turbo_jpeg", "=", "mock_turbo_jpeg", "(", "first_width", "=", "16", ",", "first_height", "=", "12", ")", "with", "patch", "(...
[ 19, 0 ]
[ 41, 39 ]
python
en
['en', 'en', 'en']
True
test_turbojpeg_load_failure
()
Handle libjpegturbo not being installed.
Handle libjpegturbo not being installed.
def test_turbojpeg_load_failure(): """Handle libjpegturbo not being installed.""" with patch("turbojpeg.TurboJPEG", side_effect=Exception): TurboJPEGSingleton() assert TurboJPEGSingleton.instance() is False with patch("turbojpeg.TurboJPEG"): TurboJPEGSingleton() assert Turb...
[ "def", "test_turbojpeg_load_failure", "(", ")", ":", "with", "patch", "(", "\"turbojpeg.TurboJPEG\"", ",", "side_effect", "=", "Exception", ")", ":", "TurboJPEGSingleton", "(", ")", "assert", "TurboJPEGSingleton", ".", "instance", "(", ")", "is", "False", "with", ...
[ 44, 0 ]
[ 53, 44 ]
python
en
['lv', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Zigbee Home Automation sensor from config entry.
Set up the Zigbee Home Automation sensor from config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Zigbee Home Automation sensor from config entry.""" entities_to_create = hass.data[DATA_ZHA][DOMAIN] unsub = async_dispatcher_connect( hass, SIGNAL_ADD_ENTITIES, functools.partial( discover...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "entities_to_create", "=", "hass", ".", "data", "[", "DATA_ZHA", "]", "[", "DOMAIN", "]", "unsub", "=", "async_dispatcher_connect", "(", "hass", ",", "S...
[ 147, 0 ]
[ 157, 59 ]
python
en
['en', 'en', 'en']
True
ensure_unique_hosts
(value)
Validate that all configs have a unique host.
Validate that all configs have a unique host.
def ensure_unique_hosts(value): """Validate that all configs have a unique host.""" vol.Schema(vol.Unique("duplicate host entries found"))( [socket.gethostbyname(entry[CONF_HOST]) for entry in value] ) return value
[ "def", "ensure_unique_hosts", "(", "value", ")", ":", "vol", ".", "Schema", "(", "vol", ".", "Unique", "(", "\"duplicate host entries found\"", ")", ")", "(", "[", "socket", ".", "gethostbyname", "(", "entry", "[", "CONF_HOST", "]", ")", "for", "entry", "i...
[ 19, 0 ]
[ 24, 16 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the AVM Fritz!Box integration.
Set up the AVM Fritz!Box integration.
async def async_setup(hass, config): """Set up the AVM Fritz!Box integration.""" if DOMAIN in config: for entry_config in config[DOMAIN][CONF_DEVICES]: hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, context={"source": "import"}, data=...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "if", "DOMAIN", "in", "config", ":", "for", "entry_config", "in", "config", "[", "DOMAIN", "]", "[", "CONF_DEVICES", "]", ":", "hass", ".", "async_create_task", "(", "hass", ".", "confi...
[ 58, 0 ]
[ 68, 15 ]
python
en
['en', 'lb', 'en']
True
async_setup_entry
(hass, entry)
Set up the AVM Fritz!Box platforms.
Set up the AVM Fritz!Box platforms.
async def async_setup_entry(hass, entry): """Set up the AVM Fritz!Box platforms.""" fritz = Fritzhome( host=entry.data[CONF_HOST], user=entry.data[CONF_USERNAME], password=entry.data[CONF_PASSWORD], ) await hass.async_add_executor_job(fritz.login) hass.data.setdefault(DOMAIN...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "fritz", "=", "Fritzhome", "(", "host", "=", "entry", ".", "data", "[", "CONF_HOST", "]", ",", "user", "=", "entry", ".", "data", "[", "CONF_USERNAME", "]", ",", "password", "=",...
[ 71, 0 ]
[ 94, 15 ]
python
en
['en', 'lb', 'en']
True
async_unload_entry
(hass, entry)
Unloading the AVM Fritz!Box platforms.
Unloading the AVM Fritz!Box platforms.
async def async_unload_entry(hass, entry): """Unloading the AVM Fritz!Box platforms.""" fritz = hass.data[DOMAIN][CONF_CONNECTIONS][entry.entry_id] await hass.async_add_executor_job(fritz.logout) unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_for...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "fritz", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "CONF_CONNECTIONS", "]", "[", "entry", ".", "entry_id", "]", "await", "hass", ".", "async_add_executor_job", "(", "fritz"...
[ 97, 0 ]
[ 113, 20 ]
python
en
['en', 'no', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Sense Hat Light platform.
Set up the Sense Hat Light platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Sense Hat Light platform.""" sensehat = SenseHat() name = config.get(CONF_NAME) add_entities([SenseHatLight(sensehat, name)])
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "sensehat", "=", "SenseHat", "(", ")", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "add_entities", "(", "[", "SenseHatLigh...
[ 25, 0 ]
[ 32, 49 ]
python
en
['en', 'da', 'en']
True
SenseHatLight.__init__
(self, sensehat, name)
Initialize an Sense Hat Light. Full brightness and white color.
Initialize an Sense Hat Light.
def __init__(self, sensehat, name): """Initialize an Sense Hat Light. Full brightness and white color. """ self._sensehat = sensehat self._name = name self._is_on = False self._brightness = 255 self._hs_color = [0, 0]
[ "def", "__init__", "(", "self", ",", "sensehat", ",", "name", ")", ":", "self", ".", "_sensehat", "=", "sensehat", "self", ".", "_name", "=", "name", "self", ".", "_is_on", "=", "False", "self", ".", "_brightness", "=", "255", "self", ".", "_hs_color",...
[ 38, 4 ]
[ 47, 31 ]
python
en
['en', 'lb', 'en']
True
SenseHatLight.name
(self)
Return the display name of this light.
Return the display name of this light.
def name(self): """Return the display name of this light.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 50, 4 ]
[ 52, 25 ]
python
en
['en', 'en', 'en']
True
SenseHatLight.brightness
(self)
Read back the brightness of the light.
Read back the brightness of the light.
def brightness(self): """Read back the brightness of the light.""" return self._brightness
[ "def", "brightness", "(", "self", ")", ":", "return", "self", ".", "_brightness" ]
[ 55, 4 ]
[ 57, 31 ]
python
en
['en', 'en', 'en']
True
SenseHatLight.hs_color
(self)
Read back the color of the light.
Read back the color of the light.
def hs_color(self): """Read back the color of the light.""" return self._hs_color
[ "def", "hs_color", "(", "self", ")", ":", "return", "self", ".", "_hs_color" ]
[ 60, 4 ]
[ 62, 29 ]
python
en
['en', 'en', 'en']
True
SenseHatLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_SENSEHAT
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_SENSEHAT" ]
[ 65, 4 ]
[ 67, 31 ]
python
en
['da', 'en', 'en']
True
SenseHatLight.is_on
(self)
Return true if light is on.
Return true if light is on.
def is_on(self): """Return true if light is on.""" return self._is_on
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_is_on" ]
[ 70, 4 ]
[ 72, 26 ]
python
en
['en', 'et', 'en']
True
SenseHatLight.should_poll
(self)
Return if we should poll this device.
Return if we should poll this device.
def should_poll(self): """Return if we should poll this device.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 75, 4 ]
[ 77, 20 ]
python
en
['en', 'en', 'en']
True
SenseHatLight.assumed_state
(self)
Return True if unable to access real state of the entity.
Return True if unable to access real state of the entity.
def assumed_state(self) -> bool: """Return True if unable to access real state of the entity.""" return True
[ "def", "assumed_state", "(", "self", ")", "->", "bool", ":", "return", "True" ]
[ 80, 4 ]
[ 82, 19 ]
python
en
['en', 'en', 'en']
True
SenseHatLight.turn_on
(self, **kwargs)
Instruct the light to turn on and set correct brightness & color.
Instruct the light to turn on and set correct brightness & color.
def turn_on(self, **kwargs): """Instruct the light to turn on and set correct brightness & color.""" if ATTR_BRIGHTNESS in kwargs: self._brightness = kwargs[ATTR_BRIGHTNESS] if ATTR_HS_COLOR in kwargs: self._hs_color = kwargs[ATTR_HS_COLOR] rgb = color_util.colo...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_BRIGHTNESS", "in", "kwargs", ":", "self", ".", "_brightness", "=", "kwargs", "[", "ATTR_BRIGHTNESS", "]", "if", "ATTR_HS_COLOR", "in", "kwargs", ":", "self", ".", "_hs_color", ...
[ 84, 4 ]
[ 98, 39 ]
python
en
['en', 'en', 'en']
True
SenseHatLight.turn_off
(self, **kwargs)
Instruct the light to turn off.
Instruct the light to turn off.
def turn_off(self, **kwargs): """Instruct the light to turn off.""" self._sensehat.clear() self._is_on = False self.schedule_update_ha_state()
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_sensehat", ".", "clear", "(", ")", "self", ".", "_is_on", "=", "False", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 100, 4 ]
[ 104, 39 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Iterate through and add all Melissa devices.
Iterate through and add all Melissa devices.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Iterate through and add all Melissa devices.""" api = hass.data[DATA_MELISSA] devices = (await api.async_fetch_devices()).values() all_devices = [] for device in devices: if device["type"] == "melissa...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "api", "=", "hass", ".", "data", "[", "DATA_MELISSA", "]", "devices", "=", "(", "await", "api", ".", "async_fetch_dev...
[ 37, 0 ]
[ 48, 35 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.__init__
(self, api, serial_number, init_data)
Initialize the climate device.
Initialize the climate device.
def __init__(self, api, serial_number, init_data): """Initialize the climate device.""" self._name = init_data["name"] self._api = api self._serial_number = serial_number self._data = init_data["controller_log"] self._state = None self._cur_settings = None
[ "def", "__init__", "(", "self", ",", "api", ",", "serial_number", ",", "init_data", ")", ":", "self", ".", "_name", "=", "init_data", "[", "\"name\"", "]", "self", ".", "_api", "=", "api", "self", ".", "_serial_number", "=", "serial_number", "self", ".",...
[ 54, 4 ]
[ 61, 33 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.name
(self)
Return the name of the thermostat, if any.
Return the name of the thermostat, if any.
def name(self): """Return the name of the thermostat, if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 64, 4 ]
[ 66, 25 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.fan_mode
(self)
Return the current fan mode.
Return the current fan mode.
def fan_mode(self): """Return the current fan mode.""" if self._cur_settings is not None: return self.melissa_fan_to_hass(self._cur_settings[self._api.FAN])
[ "def", "fan_mode", "(", "self", ")", ":", "if", "self", ".", "_cur_settings", "is", "not", "None", ":", "return", "self", ".", "melissa_fan_to_hass", "(", "self", ".", "_cur_settings", "[", "self", ".", "_api", ".", "FAN", "]", ")" ]
[ 69, 4 ]
[ 72, 78 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" if self._data: return self._data[self._api.TEMP]
[ "def", "current_temperature", "(", "self", ")", ":", "if", "self", ".", "_data", ":", "return", "self", ".", "_data", "[", "self", ".", "_api", ".", "TEMP", "]" ]
[ 75, 4 ]
[ 78, 45 ]
python
en
['en', 'la', 'en']
True
MelissaClimate.current_humidity
(self)
Return the current humidity value.
Return the current humidity value.
def current_humidity(self): """Return the current humidity value.""" if self._data: return self._data[self._api.HUMIDITY]
[ "def", "current_humidity", "(", "self", ")", ":", "if", "self", ".", "_data", ":", "return", "self", ".", "_data", "[", "self", ".", "_api", ".", "HUMIDITY", "]" ]
[ 81, 4 ]
[ 84, 49 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.target_temperature_step
(self)
Return the supported step of target temperature.
Return the supported step of target temperature.
def target_temperature_step(self): """Return the supported step of target temperature.""" return PRECISION_WHOLE
[ "def", "target_temperature_step", "(", "self", ")", ":", "return", "PRECISION_WHOLE" ]
[ 87, 4 ]
[ 89, 30 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.hvac_mode
(self)
Return the current operation mode.
Return the current operation mode.
def hvac_mode(self): """Return the current operation mode.""" if self._cur_settings is None: return None is_on = self._cur_settings[self._api.STATE] in ( self._api.STATE_ON, self._api.STATE_IDLE, ) if not is_on: return HVAC_MODE_O...
[ "def", "hvac_mode", "(", "self", ")", ":", "if", "self", ".", "_cur_settings", "is", "None", ":", "return", "None", "is_on", "=", "self", ".", "_cur_settings", "[", "self", ".", "_api", ".", "STATE", "]", "in", "(", "self", ".", "_api", ".", "STATE_O...
[ 92, 4 ]
[ 105, 74 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.hvac_modes
(self)
Return the list of available operation modes.
Return the list of available operation modes.
def hvac_modes(self): """Return the list of available operation modes.""" return OP_MODES
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "OP_MODES" ]
[ 108, 4 ]
[ 110, 23 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.fan_modes
(self)
List of available fan modes.
List of available fan modes.
def fan_modes(self): """List of available fan modes.""" return FAN_MODES
[ "def", "fan_modes", "(", "self", ")", ":", "return", "FAN_MODES" ]
[ 113, 4 ]
[ 115, 24 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.target_temperature
(self)
Return the temperature we try to reach.
Return the temperature we try to reach.
def target_temperature(self): """Return the temperature we try to reach.""" if self._cur_settings is None: return None return self._cur_settings[self._api.TEMP]
[ "def", "target_temperature", "(", "self", ")", ":", "if", "self", ".", "_cur_settings", "is", "None", ":", "return", "None", "return", "self", ".", "_cur_settings", "[", "self", ".", "_api", ".", "TEMP", "]" ]
[ 118, 4 ]
[ 122, 49 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.temperature_unit
(self)
Return the unit of measurement which this thermostat uses.
Return the unit of measurement which this thermostat uses.
def temperature_unit(self): """Return the unit of measurement which this thermostat uses.""" return TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_CELSIUS" ]
[ 125, 4 ]
[ 127, 27 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.min_temp
(self)
Return the minimum supported temperature for the thermostat.
Return the minimum supported temperature for the thermostat.
def min_temp(self): """Return the minimum supported temperature for the thermostat.""" return 16
[ "def", "min_temp", "(", "self", ")", ":", "return", "16" ]
[ 130, 4 ]
[ 132, 17 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.max_temp
(self)
Return the maximum supported temperature for the thermostat.
Return the maximum supported temperature for the thermostat.
def max_temp(self): """Return the maximum supported temperature for the thermostat.""" return 30
[ "def", "max_temp", "(", "self", ")", ":", "return", "30" ]
[ 135, 4 ]
[ 137, 17 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self): """Return the list of supported features.""" return SUPPORT_FLAGS
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_FLAGS" ]
[ 140, 4 ]
[ 142, 28 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.async_set_temperature
(self, **kwargs)
Set new target temperature.
Set new target temperature.
async def async_set_temperature(self, **kwargs): """Set new target temperature.""" temp = kwargs.get(ATTR_TEMPERATURE) await self.async_send({self._api.TEMP: temp})
[ "async", "def", "async_set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "temp", "=", "kwargs", ".", "get", "(", "ATTR_TEMPERATURE", ")", "await", "self", ".", "async_send", "(", "{", "self", ".", "_api", ".", "TEMP", ":", "temp", "}", ...
[ 144, 4 ]
[ 147, 53 ]
python
en
['en', 'ca', 'en']
True
MelissaClimate.async_set_fan_mode
(self, fan_mode)
Set fan mode.
Set fan mode.
async def async_set_fan_mode(self, fan_mode): """Set fan mode.""" melissa_fan_mode = self.hass_fan_to_melissa(fan_mode) await self.async_send({self._api.FAN: melissa_fan_mode})
[ "async", "def", "async_set_fan_mode", "(", "self", ",", "fan_mode", ")", ":", "melissa_fan_mode", "=", "self", ".", "hass_fan_to_melissa", "(", "fan_mode", ")", "await", "self", ".", "async_send", "(", "{", "self", ".", "_api", ".", "FAN", ":", "melissa_fan_...
[ 149, 4 ]
[ 152, 64 ]
python
fy
['sv', 'fy', 'nl']
False
MelissaClimate.async_set_hvac_mode
(self, hvac_mode)
Set operation mode.
Set operation mode.
async def async_set_hvac_mode(self, hvac_mode): """Set operation mode.""" if hvac_mode == HVAC_MODE_OFF: await self.async_send({self._api.STATE: self._api.STATE_OFF}) return mode = self.hass_mode_to_melissa(hvac_mode) await self.async_send( {self._api...
[ "async", "def", "async_set_hvac_mode", "(", "self", ",", "hvac_mode", ")", ":", "if", "hvac_mode", "==", "HVAC_MODE_OFF", ":", "await", "self", ".", "async_send", "(", "{", "self", ".", "_api", ".", "STATE", ":", "self", ".", "_api", ".", "STATE_OFF", "}...
[ 154, 4 ]
[ 163, 9 ]
python
en
['nl', 'ny', 'en']
False
MelissaClimate.async_send
(self, value)
Send action to service.
Send action to service.
async def async_send(self, value): """Send action to service.""" try: old_value = self._cur_settings.copy() self._cur_settings.update(value) except AttributeError: old_value = None if not await self._api.async_send( self._serial_number, "me...
[ "async", "def", "async_send", "(", "self", ",", "value", ")", ":", "try", ":", "old_value", "=", "self", ".", "_cur_settings", ".", "copy", "(", ")", "self", ".", "_cur_settings", ".", "update", "(", "value", ")", "except", "AttributeError", ":", "old_va...
[ 165, 4 ]
[ 175, 42 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.async_update
(self)
Get latest data from Melissa.
Get latest data from Melissa.
async def async_update(self): """Get latest data from Melissa.""" try: self._data = (await self._api.async_status(cached=True))[ self._serial_number ] self._cur_settings = ( await self._api.async_cur_settings(self._serial_number) ...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "self", ".", "_data", "=", "(", "await", "self", ".", "_api", ".", "async_status", "(", "cached", "=", "True", ")", ")", "[", "self", ".", "_serial_number", "]", "self", ".", "_cur_se...
[ 177, 4 ]
[ 187, 73 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.melissa_op_to_hass
(self, mode)
Translate Melissa modes to hass states.
Translate Melissa modes to hass states.
def melissa_op_to_hass(self, mode): """Translate Melissa modes to hass states.""" if mode == self._api.MODE_HEAT: return HVAC_MODE_HEAT if mode == self._api.MODE_COOL: return HVAC_MODE_COOL if mode == self._api.MODE_DRY: return HVAC_MODE_DRY if...
[ "def", "melissa_op_to_hass", "(", "self", ",", "mode", ")", ":", "if", "mode", "==", "self", ".", "_api", ".", "MODE_HEAT", ":", "return", "HVAC_MODE_HEAT", "if", "mode", "==", "self", ".", "_api", ".", "MODE_COOL", ":", "return", "HVAC_MODE_COOL", "if", ...
[ 189, 4 ]
[ 200, 19 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.melissa_fan_to_hass
(self, fan)
Translate Melissa fan modes to hass modes.
Translate Melissa fan modes to hass modes.
def melissa_fan_to_hass(self, fan): """Translate Melissa fan modes to hass modes.""" if fan == self._api.FAN_AUTO: return HVAC_MODE_AUTO if fan == self._api.FAN_LOW: return FAN_LOW if fan == self._api.FAN_MEDIUM: return FAN_MEDIUM if fan == sel...
[ "def", "melissa_fan_to_hass", "(", "self", ",", "fan", ")", ":", "if", "fan", "==", "self", ".", "_api", ".", "FAN_AUTO", ":", "return", "HVAC_MODE_AUTO", "if", "fan", "==", "self", ".", "_api", ".", "FAN_LOW", ":", "return", "FAN_LOW", "if", "fan", "=...
[ 202, 4 ]
[ 213, 19 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.hass_mode_to_melissa
(self, mode)
Translate hass states to melissa modes.
Translate hass states to melissa modes.
def hass_mode_to_melissa(self, mode): """Translate hass states to melissa modes.""" if mode == HVAC_MODE_HEAT: return self._api.MODE_HEAT if mode == HVAC_MODE_COOL: return self._api.MODE_COOL if mode == HVAC_MODE_DRY: return self._api.MODE_DRY ...
[ "def", "hass_mode_to_melissa", "(", "self", ",", "mode", ")", ":", "if", "mode", "==", "HVAC_MODE_HEAT", ":", "return", "self", ".", "_api", ".", "MODE_HEAT", "if", "mode", "==", "HVAC_MODE_COOL", ":", "return", "self", ".", "_api", ".", "MODE_COOL", "if",...
[ 215, 4 ]
[ 225, 68 ]
python
en
['en', 'en', 'en']
True
MelissaClimate.hass_fan_to_melissa
(self, fan)
Translate hass fan modes to melissa modes.
Translate hass fan modes to melissa modes.
def hass_fan_to_melissa(self, fan): """Translate hass fan modes to melissa modes.""" if fan == HVAC_MODE_AUTO: return self._api.FAN_AUTO if fan == FAN_LOW: return self._api.FAN_LOW if fan == FAN_MEDIUM: return self._api.FAN_MEDIUM if fan == FAN...
[ "def", "hass_fan_to_melissa", "(", "self", ",", "fan", ")", ":", "if", "fan", "==", "HVAC_MODE_AUTO", ":", "return", "self", ".", "_api", ".", "FAN_AUTO", "if", "fan", "==", "FAN_LOW", ":", "return", "self", ".", "_api", ".", "FAN_LOW", "if", "fan", "=...
[ 227, 4 ]
[ 237, 71 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the CUPS sensor.
Set up the CUPS sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the CUPS sensor.""" host = config[CONF_HOST] port = config[CONF_PORT] printers = config[CONF_PRINTERS] is_cups = config[CONF_IS_CUPS_SERVER] if is_cups: data = CupsData(host, port, None) data.update()...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "host", "=", "config", "[", "CONF_HOST", "]", "port", "=", "config", "[", "CONF_PORT", "]", "printers", "=", "config", "[", "CONF_PRINTE...
[ 53, 0 ]
[ 95, 27 ]
python
en
['en', 'ca', 'en']
True
CupsSensor.__init__
(self, data, printer)
Initialize the CUPS sensor.
Initialize the CUPS sensor.
def __init__(self, data, printer): """Initialize the CUPS sensor.""" self.data = data self._name = printer self._printer = None self._available = False
[ "def", "__init__", "(", "self", ",", "data", ",", "printer", ")", ":", "self", ".", "data", "=", "data", "self", ".", "_name", "=", "printer", "self", ".", "_printer", "=", "None", "self", ".", "_available", "=", "False" ]
[ 101, 4 ]
[ 106, 31 ]
python
en
['en', 'en', 'en']
True
CupsSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 109, 4 ]
[ 111, 25 ]
python
en
['en', 'mi', 'en']
True
CupsSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" if self._printer is None: return None key = self._printer["printer-state"] return PRINTER_STATES.get(key, key)
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_printer", "is", "None", ":", "return", "None", "key", "=", "self", ".", "_printer", "[", "\"printer-state\"", "]", "return", "PRINTER_STATES", ".", "get", "(", "key", ",", "key", ")" ]
[ 114, 4 ]
[ 120, 43 ]
python
en
['en', 'en', 'en']
True
CupsSensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 123, 4 ]
[ 125, 30 ]
python
en
['en', 'en', 'en']
True
CupsSensor.icon
(self)
Return the icon to use in the frontend, if any.
Return the icon to use in the frontend, if any.
def icon(self): """Return the icon to use in the frontend, if any.""" return ICON_PRINTER
[ "def", "icon", "(", "self", ")", ":", "return", "ICON_PRINTER" ]
[ 128, 4 ]
[ 130, 27 ]
python
en
['en', 'en', 'en']
True
CupsSensor.device_state_attributes
(self)
Return the state attributes of the sensor.
Return the state attributes of the sensor.
def device_state_attributes(self): """Return the state attributes of the sensor.""" if self._printer is None: return None return { ATTR_DEVICE_URI: self._printer["device-uri"], ATTR_PRINTER_INFO: self._printer["printer-info"], ATTR_PRINTER_IS_SHAR...
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "_printer", "is", "None", ":", "return", "None", "return", "{", "ATTR_DEVICE_URI", ":", "self", ".", "_printer", "[", "\"device-uri\"", "]", ",", "ATTR_PRINTER_INFO", ":", "self", "....
[ 133, 4 ]
[ 148, 9 ]
python
en
['en', 'en', 'en']
True
CupsSensor.update
(self)
Get the latest data and updates the states.
Get the latest data and updates the states.
def update(self): """Get the latest data and updates the states.""" self.data.update() self._printer = self.data.printers.get(self._name) self._available = self.data.available
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "update", "(", ")", "self", ".", "_printer", "=", "self", ".", "data", ".", "printers", ".", "get", "(", "self", ".", "_name", ")", "self", ".", "_available", "=", "self", ".", "da...
[ 150, 4 ]
[ 154, 45 ]
python
en
['en', 'en', 'en']
True
IPPSensor.__init__
(self, data, name)
Initialize the sensor.
Initialize the sensor.
def __init__(self, data, name): """Initialize the sensor.""" self.data = data self._name = name self._attributes = None self._available = False
[ "def", "__init__", "(", "self", ",", "data", ",", "name", ")", ":", "self", ".", "data", "=", "data", "self", ".", "_name", "=", "name", "self", ".", "_attributes", "=", "None", "self", ".", "_available", "=", "False" ]
[ 163, 4 ]
[ 168, 31 ]
python
en
['en', 'en', 'en']
True
IPPSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._attributes["printer-make-and-model"]
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_attributes", "[", "\"printer-make-and-model\"", "]" ]
[ 171, 4 ]
[ 173, 57 ]
python
en
['en', 'mi', 'en']
True
IPPSensor.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 ICON_PRINTER
[ "def", "icon", "(", "self", ")", ":", "return", "ICON_PRINTER" ]
[ 176, 4 ]
[ 178, 27 ]
python
en
['en', 'en', 'en']
True
IPPSensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 181, 4 ]
[ 183, 30 ]
python
en
['en', 'en', 'en']
True
IPPSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" if self._attributes is None: return None key = self._attributes["printer-state"] return PRINTER_STATES.get(key, key)
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_attributes", "is", "None", ":", "return", "None", "key", "=", "self", ".", "_attributes", "[", "\"printer-state\"", "]", "return", "PRINTER_STATES", ".", "get", "(", "key", ",", "key", ")" ]
[ 186, 4 ]
[ 192, 43 ]
python
en
['en', 'en', 'en']
True
IPPSensor.device_state_attributes
(self)
Return the state attributes of the sensor.
Return the state attributes of the sensor.
def device_state_attributes(self): """Return the state attributes of the sensor.""" if self._attributes is None: return None state_attributes = {} if "printer-info" in self._attributes: state_attributes[ATTR_PRINTER_INFO] = self._attributes["printer-info"] ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "_attributes", "is", "None", ":", "return", "None", "state_attributes", "=", "{", "}", "if", "\"printer-info\"", "in", "self", ".", "_attributes", ":", "state_attributes", "[", "ATTR_P...
[ 195, 4 ]
[ 225, 31 ]
python
en
['en', 'en', 'en']
True
IPPSensor.update
(self)
Fetch new state data for the sensor.
Fetch new state data for the sensor.
def update(self): """Fetch new state data for the sensor.""" self.data.update() self._attributes = self.data.attributes.get(self._name) self._available = self.data.available
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "update", "(", ")", "self", ".", "_attributes", "=", "self", ".", "data", ".", "attributes", ".", "get", "(", "self", ".", "_name", ")", "self", ".", "_available", "=", "self", ".", ...
[ 227, 4 ]
[ 231, 45 ]
python
en
['en', 'en', 'en']
True
MarkerSensor.__init__
(self, data, printer, name, is_cups)
Initialize the sensor.
Initialize the sensor.
def __init__(self, data, printer, name, is_cups): """Initialize the sensor.""" self.data = data self._name = name self._printer = printer self._index = data.attributes[printer]["marker-names"].index(name) self._is_cups = is_cups self._attributes = None
[ "def", "__init__", "(", "self", ",", "data", ",", "printer", ",", "name", ",", "is_cups", ")", ":", "self", ".", "data", "=", "data", "self", ".", "_name", "=", "name", "self", ".", "_printer", "=", "printer", "self", ".", "_index", "=", "data", "....
[ 240, 4 ]
[ 247, 31 ]
python
en
['en', 'en', 'en']
True
MarkerSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 250, 4 ]
[ 252, 25 ]
python
en
['en', 'mi', 'en']
True
MarkerSensor.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 ICON_MARKER
[ "def", "icon", "(", "self", ")", ":", "return", "ICON_MARKER" ]
[ 255, 4 ]
[ 257, 26 ]
python
en
['en', 'en', 'en']
True
MarkerSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" if self._attributes is None: return None return self._attributes[self._printer]["marker-levels"][self._index]
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_attributes", "is", "None", ":", "return", "None", "return", "self", ".", "_attributes", "[", "self", ".", "_printer", "]", "[", "\"marker-levels\"", "]", "[", "self", ".", "_index", "]" ]
[ 260, 4 ]
[ 265, 76 ]
python
en
['en', 'en', 'en']
True
MarkerSensor.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return PERCENTAGE
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "PERCENTAGE" ]
[ 268, 4 ]
[ 270, 25 ]
python
en
['en', 'la', 'en']
True
MarkerSensor.device_state_attributes
(self)
Return the state attributes of the sensor.
Return the state attributes of the sensor.
def device_state_attributes(self): """Return the state attributes of the sensor.""" if self._attributes is None: return None high_level = self._attributes[self._printer].get("marker-high-levels") if isinstance(high_level, list): high_level = high_level[self._inde...
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "_attributes", "is", "None", ":", "return", "None", "high_level", "=", "self", ".", "_attributes", "[", "self", ".", "_printer", "]", ".", "get", "(", "\"marker-high-levels\"", ")", ...
[ 273, 4 ]
[ 300, 9 ]
python
en
['en', 'en', 'en']
True
MarkerSensor.update
(self)
Update the state of the sensor.
Update the state of the sensor.
def update(self): """Update the state of the sensor.""" # Data fetching is done by CupsSensor/IPPSensor self._attributes = self.data.attributes
[ "def", "update", "(", "self", ")", ":", "# Data fetching is done by CupsSensor/IPPSensor", "self", ".", "_attributes", "=", "self", ".", "data", ".", "attributes" ]
[ 302, 4 ]
[ 305, 47 ]
python
en
['en', 'en', 'en']
True
CupsData.__init__
(self, host, port, ipp_printers)
Initialize the data object.
Initialize the data object.
def __init__(self, host, port, ipp_printers): """Initialize the data object.""" self._host = host self._port = port self._ipp_printers = ipp_printers self.is_cups = ipp_printers is None self.printers = None self.attributes = {} self.available = False
[ "def", "__init__", "(", "self", ",", "host", ",", "port", ",", "ipp_printers", ")", ":", "self", ".", "_host", "=", "host", "self", ".", "_port", "=", "port", "self", ".", "_ipp_printers", "=", "ipp_printers", "self", ".", "is_cups", "=", "ipp_printers",...
[ 311, 4 ]
[ 319, 30 ]
python
en
['en', 'en', 'en']
True
CupsData.update
(self)
Get the latest data from CUPS.
Get the latest data from CUPS.
def update(self): """Get the latest data from CUPS.""" cups = importlib.import_module("cups") try: conn = cups.Connection(host=self._host, port=self._port) if self.is_cups: self.printers = conn.getPrinters() for printer in self.printers: ...
[ "def", "update", "(", "self", ")", ":", "cups", "=", "importlib", ".", "import_module", "(", "\"cups\"", ")", "try", ":", "conn", "=", "cups", ".", "Connection", "(", "host", "=", "self", ".", "_host", ",", "port", "=", "self", ".", "_port", ")", "...
[ 321, 4 ]
[ 339, 34 ]
python
en
['en', 'en', 'en']
True
client
(hass, hass_ws_client)
Fixture that can interact with the config manager API.
Fixture that can interact with the config manager API.
async def client(hass, hass_ws_client): """Fixture that can interact with the config manager API.""" with patch.object(config, "SECTIONS", ["core"]): assert await async_setup_component(hass, "config", {}) return await hass_ws_client(hass)
[ "async", "def", "client", "(", "hass", ",", "hass_ws_client", ")", ":", "with", "patch", ".", "object", "(", "config", ",", "\"SECTIONS\"", ",", "[", "\"core\"", "]", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"config\"", ","...
[ 15, 0 ]
[ 19, 37 ]
python
en
['en', 'en', 'en']
True
test_validate_config_ok
(hass, hass_client)
Test checking config.
Test checking config.
async def test_validate_config_ok(hass, hass_client): """Test checking config.""" with patch.object(config, "SECTIONS", ["core"]): await async_setup_component(hass, "config", {}) client = await hass_client() with patch( "homeassistant.components.config.core.async_check_ha_config_file",...
[ "async", "def", "test_validate_config_ok", "(", "hass", ",", "hass_client", ")", ":", "with", "patch", ".", "object", "(", "config", ",", "\"SECTIONS\"", ",", "[", "\"core\"", "]", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"config\"", "...
[ 22, 0 ]
[ 49, 37 ]
python
en
['it', 'en', 'en']
True
test_websocket_core_update
(hass, client)
Test core config update websocket command.
Test core config update websocket command.
async def test_websocket_core_update(hass, client): """Test core config update websocket command.""" assert hass.config.latitude != 60 assert hass.config.longitude != 50 assert hass.config.elevation != 25 assert hass.config.location_name != "Huis" assert hass.config.units.name != CONF_UNIT_SYSTE...
[ "async", "def", "test_websocket_core_update", "(", "hass", ",", "client", ")", ":", "assert", "hass", ".", "config", ".", "latitude", "!=", "60", "assert", "hass", ".", "config", ".", "longitude", "!=", "50", "assert", "hass", ".", "config", ".", "elevatio...
[ 52, 0 ]
[ 93, 69 ]
python
en
['en', 'lb', 'en']
True
test_websocket_core_update_not_admin
(hass, hass_ws_client, hass_admin_user)
Test core config fails for non admin.
Test core config fails for non admin.
async def test_websocket_core_update_not_admin(hass, hass_ws_client, hass_admin_user): """Test core config fails for non admin.""" hass_admin_user.groups = [] with patch.object(config, "SECTIONS", ["core"]): await async_setup_component(hass, "config", {}) client = await hass_ws_client(hass) ...
[ "async", "def", "test_websocket_core_update_not_admin", "(", "hass", ",", "hass_ws_client", ",", "hass_admin_user", ")", ":", "hass_admin_user", ".", "groups", "=", "[", "]", "with", "patch", ".", "object", "(", "config", ",", "\"SECTIONS\"", ",", "[", "\"core\"...
[ 96, 0 ]
[ 110, 49 ]
python
it
['en', 'it', 'it']
True
test_websocket_bad_core_update
(hass, client)
Test core config update fails with bad parameters.
Test core config update fails with bad parameters.
async def test_websocket_bad_core_update(hass, client): """Test core config update fails with bad parameters.""" await client.send_json({"id": 7, "type": "config/core/update", "latituude": 23}) msg = await client.receive_json() assert msg["id"] == 7 assert msg["type"] == TYPE_RESULT assert not...
[ "async", "def", "test_websocket_bad_core_update", "(", "hass", ",", "client", ")", ":", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "7", ",", "\"type\"", ":", "\"config/core/update\"", ",", "\"latituude\"", ":", "23", "}", ")", "msg", "=", ...
[ 113, 0 ]
[ 122, 51 ]
python
en
['en', 'en', 'en']
True
test_detect_config
(hass, client)
Test detect config.
Test detect config.
async def test_detect_config(hass, client): """Test detect config.""" with patch( "homeassistant.util.location.async_detect_location_info", return_value=None, ): await client.send_json({"id": 1, "type": "config/core/detect"}) msg = await client.receive_json() assert msg...
[ "async", "def", "test_detect_config", "(", "hass", ",", "client", ")", ":", "with", "patch", "(", "\"homeassistant.util.location.async_detect_location_info\"", ",", "return_value", "=", "None", ",", ")", ":", "await", "client", ".", "send_json", "(", "{", "\"id\""...
[ 125, 0 ]
[ 136, 30 ]
python
en
['da', 'en', 'en']
True
test_detect_config_fail
(hass, client)
Test detect config.
Test detect config.
async def test_detect_config_fail(hass, client): """Test detect config.""" with patch( "homeassistant.util.location.async_detect_location_info", return_value=location.LocationInfo( ip=None, country_code=None, country_name=None, region_code=None, ...
[ "async", "def", "test_detect_config_fail", "(", "hass", ",", "client", ")", ":", "with", "patch", "(", "\"homeassistant.util.location.async_detect_location_info\"", ",", "return_value", "=", "location", ".", "LocationInfo", "(", "ip", "=", "None", ",", "country_code",...
[ 139, 0 ]
[ 162, 86 ]
python
en
['da', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Apple TV platform.
Set up the Apple TV platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Apple TV platform.""" if not discovery_info: return # Manage entity cache for service handler if DATA_ENTITIES not in hass.data: hass.data[DATA_ENTITIES] = [] name = discovery_info[...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "not", "discovery_info", ":", "return", "# Manage entity cache for service handler", "if", "DATA_ENTITIES", "not", "in", ...
[ 50, 0 ]
[ 75, 32 ]
python
en
['en', 'da', 'en']
True
AppleTvDevice.__init__
(self, atv, name, power)
Initialize the Apple TV device.
Initialize the Apple TV device.
def __init__(self, atv, name, power): """Initialize the Apple TV device.""" self.atv = atv self._name = name self._playing = None self._power = power self._power.listeners.append(self) self.atv.push_updater.listener = self
[ "def", "__init__", "(", "self", ",", "atv", ",", "name", ",", "power", ")", ":", "self", ".", "atv", "=", "atv", "self", ".", "_name", "=", "name", "self", ".", "_playing", "=", "None", "self", ".", "_power", "=", "power", "self", ".", "_power", ...
[ 81, 4 ]
[ 88, 45 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.async_added_to_hass
(self)
Handle when an entity is about to be added to Home Assistant.
Handle when an entity is about to be added to Home Assistant.
async def async_added_to_hass(self): """Handle when an entity is about to be added to Home Assistant.""" self._power.init()
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_power", ".", "init", "(", ")" ]
[ 90, 4 ]
[ 92, 26 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 95, 4 ]
[ 97, 25 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return self.atv.metadata.device_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "atv", ".", "metadata", ".", "device_id" ]
[ 100, 4 ]
[ 102, 42 ]
python
ca
['fr', 'ca', 'en']
False
AppleTvDevice.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 105, 4 ]
[ 107, 20 ]
python
en
['en', 'en', 'en']
True
AppleTvDevice.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" if not self._power.turned_on: return STATE_OFF if self._playing: state = self._playing.play_state if state in ( atv_const.PLAY_STATE_IDLE, atv_const.PLAY_STATE_NO_MEDIA, ...
[ "def", "state", "(", "self", ")", ":", "if", "not", "self", ".", "_power", ".", "turned_on", ":", "return", "STATE_OFF", "if", "self", ".", "_playing", ":", "state", "=", "self", ".", "_playing", ".", "play_state", "if", "state", "in", "(", "atv_const"...
[ 110, 4 ]
[ 134, 32 ]
python
en
['en', 'en', 'en']
True