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
SerialSensor.serial_read
( self, device, baudrate, bytesize, parity, stopbits, xonxoff, rtscts, dsrdtr, **kwargs, )
Read the data from the port.
Read the data from the port.
async def serial_read( self, device, baudrate, bytesize, parity, stopbits, xonxoff, rtscts, dsrdtr, **kwargs, ): """Read the data from the port.""" logged_error = False while True: try: ...
[ "async", "def", "serial_read", "(", "self", ",", "device", ",", "baudrate", ",", "bytesize", ",", "parity", ",", "stopbits", ",", "xonxoff", ",", "rtscts", ",", "dsrdtr", ",", "*", "*", "kwargs", ",", ")", ":", "logged_error", "=", "False", "while", "T...
[ 151, 4 ]
[ 217, 51 ]
python
en
['en', 'en', 'en']
True
SerialSensor._handle_error
(self)
Handle error for serial connection.
Handle error for serial connection.
async def _handle_error(self): """Handle error for serial connection.""" self._state = None self._attributes = None self.async_write_ha_state() await asyncio.sleep(5)
[ "async", "def", "_handle_error", "(", "self", ")", ":", "self", ".", "_state", "=", "None", "self", ".", "_attributes", "=", "None", "self", ".", "async_write_ha_state", "(", ")", "await", "asyncio", ".", "sleep", "(", "5", ")" ]
[ 219, 4 ]
[ 224, 30 ]
python
en
['da', 'en', 'en']
True
SerialSensor.stop_serial_read
(self, event)
Close resources.
Close resources.
def stop_serial_read(self, event): """Close resources.""" if self._serial_loop_task: self._serial_loop_task.cancel()
[ "def", "stop_serial_read", "(", "self", ",", "event", ")", ":", "if", "self", ".", "_serial_loop_task", ":", "self", ".", "_serial_loop_task", ".", "cancel", "(", ")" ]
[ 227, 4 ]
[ 230, 43 ]
python
en
['en', 'la', 'en']
False
SerialSensor.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" ]
[ 233, 4 ]
[ 235, 25 ]
python
en
['en', 'mi', 'en']
True
SerialSensor.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 238, 4 ]
[ 240, 20 ]
python
en
['en', 'en', 'en']
True
SerialSensor.device_state_attributes
(self)
Return the attributes of the entity (if any JSON present).
Return the attributes of the entity (if any JSON present).
def device_state_attributes(self): """Return the attributes of the entity (if any JSON present).""" return self._attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_attributes" ]
[ 243, 4 ]
[ 245, 31 ]
python
en
['en', 'en', 'en']
True
SerialSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 248, 4 ]
[ 250, 26 ]
python
en
['en', 'en', 'en']
True
serialize_cls
(cls)
To create an serializable class.
To create an serializable class.
def serialize_cls(cls): """ To create an serializable class. """ return _create_wrapper_cls(cls)
[ "def", "serialize_cls", "(", "cls", ")", ":", "return", "_create_wrapper_cls", "(", "cls", ")" ]
[ 122, 0 ]
[ 126, 35 ]
python
en
['en', 'error', 'th']
False
transparent_serialize
(cls)
Wrap a module but does not record parameters. For internal use only.
Wrap a module but does not record parameters. For internal use only.
def transparent_serialize(cls): """ Wrap a module but does not record parameters. For internal use only. """ return _create_wrapper_cls(cls, store_init_parameters=False)
[ "def", "transparent_serialize", "(", "cls", ")", ":", "return", "_create_wrapper_cls", "(", "cls", ",", "store_init_parameters", "=", "False", ")" ]
[ 129, 0 ]
[ 133, 64 ]
python
en
['en', 'error', 'th']
False
serialize
(cls, *args, **kwargs)
To create an serializable instance inline without decorator. For example, .. code-block:: python self.op = serialize(MyCustomOp, hidden_units=128)
To create an serializable instance inline without decorator. For example,
def serialize(cls, *args, **kwargs): """ To create an serializable instance inline without decorator. For example, .. code-block:: python self.op = serialize(MyCustomOp, hidden_units=128) """ return serialize_cls(cls)(*args, **kwargs)
[ "def", "serialize", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "serialize_cls", "(", "cls", ")", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 136, 0 ]
[ 143, 46 ]
python
en
['en', 'error', 'th']
False
basic_unit
(cls)
To wrap a module as a basic unit, to stop it from parsing and make it mutate-able.
To wrap a module as a basic unit, to stop it from parsing and make it mutate-able.
def basic_unit(cls): """ To wrap a module as a basic unit, to stop it from parsing and make it mutate-able. """ import torch.nn as nn assert issubclass(cls, nn.Module), 'When using @basic_unit, the class must be a subclass of nn.Module.' return serialize_cls(cls)
[ "def", "basic_unit", "(", "cls", ")", ":", "import", "torch", ".", "nn", "as", "nn", "assert", "issubclass", "(", "cls", ",", "nn", ".", "Module", ")", ",", "'When using @basic_unit, the class must be a subclass of nn.Module.'", "return", "serialize_cls", "(", "cl...
[ 146, 0 ]
[ 152, 29 ]
python
en
['en', 'error', 'th']
False
model_wrapper
(cls)
Wrap the model if you are using pure-python execution engine. The wrapper serves two purposes: 1. Capture the init parameters of python class so that it can be re-instantiated in another process. 2. Reset uid in `mutation` namespace so that each model counts from zero. Can be useful in unitte...
Wrap the model if you are using pure-python execution engine.
def model_wrapper(cls): """ Wrap the model if you are using pure-python execution engine. The wrapper serves two purposes: 1. Capture the init parameters of python class so that it can be re-instantiated in another process. 2. Reset uid in `mutation` namespace so that each model counts fro...
[ "def", "model_wrapper", "(", "cls", ")", ":", "return", "_create_wrapper_cls", "(", "cls", ",", "reset_mutation_uid", "=", "True", ")" ]
[ 155, 0 ]
[ 164, 60 ]
python
en
['en', 'error', 'th']
False
async_get_service
(hass, config, discovery_info=None)
Return the notify service.
Return the notify service.
async def async_get_service(hass, config, discovery_info=None): """Return the notify service.""" client = hass.data[DOMAIN] return KebaNotificationService(client)
[ "async", "def", "async_get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "client", "=", "hass", ".", "data", "[", "DOMAIN", "]", "return", "KebaNotificationService", "(", "client", ")" ]
[ 6, 0 ]
[ 10, 42 ]
python
en
['en', 'en', 'en']
True
KebaNotificationService.__init__
(self, client)
Initialize the service.
Initialize the service.
def __init__(self, client): """Initialize the service.""" self._client = client
[ "def", "__init__", "(", "self", ",", "client", ")", ":", "self", ".", "_client", "=", "client" ]
[ 16, 4 ]
[ 18, 29 ]
python
en
['en', 'en', 'en']
True
KebaNotificationService.async_send_message
(self, message="", **kwargs)
Send the message.
Send the message.
async def async_send_message(self, message="", **kwargs): """Send the message.""" text = message.replace(" ", "$") # Will be translated back by the display data = kwargs[ATTR_DATA] or {} min_time = float(data.get("min_time", 2)) max_time = float(data.get("max_time", 10)) ...
[ "async", "def", "async_send_message", "(", "self", ",", "message", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "text", "=", "message", ".", "replace", "(", "\" \"", ",", "\"$\"", ")", "# Will be translated back by the display", "data", "=", "kwargs", "["...
[ 20, 4 ]
[ 28, 61 ]
python
en
['en', 'en', 'en']
True
async_register
( hass: HomeAssistant, register: system_health.SystemHealthRegistration )
Register system health callbacks.
Register system health callbacks.
def async_register( hass: HomeAssistant, register: system_health.SystemHealthRegistration ) -> None: """Register system health callbacks.""" register.async_register_info(system_health_info, "/config/lovelace")
[ "def", "async_register", "(", "hass", ":", "HomeAssistant", ",", "register", ":", "system_health", ".", "SystemHealthRegistration", ")", "->", "None", ":", "register", ".", "async_register_info", "(", "system_health_info", ",", "\"/config/lovelace\"", ")" ]
[ 8, 0 ]
[ 12, 72 ]
python
en
['en', 'sv', 'en']
True
system_health_info
(hass)
Get info for the info page.
Get info for the info page.
async def system_health_info(hass): """Get info for the info page.""" health_info = {"dashboards": len(hass.data[DOMAIN]["dashboards"])} health_info.update(await hass.data[DOMAIN]["dashboards"][None].async_get_info()) health_info.update(await hass.data[DOMAIN]["resources"].async_get_info()) return h...
[ "async", "def", "system_health_info", "(", "hass", ")", ":", "health_info", "=", "{", "\"dashboards\"", ":", "len", "(", "hass", ".", "data", "[", "DOMAIN", "]", "[", "\"dashboards\"", "]", ")", "}", "health_info", ".", "update", "(", "await", "hass", "....
[ 15, 0 ]
[ 20, 22 ]
python
en
['en', 'en', 'en']
True
test_invalid_units
()
Test errors are raised when invalid units are passed in.
Test errors are raised when invalid units are passed in.
def test_invalid_units(): """Test errors are raised when invalid units are passed in.""" with pytest.raises(ValueError): UnitSystem( SYSTEM_NAME, INVALID_UNIT, LENGTH_METERS, VOLUME_LITERS, MASS_GRAMS, PRESSURE_PA, ) wi...
[ "def", "test_invalid_units", "(", ")", ":", "with", "pytest", ".", "raises", "(", "ValueError", ")", ":", "UnitSystem", "(", "SYSTEM_NAME", ",", "INVALID_UNIT", ",", "LENGTH_METERS", ",", "VOLUME_LITERS", ",", "MASS_GRAMS", ",", "PRESSURE_PA", ",", ")", "with"...
[ 22, 0 ]
[ 72, 9 ]
python
en
['en', 'en', 'en']
True
test_invalid_value
()
Test no conversion happens if value is non-numeric.
Test no conversion happens if value is non-numeric.
def test_invalid_value(): """Test no conversion happens if value is non-numeric.""" with pytest.raises(TypeError): METRIC_SYSTEM.length("25a", LENGTH_KILOMETERS) with pytest.raises(TypeError): METRIC_SYSTEM.temperature("50K", TEMP_CELSIUS) with pytest.raises(TypeError): METRIC_SY...
[ "def", "test_invalid_value", "(", ")", ":", "with", "pytest", ".", "raises", "(", "TypeError", ")", ":", "METRIC_SYSTEM", ".", "length", "(", "\"25a\"", ",", "LENGTH_KILOMETERS", ")", "with", "pytest", ".", "raises", "(", "TypeError", ")", ":", "METRIC_SYSTE...
[ 75, 0 ]
[ 84, 51 ]
python
en
['en', 'en', 'en']
True
test_as_dict
()
Test that the as_dict() method returns the expected dictionary.
Test that the as_dict() method returns the expected dictionary.
def test_as_dict(): """Test that the as_dict() method returns the expected dictionary.""" expected = { LENGTH: LENGTH_KILOMETERS, TEMPERATURE: TEMP_CELSIUS, VOLUME: VOLUME_LITERS, MASS: MASS_GRAMS, PRESSURE: PRESSURE_PA, } assert expected == METRIC_SYSTEM.as_dict...
[ "def", "test_as_dict", "(", ")", ":", "expected", "=", "{", "LENGTH", ":", "LENGTH_KILOMETERS", ",", "TEMPERATURE", ":", "TEMP_CELSIUS", ",", "VOLUME", ":", "VOLUME_LITERS", ",", "MASS", ":", "MASS_GRAMS", ",", "PRESSURE", ":", "PRESSURE_PA", ",", "}", "asse...
[ 87, 0 ]
[ 97, 46 ]
python
en
['en', 'en', 'en']
True
test_temperature_same_unit
()
Test no conversion happens if to unit is same as from unit.
Test no conversion happens if to unit is same as from unit.
def test_temperature_same_unit(): """Test no conversion happens if to unit is same as from unit.""" assert METRIC_SYSTEM.temperature(5, METRIC_SYSTEM.temperature_unit) == 5
[ "def", "test_temperature_same_unit", "(", ")", ":", "assert", "METRIC_SYSTEM", ".", "temperature", "(", "5", ",", "METRIC_SYSTEM", ".", "temperature_unit", ")", "==", "5" ]
[ 100, 0 ]
[ 102, 76 ]
python
en
['en', 'en', 'en']
True
test_temperature_unknown_unit
()
Test no conversion happens if unknown unit.
Test no conversion happens if unknown unit.
def test_temperature_unknown_unit(): """Test no conversion happens if unknown unit.""" with pytest.raises(ValueError): METRIC_SYSTEM.temperature(5, "K")
[ "def", "test_temperature_unknown_unit", "(", ")", ":", "with", "pytest", ".", "raises", "(", "ValueError", ")", ":", "METRIC_SYSTEM", ".", "temperature", "(", "5", ",", "\"K\"", ")" ]
[ 105, 0 ]
[ 108, 41 ]
python
en
['en', 'fr', 'en']
True
test_temperature_to_metric
()
Test temperature conversion to metric system.
Test temperature conversion to metric system.
def test_temperature_to_metric(): """Test temperature conversion to metric system.""" assert METRIC_SYSTEM.temperature(25, METRIC_SYSTEM.temperature_unit) == 25 assert ( round(METRIC_SYSTEM.temperature(80, IMPERIAL_SYSTEM.temperature_unit), 1) == 26.7 )
[ "def", "test_temperature_to_metric", "(", ")", ":", "assert", "METRIC_SYSTEM", ".", "temperature", "(", "25", ",", "METRIC_SYSTEM", ".", "temperature_unit", ")", "==", "25", "assert", "(", "round", "(", "METRIC_SYSTEM", ".", "temperature", "(", "80", ",", "IMP...
[ 111, 0 ]
[ 117, 5 ]
python
en
['en', 'en', 'en']
True
test_temperature_to_imperial
()
Test temperature conversion to imperial system.
Test temperature conversion to imperial system.
def test_temperature_to_imperial(): """Test temperature conversion to imperial system.""" assert IMPERIAL_SYSTEM.temperature(77, IMPERIAL_SYSTEM.temperature_unit) == 77 assert IMPERIAL_SYSTEM.temperature(25, METRIC_SYSTEM.temperature_unit) == 77
[ "def", "test_temperature_to_imperial", "(", ")", ":", "assert", "IMPERIAL_SYSTEM", ".", "temperature", "(", "77", ",", "IMPERIAL_SYSTEM", ".", "temperature_unit", ")", "==", "77", "assert", "IMPERIAL_SYSTEM", ".", "temperature", "(", "25", ",", "METRIC_SYSTEM", "....
[ 120, 0 ]
[ 123, 80 ]
python
en
['en', 'en', 'en']
True
test_length_unknown_unit
()
Test length conversion with unknown from unit.
Test length conversion with unknown from unit.
def test_length_unknown_unit(): """Test length conversion with unknown from unit.""" with pytest.raises(ValueError): METRIC_SYSTEM.length(5, "fr")
[ "def", "test_length_unknown_unit", "(", ")", ":", "with", "pytest", ".", "raises", "(", "ValueError", ")", ":", "METRIC_SYSTEM", ".", "length", "(", "5", ",", "\"fr\"", ")" ]
[ 126, 0 ]
[ 129, 37 ]
python
en
['en', 'en', 'en']
True
test_length_to_metric
()
Test length conversion to metric system.
Test length conversion to metric system.
def test_length_to_metric(): """Test length conversion to metric system.""" assert METRIC_SYSTEM.length(100, METRIC_SYSTEM.length_unit) == 100 assert METRIC_SYSTEM.length(5, IMPERIAL_SYSTEM.length_unit) == 8.04672
[ "def", "test_length_to_metric", "(", ")", ":", "assert", "METRIC_SYSTEM", ".", "length", "(", "100", ",", "METRIC_SYSTEM", ".", "length_unit", ")", "==", "100", "assert", "METRIC_SYSTEM", ".", "length", "(", "5", ",", "IMPERIAL_SYSTEM", ".", "length_unit", ")"...
[ 132, 0 ]
[ 135, 74 ]
python
en
['en', 'en', 'en']
True
test_length_to_imperial
()
Test length conversion to imperial system.
Test length conversion to imperial system.
def test_length_to_imperial(): """Test length conversion to imperial system.""" assert IMPERIAL_SYSTEM.length(100, IMPERIAL_SYSTEM.length_unit) == 100 assert IMPERIAL_SYSTEM.length(5, METRIC_SYSTEM.length_unit) == 3.106855
[ "def", "test_length_to_imperial", "(", ")", ":", "assert", "IMPERIAL_SYSTEM", ".", "length", "(", "100", ",", "IMPERIAL_SYSTEM", ".", "length_unit", ")", "==", "100", "assert", "IMPERIAL_SYSTEM", ".", "length", "(", "5", ",", "METRIC_SYSTEM", ".", "length_unit",...
[ 138, 0 ]
[ 141, 75 ]
python
en
['en', 'en', 'en']
True
test_pressure_same_unit
()
Test no conversion happens if to unit is same as from unit.
Test no conversion happens if to unit is same as from unit.
def test_pressure_same_unit(): """Test no conversion happens if to unit is same as from unit.""" assert METRIC_SYSTEM.pressure(5, METRIC_SYSTEM.pressure_unit) == 5
[ "def", "test_pressure_same_unit", "(", ")", ":", "assert", "METRIC_SYSTEM", ".", "pressure", "(", "5", ",", "METRIC_SYSTEM", ".", "pressure_unit", ")", "==", "5" ]
[ 144, 0 ]
[ 146, 70 ]
python
en
['en', 'en', 'en']
True
test_pressure_unknown_unit
()
Test no conversion happens if unknown unit.
Test no conversion happens if unknown unit.
def test_pressure_unknown_unit(): """Test no conversion happens if unknown unit.""" with pytest.raises(ValueError): METRIC_SYSTEM.pressure(5, "K")
[ "def", "test_pressure_unknown_unit", "(", ")", ":", "with", "pytest", ".", "raises", "(", "ValueError", ")", ":", "METRIC_SYSTEM", ".", "pressure", "(", "5", ",", "\"K\"", ")" ]
[ 149, 0 ]
[ 152, 38 ]
python
en
['en', 'fr', 'en']
True
test_pressure_to_metric
()
Test pressure conversion to metric system.
Test pressure conversion to metric system.
def test_pressure_to_metric(): """Test pressure conversion to metric system.""" assert METRIC_SYSTEM.pressure(25, METRIC_SYSTEM.pressure_unit) == 25 assert METRIC_SYSTEM.pressure(14.7, IMPERIAL_SYSTEM.pressure_unit) == pytest.approx( 101352.932, abs=1e-1 )
[ "def", "test_pressure_to_metric", "(", ")", ":", "assert", "METRIC_SYSTEM", ".", "pressure", "(", "25", ",", "METRIC_SYSTEM", ".", "pressure_unit", ")", "==", "25", "assert", "METRIC_SYSTEM", ".", "pressure", "(", "14.7", ",", "IMPERIAL_SYSTEM", ".", "pressure_u...
[ 155, 0 ]
[ 160, 5 ]
python
en
['en', 'en', 'en']
True
test_pressure_to_imperial
()
Test pressure conversion to imperial system.
Test pressure conversion to imperial system.
def test_pressure_to_imperial(): """Test pressure conversion to imperial system.""" assert IMPERIAL_SYSTEM.pressure(77, IMPERIAL_SYSTEM.pressure_unit) == 77 assert IMPERIAL_SYSTEM.pressure( 101352.932, METRIC_SYSTEM.pressure_unit ) == pytest.approx(14.7, abs=1e-4)
[ "def", "test_pressure_to_imperial", "(", ")", ":", "assert", "IMPERIAL_SYSTEM", ".", "pressure", "(", "77", ",", "IMPERIAL_SYSTEM", ".", "pressure_unit", ")", "==", "77", "assert", "IMPERIAL_SYSTEM", ".", "pressure", "(", "101352.932", ",", "METRIC_SYSTEM", ".", ...
[ 163, 0 ]
[ 168, 38 ]
python
en
['en', 'en', 'en']
True
test_properties
()
Test the unit properties are returned as expected.
Test the unit properties are returned as expected.
def test_properties(): """Test the unit properties are returned as expected.""" assert LENGTH_KILOMETERS == METRIC_SYSTEM.length_unit assert TEMP_CELSIUS == METRIC_SYSTEM.temperature_unit assert MASS_GRAMS == METRIC_SYSTEM.mass_unit assert VOLUME_LITERS == METRIC_SYSTEM.volume_unit assert PRESSU...
[ "def", "test_properties", "(", ")", ":", "assert", "LENGTH_KILOMETERS", "==", "METRIC_SYSTEM", ".", "length_unit", "assert", "TEMP_CELSIUS", "==", "METRIC_SYSTEM", ".", "temperature_unit", "assert", "MASS_GRAMS", "==", "METRIC_SYSTEM", ".", "mass_unit", "assert", "VOL...
[ 171, 0 ]
[ 177, 53 ]
python
en
['en', 'en', 'en']
True
test_is_metric
()
Test the is metric flag.
Test the is metric flag.
def test_is_metric(): """Test the is metric flag.""" assert METRIC_SYSTEM.is_metric assert not IMPERIAL_SYSTEM.is_metric
[ "def", "test_is_metric", "(", ")", ":", "assert", "METRIC_SYSTEM", ".", "is_metric", "assert", "not", "IMPERIAL_SYSTEM", ".", "is_metric" ]
[ 180, 0 ]
[ 183, 40 ]
python
en
['en', 'en', 'en']
True
validate_input
(hass: core.HomeAssistant, data)
Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user.
Validate the user input allows us to connect.
async def validate_input(hass: core.HomeAssistant, data): """Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user. """ username = data[CONF_USERNAME] password = data[CONF_PASSWORD] client_id = data[CONF_CLIENT_ID] client_secret = ...
[ "async", "def", "validate_input", "(", "hass", ":", "core", ".", "HomeAssistant", ",", "data", ")", ":", "username", "=", "data", "[", "CONF_USERNAME", "]", "password", "=", "data", "[", "CONF_PASSWORD", "]", "client_id", "=", "data", "[", "CONF_CLIENT_ID", ...
[ 36, 0 ]
[ 67, 30 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" errors = {} if user_input is not None: await self.async_set_unique_id(user_input[CONF_USERNAME]) self._abort_if_unique_id_configured() try: info = await validate_...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "await", "self", ".", "async_set_unique_id", "(", "user_input", "[", "CONF_USERNAME", "]", ")",...
[ 76, 4 ]
[ 96, 9 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_step_import
(self, user_input)
Handle import.
Handle import.
async def async_step_import(self, user_input): """Handle import.""" return await self.async_step_user(user_input)
[ "async", "def", "async_step_import", "(", "self", ",", "user_input", ")", ":", "return", "await", "self", ".", "async_step_user", "(", "user_input", ")" ]
[ 98, 4 ]
[ 100, 53 ]
python
en
['en', 'ja', 'en']
False
test_abort_if_no_implementation_registered
(hass)
Test we abort if no implementation is registered.
Test we abort if no implementation is registered.
async def test_abort_if_no_implementation_registered(hass): """Test we abort if no implementation is registered.""" flow = config_flow.NestFlowHandler() flow.hass = hass result = await flow.async_step_init() assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["reason"] == "...
[ "async", "def", "test_abort_if_no_implementation_registered", "(", "hass", ")", ":", "flow", "=", "config_flow", ".", "NestFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "result", "=", "await", "flow", ".", "async_step_init", "(", ")", "assert", "re...
[ 12, 0 ]
[ 19, 54 ]
python
en
['en', 'en', 'en']
True
test_abort_if_single_instance_allowed
(hass)
Test we abort if Nest is already setup.
Test we abort if Nest is already setup.
async def test_abort_if_single_instance_allowed(hass): """Test we abort if Nest is already setup.""" flow = config_flow.NestFlowHandler() flow.hass = hass with patch.object(hass.config_entries, "async_entries", return_value=[{}]): result = await flow.async_step_init() assert result["type"]...
[ "async", "def", "test_abort_if_single_instance_allowed", "(", "hass", ")", ":", "flow", "=", "config_flow", ".", "NestFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "with", "patch", ".", "object", "(", "hass", ".", "config_entries", ",", "\"async_en...
[ 22, 0 ]
[ 31, 56 ]
python
en
['en', 'zu', 'en']
True
test_full_flow_implementation
(hass)
Test registering an implementation and finishing flow works.
Test registering an implementation and finishing flow works.
async def test_full_flow_implementation(hass): """Test registering an implementation and finishing flow works.""" gen_authorize_url = AsyncMock(return_value="https://example.com") convert_code = AsyncMock(return_value={"access_token": "yoo"}) config_flow.register_flow_implementation( hass, "test...
[ "async", "def", "test_full_flow_implementation", "(", "hass", ")", ":", "gen_authorize_url", "=", "AsyncMock", "(", "return_value", "=", "\"https://example.com\"", ")", "convert_code", "=", "AsyncMock", "(", "return_value", "=", "{", "\"access_token\"", ":", "\"yoo\""...
[ 34, 0 ]
[ 60, 47 ]
python
en
['en', 'en', 'en']
True
test_not_pick_implementation_if_only_one
(hass)
Test we allow picking implementation if we have two.
Test we allow picking implementation if we have two.
async def test_not_pick_implementation_if_only_one(hass): """Test we allow picking implementation if we have two.""" gen_authorize_url = AsyncMock(return_value="https://example.com") config_flow.register_flow_implementation( hass, "test", "Test", gen_authorize_url, None ) flow = config_flow...
[ "async", "def", "test_not_pick_implementation_if_only_one", "(", "hass", ")", ":", "gen_authorize_url", "=", "AsyncMock", "(", "return_value", "=", "\"https://example.com\"", ")", "config_flow", ".", "register_flow_implementation", "(", "hass", ",", "\"test\"", ",", "\"...
[ 63, 0 ]
[ 74, 38 ]
python
en
['en', 'en', 'en']
True
test_abort_if_timeout_generating_auth_url
(hass)
Test we abort if generating authorize url fails.
Test we abort if generating authorize url fails.
async def test_abort_if_timeout_generating_auth_url(hass): """Test we abort if generating authorize url fails.""" gen_authorize_url = Mock(side_effect=asyncio.TimeoutError) config_flow.register_flow_implementation( hass, "test", "Test", gen_authorize_url, None ) flow = config_flow.NestFlowH...
[ "async", "def", "test_abort_if_timeout_generating_auth_url", "(", "hass", ")", ":", "gen_authorize_url", "=", "Mock", "(", "side_effect", "=", "asyncio", ".", "TimeoutError", ")", "config_flow", ".", "register_flow_implementation", "(", "hass", ",", "\"test\"", ",", ...
[ 77, 0 ]
[ 88, 54 ]
python
en
['en', 'zu', 'en']
True
test_abort_if_exception_generating_auth_url
(hass)
Test we abort if generating authorize url blows up.
Test we abort if generating authorize url blows up.
async def test_abort_if_exception_generating_auth_url(hass): """Test we abort if generating authorize url blows up.""" gen_authorize_url = Mock(side_effect=ValueError) config_flow.register_flow_implementation( hass, "test", "Test", gen_authorize_url, None ) flow = config_flow.NestFlowHandle...
[ "async", "def", "test_abort_if_exception_generating_auth_url", "(", "hass", ")", ":", "gen_authorize_url", "=", "Mock", "(", "side_effect", "=", "ValueError", ")", "config_flow", ".", "register_flow_implementation", "(", "hass", ",", "\"test\"", ",", "\"Test\"", ",", ...
[ 91, 0 ]
[ 102, 51 ]
python
en
['de', 'en', 'en']
True
test_verify_code_timeout
(hass)
Test verify code timing out.
Test verify code timing out.
async def test_verify_code_timeout(hass): """Test verify code timing out.""" gen_authorize_url = AsyncMock(return_value="https://example.com") convert_code = Mock(side_effect=asyncio.TimeoutError) config_flow.register_flow_implementation( hass, "test", "Test", gen_authorize_url, convert_code ...
[ "async", "def", "test_verify_code_timeout", "(", "hass", ")", ":", "gen_authorize_url", "=", "AsyncMock", "(", "return_value", "=", "\"https://example.com\"", ")", "convert_code", "=", "Mock", "(", "side_effect", "=", "asyncio", ".", "TimeoutError", ")", "config_flo...
[ 105, 0 ]
[ 122, 50 ]
python
en
['en', 'en', 'en']
True
test_verify_code_invalid
(hass)
Test verify code invalid.
Test verify code invalid.
async def test_verify_code_invalid(hass): """Test verify code invalid.""" gen_authorize_url = AsyncMock(return_value="https://example.com") convert_code = Mock(side_effect=config_flow.CodeInvalid) config_flow.register_flow_implementation( hass, "test", "Test", gen_authorize_url, convert_code ...
[ "async", "def", "test_verify_code_invalid", "(", "hass", ")", ":", "gen_authorize_url", "=", "AsyncMock", "(", "return_value", "=", "\"https://example.com\"", ")", "convert_code", "=", "Mock", "(", "side_effect", "=", "config_flow", ".", "CodeInvalid", ")", "config_...
[ 125, 0 ]
[ 142, 54 ]
python
en
['en', 'sk', 'en']
True
test_verify_code_unknown_error
(hass)
Test verify code unknown error.
Test verify code unknown error.
async def test_verify_code_unknown_error(hass): """Test verify code unknown error.""" gen_authorize_url = AsyncMock(return_value="https://example.com") convert_code = Mock(side_effect=config_flow.NestAuthError) config_flow.register_flow_implementation( hass, "test", "Test", gen_authorize_url, co...
[ "async", "def", "test_verify_code_unknown_error", "(", "hass", ")", ":", "gen_authorize_url", "=", "AsyncMock", "(", "return_value", "=", "\"https://example.com\"", ")", "convert_code", "=", "Mock", "(", "side_effect", "=", "config_flow", ".", "NestAuthError", ")", ...
[ 145, 0 ]
[ 162, 50 ]
python
en
['en', 'de', 'en']
True
test_verify_code_exception
(hass)
Test verify code blows up.
Test verify code blows up.
async def test_verify_code_exception(hass): """Test verify code blows up.""" gen_authorize_url = AsyncMock(return_value="https://example.com") convert_code = Mock(side_effect=ValueError) config_flow.register_flow_implementation( hass, "test", "Test", gen_authorize_url, convert_code ) fl...
[ "async", "def", "test_verify_code_exception", "(", "hass", ")", ":", "gen_authorize_url", "=", "AsyncMock", "(", "return_value", "=", "\"https://example.com\"", ")", "convert_code", "=", "Mock", "(", "side_effect", "=", "ValueError", ")", "config_flow", ".", "regist...
[ 165, 0 ]
[ 182, 57 ]
python
en
['fr', 'lb', 'en']
False
test_step_import
(hass)
Test that we trigger import when configuring with client.
Test that we trigger import when configuring with client.
async def test_step_import(hass): """Test that we trigger import when configuring with client.""" with patch("os.path.isfile", return_value=False): assert await async_setup_component( hass, DOMAIN, {DOMAIN: {"client_id": "bla", "client_secret": "bla"}} ) await hass.async_bloc...
[ "async", "def", "test_step_import", "(", "hass", ")", ":", "with", "patch", "(", "\"os.path.isfile\"", ",", "return_value", "=", "False", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"clien...
[ 185, 0 ]
[ 197, 38 ]
python
en
['en', 'en', 'en']
True
test_step_import_with_token_cache
(hass)
Test that we import existing token cache.
Test that we import existing token cache.
async def test_step_import_with_token_cache(hass): """Test that we import existing token cache.""" with patch("os.path.isfile", return_value=True), patch( "homeassistant.components.nest.config_flow.load_json", return_value={"access_token": "yo"}, ), patch( "homeassistant.components.n...
[ "async", "def", "test_step_import_with_token_cache", "(", "hass", ")", ":", "with", "patch", "(", "\"os.path.isfile\"", ",", "return_value", "=", "True", ")", ",", "patch", "(", "\"homeassistant.components.nest.config_flow.load_json\"", ",", "return_value", "=", "{", ...
[ 200, 0 ]
[ 215, 82 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the OpenEVSE sensor.
Set up the OpenEVSE sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the OpenEVSE sensor.""" host = config.get(CONF_HOST) monitored_variables = config.get(CONF_MONITORED_VARIABLES) charger = openevsewifi.Charger(host) dev = [] for variable in monitored_variables: dev.append(O...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "host", "=", "config", ".", "get", "(", "CONF_HOST", ")", "monitored_variables", "=", "config", ".", "get", "(", "CONF_MONITORED_VARIABLES",...
[ 40, 0 ]
[ 51, 27 ]
python
en
['en', 'zu', 'en']
True
OpenEVSESensor.__init__
(self, sensor_type, charger)
Initialize the sensor.
Initialize the sensor.
def __init__(self, sensor_type, charger): """Initialize the sensor.""" self._name = SENSOR_TYPES[sensor_type][0] self.type = sensor_type self._state = None self.charger = charger self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
[ "def", "__init__", "(", "self", ",", "sensor_type", ",", "charger", ")", ":", "self", ".", "_name", "=", "SENSOR_TYPES", "[", "sensor_type", "]", "[", "0", "]", "self", ".", "type", "=", "sensor_type", "self", ".", "_state", "=", "None", "self", ".", ...
[ 57, 4 ]
[ 63, 64 ]
python
en
['en', 'en', 'en']
True
OpenEVSESensor.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" ]
[ 66, 4 ]
[ 68, 25 ]
python
en
['en', 'mi', 'en']
True
OpenEVSESensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 71, 4 ]
[ 73, 26 ]
python
en
['en', 'en', 'en']
True
OpenEVSESensor.unit_of_measurement
(self)
Return the unit of measurement of this sensor.
Return the unit of measurement of this sensor.
def unit_of_measurement(self): """Return the unit of measurement of this sensor.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 76, 4 ]
[ 78, 40 ]
python
en
['en', 'id', 'en']
True
OpenEVSESensor.update
(self)
Get the monitored data from the charger.
Get the monitored data from the charger.
def update(self): """Get the monitored data from the charger.""" try: if self.type == "status": self._state = self.charger.getStatus() elif self.type == "charge_time": self._state = self.charger.getChargeTimeElapsed() / 60 elif self.typ...
[ "def", "update", "(", "self", ")", ":", "try", ":", "if", "self", ".", "type", "==", "\"status\"", ":", "self", ".", "_state", "=", "self", ".", "charger", ".", "getStatus", "(", ")", "elif", "self", ".", "type", "==", "\"charge_time\"", ":", "self",...
[ 80, 4 ]
[ 100, 72 ]
python
en
['en', 'en', 'en']
True
KaiterraApiData.__init__
(self, hass, config, session)
Initialize the API data object.
Initialize the API data object.
def __init__(self, hass, config, session): """Initialize the API data object.""" api_key = config[CONF_API_KEY] aqi_standard = config[CONF_AQI_STANDARD] devices = config[CONF_DEVICES] units = config[CONF_PREFERRED_UNITS] self._hass = hass self._api = KaiterraAPI...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ",", "session", ")", ":", "api_key", "=", "config", "[", "CONF_API_KEY", "]", "aqi_standard", "=", "config", "[", "CONF_AQI_STANDARD", "]", "devices", "=", "config", "[", "CONF_DEVICES", "]", "uni...
[ 27, 4 ]
[ 49, 22 ]
python
en
['en', 'en', 'en']
True
KaiterraApiData.async_update
(self)
Get the data from Kaiterra API.
Get the data from Kaiterra API.
async def async_update(self) -> None: """Get the data from Kaiterra API.""" try: with async_timeout.timeout(10): data = await self._api.get_latest_sensor_readings(self._devices) except (ClientResponseError, asyncio.TimeoutError): _LOGGER.debug("Couldn't f...
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":", "try", ":", "with", "async_timeout", ".", "timeout", "(", "10", ")", ":", "data", "=", "await", "self", ".", "_api", ".", "get_latest_sensor_readings", "(", "self", ".", "_devices", ")"...
[ 51, 4 ]
[ 104, 62 ]
python
en
['en', 'no', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Display the current season.
Display the current season.
def setup_platform(hass, config, add_entities, discovery_info=None): """Display the current season.""" if None in (hass.config.latitude, hass.config.longitude): _LOGGER.error("Latitude or longitude not set in Home Assistant config") return False latitude = util.convert(hass.config.latitude,...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "None", "in", "(", "hass", ".", "config", ".", "latitude", ",", "hass", ".", "config", ".", "longitude", ")", ":", "_LOGGER", ...
[ 56, 0 ]
[ 76, 15 ]
python
en
['en', 'en', 'en']
True
get_season
(date, hemisphere, season_tracking_type)
Calculate the current season.
Calculate the current season.
def get_season(date, hemisphere, season_tracking_type): """Calculate the current season.""" if hemisphere == "equator": return None if season_tracking_type == TYPE_ASTRONOMICAL: spring_start = ephem.next_equinox(str(date.year)).datetime() summer_start = ephem.next_solstice(str(date...
[ "def", "get_season", "(", "date", ",", "hemisphere", ",", "season_tracking_type", ")", ":", "if", "hemisphere", "==", "\"equator\"", ":", "return", "None", "if", "season_tracking_type", "==", "TYPE_ASTRONOMICAL", ":", "spring_start", "=", "ephem", ".", "next_equin...
[ 79, 0 ]
[ 108, 45 ]
python
en
['en', 'en', 'en']
True
Season.__init__
(self, hass, hemisphere, season_tracking_type, name)
Initialize the season.
Initialize the season.
def __init__(self, hass, hemisphere, season_tracking_type, name): """Initialize the season.""" self.hass = hass self._name = name self.hemisphere = hemisphere self.datetime = None self.type = season_tracking_type self.season = None
[ "def", "__init__", "(", "self", ",", "hass", ",", "hemisphere", ",", "season_tracking_type", ",", "name", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "_name", "=", "name", "self", ".", "hemisphere", "=", "hemisphere", "self", ".", "datetime"...
[ 114, 4 ]
[ 121, 26 ]
python
en
['en', 'en', 'en']
True
Season.name
(self)
Return the name.
Return the name.
def name(self): """Return the name.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 124, 4 ]
[ 126, 25 ]
python
en
['en', 'ig', 'en']
True
Season.state
(self)
Return the current season.
Return the current season.
def state(self): """Return the current season.""" return self.season
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "season" ]
[ 129, 4 ]
[ 131, 26 ]
python
en
['en', 'ig', 'en']
True
Season.device_class
(self)
Return the device class.
Return the device class.
def device_class(self): """Return the device class.""" return "season__season"
[ "def", "device_class", "(", "self", ")", ":", "return", "\"season__season\"" ]
[ 134, 4 ]
[ 136, 31 ]
python
en
['en', 'en', 'en']
True
Season.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return SEASON_ICONS.get(self.season, "mdi:cloud")
[ "def", "icon", "(", "self", ")", ":", "return", "SEASON_ICONS", ".", "get", "(", "self", ".", "season", ",", "\"mdi:cloud\"", ")" ]
[ 139, 4 ]
[ 141, 57 ]
python
en
['en', 'en', 'en']
True
Season.update
(self)
Update season.
Update season.
def update(self): """Update season.""" self.datetime = utcnow().replace(tzinfo=None) self.season = get_season(self.datetime, self.hemisphere, self.type)
[ "def", "update", "(", "self", ")", ":", "self", ".", "datetime", "=", "utcnow", "(", ")", ".", "replace", "(", "tzinfo", "=", "None", ")", "self", ".", "season", "=", "get_season", "(", "self", ".", "datetime", ",", "self", ".", "hemisphere", ",", ...
[ 143, 4 ]
[ 146, 75 ]
python
en
['en', 'sn', 'en']
False
async_get_triggers
(hass: HomeAssistant, device_id: str)
List device triggers for NEW_NAME devices.
List device triggers for NEW_NAME devices.
async def async_get_triggers(hass: HomeAssistant, device_id: str) -> List[dict]: """List device triggers for NEW_NAME devices.""" registry = await entity_registry.async_get_registry(hass) triggers = [] # TODO Read this comment and remove it. # This example shows how to iterate over the entities of ...
[ "async", "def", "async_get_triggers", "(", "hass", ":", "HomeAssistant", ",", "device_id", ":", "str", ")", "->", "List", "[", "dict", "]", ":", "registry", "=", "await", "entity_registry", ".", "async_get_registry", "(", "hass", ")", "triggers", "=", "[", ...
[ 34, 0 ]
[ 72, 19 ]
python
en
['fr', 'en', 'en']
True
async_attach_trigger
( hass: HomeAssistant, config: ConfigType, action: AutomationActionType, automation_info: dict, )
Attach a trigger.
Attach a trigger.
async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, action: AutomationActionType, automation_info: dict, ) -> CALLBACK_TYPE: """Attach a trigger.""" config = TRIGGER_SCHEMA(config) # TODO Implement your own logic to attach triggers. # Generally we suggest to re-use ...
[ "async", "def", "async_attach_trigger", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ",", "action", ":", "AutomationActionType", ",", "automation_info", ":", "dict", ",", ")", "->", "CALLBACK_TYPE", ":", "config", "=", "TRIGGER_SCHEMA", "...
[ 75, 0 ]
[ 104, 5 ]
python
en
['en', 'lb', 'en']
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", ")" ]
[ 25, 0 ]
[ 27, 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", ")" ]
[ 31, 0 ]
[ 33, 30 ]
python
en
['en', 'fy', 'en']
True
test_subscribing_config_topic
(hass, mqtt_mock)
Test setting up discovery.
Test setting up discovery.
async def test_subscribing_config_topic(hass, mqtt_mock): """Test setting up discovery.""" entry = hass.config_entries.async_entries(mqtt.DOMAIN)[0] discovery_topic = "homeassistant" await async_start(hass, discovery_topic, entry) assert mqtt_mock.async_subscribe.called call_args = mqtt_mock.a...
[ "async", "def", "test_subscribing_config_topic", "(", "hass", ",", "mqtt_mock", ")", ":", "entry", "=", "hass", ".", "config_entries", ".", "async_entries", "(", "mqtt", ".", "DOMAIN", ")", "[", "0", "]", "discovery_topic", "=", "\"homeassistant\"", "await", "...
[ 40, 0 ]
[ 50, 28 ]
python
en
['en', 'en', 'en']
True
test_invalid_topic
(hass, mqtt_mock)
Test sending to invalid topic.
Test sending to invalid topic.
async def test_invalid_topic(hass, mqtt_mock): """Test sending to invalid topic.""" with patch( "homeassistant.components.mqtt.discovery.async_dispatcher_send" ) as mock_dispatcher_send: mock_dispatcher_send = AsyncMock(return_value=None) async_fire_mqtt_message( hass, "...
[ "async", "def", "test_invalid_topic", "(", "hass", ",", "mqtt_mock", ")", ":", "with", "patch", "(", "\"homeassistant.components.mqtt.discovery.async_dispatcher_send\"", ")", "as", "mock_dispatcher_send", ":", "mock_dispatcher_send", "=", "AsyncMock", "(", "return_value", ...
[ 53, 0 ]
[ 64, 46 ]
python
en
['en', 'en', 'en']
True
test_invalid_json
(hass, mqtt_mock, caplog)
Test sending in invalid JSON.
Test sending in invalid JSON.
async def test_invalid_json(hass, mqtt_mock, caplog): """Test sending in invalid JSON.""" with patch( "homeassistant.components.mqtt.discovery.async_dispatcher_send" ) as mock_dispatcher_send: mock_dispatcher_send = AsyncMock(return_value=None) async_fire_mqtt_message( ...
[ "async", "def", "test_invalid_json", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "with", "patch", "(", "\"homeassistant.components.mqtt.discovery.async_dispatcher_send\"", ")", "as", "mock_dispatcher_send", ":", "mock_dispatcher_send", "=", "AsyncMock", "(", ...
[ 67, 0 ]
[ 80, 46 ]
python
en
['en', 'da', 'en']
True
test_only_valid_components
(hass, mqtt_mock, caplog)
Test for a valid component.
Test for a valid component.
async def test_only_valid_components(hass, mqtt_mock, caplog): """Test for a valid component.""" with patch( "homeassistant.components.mqtt.discovery.async_dispatcher_send" ) as mock_dispatcher_send: invalid_component = "timer" mock_dispatcher_send = AsyncMock(return_value=None) ...
[ "async", "def", "test_only_valid_components", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "with", "patch", "(", "\"homeassistant.components.mqtt.discovery.async_dispatcher_send\"", ")", "as", "mock_dispatcher_send", ":", "invalid_component", "=", "\"timer\"", ...
[ 83, 0 ]
[ 101, 42 ]
python
en
['en', 'en', 'en']
True
test_correct_config_discovery
(hass, mqtt_mock, caplog)
Test sending in correct JSON.
Test sending in correct JSON.
async def test_correct_config_discovery(hass, mqtt_mock, caplog): """Test sending in correct JSON.""" async_fire_mqtt_message( hass, "homeassistant/binary_sensor/bla/config", '{ "name": "Beer", "state_topic": "test-topic" }', ) await hass.async_block_till_done() state = hass...
[ "async", "def", "test_correct_config_discovery", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "async_fire_mqtt_message", "(", "hass", ",", "\"homeassistant/binary_sensor/bla/config\"", ",", "'{ \"name\": \"Beer\", \"state_topic\": \"test-topic\" }'", ",", ")", "awa...
[ 104, 0 ]
[ 117, 68 ]
python
en
['en', 'da', 'en']
True
test_discover_fan
(hass, mqtt_mock, caplog)
Test discovering an MQTT fan.
Test discovering an MQTT fan.
async def test_discover_fan(hass, mqtt_mock, caplog): """Test discovering an MQTT fan.""" async_fire_mqtt_message( hass, "homeassistant/fan/bla/config", ('{ "name": "Beer",' ' "command_topic": "test_topic" }'), ) await hass.async_block_till_done() state = hass.states.get("f...
[ "async", "def", "test_discover_fan", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "async_fire_mqtt_message", "(", "hass", ",", "\"homeassistant/fan/bla/config\"", ",", "(", "'{ \"name\": \"Beer\",'", "' \"command_topic\": \"test_topic\" }'", ")", ",", ")", "...
[ 120, 0 ]
[ 133, 58 ]
python
en
['en', 'lb', 'en']
True
test_discover_climate
(hass, mqtt_mock, caplog)
Test discovering an MQTT climate component.
Test discovering an MQTT climate component.
async def test_discover_climate(hass, mqtt_mock, caplog): """Test discovering an MQTT climate component.""" data = ( '{ "name": "ClimateTest",' ' "current_temperature_topic": "climate/bla/current_temp",' ' "temperature_command_topic": "climate/bla/target_temp" }' ) async_fire_...
[ "async", "def", "test_discover_climate", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "data", "=", "(", "'{ \"name\": \"ClimateTest\",'", "' \"current_temperature_topic\": \"climate/bla/current_temp\",'", "' \"temperature_command_topic\": \"climate/bla/target_temp\" }'",...
[ 136, 0 ]
[ 151, 62 ]
python
en
['en', 'en', 'en']
True
test_discover_alarm_control_panel
(hass, mqtt_mock, caplog)
Test discovering an MQTT alarm control panel component.
Test discovering an MQTT alarm control panel component.
async def test_discover_alarm_control_panel(hass, mqtt_mock, caplog): """Test discovering an MQTT alarm control panel component.""" data = ( '{ "name": "AlarmControlPanelTest",' ' "state_topic": "test_topic",' ' "command_topic": "test_topic" }' ) async_fire_mqtt_message(hass, ...
[ "async", "def", "test_discover_alarm_control_panel", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "data", "=", "(", "'{ \"name\": \"AlarmControlPanelTest\",'", "' \"state_topic\": \"test_topic\",'", "' \"command_topic\": \"test_topic\" }'", ")", "async_fire_mqtt_mess...
[ 154, 0 ]
[ 169, 74 ]
python
en
['en', 'en', 'en']
True
test_discovery_incl_nodeid
(hass, mqtt_mock, caplog)
Test sending in correct JSON with optional node_id included.
Test sending in correct JSON with optional node_id included.
async def test_discovery_incl_nodeid(hass, mqtt_mock, caplog): """Test sending in correct JSON with optional node_id included.""" async_fire_mqtt_message( hass, "homeassistant/binary_sensor/my_node_id/bla/config", '{ "name": "Beer", "state_topic": "test-topic" }', ) await hass.as...
[ "async", "def", "test_discovery_incl_nodeid", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "async_fire_mqtt_message", "(", "hass", ",", "\"homeassistant/binary_sensor/my_node_id/bla/config\"", ",", "'{ \"name\": \"Beer\", \"state_topic\": \"test-topic\" }'", ",", ")"...
[ 172, 0 ]
[ 185, 79 ]
python
en
['en', 'en', 'en']
True
test_non_duplicate_discovery
(hass, mqtt_mock, caplog)
Test for a non duplicate component.
Test for a non duplicate component.
async def test_non_duplicate_discovery(hass, mqtt_mock, caplog): """Test for a non duplicate component.""" async_fire_mqtt_message( hass, "homeassistant/binary_sensor/bla/config", '{ "name": "Beer", "state_topic": "test-topic" }', ) async_fire_mqtt_message( hass, ...
[ "async", "def", "test_non_duplicate_discovery", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "async_fire_mqtt_message", "(", "hass", ",", "\"homeassistant/binary_sensor/bla/config\"", ",", "'{ \"name\": \"Beer\", \"state_topic\": \"test-topic\" }'", ",", ")", "asyn...
[ 188, 0 ]
[ 208, 84 ]
python
en
['fr', 'en', 'en']
True
test_removal
(hass, mqtt_mock, caplog)
Test removal of component through empty discovery message.
Test removal of component through empty discovery message.
async def test_removal(hass, mqtt_mock, caplog): """Test removal of component through empty discovery message.""" async_fire_mqtt_message( hass, "homeassistant/binary_sensor/bla/config", '{ "name": "Beer", "state_topic": "test-topic" }', ) await hass.async_block_till_done() s...
[ "async", "def", "test_removal", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "async_fire_mqtt_message", "(", "hass", ",", "\"homeassistant/binary_sensor/bla/config\"", ",", "'{ \"name\": \"Beer\", \"state_topic\": \"test-topic\" }'", ",", ")", "await", "hass", ...
[ 211, 0 ]
[ 225, 24 ]
python
en
['en', 'en', 'en']
True
test_rediscover
(hass, mqtt_mock, caplog)
Test rediscover of removed component.
Test rediscover of removed component.
async def test_rediscover(hass, mqtt_mock, caplog): """Test rediscover of removed component.""" async_fire_mqtt_message( hass, "homeassistant/binary_sensor/bla/config", '{ "name": "Beer", "state_topic": "test-topic" }', ) await hass.async_block_till_done() state = hass.states...
[ "async", "def", "test_rediscover", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "async_fire_mqtt_message", "(", "hass", ",", "\"homeassistant/binary_sensor/bla/config\"", ",", "'{ \"name\": \"Beer\", \"state_topic\": \"test-topic\" }'", ",", ")", "await", "hass",...
[ 228, 0 ]
[ 251, 28 ]
python
en
['en', 'en', 'en']
True
test_duplicate_removal
(hass, mqtt_mock, caplog)
Test for a non duplicate component.
Test for a non duplicate component.
async def test_duplicate_removal(hass, mqtt_mock, caplog): """Test for a non duplicate component.""" async_fire_mqtt_message( hass, "homeassistant/binary_sensor/bla/config", '{ "name": "Beer", "state_topic": "test-topic" }', ) await hass.async_block_till_done() async_fire_mqt...
[ "async", "def", "test_duplicate_removal", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "async_fire_mqtt_message", "(", "hass", ",", "\"homeassistant/binary_sensor/bla/config\"", ",", "'{ \"name\": \"Beer\", \"state_topic\": \"test-topic\" }'", ",", ")", "await", ...
[ 254, 0 ]
[ 269, 88 ]
python
en
['fr', 'en', 'en']
True
test_cleanup_device
(hass, device_reg, entity_reg, mqtt_mock)
Test discvered device is cleaned up when removed from registry.
Test discvered device is cleaned up when removed from registry.
async def test_cleanup_device(hass, device_reg, entity_reg, mqtt_mock): """Test discvered device is cleaned up when removed from registry.""" data = ( '{ "device":{"identifiers":["0AFFD2"]},' ' "state_topic": "foobar/sensor",' ' "unique_id": "unique" }' ) async_fire_mqtt_messa...
[ "async", "def", "test_cleanup_device", "(", "hass", ",", "device_reg", ",", "entity_reg", ",", "mqtt_mock", ")", ":", "data", "=", "(", "'{ \"device\":{\"identifiers\":[\"0AFFD2\"]},'", "' \"state_topic\": \"foobar/sensor\",'", "' \"unique_id\": \"unique\" }'", ")", "async_...
[ 272, 0 ]
[ 309, 5 ]
python
en
['en', 'en', 'en']
True
test_discovery_expansion
(hass, mqtt_mock, caplog)
Test expansion of abbreviated discovery payload.
Test expansion of abbreviated discovery payload.
async def test_discovery_expansion(hass, mqtt_mock, caplog): """Test expansion of abbreviated discovery payload.""" data = ( '{ "~": "some/base/topic",' ' "name": "DiscoveryExpansionTest1",' ' "stat_t": "test_topic/~",' ' "cmd_t": "~/test_topic",' ' "dev":{' '...
[ "async", "def", "test_discovery_expansion", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "data", "=", "(", "'{ \"~\": \"some/base/topic\",'", "' \"name\": \"DiscoveryExpansionTest1\",'", "' \"stat_t\": \"test_topic/~\",'", "' \"cmd_t\": \"~/test_topic\",'", "' \"de...
[ 312, 0 ]
[ 341, 34 ]
python
en
['en', 'en', 'en']
True
test_missing_discover_abbreviations
(hass, mqtt_mock, caplog)
Check MQTT platforms for missing abbreviations.
Check MQTT platforms for missing abbreviations.
async def test_missing_discover_abbreviations(hass, mqtt_mock, caplog): """Check MQTT platforms for missing abbreviations.""" missing = [] regex = re.compile(r"(CONF_[a-zA-Z\d_]*) *= *[\'\"]([a-zA-Z\d_]*)[\'\"]") for fil in Path(mqtt.__file__).parent.rglob("*.py"): if fil.name == "trigger.py": ...
[ "async", "def", "test_missing_discover_abbreviations", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "missing", "=", "[", "]", "regex", "=", "re", ".", "compile", "(", "r\"(CONF_[a-zA-Z\\d_]*) *= *[\\'\\\"]([a-zA-Z\\d_]*)[\\'\\\"]\"", ")", "for", "fil", "i...
[ 376, 0 ]
[ 397, 22 ]
python
en
['en', 'sv', 'en']
True
test_no_implicit_state_topic_switch
(hass, mqtt_mock, caplog)
Test no implicit state topic for switch.
Test no implicit state topic for switch.
async def test_no_implicit_state_topic_switch(hass, mqtt_mock, caplog): """Test no implicit state topic for switch.""" data = '{ "name": "Test1",' ' "command_topic": "cmnd"' "}" async_fire_mqtt_message(hass, "homeassistant/switch/bla/config", data) await hass.async_block_till_done() assert "implic...
[ "async", "def", "test_no_implicit_state_topic_switch", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "data", "=", "'{ \"name\": \"Test1\",'", "' \"command_topic\": \"cmnd\"'", "\"}\"", "async_fire_mqtt_message", "(", "hass", ",", "\"homeassistant/switch/bla/config\...
[ 400, 0 ]
[ 418, 31 ]
python
en
['en', 'en', 'en']
True
test_complex_discovery_topic_prefix
(hass, mqtt_mock, caplog)
Tests handling of discovery topic prefix with multiple slashes.
Tests handling of discovery topic prefix with multiple slashes.
async def test_complex_discovery_topic_prefix(hass, mqtt_mock, caplog): """Tests handling of discovery topic prefix with multiple slashes.""" async_fire_mqtt_message( hass, ("my_home/homeassistant/register/binary_sensor/node1/object1/config"), '{ "name": "Beer", "state_topic": "test-topi...
[ "async", "def", "test_complex_discovery_topic_prefix", "(", "hass", ",", "mqtt_mock", ",", "caplog", ")", ":", "async_fire_mqtt_message", "(", "hass", ",", "(", "\"my_home/homeassistant/register/binary_sensor/node1/object1/config\"", ")", ",", "'{ \"name\": \"Beer\", \"state_to...
[ 430, 0 ]
[ 443, 78 ]
python
en
['en', 'en', 'en']
True
test_mqtt_integration_discovery_subscribe_unsubscribe
( hass, mqtt_client_mock, mqtt_mock )
Check MQTT integration discovery subscribe and unsubscribe.
Check MQTT integration discovery subscribe and unsubscribe.
async def test_mqtt_integration_discovery_subscribe_unsubscribe( hass, mqtt_client_mock, mqtt_mock ): """Check MQTT integration discovery subscribe and unsubscribe.""" mock_entity_platform(hass, "config_flow.comp", None) entry = hass.config_entries.async_entries("mqtt")[0] mqtt_mock().connected = T...
[ "async", "def", "test_mqtt_integration_discovery_subscribe_unsubscribe", "(", "hass", ",", "mqtt_client_mock", ",", "mqtt_mock", ")", ":", "mock_entity_platform", "(", "hass", ",", "\"config_flow.comp\"", ",", "None", ")", "entry", "=", "hass", ".", "config_entries", ...
[ 446, 0 ]
[ 483, 54 ]
python
en
['en', 'en', 'en']
True
test_mqtt_discovery_unsubscribe_once
(hass, mqtt_client_mock, mqtt_mock)
Check MQTT integration discovery unsubscribe once.
Check MQTT integration discovery unsubscribe once.
async def test_mqtt_discovery_unsubscribe_once(hass, mqtt_client_mock, mqtt_mock): """Check MQTT integration discovery unsubscribe once.""" mock_entity_platform(hass, "config_flow.comp", None) entry = hass.config_entries.async_entries("mqtt")[0] mqtt_mock().connected = True with patch( "ho...
[ "async", "def", "test_mqtt_discovery_unsubscribe_once", "(", "hass", ",", "mqtt_client_mock", ",", "mqtt_mock", ")", ":", "mock_entity_platform", "(", "hass", ",", "\"config_flow.comp\"", ",", "None", ")", "entry", "=", "hass", ".", "config_entries", ".", "async_ent...
[ 486, 0 ]
[ 515, 80 ]
python
en
['en', 'en', 'en']
True
test_deconz_events
(hass)
Test successful creation of deconz events.
Test successful creation of deconz events.
async def test_deconz_events(hass): """Test successful creation of deconz events.""" data = deepcopy(DECONZ_WEB_REQUEST) data["sensors"] = deepcopy(SENSORS) config_entry = await setup_deconz_integration(hass, get_state_response=data) gateway = get_gateway_from_config_entry(hass, config_entry) a...
[ "async", "def", "test_deconz_events", "(", "hass", ")", ":", "data", "=", "deepcopy", "(", "DECONZ_WEB_REQUEST", ")", "data", "[", "\"sensors\"", "]", "=", "deepcopy", "(", "SENSORS", ")", "config_entry", "=", "await", "setup_deconz_integration", "(", "hass", ...
[ 55, 0 ]
[ 120, 35 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up access to BloomSky cameras.
Set up access to BloomSky cameras.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up access to BloomSky cameras.""" if discovery_info is not None: return bloomsky = hass.data[DOMAIN] for device in bloomsky.devices.values(): add_entities([BloomSkyCamera(bloomsky, device)])
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "not", "None", ":", "return", "bloomsky", "=", "hass", ".", "data", "[", "DOMAIN", "]", "for", "device", ...
[ 10, 0 ]
[ 18, 56 ]
python
en
['en', 'en', 'en']
True
BloomSkyCamera.__init__
(self, bs, device)
Initialize access to the BloomSky camera images.
Initialize access to the BloomSky camera images.
def __init__(self, bs, device): """Initialize access to the BloomSky camera images.""" super().__init__() self._name = device["DeviceName"] self._id = device["DeviceID"] self._bloomsky = bs self._url = "" self._last_url = "" # last_image will store images ...
[ "def", "__init__", "(", "self", ",", "bs", ",", "device", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_name", "=", "device", "[", "\"DeviceName\"", "]", "self", ".", "_id", "=", "device", "[", "\"DeviceID\"", "]", "self", ...
[ 24, 4 ]
[ 36, 50 ]
python
en
['en', 'en', 'en']
True
BloomSkyCamera.camera_image
(self)
Update the camera's image if it has changed.
Update the camera's image if it has changed.
def camera_image(self): """Update the camera's image if it has changed.""" try: self._url = self._bloomsky.devices[self._id]["Data"]["ImageURL"] self._bloomsky.refresh_devices() # If the URL hasn't changed then the image hasn't changed. if self._url != sel...
[ "def", "camera_image", "(", "self", ")", ":", "try", ":", "self", ".", "_url", "=", "self", ".", "_bloomsky", ".", "devices", "[", "self", ".", "_id", "]", "[", "\"Data\"", "]", "[", "\"ImageURL\"", "]", "self", ".", "_bloomsky", ".", "refresh_devices"...
[ 38, 4 ]
[ 52, 31 ]
python
en
['en', 'en', 'en']
True
BloomSkyCamera.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return self._id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_id" ]
[ 55, 4 ]
[ 57, 23 ]
python
ca
['fr', 'ca', 'en']
False
BloomSkyCamera.name
(self)
Return the name of this BloomSky device.
Return the name of this BloomSky device.
def name(self): """Return the name of this BloomSky device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 60, 4 ]
[ 62, 25 ]
python
en
['en', 'en', 'en']
True
registry
(hass)
Return a configured device registry.
Return a configured device registry.
def registry(hass): """Return a configured device registry.""" return mock_device_registry(hass)
[ "def", "registry", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 13, 0 ]
[ 15, 37 ]
python
en
['en', 'en', 'en']
True
create_registrations
(hass, authed_api_client)
Return two new registrations.
Return two new registrations.
async def create_registrations(hass, authed_api_client): """Return two new registrations.""" await async_setup_component(hass, DOMAIN, {DOMAIN: {}}) enc_reg = await authed_api_client.post( "/api/mobile_app/registrations", json=REGISTER ) assert enc_reg.status == 201 enc_reg_json = awai...
[ "async", "def", "create_registrations", "(", "hass", ",", "authed_api_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "}", "}", ")", "enc_reg", "=", "await", "authed_api_client", ".", "post", "("...
[ 19, 0 ]
[ 39, 41 ]
python
en
['en', 'bg', 'en']
True
webhook_client
(hass, authed_api_client, aiohttp_client)
mobile_app mock client.
mobile_app mock client.
async def webhook_client(hass, authed_api_client, aiohttp_client): """mobile_app mock client.""" # We pass in the authed_api_client server instance because # it is used inside create_registrations and just passing in # the app instance would cause the server to start twice, # which caused deprecatio...
[ "async", "def", "webhook_client", "(", "hass", ",", "authed_api_client", ",", "aiohttp_client", ")", ":", "# We pass in the authed_api_client server instance because", "# it is used inside create_registrations and just passing in", "# the app instance would cause the server to start twice,...
[ 43, 0 ]
[ 49, 57 ]
python
en
['en', 'fr', 'en']
True
authed_api_client
(hass, hass_client)
Provide an authenticated client for mobile_app to use.
Provide an authenticated client for mobile_app to use.
async def authed_api_client(hass, hass_client): """Provide an authenticated client for mobile_app to use.""" await async_setup_component(hass, DOMAIN, {DOMAIN: {}}) await hass.async_block_till_done() return await hass_client()
[ "async", "def", "authed_api_client", "(", "hass", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "}", "}", ")", "await", "hass", ".", "async_block_till_done", "(", ")", "return", "a...
[ 53, 0 ]
[ 57, 30 ]
python
en
['en', 'en', 'en']
True
setup_ws
(hass)
Configure the websocket_api component.
Configure the websocket_api component.
async def setup_ws(hass): """Configure the websocket_api component.""" assert await async_setup_component(hass, "websocket_api", {}) await hass.async_block_till_done()
[ "async", "def", "setup_ws", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"websocket_api\"", ",", "{", "}", ")", "await", "hass", ".", "async_block_till_done", "(", ")" ]
[ 61, 0 ]
[ 64, 38 ]
python
en
['en', 'ca', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the platform.
Set up the platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the platform.""" # Validate credentials by processing image. api_key = config[CONF_API_KEY] account_type = config[CONF_ACCOUNT_TYPE] api = hound.cloud(api_key, account_type) try: api.detect(b"Test") except...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "# Validate credentials by processing image.", "api_key", "=", "config", "[", "CONF_API_KEY", "]", "account_type", "=", "config", "[", "CONF_ACCOU...
[ 45, 0 ]
[ 71, 26 ]
python
en
['en', 'da', 'en']
True