Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
test_invalid_port_number
(hass, numato_fixture, config)
Test validation of ADC port number type.
Test validation of ADC port number type.
async def test_invalid_port_number(hass, numato_fixture, config): """Test validation of ADC port number type.""" sensorports_cfg = config["numato"]["devices"][0]["sensors"]["ports"] port1_config = sensorports_cfg["1"] sensorports_cfg["one"] = port1_config del sensorports_cfg["1"] assert not awai...
[ "async", "def", "test_invalid_port_number", "(", "hass", ",", "numato_fixture", ",", "config", ")", ":", "sensorports_cfg", "=", "config", "[", "\"numato\"", "]", "[", "\"devices\"", "]", "[", "0", "]", "[", "\"sensors\"", "]", "[", "\"ports\"", "]", "port1_...
[ 63, 0 ]
[ 71, 37 ]
python
en
['en', 'en', 'en']
True
test_too_low_adc_port_number
(hass, numato_fixture, config)
Test handling of failing component setup. Tries setting up an ADC on a port below (0) the allowed range.
Test handling of failing component setup.
async def test_too_low_adc_port_number(hass, numato_fixture, config): """Test handling of failing component setup. Tries setting up an ADC on a port below (0) the allowed range. """ sensorports_cfg = config["numato"]["devices"][0]["sensors"]["ports"] sensorports_cfg.update({0: {"name": "toolow"}})...
[ "async", "def", "test_too_low_adc_port_number", "(", "hass", ",", "numato_fixture", ",", "config", ")", ":", "sensorports_cfg", "=", "config", "[", "\"numato\"", "]", "[", "\"devices\"", "]", "[", "0", "]", "[", "\"sensors\"", "]", "[", "\"ports\"", "]", "se...
[ 74, 0 ]
[ 83, 37 ]
python
en
['en', 'bg', 'en']
True
test_too_high_adc_port_number
(hass, numato_fixture, config)
Test handling of failing component setup. Tries setting up an ADC on a port above (8) the allowed range.
Test handling of failing component setup.
async def test_too_high_adc_port_number(hass, numato_fixture, config): """Test handling of failing component setup. Tries setting up an ADC on a port above (8) the allowed range. """ sensorports_cfg = config["numato"]["devices"][0]["sensors"]["ports"] sensorports_cfg.update({8: {"name": "toohigh"}}...
[ "async", "def", "test_too_high_adc_port_number", "(", "hass", ",", "numato_fixture", ",", "config", ")", ":", "sensorports_cfg", "=", "config", "[", "\"numato\"", "]", "[", "\"devices\"", "]", "[", "0", "]", "[", "\"sensors\"", "]", "[", "\"ports\"", "]", "s...
[ 86, 0 ]
[ 94, 37 ]
python
en
['en', 'bg', 'en']
True
test_invalid_adc_range_value_type
(hass, numato_fixture, config)
Test validation of ADC range config's types. Replaces the source range beginning by a string.
Test validation of ADC range config's types.
async def test_invalid_adc_range_value_type(hass, numato_fixture, config): """Test validation of ADC range config's types. Replaces the source range beginning by a string. """ sensorports_cfg = config["numato"]["devices"][0]["sensors"]["ports"] sensorports_cfg["1"]["source_range"][0] = "zero" a...
[ "async", "def", "test_invalid_adc_range_value_type", "(", "hass", ",", "numato_fixture", ",", "config", ")", ":", "sensorports_cfg", "=", "config", "[", "\"numato\"", "]", "[", "\"devices\"", "]", "[", "0", "]", "[", "\"sensors\"", "]", "[", "\"ports\"", "]", ...
[ 97, 0 ]
[ 105, 37 ]
python
en
['en', 'en', 'en']
True
test_invalid_adc_source_range_length
(hass, numato_fixture, config)
Test validation of ADC range config's length. Adds an element to the source range.
Test validation of ADC range config's length.
async def test_invalid_adc_source_range_length(hass, numato_fixture, config): """Test validation of ADC range config's length. Adds an element to the source range. """ sensorports_cfg = config["numato"]["devices"][0]["sensors"]["ports"] sensorports_cfg["1"]["source_range"].append(42) assert not...
[ "async", "def", "test_invalid_adc_source_range_length", "(", "hass", ",", "numato_fixture", ",", "config", ")", ":", "sensorports_cfg", "=", "config", "[", "\"numato\"", "]", "[", "\"devices\"", "]", "[", "0", "]", "[", "\"sensors\"", "]", "[", "\"ports\"", "]...
[ 108, 0 ]
[ 116, 37 ]
python
en
['en', 'en', 'en']
True
test_invalid_adc_source_range_order
(hass, numato_fixture, config)
Test validation of ADC range config's order. Sets the source range to a decreasing [2, 1].
Test validation of ADC range config's order.
async def test_invalid_adc_source_range_order(hass, numato_fixture, config): """Test validation of ADC range config's order. Sets the source range to a decreasing [2, 1]. """ sensorports_cfg = config["numato"]["devices"][0]["sensors"]["ports"] sensorports_cfg["1"]["source_range"] = [2, 1] asser...
[ "async", "def", "test_invalid_adc_source_range_order", "(", "hass", ",", "numato_fixture", ",", "config", ")", ":", "sensorports_cfg", "=", "config", "[", "\"numato\"", "]", "[", "\"devices\"", "]", "[", "0", "]", "[", "\"sensors\"", "]", "[", "\"ports\"", "]"...
[ 119, 0 ]
[ 127, 37 ]
python
en
['en', 'da', 'en']
True
test_invalid_adc_destination_range_value_type
(hass, numato_fixture, config)
Test validation of ADC range . Replaces the destination range beginning by a string.
Test validation of ADC range .
async def test_invalid_adc_destination_range_value_type(hass, numato_fixture, config): """Test validation of ADC range . Replaces the destination range beginning by a string. """ sensorports_cfg = config["numato"]["devices"][0]["sensors"]["ports"] sensorports_cfg["1"]["destination_range"][0] = "zer...
[ "async", "def", "test_invalid_adc_destination_range_value_type", "(", "hass", ",", "numato_fixture", ",", "config", ")", ":", "sensorports_cfg", "=", "config", "[", "\"numato\"", "]", "[", "\"devices\"", "]", "[", "0", "]", "[", "\"sensors\"", "]", "[", "\"ports...
[ 130, 0 ]
[ 138, 37 ]
python
en
['en', 'zu', 'en']
True
test_invalid_adc_destination_range_length
(hass, numato_fixture, config)
Test validation of ADC range config's length. Adds an element to the destination range.
Test validation of ADC range config's length.
async def test_invalid_adc_destination_range_length(hass, numato_fixture, config): """Test validation of ADC range config's length. Adds an element to the destination range. """ sensorports_cfg = config["numato"]["devices"][0]["sensors"]["ports"] sensorports_cfg["1"]["destination_range"].append(42)...
[ "async", "def", "test_invalid_adc_destination_range_length", "(", "hass", ",", "numato_fixture", ",", "config", ")", ":", "sensorports_cfg", "=", "config", "[", "\"numato\"", "]", "[", "\"devices\"", "]", "[", "0", "]", "[", "\"sensors\"", "]", "[", "\"ports\"",...
[ 141, 0 ]
[ 149, 37 ]
python
en
['en', 'en', 'en']
True
test_invalid_adc_destination_range_order
(hass, numato_fixture, config)
Test validation of ADC range config's order. Sets the destination range to a decreasing [2, 1].
Test validation of ADC range config's order.
async def test_invalid_adc_destination_range_order(hass, numato_fixture, config): """Test validation of ADC range config's order. Sets the destination range to a decreasing [2, 1]. """ sensorports_cfg = config["numato"]["devices"][0]["sensors"]["ports"] sensorports_cfg["1"]["destination_range"] = [...
[ "async", "def", "test_invalid_adc_destination_range_order", "(", "hass", ",", "numato_fixture", ",", "config", ")", ":", "sensorports_cfg", "=", "config", "[", "\"numato\"", "]", "[", "\"devices\"", "]", "[", "0", "]", "[", "\"sensors\"", "]", "[", "\"ports\"", ...
[ 152, 0 ]
[ 160, 37 ]
python
en
['en', 'da', 'en']
True
icon_for_battery_level
( battery_level: Optional[int] = None, charging: bool = False )
Return a battery icon valid identifier.
Return a battery icon valid identifier.
def icon_for_battery_level( battery_level: Optional[int] = None, charging: bool = False ) -> str: """Return a battery icon valid identifier.""" icon = "mdi:battery" if battery_level is None: return f"{icon}-unknown" if charging and battery_level > 10: icon += "-charging-{}".format(in...
[ "def", "icon_for_battery_level", "(", "battery_level", ":", "Optional", "[", "int", "]", "=", "None", ",", "charging", ":", "bool", "=", "False", ")", "->", "str", ":", "icon", "=", "\"mdi:battery\"", "if", "battery_level", "is", "None", ":", "return", "f\...
[ 4, 0 ]
[ 19, 15 ]
python
en
['en', 'fy', 'en']
True
icon_for_signal_level
(signal_level: Optional[int] = None)
Return a signal icon valid identifier.
Return a signal icon valid identifier.
def icon_for_signal_level(signal_level: Optional[int] = None) -> str: """Return a signal icon valid identifier.""" if signal_level is None or signal_level == 0: return "mdi:signal-cellular-outline" if signal_level > 70: return "mdi:signal-cellular-3" if signal_level > 30: return ...
[ "def", "icon_for_signal_level", "(", "signal_level", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "str", ":", "if", "signal_level", "is", "None", "or", "signal_level", "==", "0", ":", "return", "\"mdi:signal-cellular-outline\"", "if", "signal_level"...
[ 22, 0 ]
[ 30, 34 ]
python
en
['en', 'cy', 'en']
True
setup_platform
(hass, config_entry, config)
Set up the media player platform for testing.
Set up the media player platform for testing.
async def setup_platform(hass, config_entry, config): """Set up the media player platform for testing.""" config_entry.add_to_hass(hass) assert await async_setup_component(hass, DOMAIN, config) await hass.async_block_till_done()
[ "async", "def", "setup_platform", "(", "hass", ",", "config_entry", ",", "config", ")", ":", "config_entry", ".", "add_to_hass", "(", "hass", ")", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "config", ")", "await", "hass", "....
[ 9, 0 ]
[ 13, 38 ]
python
en
['en', 'da', 'en']
True
test_async_setup_entry_hosts
(hass, config_entry, config, soco)
Test static setup.
Test static setup.
async def test_async_setup_entry_hosts(hass, config_entry, config, soco): """Test static setup.""" await setup_platform(hass, config_entry, config) entity = hass.data[media_player.DATA_SONOS].entities[0] assert entity.soco == soco
[ "async", "def", "test_async_setup_entry_hosts", "(", "hass", ",", "config_entry", ",", "config", ",", "soco", ")", ":", "await", "setup_platform", "(", "hass", ",", "config_entry", ",", "config", ")", "entity", "=", "hass", ".", "data", "[", "media_player", ...
[ 16, 0 ]
[ 21, 30 ]
python
en
['en', 'bg', 'en']
True
test_async_setup_entry_discover
(hass, config_entry, discover)
Test discovery setup.
Test discovery setup.
async def test_async_setup_entry_discover(hass, config_entry, discover): """Test discovery setup.""" await setup_platform(hass, config_entry, {}) entity = hass.data[media_player.DATA_SONOS].entities[0] assert entity.unique_id == "RINCON_test"
[ "async", "def", "test_async_setup_entry_discover", "(", "hass", ",", "config_entry", ",", "discover", ")", ":", "await", "setup_platform", "(", "hass", ",", "config_entry", ",", "{", "}", ")", "entity", "=", "hass", ".", "data", "[", "media_player", ".", "DA...
[ 24, 0 ]
[ 29, 44 ]
python
en
['en', 'haw', 'en']
True
test_services
(hass, config_entry, config, hass_read_only_user)
Test join/unjoin requires control access.
Test join/unjoin requires control access.
async def test_services(hass, config_entry, config, hass_read_only_user): """Test join/unjoin requires control access.""" await setup_platform(hass, config_entry, config) with pytest.raises(Unauthorized): await hass.services.async_call( DOMAIN, media_player.SERVICE_JOIN, ...
[ "async", "def", "test_services", "(", "hass", ",", "config_entry", ",", "config", ",", "hass_read_only_user", ")", ":", "await", "setup_platform", "(", "hass", ",", "config_entry", ",", "config", ")", "with", "pytest", ".", "raises", "(", "Unauthorized", ")", ...
[ 32, 0 ]
[ 43, 9 ]
python
en
['fi', 'en', 'en']
True
test_device_registry
(hass, config_entry, config, soco)
Test sonos device registered in the device registry.
Test sonos device registered in the device registry.
async def test_device_registry(hass, config_entry, config, soco): """Test sonos device registered in the device registry.""" await setup_platform(hass, config_entry, config) device_registry = await hass.helpers.device_registry.async_get_registry() reg_device = device_registry.async_get_device( ...
[ "async", "def", "test_device_registry", "(", "hass", ",", "config_entry", ",", "config", ",", "soco", ")", ":", "await", "setup_platform", "(", "hass", ",", "config_entry", ",", "config", ")", "device_registry", "=", "await", "hass", ".", "helpers", ".", "de...
[ 46, 0 ]
[ 59, 38 ]
python
en
['en', 'en', 'it']
True
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 26, 0 ]
[ 28, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 32, 0 ]
[ 34, 30 ]
python
en
['en', 'fy', 'en']
True
calls
(hass)
Track calls to a mock service.
Track calls to a mock service.
def calls(hass): """Track calls to a mock service.""" return async_mock_service(hass, "test", "automation")
[ "def", "calls", "(", "hass", ")", ":", "return", "async_mock_service", "(", "hass", ",", "\"test\"", ",", "\"automation\"", ")" ]
[ 38, 0 ]
[ 40, 57 ]
python
en
['en', 'en', 'en']
True
test_get_triggers
(hass, device_reg, entity_reg)
Test we get the expected triggers from a sensor.
Test we get the expected triggers from a sensor.
async def test_get_triggers(hass, device_reg, entity_reg): """Test we get the expected triggers from a sensor.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg...
[ "async", "def", "test_get_triggers", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "config_entry", "=", "MockConfigEnt...
[ 43, 0 ]
[ 79, 40 ]
python
en
['en', 'en', 'en']
True
test_get_trigger_capabilities
(hass, device_reg, entity_reg)
Test we get the expected capabilities from a sensor trigger.
Test we get the expected capabilities from a sensor trigger.
async def test_get_trigger_capabilities(hass, device_reg, entity_reg): """Test we get the expected capabilities from a sensor trigger.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) d...
[ "async", "def", "test_get_trigger_capabilities", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "config_entry", "=", "M...
[ 82, 0 ]
[ 126, 52 ]
python
en
['en', 'en', 'en']
True
test_get_trigger_capabilities_none
(hass, device_reg, entity_reg)
Test we get the expected capabilities from a sensor trigger.
Test we get the expected capabilities from a sensor trigger.
async def test_get_trigger_capabilities_none(hass, device_reg, entity_reg): """Test we get the expected capabilities from a sensor trigger.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) ...
[ "async", "def", "test_get_trigger_capabilities_none", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "config_entry", "=",...
[ 129, 0 ]
[ 162, 52 ]
python
en
['en', 'en', 'en']
True
test_if_fires_not_on_above_below
(hass, calls, caplog)
Test for value triggers firing.
Test for value triggers firing.
async def test_if_fires_not_on_above_below(hass, calls, caplog): """Test for value triggers firing.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) await hass.async_block_till_done() sen...
[ "async", "def", "test_if_fires_not_on_above_below", "(", "hass", ",", "calls", ",", "caplog", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "assert", "await", "async_set...
[ 165, 0 ]
[ 192, 69 ]
python
en
['en', 'en', 'en']
True
test_if_fires_on_state_above
(hass, calls)
Test for value triggers firing.
Test for value triggers firing.
async def test_if_fires_on_state_above(hass, calls): """Test for value triggers firing.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) await hass.async_block_till_done() sensor1 = platf...
[ "async", "def", "test_if_fires_on_state_above", "(", "hass", ",", "calls", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "assert", "await", "async_setup_component", "(", ...
[ 195, 0 ]
[ 250, 5 ]
python
en
['en', 'en', 'en']
True
test_if_fires_on_state_below
(hass, calls)
Test for value triggers firing.
Test for value triggers firing.
async def test_if_fires_on_state_below(hass, calls): """Test for value triggers firing.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) await hass.async_block_till_done() sensor1 = platf...
[ "async", "def", "test_if_fires_on_state_below", "(", "hass", ",", "calls", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "assert", "await", "async_setup_component", "(", ...
[ 253, 0 ]
[ 308, 5 ]
python
en
['en', 'en', 'en']
True
test_if_fires_on_state_between
(hass, calls)
Test for value triggers firing.
Test for value triggers firing.
async def test_if_fires_on_state_between(hass, calls): """Test for value triggers firing.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) await hass.async_block_till_done() sensor1 = pla...
[ "async", "def", "test_if_fires_on_state_between", "(", "hass", ",", "calls", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "assert", "await", "async_setup_component", "(",...
[ 311, 0 ]
[ 378, 5 ]
python
en
['en', 'en', 'en']
True
test_if_fires_on_state_change_with_for
(hass, calls)
Test for triggers firing with delay.
Test for triggers firing with delay.
async def test_if_fires_on_state_change_with_for(hass, calls): """Test for triggers firing with delay.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) await hass.async_block_till_done() ...
[ "async", "def", "test_if_fires_on_state_change_with_for", "(", "hass", ",", "calls", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "assert", "await", "async_setup_component"...
[ 381, 0 ]
[ 439, 5 ]
python
en
['en', 'en', 'en']
True
test_query
(hass)
Test the SQL sensor.
Test the SQL sensor.
async def test_query(hass): """Test the SQL sensor.""" config = { "sensor": { "platform": "sql", "db_url": "sqlite://", "queries": [ { "name": "count_tables", "query": "SELECT 5 as value", "co...
[ "async", "def", "test_query", "(", "hass", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"sql\"", ",", "\"db_url\"", ":", "\"sqlite://\"", ",", "\"queries\"", ":", "[", "{", "\"name\"", ":", "\"count_tables\"", ",", "\"query\""...
[ 9, 0 ]
[ 30, 41 ]
python
en
['en', 'da', 'en']
True
test_invalid_query
(hass)
Test the SQL sensor for invalid queries.
Test the SQL sensor for invalid queries.
async def test_invalid_query(hass): """Test the SQL sensor for invalid queries.""" with pytest.raises(vol.Invalid): validate_sql_select("DROP TABLE *") config = { "sensor": { "platform": "sql", "db_url": "sqlite://", "queries": [ { ...
[ "async", "def", "test_invalid_query", "(", "hass", ")", ":", "with", "pytest", ".", "raises", "(", "vol", ".", "Invalid", ")", ":", "validate_sql_select", "(", "\"DROP TABLE *\"", ")", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"sql\"...
[ 33, 0 ]
[ 56, 39 ]
python
en
['en', 'en', 'en']
True
create_camera
(accessory)
Define camera characteristics.
Define camera characteristics.
def create_camera(accessory): """Define camera characteristics.""" accessory.add_service(ServicesTypes.CAMERA_RTP_STREAM_MANAGEMENT)
[ "def", "create_camera", "(", "accessory", ")", ":", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "CAMERA_RTP_STREAM_MANAGEMENT", ")" ]
[ 11, 0 ]
[ 13, 69 ]
python
ca
['it', 'ca', 'en']
False
test_read_state
(hass, utcnow)
Test reading the state of a HomeKit camera.
Test reading the state of a HomeKit camera.
async def test_read_state(hass, utcnow): """Test reading the state of a HomeKit camera.""" helper = await setup_test_component(hass, create_camera) state = await helper.poll_and_get_state() assert state.state == "idle"
[ "async", "def", "test_read_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_camera", ")", "state", "=", "await", "helper", ".", "poll_and_get_state", "(", ")", "assert", "state", ".", "st...
[ 16, 0 ]
[ 21, 32 ]
python
en
['en', 'en', 'en']
True
test_get_image
(hass, utcnow)
Test getting a JPEG from a camera.
Test getting a JPEG from a camera.
async def test_get_image(hass, utcnow): """Test getting a JPEG from a camera.""" helper = await setup_test_component(hass, create_camera) image = await camera.async_get_image(hass, helper.entity_id) assert image.content == base64.b64decode(FAKE_CAMERA_IMAGE)
[ "async", "def", "test_get_image", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_camera", ")", "image", "=", "await", "camera", ".", "async_get_image", "(", "hass", ",", "helper", ".", "entity_...
[ 24, 0 ]
[ 28, 63 ]
python
en
['en', 'en', 'en']
True
calc_melt_Clark2009
(ta, precip, d_snow, doy, acc, tmelt=274.16, **config)
calculate the melt rate (mm day^-1) at current timestep according to Clark 2009 :param ta: grid of current temperature (K) :param precip: grid of current precipitation (mm) :param d_snow: grid with current days since last snowfall (days) :param doy: current day of year (can be decimal) :param a...
calculate the melt rate (mm day^-1) at current timestep according to Clark 2009 :param ta: grid of current temperature (K) :param precip: grid of current precipitation (mm) :param d_snow: grid with current days since last snowfall (days) :param doy: current day of year (can be decimal) :param a...
def calc_melt_Clark2009(ta, precip, d_snow, doy, acc, tmelt=274.16, **config): """ calculate the melt rate (mm day^-1) at current timestep according to Clark 2009 :param ta: grid of current temperature (K) :param precip: grid of current precipitation (mm) :param d_snow: grid with current days since ...
[ "def", "calc_melt_Clark2009", "(", "ta", ",", "precip", ",", "d_snow", ",", "doy", ",", "acc", ",", "tmelt", "=", "274.16", ",", "*", "*", "config", ")", ":", "# determine melt factor", "mf", "=", "calc_melt_factor_Clark2009", "(", "doy", ",", "d_snow", ",...
[ 12, 0 ]
[ 29, 20 ]
python
en
['en', 'error', 'th']
False
calc_melt_factor_Clark2009
(doy, d_snow, precip, acc, mf_mean=5.0, mf_amp=5.0, mf_alb=2.5, mf_alb_decay=5.0, mf_ros=2.5, mf_doy_max_ddf=356, **config)
calculate the grid melt factor according to Clark 2009. Depends on day of year, time since snowfall and rain on snow. :param doy: current day of year :param d_snow: grid of days since last snowfall :param precip: grid of precip at current timestep :param acc: grid of accumulation at current timeste...
calculate the grid melt factor according to Clark 2009. Depends on day of year, time since snowfall and rain on snow. :param doy: current day of year :param d_snow: grid of days since last snowfall :param precip: grid of precip at current timestep :param acc: grid of accumulation at current timeste...
def calc_melt_factor_Clark2009(doy, d_snow, precip, acc, mf_mean=5.0, mf_amp=5.0, mf_alb=2.5, mf_alb_decay=5.0, mf_ros=2.5, mf_doy_max_ddf=356, **config): """ calculate the grid melt factor according to Clark 2009. Depends on day of year, time since snowfall and rain on snow. ...
[ "def", "calc_melt_factor_Clark2009", "(", "doy", ",", "d_snow", ",", "precip", ",", "acc", ",", "mf_mean", "=", "5.0", ",", "mf_amp", "=", "5.0", ",", "mf_alb", "=", "2.5", ",", "mf_alb_decay", "=", "5.0", ",", "mf_ros", "=", "2.5", ",", "mf_doy_max_ddf"...
[ 32, 0 ]
[ 62, 13 ]
python
en
['en', 'error', 'th']
False
calc_acc
(ta, precip, tacc=274.16, **config)
calculate accumulation when precip is below threshold :param ta: grid of current temperature (K) :param precip: grid of current precipitation (mm) :param tacc: temperature threshold for accumlation (K) :return: acc: grid of accumulation in current timestep (mm)
calculate accumulation when precip is below threshold :param ta: grid of current temperature (K) :param precip: grid of current precipitation (mm) :param tacc: temperature threshold for accumlation (K) :return: acc: grid of accumulation in current timestep (mm)
def calc_acc(ta, precip, tacc=274.16, **config): """ calculate accumulation when precip is below threshold :param ta: grid of current temperature (K) :param precip: grid of current precipitation (mm) :param tacc: temperature threshold for accumlation (K) :return: acc: grid of accumulation in cu...
[ "def", "calc_acc", "(", "ta", ",", "precip", ",", "tacc", "=", "274.16", ",", "*", "*", "config", ")", ":", "acc", "=", "precip", ".", "copy", "(", ")", "acc", "[", "(", "ta", ">=", "tacc", ")", "]", "=", "0", "return", "acc" ]
[ 65, 0 ]
[ 76, 14 ]
python
en
['en', 'error', 'th']
False
calc_melt_dsc_snow
(ta, sw, d_snow, swe, tmelt=274.16, tf=0.04 * 24, rf=0.009 * 24, alb=None, precip_per_s=None,**config)
calculate the melt rate (mm day^-1) at current timestep according to dsc_snow model. calculates albedo if not available in the configuration :param ta: grid of current temperature (K) :param precip: grid of current precipitation (mm) :param sw: grid of current incoming shortwave rad (W m^-2) :param...
calculate the melt rate (mm day^-1) at current timestep according to dsc_snow model. calculates albedo if not available in the configuration :param ta: grid of current temperature (K) :param precip: grid of current precipitation (mm) :param sw: grid of current incoming shortwave rad (W m^-2) :param...
def calc_melt_dsc_snow(ta, sw, d_snow, swe, tmelt=274.16, tf=0.04 * 24, rf=0.009 * 24, alb=None, precip_per_s=None,**config): """ calculate the melt rate (mm day^-1) at current timestep according to dsc_snow model. calculates albedo if not available in the configuration :param ta: grid of current temperatur...
[ "def", "calc_melt_dsc_snow", "(", "ta", ",", "sw", ",", "d_snow", ",", "swe", ",", "tmelt", "=", "274.16", ",", "tf", "=", "0.04", "*", "24", ",", "rf", "=", "0.009", "*", "24", ",", "alb", "=", "None", ",", "precip_per_s", "=", "None", ",", "*",...
[ 79, 0 ]
[ 109, 20 ]
python
en
['en', 'error', 'th']
False
calc_albedo_snow
(ts, snow, dc=11.0, tc=21.9, a_ice=0.34, a_freshsnow=0.9, a_firn=0.53, **config)
! albedo calculated using 'time' - based on time since last snowfall(Oerlemans + Knap 1998) ! albedo = albedo output grid ! ts = time(days) since last snowfall ! snow = grid of snow thickness( in mm w.e.) ! dc = 'characteristic depth'(11 mm w.e.) ! t...
! albedo calculated using 'time' - based on time since last snowfall(Oerlemans + Knap 1998) ! albedo = albedo output grid ! ts = time(days) since last snowfall ! snow = grid of snow thickness( in mm w.e.) ! dc = 'characteristic depth'(11 mm w.e.) ! t...
def calc_albedo_snow(ts, snow, dc=11.0, tc=21.9, a_ice=0.34, a_freshsnow=0.9, a_firn=0.53, **config): """ ! albedo calculated using 'time' - based on time since last snowfall(Oerlemans + Knap 1998) ! albedo = albedo output grid ! ts = time(days) since last snowfall ! snow = gr...
[ "def", "calc_albedo_snow", "(", "ts", ",", "snow", ",", "dc", "=", "11.0", ",", "tc", "=", "21.9", ",", "a_ice", "=", "0.34", ",", "a_freshsnow", "=", "0.9", ",", "a_firn", "=", "0.53", ",", "*", "*", "config", ")", ":", "a_snow", "=", "a_firn", ...
[ 112, 0 ]
[ 126, 17 ]
python
en
['en', 'error', 'th']
False
calc_dswe
(swe, d_snow, ta, precip, doy, dtstep, sw=None, which_melt='clark2009', **config)
calculate the change in swe for a given timestep (mm water equivalent) :param swe: grid with current state of SWE (mm water equivalent) :param d_snow: grid with current days since last snowfall (days) :param ta: grid of current temperature (K) :param precip: grid of current precipitation (mm) :...
calculate the change in swe for a given timestep (mm water equivalent) :param swe: grid with current state of SWE (mm water equivalent) :param d_snow: grid with current days since last snowfall (days) :param ta: grid of current temperature (K) :param precip: grid of current precipitation (mm) :...
def calc_dswe(swe, d_snow, ta, precip, doy, dtstep, sw=None, which_melt='clark2009', **config): """ calculate the change in swe for a given timestep (mm water equivalent) :param swe: grid with current state of SWE (mm water equivalent) :param d_snow: grid with current days since last snowfall (days) ...
[ "def", "calc_dswe", "(", "swe", ",", "d_snow", ",", "ta", ",", "precip", ",", "doy", ",", "dtstep", ",", "sw", "=", "None", ",", "which_melt", "=", "'clark2009'", ",", "*", "*", "config", ")", ":", "acc", "=", "calc_acc", "(", "ta", ",", "precip", ...
[ 129, 0 ]
[ 151, 33 ]
python
en
['en', 'error', 'th']
False
snow_main_simple
(inp_ta, inp_precip, inp_doy, inp_hourdec, dtstep, init_swe=None, init_d_snow=None, inp_sw=None, which_melt='clark2009', alb_swe_thres=5.0, \ num_secs_output=86400, **config)
main snow model loop. handles timestepping and storage of output. assumes input data is at same temporal and spatial resolution as model time step (dtstep). Output is writen at the end of each day, then passed out :param inp_ta: air temperature in K. dimensions (time,spatial:) :param inp_precip: precip...
main snow model loop. handles timestepping and storage of output. assumes input data is at same temporal and spatial resolution as model time step (dtstep). Output is writen at the end of each day, then passed out :param inp_ta: air temperature in K. dimensions (time,spatial:) :param inp_precip: precip...
def snow_main_simple(inp_ta, inp_precip, inp_doy, inp_hourdec, dtstep, init_swe=None, init_d_snow=None, inp_sw=None, which_melt='clark2009', alb_swe_thres=5.0, \ num_secs_output=86400, **config): """ main snow model loop. handles timestepping and storage of output. assumes input data is...
[ "def", "snow_main_simple", "(", "inp_ta", ",", "inp_precip", ",", "inp_doy", ",", "inp_hourdec", ",", "dtstep", ",", "init_swe", "=", "None", ",", "init_d_snow", "=", "None", ",", "inp_sw", "=", "None", ",", "which_melt", "=", "'clark2009'", ",", "alb_swe_th...
[ 154, 0 ]
[ 236, 42 ]
python
en
['en', 'error', 'th']
False
snow_main
(inp_file, init_swe=None, init_d_snow=None, which_melt='clark2009', alb_swe_thres=5.0, **config)
main snow model loop. handles timestepping and storage of output. assumes all the input data is on the same spatial and temporal grid. Runs the model for the length of the netCDF file Output is writen at the end of each day. :param inp_file: full path to netCDF input file :param init_swe: inita...
main snow model loop. handles timestepping and storage of output. assumes all the input data is on the same spatial and temporal grid. Runs the model for the length of the netCDF file Output is writen at the end of each day. :param inp_file: full path to netCDF input file :param init_swe: inita...
def snow_main(inp_file, init_swe=None, init_d_snow=None, which_melt='clark2009', alb_swe_thres=5.0, **config): """ main snow model loop. handles timestepping and storage of output. assumes all the input data is on the same spatial and temporal grid. Runs the model for the length of the netCDF file O...
[ "def", "snow_main", "(", "inp_file", ",", "init_swe", "=", "None", ",", "init_d_snow", "=", "None", ",", "which_melt", "=", "'clark2009'", ",", "alb_swe_thres", "=", "5.0", ",", "*", "*", "config", ")", ":", "# load netCDF file and get the spatial dimensions out o...
[ 239, 0 ]
[ 314, 34 ]
python
en
['en', 'error', 'th']
False
read_met_input
(inp_nc_file, i)
read met input from net CDF file variable and units required are air_temperature' "K" 'precipitation_amount' "mm per timestep" 'surface_downwelling_shortwave_flux' "W / m2" :param inp_nc_file: :return: inp_ta, inp_p, inp_sw: arrays containing the input data for a single timestamp
read met input from net CDF file variable and units required are air_temperature' "K" 'precipitation_amount' "mm per timestep" 'surface_downwelling_shortwave_flux' "W / m2" :param inp_nc_file: :return: inp_ta, inp_p, inp_sw: arrays containing the input data for a single timestamp
def read_met_input(inp_nc_file, i): """ read met input from net CDF file variable and units required are air_temperature' "K" 'precipitation_amount' "mm per timestep" 'surface_downwelling_shortwave_flux' "W / m2" :param inp_nc_file: :return: inp_ta, inp_p, inp_sw: arrays containing the input dat...
[ "def", "read_met_input", "(", "inp_nc_file", ",", "i", ")", ":", "inp_ta", "=", "inp_nc_file", ".", "get_variables_by_attributes", "(", "standard_name", "=", "'air_temperature'", ")", "[", "0", "]", "[", "i", ",", ":", "]", "inp_p", "=", "inp_nc_file", ".", ...
[ 317, 0 ]
[ 329, 32 ]
python
en
['en', 'error', 'th']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Add covers for a config entry.
Add covers for a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Add covers for a config entry.""" broker = hass.data[DOMAIN][DATA_BROKERS][config_entry.entry_id] async_add_entities( [ SmartThingsCover(device) for device in broker.devices.values() if broker...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "broker", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_BROKERS", "]", "[", "config_entry", ".", "entry_id", "]", "async_add_entities", "(", ...
[ 35, 0 ]
[ 45, 5 ]
python
en
['en', 'en', 'en']
True
get_capabilities
(capabilities: Sequence[str])
Return all capabilities supported if minimum required are present.
Return all capabilities supported if minimum required are present.
def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]: """Return all capabilities supported if minimum required are present.""" min_required = [ Capability.door_control, Capability.garage_door_control, Capability.window_shade, ] # Must have one of the min_r...
[ "def", "get_capabilities", "(", "capabilities", ":", "Sequence", "[", "str", "]", ")", "->", "Optional", "[", "Sequence", "[", "str", "]", "]", ":", "min_required", "=", "[", "Capability", ".", "door_control", ",", "Capability", ".", "garage_door_control", "...
[ 48, 0 ]
[ 60, 15 ]
python
en
['en', 'en', 'en']
True
SmartThingsCover.__init__
(self, device)
Initialize the cover class.
Initialize the cover class.
def __init__(self, device): """Initialize the cover class.""" super().__init__(device) self._device_class = None self._state = None self._state_attrs = None self._supported_features = SUPPORT_OPEN | SUPPORT_CLOSE if Capability.switch_level in device.capabilities: ...
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ")", "self", ".", "_device_class", "=", "None", "self", ".", "_state", "=", "None", "self", ".", "_state_attrs", "=", "None", "self", ".", "_s...
[ 66, 4 ]
[ 74, 60 ]
python
en
['en', 'en', 'en']
True
SmartThingsCover.async_close_cover
(self, **kwargs)
Close cover.
Close cover.
async def async_close_cover(self, **kwargs): """Close cover.""" # Same command for all 3 supported capabilities await self._device.close(set_status=True) # State is set optimistically in the commands above, therefore update # the entity state ahead of receiving the confirming pus...
[ "async", "def", "async_close_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Same command for all 3 supported capabilities", "await", "self", ".", "_device", ".", "close", "(", "set_status", "=", "True", ")", "# State is set optimistically in the commands abo...
[ 76, 4 ]
[ 82, 49 ]
python
en
['en', 'la', 'en']
False
SmartThingsCover.async_open_cover
(self, **kwargs)
Open the cover.
Open the cover.
async def async_open_cover(self, **kwargs): """Open the cover.""" # Same for all capability types await self._device.open(set_status=True) # State is set optimistically in the commands above, therefore update # the entity state ahead of receiving the confirming push updates ...
[ "async", "def", "async_open_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Same for all capability types", "await", "self", ".", "_device", ".", "open", "(", "set_status", "=", "True", ")", "# State is set optimistically in the commands above, therefore upda...
[ 84, 4 ]
[ 90, 49 ]
python
en
['en', 'en', 'en']
True
SmartThingsCover.async_set_cover_position
(self, **kwargs)
Move the cover to a specific position.
Move the cover to a specific position.
async def async_set_cover_position(self, **kwargs): """Move the cover to a specific position.""" if not self._supported_features & SUPPORT_SET_POSITION: return # Do not set_status=True as device will report progress. await self._device.set_level(kwargs[ATTR_POSITION], 0)
[ "async", "def", "async_set_cover_position", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "_supported_features", "&", "SUPPORT_SET_POSITION", ":", "return", "# Do not set_status=True as device will report progress.", "await", "self", ".", "...
[ 92, 4 ]
[ 97, 62 ]
python
en
['en', 'en', 'en']
True
SmartThingsCover.async_update
(self)
Update the attrs of the cover.
Update the attrs of the cover.
async def async_update(self): """Update the attrs of the cover.""" value = None if Capability.door_control in self._device.capabilities: self._device_class = DEVICE_CLASS_DOOR value = self._device.status.door elif Capability.window_shade in self._device.capabiliti...
[ "async", "def", "async_update", "(", "self", ")", ":", "value", "=", "None", "if", "Capability", ".", "door_control", "in", "self", ".", "_device", ".", "capabilities", ":", "self", ".", "_device_class", "=", "DEVICE_CLASS_DOOR", "value", "=", "self", ".", ...
[ 99, 4 ]
[ 117, 59 ]
python
en
['en', 'en', 'en']
True
SmartThingsCover.is_opening
(self)
Return if the cover is opening or not.
Return if the cover is opening or not.
def is_opening(self): """Return if the cover is opening or not.""" return self._state == STATE_OPENING
[ "def", "is_opening", "(", "self", ")", ":", "return", "self", ".", "_state", "==", "STATE_OPENING" ]
[ 120, 4 ]
[ 122, 43 ]
python
en
['en', 'en', 'en']
True
SmartThingsCover.is_closing
(self)
Return if the cover is closing or not.
Return if the cover is closing or not.
def is_closing(self): """Return if the cover is closing or not.""" return self._state == STATE_CLOSING
[ "def", "is_closing", "(", "self", ")", ":", "return", "self", ".", "_state", "==", "STATE_CLOSING" ]
[ 125, 4 ]
[ 127, 43 ]
python
en
['en', 'en', 'en']
True
SmartThingsCover.is_closed
(self)
Return if the cover is closed or not.
Return if the cover is closed or not.
def is_closed(self): """Return if the cover is closed or not.""" if self._state == STATE_CLOSED: return True return None if self._state is None else False
[ "def", "is_closed", "(", "self", ")", ":", "if", "self", ".", "_state", "==", "STATE_CLOSED", ":", "return", "True", "return", "None", "if", "self", ".", "_state", "is", "None", "else", "False" ]
[ 130, 4 ]
[ 134, 53 ]
python
en
['en', 'en', 'en']
True
SmartThingsCover.current_cover_position
(self)
Return current position of cover.
Return current position of cover.
def current_cover_position(self): """Return current position of cover.""" if not self._supported_features & SUPPORT_SET_POSITION: return None return self._device.status.level
[ "def", "current_cover_position", "(", "self", ")", ":", "if", "not", "self", ".", "_supported_features", "&", "SUPPORT_SET_POSITION", ":", "return", "None", "return", "self", ".", "_device", ".", "status", ".", "level" ]
[ 137, 4 ]
[ 141, 40 ]
python
en
['en', 'en', 'en']
True
SmartThingsCover.device_class
(self)
Define this cover as a garage door.
Define this cover as a garage door.
def device_class(self): """Define this cover as a garage door.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 144, 4 ]
[ 146, 33 ]
python
en
['en', 'en', 'en']
True
SmartThingsCover.device_state_attributes
(self)
Get additional state attributes.
Get additional state attributes.
def device_state_attributes(self): """Get additional state attributes.""" return self._state_attrs
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_state_attrs" ]
[ 149, 4 ]
[ 151, 32 ]
python
en
['en', 'en', 'en']
True
SmartThingsCover.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return self._supported_features
[ "def", "supported_features", "(", "self", ")", ":", "return", "self", ".", "_supported_features" ]
[ 154, 4 ]
[ 156, 39 ]
python
en
['da', 'en', 'en']
True
test_webcomponent_custom_path_not_found
(hass)
Test if a web component is found in config panels dir.
Test if a web component is found in config panels dir.
async def test_webcomponent_custom_path_not_found(hass): """Test if a web component is found in config panels dir.""" filename = "mock.file" config = { "panel_custom": { "name": "todomvc", "webcomponent_path": filename, "sidebar_title": "Sidebar Title", ...
[ "async", "def", "test_webcomponent_custom_path_not_found", "(", "hass", ")", ":", "filename", "=", "\"mock.file\"", "config", "=", "{", "\"panel_custom\"", ":", "{", "\"name\"", ":", "\"todomvc\"", ",", "\"webcomponent_path\"", ":", "filename", ",", "\"sidebar_title\"...
[ 7, 0 ]
[ 29, 39 ]
python
en
['en', 'en', 'en']
True
test_js_webcomponent
(hass)
Test if a web component is found in config panels dir.
Test if a web component is found in config panels dir.
async def test_js_webcomponent(hass): """Test if a web component is found in config panels dir.""" config = { "panel_custom": { "name": "todo-mvc", "js_url": "/local/bla.js", "sidebar_title": "Sidebar Title", "sidebar_icon": "mdi:iconicon", "ur...
[ "async", "def", "test_js_webcomponent", "(", "hass", ")", ":", "config", "=", "{", "\"panel_custom\"", ":", "{", "\"name\"", ":", "\"todo-mvc\"", ",", "\"js_url\"", ":", "\"/local/bla.js\"", ",", "\"sidebar_title\"", ":", "\"Sidebar Title\"", ",", "\"sidebar_icon\""...
[ 32, 0 ]
[ 68, 49 ]
python
en
['en', 'en', 'en']
True
test_module_webcomponent
(hass)
Test if a js module is found in config panels dir.
Test if a js module is found in config panels dir.
async def test_module_webcomponent(hass): """Test if a js module is found in config panels dir.""" config = { "panel_custom": { "name": "todo-mvc", "module_url": "/local/bla.js", "sidebar_title": "Sidebar Title", "sidebar_icon": "mdi:iconicon", ...
[ "async", "def", "test_module_webcomponent", "(", "hass", ")", ":", "config", "=", "{", "\"panel_custom\"", ":", "{", "\"name\"", ":", "\"todo-mvc\"", ",", "\"module_url\"", ":", "\"/local/bla.js\"", ",", "\"sidebar_title\"", ":", "\"Sidebar Title\"", ",", "\"sidebar...
[ 71, 0 ]
[ 109, 49 ]
python
en
['en', 'en', 'en']
True
test_latest_and_es5_build
(hass)
Test specifying an es5 and latest build.
Test specifying an es5 and latest build.
async def test_latest_and_es5_build(hass): """Test specifying an es5 and latest build.""" config = { "panel_custom": { "name": "todo-mvc", "js_url": "/local/es5.js", "module_url": "/local/latest.js", "url_path": "nice_url", } } assert awai...
[ "async", "def", "test_latest_and_es5_build", "(", "hass", ")", ":", "config", "=", "{", "\"panel_custom\"", ":", "{", "\"name\"", ":", "\"todo-mvc\"", ",", "\"js_url\"", ":", "\"/local/es5.js\"", ",", "\"module_url\"", ":", "\"/local/latest.js\"", ",", "\"url_path\"...
[ 112, 0 ]
[ 141, 48 ]
python
en
['en', 'en', 'en']
True
test_url_path_conflict
(hass)
Test config with overlapping url path.
Test config with overlapping url path.
async def test_url_path_conflict(hass): """Test config with overlapping url path.""" assert await setup.async_setup_component( hass, "panel_custom", { "panel_custom": [ {"name": "todo-mvc", "js_url": "/local/bla.js"}, {"name": "todo-mvc", "js_u...
[ "async", "def", "test_url_path_conflict", "(", "hass", ")", ":", "assert", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"panel_custom\"", ",", "{", "\"panel_custom\"", ":", "[", "{", "\"name\"", ":", "\"todo-mvc\"", ",", "\"js_url\"", ":",...
[ 144, 0 ]
[ 155, 5 ]
python
en
['en', 'en', 'en']
True
convert_examples_to_features
(examples, tokenizer, max_seq_length, is_training)
Loads a data file into a list of `InputBatch`s.
Loads a data file into a list of `InputBatch`s.
def convert_examples_to_features(examples, tokenizer, max_seq_length, is_training): """Loads a data file into a list of `InputBatch`s.""" # Swag is a multiple choice task. To perform this task using Bert, # we will use the formatting proposed in "Improving Language # Understanding by Generative Pre-Tra...
[ "def", "convert_examples_to_features", "(", "examples", ",", "tokenizer", ",", "max_seq_length", ",", "is_training", ")", ":", "# Swag is a multiple choice task. To perform this task using Bert,", "# we will use the formatting proposed in \"Improving Language", "# Understanding by Genera...
[ 126, 0 ]
[ 195, 19 ]
python
en
['en', 'en', 'en']
True
_truncate_seq_pair
(tokens_a, tokens_b, max_length)
Truncates a sequence pair in place to the maximum length.
Truncates a sequence pair in place to the maximum length.
def _truncate_seq_pair(tokens_a, tokens_b, max_length): """Truncates a sequence pair in place to the maximum length.""" # This is a simple heuristic which will always truncate the longer sequence # one token at a time. This makes more sense than truncating an equal percent # of tokens from each, since ...
[ "def", "_truncate_seq_pair", "(", "tokens_a", ",", "tokens_b", ",", "max_length", ")", ":", "# This is a simple heuristic which will always truncate the longer sequence", "# one token at a time. This makes more sense than truncating an equal percent", "# of tokens from each, since if one seq...
[ 198, 0 ]
[ 212, 26 ]
python
en
['en', 'en', 'en']
True
train
(args, train_dataset, model, tokenizer)
Train the model
Train the model
def train(args, train_dataset, model, tokenizer): """ Train the model """ if args.local_rank in [-1, 0]: tb_writer = SummaryWriter() args.train_batch_size = args.per_gpu_train_batch_size * max(1, args.n_gpu) train_sampler = RandomSampler(train_dataset) if args.local_rank == -1 else DistributedS...
[ "def", "train", "(", "args", ",", "train_dataset", ",", "model", ",", "tokenizer", ")", ":", "if", "args", ".", "local_rank", "in", "[", "-", "1", ",", "0", "]", ":", "tb_writer", "=", "SummaryWriter", "(", ")", "args", ".", "train_batch_size", "=", ...
[ 277, 0 ]
[ 412, 45 ]
python
en
['en', 'it', 'en']
True
async_get_platforms
( hass: HomeAssistantType, integration_name: str )
Find existing platforms.
Find existing platforms.
def async_get_platforms( hass: HomeAssistantType, integration_name: str ) -> List[EntityPlatform]: """Find existing platforms.""" if ( DATA_ENTITY_PLATFORM not in hass.data or integration_name not in hass.data[DATA_ENTITY_PLATFORM] ): return [] platforms: List[EntityPlatform...
[ "def", "async_get_platforms", "(", "hass", ":", "HomeAssistantType", ",", "integration_name", ":", "str", ")", "->", "List", "[", "EntityPlatform", "]", ":", "if", "(", "DATA_ENTITY_PLATFORM", "not", "in", "hass", ".", "data", "or", "integration_name", "not", ...
[ 627, 0 ]
[ 639, 20 ]
python
en
['en', 'da', 'en']
True
EntityPlatform.__init__
( self, *, hass: HomeAssistantType, logger: Logger, domain: str, platform_name: str, platform: Optional[ModuleType], scan_interval: timedelta, entity_namespace: Optional[str], )
Initialize the entity platform.
Initialize the entity platform.
def __init__( self, *, hass: HomeAssistantType, logger: Logger, domain: str, platform_name: str, platform: Optional[ModuleType], scan_interval: timedelta, entity_namespace: Optional[str], ): """Initialize the entity platform.""" ...
[ "def", "__init__", "(", "self", ",", "*", ",", "hass", ":", "HomeAssistantType", ",", "logger", ":", "Logger", ",", "domain", ":", "str", ",", "platform_name", ":", "str", ",", "platform", ":", "Optional", "[", "ModuleType", "]", ",", "scan_interval", ":...
[ 43, 4 ]
[ 81, 22 ]
python
en
['en', 'pl', 'en']
True
EntityPlatform.__repr__
(self)
Represent an EntityPlatform.
Represent an EntityPlatform.
def __repr__(self): """Represent an EntityPlatform.""" return f"<EntityPlatform domain={self.domain} platform_name={self.platform_name} config_entry={self.config_entry}>"
[ "def", "__repr__", "(", "self", ")", ":", "return", "f\"<EntityPlatform domain={self.domain} platform_name={self.platform_name} config_entry={self.config_entry}>\"" ]
[ 83, 4 ]
[ 85, 123 ]
python
en
['en', 'de', 'en']
True
EntityPlatform._get_parallel_updates_semaphore
( self, entity_has_async_update: bool )
Get or create a semaphore for parallel updates. Semaphore will be created on demand because we base it off if update method is async or not. If parallel updates is set to 0, we skip the semaphore. If parallel updates is set to a number, we initialize the semaphore to that number. The d...
Get or create a semaphore for parallel updates.
def _get_parallel_updates_semaphore( self, entity_has_async_update: bool ) -> Optional[asyncio.Semaphore]: """Get or create a semaphore for parallel updates. Semaphore will be created on demand because we base it off if update method is async or not. If parallel updates is set to 0...
[ "def", "_get_parallel_updates_semaphore", "(", "self", ",", "entity_has_async_update", ":", "bool", ")", "->", "Optional", "[", "asyncio", ".", "Semaphore", "]", ":", "if", "self", ".", "parallel_updates_created", ":", "return", "self", ".", "parallel_updates", "s...
[ 88, 4 ]
[ 116, 36 ]
python
en
['en', 'en', 'en']
True
EntityPlatform.async_setup
(self, platform_config, discovery_info=None)
Set up the platform from a config file.
Set up the platform from a config file.
async def async_setup(self, platform_config, discovery_info=None): """Set up the platform from a config file.""" platform = self.platform hass = self.hass if not hasattr(platform, "async_setup_platform") and not hasattr( platform, "setup_platform" ): self...
[ "async", "def", "async_setup", "(", "self", ",", "platform_config", ",", "discovery_info", "=", "None", ")", ":", "platform", "=", "self", ".", "platform", "hass", "=", "self", ".", "hass", "if", "not", "hasattr", "(", "platform", ",", "\"async_setup_platfor...
[ 118, 4 ]
[ 155, 65 ]
python
en
['en', 'en', 'en']
True
EntityPlatform.async_setup_entry
(self, config_entry: config_entries.ConfigEntry)
Set up the platform from a config entry.
Set up the platform from a config entry.
async def async_setup_entry(self, config_entry: config_entries.ConfigEntry) -> bool: """Set up the platform from a config entry.""" # Store it so that we can save config entry ID in entity registry self.config_entry = config_entry platform = self.platform @callback def a...
[ "async", "def", "async_setup_entry", "(", "self", ",", "config_entry", ":", "config_entries", ".", "ConfigEntry", ")", "->", "bool", ":", "# Store it so that we can save config entry ID in entity registry", "self", ".", "config_entry", "=", "config_entry", "platform", "="...
[ 157, 4 ]
[ 170, 72 ]
python
en
['en', 'en', 'en']
True
EntityPlatform._async_setup_platform
( self, async_create_setup_task: Callable[[], Coroutine], tries: int = 0 )
Set up a platform via config file or config entry. async_create_setup_task creates a coroutine that sets up platform.
Set up a platform via config file or config entry.
async def _async_setup_platform( self, async_create_setup_task: Callable[[], Coroutine], tries: int = 0 ) -> bool: """Set up a platform via config file or config entry. async_create_setup_task creates a coroutine that sets up platform. """ current_platform.set(self) ...
[ "async", "def", "_async_setup_platform", "(", "self", ",", "async_create_setup_task", ":", "Callable", "[", "[", "]", ",", "Coroutine", "]", ",", "tries", ":", "int", "=", "0", ")", "->", "bool", ":", "current_platform", ".", "set", "(", "self", ")", "lo...
[ 172, 4 ]
[ 245, 30 ]
python
en
['en', 'pt', 'en']
True
EntityPlatform._schedule_add_entities
( self, new_entities: Iterable["Entity"], update_before_add: bool = False )
Schedule adding entities for a single platform, synchronously.
Schedule adding entities for a single platform, synchronously.
def _schedule_add_entities( self, new_entities: Iterable["Entity"], update_before_add: bool = False ) -> None: """Schedule adding entities for a single platform, synchronously.""" run_callback_threadsafe( self.hass.loop, self._async_schedule_add_entities, ...
[ "def", "_schedule_add_entities", "(", "self", ",", "new_entities", ":", "Iterable", "[", "\"Entity\"", "]", ",", "update_before_add", ":", "bool", "=", "False", ")", "->", "None", ":", "run_callback_threadsafe", "(", "self", ".", "hass", ".", "loop", ",", "s...
[ 247, 4 ]
[ 256, 18 ]
python
en
['en', 'en', 'en']
True
EntityPlatform._async_schedule_add_entities
( self, new_entities: Iterable["Entity"], update_before_add: bool = False )
Schedule adding entities for a single platform async.
Schedule adding entities for a single platform async.
def _async_schedule_add_entities( self, new_entities: Iterable["Entity"], update_before_add: bool = False ) -> None: """Schedule adding entities for a single platform async.""" task = self.hass.async_create_task( self.async_add_entities(new_entities, update_before_add=update_befo...
[ "def", "_async_schedule_add_entities", "(", "self", ",", "new_entities", ":", "Iterable", "[", "\"Entity\"", "]", ",", "update_before_add", ":", "bool", "=", "False", ")", "->", "None", ":", "task", "=", "self", ".", "hass", ".", "async_create_task", "(", "s...
[ 259, 4 ]
[ 268, 36 ]
python
en
['en', 'en', 'en']
True
EntityPlatform.add_entities
( self, new_entities: Iterable["Entity"], update_before_add: bool = False )
Add entities for a single platform.
Add entities for a single platform.
def add_entities( self, new_entities: Iterable["Entity"], update_before_add: bool = False ) -> None: """Add entities for a single platform.""" # That avoid deadlocks if update_before_add: self.logger.warning( "Call 'add_entities' with update_before_add=Tru...
[ "def", "add_entities", "(", "self", ",", "new_entities", ":", "Iterable", "[", "\"Entity\"", "]", ",", "update_before_add", ":", "bool", "=", "False", ")", "->", "None", ":", "# That avoid deadlocks", "if", "update_before_add", ":", "self", ".", "logger", ".",...
[ 270, 4 ]
[ 284, 18 ]
python
en
['en', 'en', 'en']
True
EntityPlatform.async_add_entities
( self, new_entities: Iterable["Entity"], update_before_add: bool = False )
Add entities for a single platform async. This method must be run in the event loop.
Add entities for a single platform async.
async def async_add_entities( self, new_entities: Iterable["Entity"], update_before_add: bool = False ) -> None: """Add entities for a single platform async. This method must be run in the event loop. """ # handle empty list from component/platform if not new_entitie...
[ "async", "def", "async_add_entities", "(", "self", ",", "new_entities", ":", "Iterable", "[", "\"Entity\"", "]", ",", "update_before_add", ":", "bool", "=", "False", ")", "->", "None", ":", "# handle empty list from component/platform", "if", "not", "new_entities", ...
[ 286, 4 ]
[ 340, 9 ]
python
en
['en', 'cy', 'en']
True
EntityPlatform._async_add_entity
( self, entity, update_before_add, entity_registry, device_registry )
Add an entity to the platform.
Add an entity to the platform.
async def _async_add_entity( self, entity, update_before_add, entity_registry, device_registry ): """Add an entity to the platform.""" if entity is None: raise ValueError("Entity cannot be None") entity.add_to_platform_start( self.hass, self, ...
[ "async", "def", "_async_add_entity", "(", "self", ",", "entity", ",", "update_before_add", ",", "entity_registry", ",", "device_registry", ")", ":", "if", "entity", "is", "None", ":", "raise", "ValueError", "(", "\"Entity cannot be None\"", ")", "entity", ".", "...
[ 342, 4 ]
[ 506, 45 ]
python
en
['en', 'en', 'en']
True
EntityPlatform.async_reset
(self)
Remove all entities and reset data. This method must be run in the event loop.
Remove all entities and reset data.
async def async_reset(self) -> None: """Remove all entities and reset data. This method must be run in the event loop. """ if self._async_cancel_retry_setup is not None: self._async_cancel_retry_setup() self._async_cancel_retry_setup = None if not self.e...
[ "async", "def", "async_reset", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_async_cancel_retry_setup", "is", "not", "None", ":", "self", ".", "_async_cancel_retry_setup", "(", ")", "self", ".", "_async_cancel_retry_setup", "=", "None", "if", "not"...
[ 508, 4 ]
[ 527, 36 ]
python
en
['en', 'en', 'en']
True
EntityPlatform.async_destroy
(self)
Destroy an entity platform. Call before discarding the object.
Destroy an entity platform.
async def async_destroy(self) -> None: """Destroy an entity platform. Call before discarding the object. """ await self.async_reset() self.hass.data[DATA_ENTITY_PLATFORM][self.platform_name].remove(self)
[ "async", "def", "async_destroy", "(", "self", ")", "->", "None", ":", "await", "self", ".", "async_reset", "(", ")", "self", ".", "hass", ".", "data", "[", "DATA_ENTITY_PLATFORM", "]", "[", "self", ".", "platform_name", "]", ".", "remove", "(", "self", ...
[ 529, 4 ]
[ 535, 77 ]
python
en
['en', 'cy', 'en']
True
EntityPlatform.async_remove_entity
(self, entity_id: str)
Remove entity id from platform.
Remove entity id from platform.
async def async_remove_entity(self, entity_id: str) -> None: """Remove entity id from platform.""" await self.entities[entity_id].async_remove() # Clean up polling job if no longer needed if self._async_unsub_polling is not None and not any( entity.should_poll for entity in ...
[ "async", "def", "async_remove_entity", "(", "self", ",", "entity_id", ":", "str", ")", "->", "None", ":", "await", "self", ".", "entities", "[", "entity_id", "]", ".", "async_remove", "(", ")", "# Clean up polling job if no longer needed", "if", "self", ".", "...
[ 537, 4 ]
[ 546, 44 ]
python
en
['en', 'en', 'en']
True
EntityPlatform.async_extract_from_service
( self, service_call: ServiceCall, expand_group: bool = True )
Extract all known and available entities from a service call. Will return an empty list if entities specified but unknown. This method must be run in the event loop.
Extract all known and available entities from a service call.
async def async_extract_from_service( self, service_call: ServiceCall, expand_group: bool = True ) -> List["Entity"]: """Extract all known and available entities from a service call. Will return an empty list if entities specified but unknown. This method must be run in the event l...
[ "async", "def", "async_extract_from_service", "(", "self", ",", "service_call", ":", "ServiceCall", ",", "expand_group", ":", "bool", "=", "True", ")", "->", "List", "[", "\"Entity\"", "]", ":", "return", "await", "service", ".", "async_extract_entities", "(", ...
[ 548, 4 ]
[ 559, 9 ]
python
en
['en', 'en', 'en']
True
EntityPlatform.async_register_entity_service
(self, name, schema, func, required_features=None)
Register an entity service. Services will automatically be shared by all platforms of the same domain.
Register an entity service.
def async_register_entity_service(self, name, schema, func, required_features=None): """Register an entity service. Services will automatically be shared by all platforms of the same domain. """ if self.hass.services.has_service(self.platform_name, name): return if ...
[ "def", "async_register_entity_service", "(", "self", ",", "name", ",", "schema", ",", "func", ",", "required_features", "=", "None", ")", ":", "if", "self", ".", "hass", ".", "services", ".", "has_service", "(", "self", ".", "platform_name", ",", "name", "...
[ 562, 4 ]
[ 589, 9 ]
python
en
['en', 'en', 'en']
True
EntityPlatform._update_entity_states
(self, now: datetime)
Update the states of all the polling entities. To protect from flooding the executor, we will update async entities in parallel and other entities sequential. This method must be run in the event loop.
Update the states of all the polling entities.
async def _update_entity_states(self, now: datetime) -> None: """Update the states of all the polling entities. To protect from flooding the executor, we will update async entities in parallel and other entities sequential. This method must be run in the event loop. """ ...
[ "async", "def", "_update_entity_states", "(", "self", ",", "now", ":", "datetime", ")", "->", "None", ":", "if", "self", ".", "_process_updates", "is", "None", ":", "self", ".", "_process_updates", "=", "asyncio", ".", "Lock", "(", ")", "if", "self", "."...
[ 591, 4 ]
[ 618, 44 ]
python
en
['en', 'en', 'en']
True
_get_file
(file_path)
Get a PIL acceptable input file reference. Allows us to mock patch during testing to make BytesIO stream.
Get a PIL acceptable input file reference.
def _get_file(file_path): """Get a PIL acceptable input file reference. Allows us to mock patch during testing to make BytesIO stream. """ return file_path
[ "def", "_get_file", "(", "file_path", ")", ":", "return", "file_path" ]
[ 41, 0 ]
[ 46, 20 ]
python
en
['en', 'en', 'en']
True
_get_color
(file_handler)
Given an image file, extract the predominant color from it.
Given an image file, extract the predominant color from it.
def _get_color(file_handler) -> tuple: """Given an image file, extract the predominant color from it.""" color_thief = ColorThief(file_handler) # get_color returns a SINGLE RGB value for the given image color = color_thief.get_color(quality=1) _LOGGER.debug("Extracted RGB color %s from image", col...
[ "def", "_get_color", "(", "file_handler", ")", "->", "tuple", ":", "color_thief", "=", "ColorThief", "(", "file_handler", ")", "# get_color returns a SINGLE RGB value for the given image", "color", "=", "color_thief", ".", "get_color", "(", "quality", "=", "1", ")", ...
[ 49, 0 ]
[ 58, 16 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, hass_config)
Set up services for color_extractor integration.
Set up services for color_extractor integration.
async def async_setup(hass, hass_config): """Set up services for color_extractor integration.""" async def async_handle_service(service_call): """Decide which color_extractor method to call based on service.""" service_data = dict(service_call.data) try: if ATTR_URL in serv...
[ "async", "def", "async_setup", "(", "hass", ",", "hass_config", ")", ":", "async", "def", "async_handle_service", "(", "service_call", ")", ":", "\"\"\"Decide which color_extractor method to call based on service.\"\"\"", "service_data", "=", "dict", "(", "service_call", ...
[ 61, 0 ]
[ 148, 15 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the aREST switches.
Set up the aREST switches.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the aREST switches.""" resource = config[CONF_RESOURCE] try: response = requests.get(resource, timeout=10) except requests.exceptions.MissingSchema: _LOGGER.error( "Missing resource or schema in c...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "resource", "=", "config", "[", "CONF_RESOURCE", "]", "try", ":", "response", "=", "requests", ".", "get", "(", "resource", ",", "timeou...
[ 40, 0 ]
[ 79, 21 ]
python
en
['en', 'en', 'en']
True
ArestSwitchBase.__init__
(self, resource, location, name)
Initialize the switch.
Initialize the switch.
def __init__(self, resource, location, name): """Initialize the switch.""" self._resource = resource self._name = f"{location.title()} {name.title()}" self._state = None self._available = True
[ "def", "__init__", "(", "self", ",", "resource", ",", "location", ",", "name", ")", ":", "self", ".", "_resource", "=", "resource", "self", ".", "_name", "=", "f\"{location.title()} {name.title()}\"", "self", ".", "_state", "=", "None", "self", ".", "_availa...
[ 85, 4 ]
[ 90, 30 ]
python
en
['en', 'en', 'en']
True
ArestSwitchBase.name
(self)
Return the name of the switch.
Return the name of the switch.
def name(self): """Return the name of the switch.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 93, 4 ]
[ 95, 25 ]
python
en
['en', 'en', 'en']
True
ArestSwitchBase.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 98, 4 ]
[ 100, 26 ]
python
en
['en', 'fy', 'en']
True
ArestSwitchBase.available
(self)
Could the device be accessed during the last update call.
Could the device be accessed during the last update call.
def available(self): """Could the device be accessed during the last update call.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 103, 4 ]
[ 105, 30 ]
python
en
['en', 'en', 'en']
True
ArestSwitchFunction.__init__
(self, resource, location, name, func)
Initialize the switch.
Initialize the switch.
def __init__(self, resource, location, name, func): """Initialize the switch.""" super().__init__(resource, location, name) self._func = func request = requests.get(f"{self._resource}/{self._func}", timeout=10) if request.status_code != HTTP_OK: _LOGGER.error("Can't...
[ "def", "__init__", "(", "self", ",", "resource", ",", "location", ",", "name", ",", "func", ")", ":", "super", "(", ")", ".", "__init__", "(", "resource", ",", "location", ",", "name", ")", "self", ".", "_func", "=", "func", "request", "=", "requests...
[ 111, 4 ]
[ 127, 45 ]
python
en
['en', 'en', 'en']
True
ArestSwitchFunction.turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
def turn_on(self, **kwargs): """Turn the device on.""" request = requests.get( f"{self._resource}/{self._func}", timeout=10, params={"params": "1"} ) if request.status_code == HTTP_OK: self._state = True else: _LOGGER.error("Can't turn on func...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "request", "=", "requests", ".", "get", "(", "f\"{self._resource}/{self._func}\"", ",", "timeout", "=", "10", ",", "params", "=", "{", "\"params\"", ":", "\"1\"", "}", ")", "if", "request"...
[ 129, 4 ]
[ 138, 88 ]
python
en
['en', 'en', 'en']
True
ArestSwitchFunction.turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
def turn_off(self, **kwargs): """Turn the device off.""" request = requests.get( f"{self._resource}/{self._func}", timeout=10, params={"params": "0"} ) if request.status_code == HTTP_OK: self._state = False else: _LOGGER.error( ...
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "request", "=", "requests", ".", "get", "(", "f\"{self._resource}/{self._func}\"", ",", "timeout", "=", "10", ",", "params", "=", "{", "\"params\"", ":", "\"0\"", "}", ")", "if", "request...
[ 140, 4 ]
[ 151, 13 ]
python
en
['en', 'en', 'en']
True
ArestSwitchFunction.update
(self)
Get the latest data from aREST API and update the state.
Get the latest data from aREST API and update the state.
def update(self): """Get the latest data from aREST API and update the state.""" try: request = requests.get(f"{self._resource}/{self._func}", timeout=10) self._state = request.json()["return_value"] != 0 self._available = True except requests.exceptions.Conne...
[ "def", "update", "(", "self", ")", ":", "try", ":", "request", "=", "requests", ".", "get", "(", "f\"{self._resource}/{self._func}\"", ",", "timeout", "=", "10", ")", "self", ".", "_state", "=", "request", ".", "json", "(", ")", "[", "\"return_value\"", ...
[ 153, 4 ]
[ 161, 35 ]
python
en
['en', 'en', 'en']
True
ArestSwitchPin.__init__
(self, resource, location, name, pin, invert)
Initialize the switch.
Initialize the switch.
def __init__(self, resource, location, name, pin, invert): """Initialize the switch.""" super().__init__(resource, location, name) self._pin = pin self.invert = invert request = requests.get(f"{self._resource}/mode/{self._pin}/o", timeout=10) if request.status_code != HT...
[ "def", "__init__", "(", "self", ",", "resource", ",", "location", ",", "name", ",", "pin", ",", "invert", ")", ":", "super", "(", ")", ".", "__init__", "(", "resource", ",", "location", ",", "name", ")", "self", ".", "_pin", "=", "pin", "self", "."...
[ 167, 4 ]
[ 176, 35 ]
python
en
['en', 'en', 'en']
True
ArestSwitchPin.turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
def turn_on(self, **kwargs): """Turn the device on.""" turn_on_payload = int(not self.invert) request = requests.get( f"{self._resource}/digital/{self._pin}/{turn_on_payload}", timeout=10 ) if request.status_code == HTTP_OK: self._state = True else...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "turn_on_payload", "=", "int", "(", "not", "self", ".", "invert", ")", "request", "=", "requests", ".", "get", "(", "f\"{self._resource}/digital/{self._pin}/{turn_on_payload}\"", ",", "timeout", ...
[ 178, 4 ]
[ 187, 82 ]
python
en
['en', 'en', 'en']
True
ArestSwitchPin.turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
def turn_off(self, **kwargs): """Turn the device off.""" turn_off_payload = int(self.invert) request = requests.get( f"{self._resource}/digital/{self._pin}/{turn_off_payload}", timeout=10 ) if request.status_code == HTTP_OK: self._state = False els...
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "turn_off_payload", "=", "int", "(", "self", ".", "invert", ")", "request", "=", "requests", ".", "get", "(", "f\"{self._resource}/digital/{self._pin}/{turn_off_payload}\"", ",", "timeout", "=", ...
[ 189, 4 ]
[ 198, 83 ]
python
en
['en', 'en', 'en']
True
ArestSwitchPin.update
(self)
Get the latest data from aREST API and update the state.
Get the latest data from aREST API and update the state.
def update(self): """Get the latest data from aREST API and update the state.""" try: request = requests.get(f"{self._resource}/digital/{self._pin}", timeout=10) status_value = int(self.invert) self._state = request.json()["return_value"] != status_value s...
[ "def", "update", "(", "self", ")", ":", "try", ":", "request", "=", "requests", ".", "get", "(", "f\"{self._resource}/digital/{self._pin}\"", ",", "timeout", "=", "10", ")", "status_value", "=", "int", "(", "self", ".", "invert", ")", "self", ".", "_state"...
[ 200, 4 ]
[ 209, 35 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
( hass, hass_config, async_add_entities, discovery_info=None )
Set up the LCN sensor platform.
Set up the LCN sensor platform.
async def async_setup_platform( hass, hass_config, async_add_entities, discovery_info=None ): """Set up the LCN sensor platform.""" if discovery_info is None: return devices = [] for config in discovery_info: address, connection_id = config[CONF_ADDRESS] addr = pypck.lcn_add...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "hass_config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "devices", "=", "[", "]", "for", "config", "in", "discovery_i...
[ 19, 0 ]
[ 41, 31 ]
python
en
['en', 'da', 'en']
True
LcnVariableSensor.__init__
(self, config, address_connection)
Initialize the LCN sensor.
Initialize the LCN sensor.
def __init__(self, config, address_connection): """Initialize the LCN sensor.""" super().__init__(config, address_connection) self.variable = pypck.lcn_defs.Var[config[CONF_SOURCE]] self.unit = pypck.lcn_defs.VarUnit.parse(config[CONF_UNIT_OF_MEASUREMENT]) self._value = None
[ "def", "__init__", "(", "self", ",", "config", ",", "address_connection", ")", ":", "super", "(", ")", ".", "__init__", "(", "config", ",", "address_connection", ")", "self", ".", "variable", "=", "pypck", ".", "lcn_defs", ".", "Var", "[", "config", "[",...
[ 47, 4 ]
[ 54, 26 ]
python
en
['en', 'fy', 'en']
True
LcnVariableSensor.async_added_to_hass
(self)
Run when entity about to be added to hass.
Run when entity about to be added to hass.
async def async_added_to_hass(self): """Run when entity about to be added to hass.""" await super().async_added_to_hass() await self.address_connection.activate_status_request_handler(self.variable)
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "await", "self", ".", "address_connection", ".", "activate_status_request_handler", "(", "self", ".", "variable", ")" ]
[ 56, 4 ]
[ 59, 84 ]
python
en
['en', 'en', 'en']
True