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
MiTempBtSensor.force_update
(self)
Force update.
Force update.
def force_update(self): """Force update.""" return self._force_update
[ "def", "force_update", "(", "self", ")", ":", "return", "self", ".", "_force_update" ]
[ 145, 4 ]
[ 147, 33 ]
python
en
['en', 'en', 'en']
False
MiTempBtSensor.update
(self)
Update current conditions. This uses a rolling median over 3 values to filter out outliers.
Update current conditions.
def update(self): """ Update current conditions. This uses a rolling median over 3 values to filter out outliers. """ try: _LOGGER.debug("Polling data for %s", self.name) data = self.poller.parameter_value(self.parameter) except OSError as ioerr: ...
[ "def", "update", "(", "self", ")", ":", "try", ":", "_LOGGER", ".", "debug", "(", "\"Polling data for %s\"", ",", "self", ".", "name", ")", "data", "=", "self", ".", "poller", ".", "parameter_value", "(", "self", ".", "parameter", ")", "except", "OSError...
[ 149, 4 ]
[ 188, 71 ]
python
en
['en', 'error', 'th']
False
test_form
(hass)
Test we get the form.
Test we get the form.
async def test_form(hass): """Test we get the form.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert result["errors...
[ "async", "def", "test_form", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(...
[ 10, 0 ]
[ 39, 48 ]
python
en
['en', 'en', 'en']
True
test_form_invalid_auth
(hass)
Test we handle invalid auth.
Test we handle invalid auth.
async def test_form_invalid_auth(hass): """Test we handle invalid auth.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch("pysmarthab.SmartHab.async_login"), patch( "pysmarthab.SmartHab.is_logged_in", return_value=...
[ "async", "def", "test_form_invalid_auth", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ")"...
[ 42, 0 ]
[ 57, 56 ]
python
en
['en', 'en', 'en']
True
test_form_service_error
(hass)
Test we handle service errors.
Test we handle service errors.
async def test_form_service_error(hass): """Test we handle service errors.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "pysmarthab.SmartHab.async_login", side_effect=pysmarthab.RequestFailedException...
[ "async", "def", "test_form_service_error", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ")...
[ 60, 0 ]
[ 76, 51 ]
python
en
['de', 'en', 'en']
True
test_form_unknown_error
(hass)
Test we handle unknown errors.
Test we handle unknown errors.
async def test_form_unknown_error(hass): """Test we handle unknown errors.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "pysmarthab.SmartHab.async_login", side_effect=Exception, ): result2...
[ "async", "def", "test_form_unknown_error", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ")...
[ 79, 0 ]
[ 95, 51 ]
python
en
['en', 'de', 'en']
True
test_import
(hass)
Test import.
Test import.
async def test_import(hass): """Test import.""" await setup.async_setup_component(hass, "persistent_notification", {}) imported_conf = { CONF_EMAIL: "mock@example.com", CONF_PASSWORD: "test-password", } with patch("pysmarthab.SmartHab.async_login"), patch( "pysmarthab.Smart...
[ "async", "def", "test_import", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "imported_conf", "=", "{", "CONF_EMAIL", ":", "\"mock@example.com\"", ",", "CONF_PASSWORD", ...
[ 98, 0 ]
[ 126, 48 ]
python
de
['de', 'la', 'en']
False
test_entity_state
(hass, device_factory)
Tests the state attributes properly match the fan types.
Tests the state attributes properly match the fan types.
async def test_entity_state(hass, device_factory): """Tests the state attributes properly match the fan types.""" device = device_factory( "Fan 1", capabilities=[Capability.switch, Capability.fan_speed], status={Attribute.switch: "on", Attribute.fan_speed: 2}, ) await setup_platf...
[ "async", "def", "test_entity_state", "(", "hass", ",", "device_factory", ")", ":", "device", "=", "device_factory", "(", "\"Fan 1\"", ",", "capabilities", "=", "[", "Capability", ".", "switch", ",", "Capability", ".", "fan_speed", "]", ",", "status", "=", "{...
[ 25, 0 ]
[ 44, 5 ]
python
en
['en', 'en', 'en']
True
test_entity_and_device_attributes
(hass, device_factory)
Test the attributes of the entity are correct.
Test the attributes of the entity are correct.
async def test_entity_and_device_attributes(hass, device_factory): """Test the attributes of the entity are correct.""" # Arrange device = device_factory( "Fan 1", capabilities=[Capability.switch, Capability.fan_speed], status={Attribute.switch: "on", Attribute.fan_speed: 2}, ) ...
[ "async", "def", "test_entity_and_device_attributes", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Fan 1\"", ",", "capabilities", "=", "[", "Capability", ".", "switch", ",", "Capability", ".", "fan_speed", "]",...
[ 47, 0 ]
[ 68, 46 ]
python
en
['en', 'en', 'en']
True
test_turn_off
(hass, device_factory)
Test the fan turns of successfully.
Test the fan turns of successfully.
async def test_turn_off(hass, device_factory): """Test the fan turns of successfully.""" # Arrange device = device_factory( "Fan 1", capabilities=[Capability.switch, Capability.fan_speed], status={Attribute.switch: "on", Attribute.fan_speed: 2}, ) await setup_platform(hass, F...
[ "async", "def", "test_turn_off", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Fan 1\"", ",", "capabilities", "=", "[", "Capability", ".", "switch", ",", "Capability", ".", "fan_speed", "]", ",", "status", ...
[ 71, 0 ]
[ 87, 31 ]
python
en
['en', 'en', 'en']
True
test_turn_on
(hass, device_factory)
Test the fan turns of successfully.
Test the fan turns of successfully.
async def test_turn_on(hass, device_factory): """Test the fan turns of successfully.""" # Arrange device = device_factory( "Fan 1", capabilities=[Capability.switch, Capability.fan_speed], status={Attribute.switch: "off", Attribute.fan_speed: 0}, ) await setup_platform(hass, F...
[ "async", "def", "test_turn_on", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Fan 1\"", ",", "capabilities", "=", "[", "Capability", ".", "switch", ",", "Capability", ".", "fan_speed", "]", ",", "status", ...
[ 90, 0 ]
[ 106, 30 ]
python
en
['en', 'en', 'en']
True
test_turn_on_with_speed
(hass, device_factory)
Test the fan turns on to the specified speed.
Test the fan turns on to the specified speed.
async def test_turn_on_with_speed(hass, device_factory): """Test the fan turns on to the specified speed.""" # Arrange device = device_factory( "Fan 1", capabilities=[Capability.switch, Capability.fan_speed], status={Attribute.switch: "off", Attribute.fan_speed: 0}, ) await s...
[ "async", "def", "test_turn_on_with_speed", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Fan 1\"", ",", "capabilities", "=", "[", "Capability", ".", "switch", ",", "Capability", ".", "fan_speed", "]", ",", ...
[ 109, 0 ]
[ 129, 53 ]
python
en
['en', 'en', 'en']
True
test_set_speed
(hass, device_factory)
Test setting to specific fan speed.
Test setting to specific fan speed.
async def test_set_speed(hass, device_factory): """Test setting to specific fan speed.""" # Arrange device = device_factory( "Fan 1", capabilities=[Capability.switch, Capability.fan_speed], status={Attribute.switch: "off", Attribute.fan_speed: 0}, ) await setup_platform(hass,...
[ "async", "def", "test_set_speed", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Fan 1\"", ",", "capabilities", "=", "[", "Capability", ".", "switch", ",", "Capability", ".", "fan_speed", "]", ",", "status",...
[ 132, 0 ]
[ 152, 53 ]
python
en
['en', 'fy', 'en']
True
test_update_from_signal
(hass, device_factory)
Test the fan updates when receiving a signal.
Test the fan updates when receiving a signal.
async def test_update_from_signal(hass, device_factory): """Test the fan updates when receiving a signal.""" # Arrange device = device_factory( "Fan 1", capabilities=[Capability.switch, Capability.fan_speed], status={Attribute.switch: "off", Attribute.fan_speed: 0}, ) await s...
[ "async", "def", "test_update_from_signal", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Fan 1\"", ",", "capabilities", "=", "[", "Capability", ".", "switch", ",", "Capability", ".", "fan_speed", "]", ",", ...
[ 155, 0 ]
[ 171, 30 ]
python
en
['en', 'lb', 'en']
True
test_unload_config_entry
(hass, device_factory)
Test the fan is removed when the config entry is unloaded.
Test the fan is removed when the config entry is unloaded.
async def test_unload_config_entry(hass, device_factory): """Test the fan is removed when the config entry is unloaded.""" # Arrange device = device_factory( "Fan 1", capabilities=[Capability.switch, Capability.fan_speed], status={Attribute.switch: "off", Attribute.fan_speed: 0}, ...
[ "async", "def", "test_unload_config_entry", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Fan 1\"", ",", "capabilities", "=", "[", "Capability", ".", "switch", ",", "Capability", ".", "fan_speed", "]", ",", ...
[ 174, 0 ]
[ 186, 43 ]
python
en
['en', 'en', 'en']
True
register_discovery_flow
( domain: str, title: str, discovery_function: DiscoveryFunctionType, connection_class: str, )
Register flow for discovered integrations that not require auth.
Register flow for discovered integrations that not require auth.
def register_discovery_flow( domain: str, title: str, discovery_function: DiscoveryFunctionType, connection_class: str, ) -> None: """Register flow for discovered integrations that not require auth.""" class DiscoveryFlow(DiscoveryFlowHandler): """Discovery flow handler.""" def...
[ "def", "register_discovery_flow", "(", "domain", ":", "str", ",", "title", ":", "str", ",", "discovery_function", ":", "DiscoveryFunctionType", ",", "connection_class", ":", "str", ",", ")", "->", "None", ":", "class", "DiscoveryFlow", "(", "DiscoveryFlowHandler",...
[ 99, 0 ]
[ 113, 59 ]
python
en
['en', 'en', 'en']
True
register_webhook_flow
( domain: str, title: str, description_placeholder: dict, allow_multiple: bool = False )
Register flow for webhook integrations.
Register flow for webhook integrations.
def register_webhook_flow( domain: str, title: str, description_placeholder: dict, allow_multiple: bool = False ) -> None: """Register flow for webhook integrations.""" class WebhookFlow(WebhookFlowHandler): """Webhook flow handler.""" def __init__(self) -> None: super().__init...
[ "def", "register_webhook_flow", "(", "domain", ":", "str", ",", "title", ":", "str", ",", "description_placeholder", ":", "dict", ",", "allow_multiple", ":", "bool", "=", "False", ")", "->", "None", ":", "class", "WebhookFlow", "(", "WebhookFlowHandler", ")", ...
[ 168, 0 ]
[ 179, 57 ]
python
en
['en', 'da', 'en']
True
webhook_async_remove_entry
( hass: HomeAssistantType, entry: config_entries.ConfigEntry )
Remove a webhook config entry.
Remove a webhook config entry.
async def webhook_async_remove_entry( hass: HomeAssistantType, entry: config_entries.ConfigEntry ) -> None: """Remove a webhook config entry.""" if not entry.data.get("cloudhook") or "cloud" not in hass.config.components: return await hass.components.cloud.async_delete_cloudhook(entry.data["web...
[ "async", "def", "webhook_async_remove_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "config_entries", ".", "ConfigEntry", ")", "->", "None", ":", "if", "not", "entry", ".", "data", ".", "get", "(", "\"cloudhook\"", ")", "or", "\"cloud\"", ...
[ 182, 0 ]
[ 189, 80 ]
python
en
['en', 'en', 'en']
True
DiscoveryFlowHandler.__init__
( self, domain: str, title: str, discovery_function: DiscoveryFunctionType, connection_class: str, )
Initialize the discovery config flow.
Initialize the discovery config flow.
def __init__( self, domain: str, title: str, discovery_function: DiscoveryFunctionType, connection_class: str, ) -> None: """Initialize the discovery config flow.""" self._domain = domain self._title = title self._discovery_function = discovery...
[ "def", "__init__", "(", "self", ",", "domain", ":", "str", ",", "title", ":", "str", ",", "discovery_function", ":", "DiscoveryFunctionType", ",", "connection_class", ":", "str", ",", ")", "->", "None", ":", "self", ".", "_domain", "=", "domain", "self", ...
[ 15, 4 ]
[ 26, 48 ]
python
en
['en', 'en', 'en']
True
DiscoveryFlowHandler.async_step_user
( self, user_input: Optional[Dict[str, Any]] = None )
Handle a flow initialized by the user.
Handle a flow initialized by the user.
async def async_step_user( self, user_input: Optional[Dict[str, Any]] = None ) -> Dict[str, Any]: """Handle a flow initialized by the user.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") await self.async_set_unique_id(self....
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "self", ".", "_async_current_entries", "(", ")"...
[ 28, 4 ]
[ 37, 46 ]
python
en
['en', 'en', 'en']
True
DiscoveryFlowHandler.async_step_confirm
( self, user_input: Optional[Dict[str, Any]] = None )
Confirm setup.
Confirm setup.
async def async_step_confirm( self, user_input: Optional[Dict[str, Any]] = None ) -> Dict[str, Any]: """Confirm setup.""" if user_input is None: return self.async_show_form(step_id="confirm") if self.source == config_entries.SOURCE_USER: # Get current discove...
[ "async", "def", "async_step_confirm", "(", "self", ",", "user_input", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "user_input", "is", "None", ":", "return", ...
[ 39, 4 ]
[ 67, 66 ]
python
en
['en', 'pt', 'en']
False
DiscoveryFlowHandler.async_step_discovery
( self, discovery_info: Dict[str, Any] )
Handle a flow initialized by discovery.
Handle a flow initialized by discovery.
async def async_step_discovery( self, discovery_info: Dict[str, Any] ) -> Dict[str, Any]: """Handle a flow initialized by discovery.""" if self._async_in_progress() or self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") await self.asy...
[ "async", "def", "async_step_discovery", "(", "self", ",", "discovery_info", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "self", ".", "_async_in_progress", "(", ")", "or", "self", ".", "_async_cur...
[ 69, 4 ]
[ 78, 46 ]
python
en
['en', 'en', 'en']
True
DiscoveryFlowHandler.async_step_import
(self, _: Optional[Dict[str, Any]])
Handle a flow initialized by import.
Handle a flow initialized by import.
async def async_step_import(self, _: Optional[Dict[str, Any]]) -> Dict[str, Any]: """Handle a flow initialized by import.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") # Cancel other flows. assert self.hass is not None ...
[ "async", "def", "async_step_import", "(", "self", ",", "_", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "self", ".", "_async_current_entries", "(", ")", ":", "return", "...
[ 85, 4 ]
[ 96, 66 ]
python
en
['en', 'en', 'en']
True
WebhookFlowHandler.__init__
( self, domain: str, title: str, description_placeholder: dict, allow_multiple: bool, )
Initialize the discovery config flow.
Initialize the discovery config flow.
def __init__( self, domain: str, title: str, description_placeholder: dict, allow_multiple: bool, ) -> None: """Initialize the discovery config flow.""" self._domain = domain self._title = title self._description_placeholder = description_place...
[ "def", "__init__", "(", "self", ",", "domain", ":", "str", ",", "title", ":", "str", ",", "description_placeholder", ":", "dict", ",", "allow_multiple", ":", "bool", ",", ")", "->", "None", ":", "self", ".", "_domain", "=", "domain", "self", ".", "_tit...
[ 121, 4 ]
[ 132, 45 ]
python
en
['en', 'en', 'en']
True
WebhookFlowHandler.async_step_user
( self, user_input: Optional[Dict[str, Any]] = None )
Handle a user initiated set up flow to create a webhook.
Handle a user initiated set up flow to create a webhook.
async def async_step_user( self, user_input: Optional[Dict[str, Any]] = None ) -> Dict[str, Any]: """Handle a user initiated set up flow to create a webhook.""" if not self._allow_multiple and self._async_current_entries(): return self.async_abort(reason="single_instance_allowed"...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "not", "self", ".", "_allow_multiple", "and", ...
[ 134, 4 ]
[ 165, 9 ]
python
en
['en', 'en', 'en']
True
serial_connect
(self)
Mock a serial connection.
Mock a serial connection.
def serial_connect(self): """Mock a serial connection.""" self.serial = True
[ "def", "serial_connect", "(", "self", ")", ":", "self", ".", "serial", "=", "True" ]
[ 19, 0 ]
[ 21, 22 ]
python
en
['en', 'en', 'en']
True
serial_connect_fail
(self)
Mock a failed serial connection.
Mock a failed serial connection.
def serial_connect_fail(self): """Mock a failed serial connection.""" self.serial = None
[ "def", "serial_connect_fail", "(", "self", ")", ":", "self", ".", "serial", "=", "None" ]
[ 24, 0 ]
[ 26, 22 ]
python
en
['en', 'ga', 'en']
True
com_port
()
Mock of a serial port.
Mock of a serial port.
def com_port(): """Mock of a serial port.""" port = serial.tools.list_ports_common.ListPortInfo() port.serial_number = "1234" port.manufacturer = "Virtual serial port" port.device = "/dev/ttyUSB1234" port.description = "Some serial port" return port
[ "def", "com_port", "(", ")", ":", "port", "=", "serial", ".", "tools", ".", "list_ports_common", ".", "ListPortInfo", "(", ")", "port", ".", "serial_number", "=", "\"1234\"", "port", ".", "manufacturer", "=", "\"Virtual serial port\"", "port", ".", "device", ...
[ 29, 0 ]
[ 37, 15 ]
python
en
['en', 'en', 'en']
True
test_setup_network
(connect_mock, hass)
Test we can setup network.
Test we can setup network.
async def test_setup_network(connect_mock, hass): """Test we can setup network.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert result["step_id"] == "user" assert result["errors"] == {...
[ "async", "def", "test_setup_network", "(", "connect_mock", ",", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURC...
[ 44, 0 ]
[ 76, 5 ]
python
en
['en', 'en', 'en']
True
test_setup_serial
(com_mock, connect_mock, hass)
Test we can setup serial.
Test we can setup serial.
async def test_setup_serial(com_mock, connect_mock, hass): """Test we can setup serial.""" port = com_port() result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert result["step_id"] == "user" ...
[ "async", "def", "test_setup_serial", "(", "com_mock", ",", "connect_mock", ",", "hass", ")", ":", "port", "=", "com_port", "(", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", ...
[ 88, 0 ]
[ 122, 5 ]
python
en
['en', 'en', 'en']
True
test_setup_serial_manual
(com_mock, connect_mock, hass)
Test we can setup serial with manual entry.
Test we can setup serial with manual entry.
async def test_setup_serial_manual(com_mock, connect_mock, hass): """Test we can setup serial with manual entry.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert result["step_id"] == "user"...
[ "async", "def", "test_setup_serial_manual", "(", "com_mock", ",", "connect_mock", ",", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "confi...
[ 134, 0 ]
[ 174, 5 ]
python
en
['en', 'en', 'en']
True
test_setup_network_fail
(connect_mock, hass)
Test we can setup network.
Test we can setup network.
async def test_setup_network_fail(connect_mock, hass): """Test we can setup network.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert result["step_id"] == "user" assert result["errors"]...
[ "async", "def", "test_setup_network_fail", "(", "connect_mock", ",", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "...
[ 181, 0 ]
[ 206, 57 ]
python
en
['en', 'en', 'en']
True
test_setup_serial_fail
(com_mock, connect_mock, hass)
Test setup serial failed connection.
Test setup serial failed connection.
async def test_setup_serial_fail(com_mock, connect_mock, hass): """Test setup serial failed connection.""" port = com_port() result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert result["step_...
[ "async", "def", "test_setup_serial_fail", "(", "com_mock", ",", "connect_mock", ",", "hass", ")", ":", "port", "=", "com_port", "(", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", ...
[ 214, 0 ]
[ 241, 57 ]
python
en
['en', 'ga', 'en']
True
test_setup_serial_manual_fail
(com_mock, hass)
Test setup serial failed connection.
Test setup serial failed connection.
async def test_setup_serial_manual_fail(com_mock, hass): """Test setup serial failed connection.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert result["step_id"] == "user" assert resu...
[ "async", "def", "test_setup_serial_manual_fail", "(", "com_mock", ",", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", ...
[ 249, 0 ]
[ 282, 57 ]
python
en
['en', 'ga', 'en']
True
test_import_serial
(connect_mock, hass)
Test we can import.
Test we can import.
async def test_import_serial(connect_mock, hass): """Test we can import.""" await setup.async_setup_component(hass, "persistent_notification", {}) with patch("homeassistant.components.rfxtrx.async_setup_entry", return_value=True): result = await hass.config_entries.flow.async_init( DOMA...
[ "async", "def", "test_import_serial", "(", "connect_mock", ",", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "with", "patch", "(", "\"homeassistant.components.rfxtrx.async_setup_...
[ 293, 0 ]
[ 311, 5 ]
python
en
['en', 'en', 'en']
True
test_import_network
(connect_mock, hass)
Test we can import.
Test we can import.
async def test_import_network(connect_mock, hass): """Test we can import.""" await setup.async_setup_component(hass, "persistent_notification", {}) with patch("homeassistant.components.rfxtrx.async_setup_entry", return_value=True): result = await hass.config_entries.flow.async_init( DOM...
[ "async", "def", "test_import_network", "(", "connect_mock", ",", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "with", "patch", "(", "\"homeassistant.components.rfxtrx.async_setup...
[ 318, 0 ]
[ 336, 5 ]
python
en
['en', 'en', 'en']
True
test_import_network_connection_fail
(connect_mock, hass)
Test we can import.
Test we can import.
async def test_import_network_connection_fail(connect_mock, hass): """Test we can import.""" await setup.async_setup_component(hass, "persistent_notification", {}) with patch("homeassistant.components.rfxtrx.async_setup_entry", return_value=True): result = await hass.config_entries.flow.async_init(...
[ "async", "def", "test_import_network_connection_fail", "(", "connect_mock", ",", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "with", "patch", "(", "\"homeassistant.components.rf...
[ 343, 0 ]
[ 355, 47 ]
python
en
['en', 'en', 'en']
True
test_import_update
(hass)
Test we can import.
Test we can import.
async def test_import_update(hass): """Test we can import.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain=DOMAIN, data={ "host": None, "port": None, "device": "/dev/tty123", "debug": F...
[ "async", "def", "test_import_update", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", ...
[ 358, 0 ]
[ 388, 51 ]
python
en
['en', 'en', 'en']
True
test_import_migrate
(hass)
Test we can import.
Test we can import.
async def test_import_migrate(hass): """Test we can import.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain=DOMAIN, data={"host": None, "port": None, "device": "/dev/tty123", "debug": False}, unique_id=DOMAIN, ) entry...
[ "async", "def", "test_import_migrate", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", ...
[ 391, 0 ]
[ 419, 38 ]
python
en
['en', 'en', 'en']
True
test_options_global
(hass)
Test if we can set global options.
Test if we can set global options.
async def test_options_global(hass): """Test if we can set global options.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain=DOMAIN, data={ "host": None, "port": None, "device": "/dev/tty123", ...
[ "async", "def", "test_options_global", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", ...
[ 422, 0 ]
[ 452, 38 ]
python
en
['en', 'en', 'en']
True
test_options_add_device
(hass)
Test we can add a device.
Test we can add a device.
async def test_options_add_device(hass): """Test we can add a device.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain=DOMAIN, data={ "host": None, "port": None, "device": "/dev/tty123", ...
[ "async", "def", "test_options_add_device", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "...
[ 455, 0 ]
[ 518, 67 ]
python
en
['en', 'en', 'en']
True
test_options_add_duplicate_device
(hass)
Test we can add a device.
Test we can add a device.
async def test_options_add_duplicate_device(hass): """Test we can add a device.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain=DOMAIN, data={ "host": None, "port": None, "device": "/dev/tty123", ...
[ "async", "def", "test_options_add_duplicate_device", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "...
[ 521, 0 ]
[ 555, 72 ]
python
en
['en', 'en', 'en']
True
test_options_add_remove_device
(hass)
Test we can add a device.
Test we can add a device.
async def test_options_add_remove_device(hass): """Test we can add a device.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain=DOMAIN, data={ "host": None, "port": None, "device": "/dev/tty123", ...
[ "async", "def", "test_options_add_remove_device", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "dat...
[ 558, 0 ]
[ 639, 20 ]
python
en
['en', 'en', 'en']
True
test_options_replace_sensor_device
(hass)
Test we can replace a sensor device.
Test we can replace a sensor device.
async def test_options_replace_sensor_device(hass): """Test we can replace a sensor device.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain=DOMAIN, data={ "host": None, "port": None, "device": "/de...
[ "async", "def", "test_options_replace_sensor_device", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", ...
[ 642, 0 ]
[ 800, 20 ]
python
en
['en', 'en', 'en']
True
test_options_replace_control_device
(hass)
Test we can replace a control device.
Test we can replace a control device.
async def test_options_replace_control_device(hass): """Test we can replace a control device.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain=DOMAIN, data={ "host": None, "port": None, "device": "/...
[ "async", "def", "test_options_replace_control_device", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", ...
[ 803, 0 ]
[ 909, 20 ]
python
en
['en', 'en', 'en']
True
test_options_remove_multiple_devices
(hass)
Test we can add a device.
Test we can add a device.
async def test_options_remove_multiple_devices(hass): """Test we can add a device.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain=DOMAIN, data={ "host": None, "port": None, "device": "/dev/tty123"...
[ "async", "def", "test_options_remove_multiple_devices", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", ...
[ 912, 0 ]
[ 980, 16 ]
python
en
['en', 'en', 'en']
True
test_options_add_and_configure_device
(hass)
Test we can add a device.
Test we can add a device.
async def test_options_add_and_configure_device(hass): """Test we can add a device.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain=DOMAIN, data={ "host": None, "port": None, "device": "/dev/tty123...
[ "async", "def", "test_options_add_and_configure_device", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",",...
[ 983, 0 ]
[ 1102, 75 ]
python
en
['en', 'en', 'en']
True
test_get_serial_by_id_no_dir
()
Test serial by id conversion if there's no /dev/serial/by-id.
Test serial by id conversion if there's no /dev/serial/by-id.
def test_get_serial_by_id_no_dir(): """Test serial by id conversion if there's no /dev/serial/by-id.""" p1 = patch("os.path.isdir", MagicMock(return_value=False)) p2 = patch("os.scandir") with p1 as is_dir_mock, p2 as scan_mock: res = config_flow.get_serial_by_id(sentinel.path) assert re...
[ "def", "test_get_serial_by_id_no_dir", "(", ")", ":", "p1", "=", "patch", "(", "\"os.path.isdir\"", ",", "MagicMock", "(", "return_value", "=", "False", ")", ")", "p2", "=", "patch", "(", "\"os.scandir\"", ")", "with", "p1", "as", "is_dir_mock", ",", "p2", ...
[ 1105, 0 ]
[ 1113, 40 ]
python
en
['en', 'en', 'en']
True
test_get_serial_by_id
()
Test serial by id conversion.
Test serial by id conversion.
def test_get_serial_by_id(): """Test serial by id conversion.""" p1 = patch("os.path.isdir", MagicMock(return_value=True)) p2 = patch("os.scandir") def _realpath(path): if path is sentinel.matched_link: return sentinel.path return sentinel.serial_link_path p3 = patch("o...
[ "def", "test_get_serial_by_id", "(", ")", ":", "p1", "=", "patch", "(", "\"os.path.isdir\"", ",", "MagicMock", "(", "return_value", "=", "True", ")", ")", "p2", "=", "patch", "(", "\"os.scandir\"", ")", "def", "_realpath", "(", "path", ")", ":", "if", "p...
[ 1116, 0 ]
[ 1149, 40 ]
python
en
['en', 'en', 'en']
True
_api_bool
(funct)
Return a boolean.
Return a boolean.
def _api_bool(funct): """Return a boolean.""" async def _wrapper(*argv, **kwargs): """Wrap function.""" try: data = await funct(*argv, **kwargs) return data["result"] == "ok" except HassioAPIError: return False return _wrapper
[ "def", "_api_bool", "(", "funct", ")", ":", "async", "def", "_wrapper", "(", "*", "argv", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrap function.\"\"\"", "try", ":", "data", "=", "await", "funct", "(", "*", "argv", ",", "*", "*", "kwargs", ")", "ret...
[ 24, 0 ]
[ 35, 19 ]
python
en
['en', 'gd', 'en']
True
api_data
(funct)
Return data of an api.
Return data of an api.
def api_data(funct): """Return data of an api.""" async def _wrapper(*argv, **kwargs): """Wrap function.""" data = await funct(*argv, **kwargs) if data["result"] == "ok": return data["data"] raise HassioAPIError(data["message"]) return _wrapper
[ "def", "api_data", "(", "funct", ")", ":", "async", "def", "_wrapper", "(", "*", "argv", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrap function.\"\"\"", "data", "=", "await", "funct", "(", "*", "argv", ",", "*", "*", "kwargs", ")", "if", "data", "["...
[ 38, 0 ]
[ 48, 19 ]
python
en
['en', 'no', 'en']
True
HassIO.__init__
(self, loop, websession, ip)
Initialize Hass.io API.
Initialize Hass.io API.
def __init__(self, loop, websession, ip): """Initialize Hass.io API.""" self.loop = loop self.websession = websession self._ip = ip
[ "def", "__init__", "(", "self", ",", "loop", ",", "websession", ",", "ip", ")", ":", "self", ".", "loop", "=", "loop", "self", ".", "websession", "=", "websession", "self", ".", "_ip", "=", "ip" ]
[ 54, 4 ]
[ 58, 21 ]
python
es
['es', 'pl', 'it']
False
HassIO.is_connected
(self)
Return true if it connected to Hass.io supervisor. This method return a coroutine.
Return true if it connected to Hass.io supervisor.
def is_connected(self): """Return true if it connected to Hass.io supervisor. This method return a coroutine. """ return self.send_command("/supervisor/ping", method="get", timeout=15)
[ "def", "is_connected", "(", "self", ")", ":", "return", "self", ".", "send_command", "(", "\"/supervisor/ping\"", ",", "method", "=", "\"get\"", ",", "timeout", "=", "15", ")" ]
[ 61, 4 ]
[ 66, 78 ]
python
en
['en', 'en', 'en']
True
HassIO.get_info
(self)
Return generic Supervisor information. This method return a coroutine.
Return generic Supervisor information.
def get_info(self): """Return generic Supervisor information. This method return a coroutine. """ return self.send_command("/info", method="get")
[ "def", "get_info", "(", "self", ")", ":", "return", "self", ".", "send_command", "(", "\"/info\"", ",", "method", "=", "\"get\"", ")" ]
[ 69, 4 ]
[ 74, 55 ]
python
da
['nl', 'da', 'en']
False
HassIO.get_host_info
(self)
Return data for Host. This method return a coroutine.
Return data for Host.
def get_host_info(self): """Return data for Host. This method return a coroutine. """ return self.send_command("/host/info", method="get")
[ "def", "get_host_info", "(", "self", ")", ":", "return", "self", ".", "send_command", "(", "\"/host/info\"", ",", "method", "=", "\"get\"", ")" ]
[ 77, 4 ]
[ 82, 60 ]
python
en
['en', 'no', 'en']
True
HassIO.get_os_info
(self)
Return data for the OS. This method return a coroutine.
Return data for the OS.
def get_os_info(self): """Return data for the OS. This method return a coroutine. """ return self.send_command("/os/info", method="get")
[ "def", "get_os_info", "(", "self", ")", ":", "return", "self", ".", "send_command", "(", "\"/os/info\"", ",", "method", "=", "\"get\"", ")" ]
[ 85, 4 ]
[ 90, 58 ]
python
en
['en', 'no', 'en']
True
HassIO.get_core_info
(self)
Return data for Home Asssistant Core. This method returns a coroutine.
Return data for Home Asssistant Core.
def get_core_info(self): """Return data for Home Asssistant Core. This method returns a coroutine. """ return self.send_command("/core/info", method="get")
[ "def", "get_core_info", "(", "self", ")", ":", "return", "self", ".", "send_command", "(", "\"/core/info\"", ",", "method", "=", "\"get\"", ")" ]
[ 93, 4 ]
[ 98, 60 ]
python
en
['en', 'en', 'en']
True
HassIO.get_supervisor_info
(self)
Return data for the Supervisor. This method returns a coroutine.
Return data for the Supervisor.
def get_supervisor_info(self): """Return data for the Supervisor. This method returns a coroutine. """ return self.send_command("/supervisor/info", method="get")
[ "def", "get_supervisor_info", "(", "self", ")", ":", "return", "self", ".", "send_command", "(", "\"/supervisor/info\"", ",", "method", "=", "\"get\"", ")" ]
[ 101, 4 ]
[ 106, 66 ]
python
en
['en', 'no', 'en']
True
HassIO.get_addon_info
(self, addon)
Return data for a Add-on. This method return a coroutine.
Return data for a Add-on.
def get_addon_info(self, addon): """Return data for a Add-on. This method return a coroutine. """ return self.send_command(f"/addons/{addon}/info", method="get")
[ "def", "get_addon_info", "(", "self", ",", "addon", ")", ":", "return", "self", ".", "send_command", "(", "f\"/addons/{addon}/info\"", ",", "method", "=", "\"get\"", ")" ]
[ 109, 4 ]
[ 114, 71 ]
python
en
['en', 'en', 'en']
True
HassIO.get_ingress_panels
(self)
Return data for Add-on ingress panels. This method return a coroutine.
Return data for Add-on ingress panels.
def get_ingress_panels(self): """Return data for Add-on ingress panels. This method return a coroutine. """ return self.send_command("/ingress/panels", method="get")
[ "def", "get_ingress_panels", "(", "self", ")", ":", "return", "self", ".", "send_command", "(", "\"/ingress/panels\"", ",", "method", "=", "\"get\"", ")" ]
[ 117, 4 ]
[ 122, 65 ]
python
en
['id', 'no', 'en']
False
HassIO.restart_homeassistant
(self)
Restart Home-Assistant container. This method return a coroutine.
Restart Home-Assistant container.
def restart_homeassistant(self): """Restart Home-Assistant container. This method return a coroutine. """ return self.send_command("/homeassistant/restart")
[ "def", "restart_homeassistant", "(", "self", ")", ":", "return", "self", ".", "send_command", "(", "\"/homeassistant/restart\"", ")" ]
[ 125, 4 ]
[ 130, 58 ]
python
en
['fr', 'en', 'en']
True
HassIO.stop_homeassistant
(self)
Stop Home-Assistant container. This method return a coroutine.
Stop Home-Assistant container.
def stop_homeassistant(self): """Stop Home-Assistant container. This method return a coroutine. """ return self.send_command("/homeassistant/stop")
[ "def", "stop_homeassistant", "(", "self", ")", ":", "return", "self", ".", "send_command", "(", "\"/homeassistant/stop\"", ")" ]
[ 133, 4 ]
[ 138, 55 ]
python
en
['fr', 'en', 'en']
True
HassIO.retrieve_discovery_messages
(self)
Return all discovery data from Hass.io API. This method return a coroutine.
Return all discovery data from Hass.io API.
def retrieve_discovery_messages(self): """Return all discovery data from Hass.io API. This method return a coroutine. """ return self.send_command("/discovery", method="get")
[ "def", "retrieve_discovery_messages", "(", "self", ")", ":", "return", "self", ".", "send_command", "(", "\"/discovery\"", ",", "method", "=", "\"get\"", ")" ]
[ 141, 4 ]
[ 146, 60 ]
python
en
['en', 'en', 'en']
True
HassIO.get_discovery_message
(self, uuid)
Return a single discovery data message. This method return a coroutine.
Return a single discovery data message.
def get_discovery_message(self, uuid): """Return a single discovery data message. This method return a coroutine. """ return self.send_command(f"/discovery/{uuid}", method="get")
[ "def", "get_discovery_message", "(", "self", ",", "uuid", ")", ":", "return", "self", ".", "send_command", "(", "f\"/discovery/{uuid}\"", ",", "method", "=", "\"get\"", ")" ]
[ 149, 4 ]
[ 154, 68 ]
python
en
['it', 'en', 'en']
True
HassIO.update_hass_api
(self, http_config, refresh_token)
Update Home Assistant API data on Hass.io.
Update Home Assistant API data on Hass.io.
async def update_hass_api(self, http_config, refresh_token): """Update Home Assistant API data on Hass.io.""" port = http_config.get(CONF_SERVER_PORT) or SERVER_PORT options = { "ssl": CONF_SSL_CERTIFICATE in http_config, "port": port, "watchdog": True, ...
[ "async", "def", "update_hass_api", "(", "self", ",", "http_config", ",", "refresh_token", ")", ":", "port", "=", "http_config", ".", "get", "(", "CONF_SERVER_PORT", ")", "or", "SERVER_PORT", "options", "=", "{", "\"ssl\"", ":", "CONF_SSL_CERTIFICATE", "in", "h...
[ 157, 4 ]
[ 173, 81 ]
python
en
['en', 'en', 'en']
True
HassIO.update_hass_timezone
(self, timezone)
Update Home-Assistant timezone data on Hass.io. This method return a coroutine.
Update Home-Assistant timezone data on Hass.io.
def update_hass_timezone(self, timezone): """Update Home-Assistant timezone data on Hass.io. This method return a coroutine. """ return self.send_command("/supervisor/options", payload={"timezone": timezone})
[ "def", "update_hass_timezone", "(", "self", ",", "timezone", ")", ":", "return", "self", ".", "send_command", "(", "\"/supervisor/options\"", ",", "payload", "=", "{", "\"timezone\"", ":", "timezone", "}", ")" ]
[ 176, 4 ]
[ 181, 87 ]
python
en
['en', 'en', 'en']
True
HassIO.send_command
(self, command, method="post", payload=None, timeout=10)
Send API command to Hass.io. This method is a coroutine.
Send API command to Hass.io.
async def send_command(self, command, method="post", payload=None, timeout=10): """Send API command to Hass.io. This method is a coroutine. """ try: with async_timeout.timeout(timeout): request = await self.websession.request( method, ...
[ "async", "def", "send_command", "(", "self", ",", "command", ",", "method", "=", "\"post\"", ",", "payload", "=", "None", ",", "timeout", "=", "10", ")", ":", "try", ":", "with", "async_timeout", ".", "timeout", "(", "timeout", ")", ":", "request", "="...
[ 183, 4 ]
[ 210, 30 ]
python
en
['en', 'mi', 'en']
True
Calibrator.__init__
(self, training_data, cache_file, batch_size=64, algorithm=trt.CalibrationAlgoType.ENTROPY_CALIBRATION_2)
Parameters ---------- training_data : numpy array The data using to calibrate quantization model cache_file : str The path user want to store calibrate cache file batch_size : int The batch_size of calibrating process algorithm : tenso...
Parameters ---------- training_data : numpy array The data using to calibrate quantization model cache_file : str The path user want to store calibrate cache file batch_size : int The batch_size of calibrating process algorithm : tenso...
def __init__(self, training_data, cache_file, batch_size=64, algorithm=trt.CalibrationAlgoType.ENTROPY_CALIBRATION_2): """ Parameters ---------- training_data : numpy array The data using to calibrate quantization model cache_file : str The path user want ...
[ "def", "__init__", "(", "self", ",", "training_data", ",", "cache_file", ",", "batch_size", "=", "64", ",", "algorithm", "=", "trt", ".", "CalibrationAlgoType", ".", "ENTROPY_CALIBRATION_2", ")", ":", "trt", ".", "IInt8Calibrator", ".", "__init__", "(", "self"...
[ 11, 4 ]
[ 37, 81 ]
python
en
['en', 'error', 'th']
False
Calibrator.get_batch
(self, names)
This function is used to define the way of feeding calibrating data each batch. Parameters ---------- names : str The names of the network inputs for each object in the bindings array Returns ------- list A list of device memory pointer...
This function is used to define the way of feeding calibrating data each batch.
def get_batch(self, names): """ This function is used to define the way of feeding calibrating data each batch. Parameters ---------- names : str The names of the network inputs for each object in the bindings array Returns ------- list ...
[ "def", "get_batch", "(", "self", ",", "names", ")", ":", "if", "self", ".", "current_index", "+", "self", ".", "batch_size", ">", "self", ".", "data", ".", "shape", "[", "0", "]", ":", "return", "None", "current_batch", "=", "int", "(", "self", ".", ...
[ 45, 4 ]
[ 73, 30 ]
python
en
['en', 'error', 'th']
False
Calibrator.read_calibration_cache
(self)
If there is a cache, use it instead of calibrating again. Otherwise, implicitly return None. Returns ------- cache object A cache object which contains calibration parameters for quantization
If there is a cache, use it instead of calibrating again. Otherwise, implicitly return None.
def read_calibration_cache(self): """ If there is a cache, use it instead of calibrating again. Otherwise, implicitly return None. Returns ------- cache object A cache object which contains calibration parameters for quantization """ if os.path.exists...
[ "def", "read_calibration_cache", "(", "self", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "cache_file", ")", ":", "with", "open", "(", "self", ".", "cache_file", ",", "\"rb\"", ")", "as", "f", ":", "return", "f", ".", "read", ...
[ 75, 4 ]
[ 86, 31 ]
python
en
['en', 'error', 'th']
False
Calibrator.write_calibration_cache
(self, cache)
Write calibration cache to specific path. Parameters ---------- cache : str The calibration cache to write
Write calibration cache to specific path.
def write_calibration_cache(self, cache): """ Write calibration cache to specific path. Parameters ---------- cache : str The calibration cache to write """ with open(self.cache_file, "wb") as f: f.write(cache)
[ "def", "write_calibration_cache", "(", "self", ",", "cache", ")", ":", "with", "open", "(", "self", ".", "cache_file", ",", "\"wb\"", ")", "as", "f", ":", "f", ".", "write", "(", "cache", ")" ]
[ 88, 4 ]
[ 98, 26 ]
python
en
['en', 'error', 'th']
False
WiLightFlowHandler.__init__
(self)
Initialize the WiLight flow.
Initialize the WiLight flow.
def __init__(self): """Initialize the WiLight flow.""" self._host = None self._serial_number = None self._title = None self._model_name = None self._wilight_components = [] self._components_text = ""
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "_host", "=", "None", "self", ".", "_serial_number", "=", "None", "self", ".", "_title", "=", "None", "self", ".", "_model_name", "=", "None", "self", ".", "_wilight_components", "=", "[", "]", "se...
[ 26, 4 ]
[ 33, 34 ]
python
en
['en', 'en', 'en']
True
WiLightFlowHandler.async_step_ssdp
(self, discovery_info)
Handle a discovered WiLight.
Handle a discovered WiLight.
async def async_step_ssdp(self, discovery_info): """Handle a discovered WiLight.""" # Filter out basic information if ( ssdp.ATTR_SSDP_LOCATION not in discovery_info or ssdp.ATTR_UPNP_MANUFACTURER not in discovery_info or ssdp.ATTR_UPNP_SERIAL not in discovery...
[ "async", "def", "async_step_ssdp", "(", "self", ",", "discovery_info", ")", ":", "# Filter out basic information", "if", "(", "ssdp", ".", "ATTR_SSDP_LOCATION", "not", "in", "discovery_info", "or", "ssdp", ".", "ATTR_UPNP_MANUFACTURER", "not", "in", "discovery_info", ...
[ 52, 4 ]
[ 88, 46 ]
python
en
['en', 'en', 'en']
True
WiLightFlowHandler.async_step_confirm
(self, user_input=None)
Handle user-confirmation of discovered WiLight.
Handle user-confirmation of discovered WiLight.
async def async_step_confirm(self, user_input=None): """Handle user-confirmation of discovered WiLight.""" if user_input is not None: return self._get_entry() return self.async_show_form( step_id="confirm", description_placeholders={ "name": s...
[ "async", "def", "async_step_confirm", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "_get_entry", "(", ")", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"conf...
[ 90, 4 ]
[ 102, 9 ]
python
en
['en', 'en', 'en']
True
async_get_triggers
(hass: HomeAssistant, device_id: str)
List device triggers for Humidifier devices.
List device triggers for Humidifier devices.
async def async_get_triggers(hass: HomeAssistant, device_id: str) -> List[dict]: """List device triggers for Humidifier devices.""" registry = await entity_registry.async_get_registry(hass) triggers = await toggle_entity.async_get_triggers(hass, device_id, DOMAIN) # Get all the integrations entities fo...
[ "async", "def", "async_get_triggers", "(", "hass", ":", "HomeAssistant", ",", "device_id", ":", "str", ")", "->", "List", "[", "dict", "]", ":", "registry", "=", "await", "entity_registry", ".", "async_get_registry", "(", "hass", ")", "triggers", "=", "await...
[ 50, 0 ]
[ 69, 19 ]
python
en
['da', '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.""" trigger_type = config[CONF_TYPE] if trigger_type == "target_humidity_changed": numeric_state_config = { ...
[ "async", "def", "async_attach_trigger", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ",", "action", ":", "AutomationActionType", ",", "automation_info", ":", "dict", ",", ")", "->", "CALLBACK_TYPE", ":", "trigger_type", "=", "config", "["...
[ 72, 0 ]
[ 104, 5 ]
python
en
['en', 'lb', 'en']
True
async_get_trigger_capabilities
(hass: HomeAssistant, config)
List trigger capabilities.
List trigger capabilities.
async def async_get_trigger_capabilities(hass: HomeAssistant, config): """List trigger capabilities.""" trigger_type = config[CONF_TYPE] if trigger_type == "target_humidity_changed": return { "extra_fields": vol.Schema( { vol.Optional( ...
[ "async", "def", "async_get_trigger_capabilities", "(", "hass", ":", "HomeAssistant", ",", "config", ")", ":", "trigger_type", "=", "config", "[", "CONF_TYPE", "]", "if", "trigger_type", "==", "\"target_humidity_changed\"", ":", "return", "{", "\"extra_fields\"", ":"...
[ 107, 0 ]
[ 125, 75 ]
python
en
['en', 'la', 'en']
True
async_get_actions
(hass: HomeAssistant, device_id: str)
List device actions for Humidifier devices.
List device actions for Humidifier devices.
async def async_get_actions(hass: HomeAssistant, device_id: str) -> List[dict]: """List device actions for Humidifier devices.""" registry = await entity_registry.async_get_registry(hass) actions = await toggle_entity.async_get_actions(hass, device_id, DOMAIN) # Get all the integrations entities for th...
[ "async", "def", "async_get_actions", "(", "hass", ":", "HomeAssistant", ",", "device_id", ":", "str", ")", "->", "List", "[", "dict", "]", ":", "registry", "=", "await", "entity_registry", ".", "async_get_registry", "(", "hass", ")", "actions", "=", "await",...
[ 41, 0 ]
[ 76, 18 ]
python
en
['fr', 'en', 'en']
True
async_call_action_from_config
( hass: HomeAssistant, config: dict, variables: dict, context: Optional[Context] )
Execute a device action.
Execute a device action.
async def async_call_action_from_config( hass: HomeAssistant, config: dict, variables: dict, context: Optional[Context] ) -> None: """Execute a device action.""" config = ACTION_SCHEMA(config) service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]} if config[CONF_TYPE] == "set_humidity": s...
[ "async", "def", "async_call_action_from_config", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ",", "variables", ":", "dict", ",", "context", ":", "Optional", "[", "Context", "]", ")", "->", "None", ":", "config", "=", "ACTION_SCHEMA", "(", ...
[ 79, 0 ]
[ 100, 5 ]
python
en
['ro', 'en', 'en']
True
async_get_action_capabilities
(hass, config)
List action capabilities.
List action capabilities.
async def async_get_action_capabilities(hass, config): """List action capabilities.""" state = hass.states.get(config[CONF_ENTITY_ID]) action_type = config[CONF_TYPE] fields = {} if action_type == "set_humidity": fields[vol.Required(const.ATTR_HUMIDITY)] = vol.Coerce(int) elif action_t...
[ "async", "def", "async_get_action_capabilities", "(", "hass", ",", "config", ")", ":", "state", "=", "hass", ".", "states", ".", "get", "(", "config", "[", "CONF_ENTITY_ID", "]", ")", "action_type", "=", "config", "[", "CONF_TYPE", "]", "fields", "=", "{",...
[ 103, 0 ]
[ 121, 47 ]
python
en
['ro', 'ga', 'en']
False
setup
(hass, config)
Initialize the Python script component.
Initialize the Python script component.
def setup(hass, config): """Initialize the Python script component.""" path = hass.config.path(FOLDER) if not os.path.isdir(path): _LOGGER.warning("Folder %s not found in configuration folder", FOLDER) return False discover_scripts(hass) def reload_scripts_handler(call): "...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "path", "=", "hass", ".", "config", ".", "path", "(", "FOLDER", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "_LOGGER", ".", "warning", "(", "\"Folder %s not found in ...
[ 78, 0 ]
[ 94, 15 ]
python
en
['en', 'fr', 'en']
True
discover_scripts
(hass)
Discover python scripts in folder.
Discover python scripts in folder.
def discover_scripts(hass): """Discover python scripts in folder.""" path = hass.config.path(FOLDER) if not os.path.isdir(path): _LOGGER.warning("Folder %s not found in configuration folder", FOLDER) return False def python_script_service_handler(call): """Handle python script ...
[ "def", "discover_scripts", "(", "hass", ")", ":", "path", "=", "hass", ".", "config", ".", "path", "(", "FOLDER", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "_LOGGER", ".", "warning", "(", "\"Folder %s not found in configur...
[ 97, 0 ]
[ 130, 66 ]
python
en
['en', 'en', 'en']
True
execute_script
(hass, name, data=None)
Execute a script.
Execute a script.
def execute_script(hass, name, data=None): """Execute a script.""" filename = f"{name}.py" with open(hass.config.path(FOLDER, sanitize_filename(filename))) as fil: source = fil.read() execute(hass, filename, source, data)
[ "def", "execute_script", "(", "hass", ",", "name", ",", "data", "=", "None", ")", ":", "filename", "=", "f\"{name}.py\"", "with", "open", "(", "hass", ".", "config", ".", "path", "(", "FOLDER", ",", "sanitize_filename", "(", "filename", ")", ")", ")", ...
[ 134, 0 ]
[ 139, 41 ]
python
en
['en', 'ca', 'en']
True
execute
(hass, filename, source, data=None)
Execute Python source.
Execute Python source.
def execute(hass, filename, source, data=None): """Execute Python source.""" compiled = compile_restricted_exec(source, filename=filename) if compiled.errors: _LOGGER.error( "Error loading script %s: %s", filename, ", ".join(compiled.errors) ) return if compiled.wa...
[ "def", "execute", "(", "hass", ",", "filename", ",", "source", ",", "data", "=", "None", ")", ":", "compiled", "=", "compile_restricted_exec", "(", "source", ",", "filename", "=", "filename", ")", "if", "compiled", ".", "errors", ":", "_LOGGER", ".", "er...
[ 143, 0 ]
[ 220, 59 ]
python
ceb
['fr', 'ceb', 'en']
False
StubPrinter.__init__
(self, _getattr_)
Initialize our printer.
Initialize our printer.
def __init__(self, _getattr_): """Initialize our printer."""
[ "def", "__init__", "(", "self", ",", "_getattr_", ")", ":" ]
[ 226, 4 ]
[ 227, 37 ]
python
en
['en', 'en', 'en']
True
StubPrinter._call_print
(self, *objects, **kwargs)
Print text.
Print text.
def _call_print(self, *objects, **kwargs): """Print text.""" # pylint: disable=no-self-use _LOGGER.warning("Don't use print() inside scripts. Use logger.info() instead")
[ "def", "_call_print", "(", "self", ",", "*", "objects", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=no-self-use", "_LOGGER", ".", "warning", "(", "\"Don't use print() inside scripts. Use logger.info() instead\"", ")" ]
[ 229, 4 ]
[ 232, 86 ]
python
en
['en', 'hu', 'en']
False
TimeWrapper.sleep
(self, *args, **kwargs)
Sleep method that warns once.
Sleep method that warns once.
def sleep(self, *args, **kwargs): """Sleep method that warns once.""" if not TimeWrapper.warned: TimeWrapper.warned = True _LOGGER.warning( "Using time.sleep can reduce the performance of Home Assistant" ) time.sleep(*args, **kwargs)
[ "def", "sleep", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "TimeWrapper", ".", "warned", ":", "TimeWrapper", ".", "warned", "=", "True", "_LOGGER", ".", "warning", "(", "\"Using time.sleep can reduce the performance of Home ...
[ 242, 4 ]
[ 250, 35 ]
python
en
['en', 'xh', 'en']
True
TimeWrapper.__getattr__
(self, attr)
Fetch an attribute from Time module.
Fetch an attribute from Time module.
def __getattr__(self, attr): """Fetch an attribute from Time module.""" attribute = getattr(time, attr) if callable(attribute): def wrapper(*args, **kw): """Wrap to return callable method if callable.""" return attribute(*args, **kw) retu...
[ "def", "__getattr__", "(", "self", ",", "attr", ")", ":", "attribute", "=", "getattr", "(", "time", ",", "attr", ")", "if", "callable", "(", "attribute", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "\"\"\"Wrap to retu...
[ 252, 4 ]
[ 262, 24 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the GC100 devices.
Set up the GC100 devices.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the GC100 devices.""" switches = [] ports = config.get(CONF_PORTS) for port in ports: for port_addr, port_name in port.items(): switches.append(GC100Switch(port_name, port_addr, hass.data[DATA_GC100])) ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "switches", "=", "[", "]", "ports", "=", "config", ".", "get", "(", "CONF_PORTS", ")", "for", "port", "in", "ports", ":", "for", "po...
[ 17, 0 ]
[ 24, 32 ]
python
en
['en', 'en', 'en']
True
GC100Switch.__init__
(self, name, port_addr, gc100)
Initialize the GC100 switch.
Initialize the GC100 switch.
def __init__(self, name, port_addr, gc100): """Initialize the GC100 switch.""" self._name = name or DEVICE_DEFAULT_NAME self._port_addr = port_addr self._gc100 = gc100 self._state = None
[ "def", "__init__", "(", "self", ",", "name", ",", "port_addr", ",", "gc100", ")", ":", "self", ".", "_name", "=", "name", "or", "DEVICE_DEFAULT_NAME", "self", ".", "_port_addr", "=", "port_addr", "self", ".", "_gc100", "=", "gc100", "self", ".", "_state"...
[ 30, 4 ]
[ 35, 26 ]
python
en
['en', 'en', 'en']
True
GC100Switch.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" ]
[ 38, 4 ]
[ 40, 25 ]
python
en
['en', 'en', 'en']
True
GC100Switch.is_on
(self)
Return the state of the entity.
Return the state of the entity.
def is_on(self): """Return the state of the entity.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 43, 4 ]
[ 45, 26 ]
python
en
['en', 'en', 'en']
True
GC100Switch.turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
def turn_on(self, **kwargs): """Turn the device on.""" self._gc100.write_switch(self._port_addr, 1, self.set_state)
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_gc100", ".", "write_switch", "(", "self", ".", "_port_addr", ",", "1", ",", "self", ".", "set_state", ")" ]
[ 47, 4 ]
[ 49, 68 ]
python
en
['en', 'en', 'en']
True
GC100Switch.turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
def turn_off(self, **kwargs): """Turn the device off.""" self._gc100.write_switch(self._port_addr, 0, self.set_state)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_gc100", ".", "write_switch", "(", "self", ".", "_port_addr", ",", "0", ",", "self", ".", "set_state", ")" ]
[ 51, 4 ]
[ 53, 68 ]
python
en
['en', 'en', 'en']
True
GC100Switch.update
(self)
Update the sensor state.
Update the sensor state.
def update(self): """Update the sensor state.""" self._gc100.read_sensor(self._port_addr, self.set_state)
[ "def", "update", "(", "self", ")", ":", "self", ".", "_gc100", ".", "read_sensor", "(", "self", ".", "_port_addr", ",", "self", ".", "set_state", ")" ]
[ 55, 4 ]
[ 57, 64 ]
python
en
['en', 'co', 'en']
True
GC100Switch.set_state
(self, state)
Set the current state.
Set the current state.
def set_state(self, state): """Set the current state.""" self._state = state == 1 self.schedule_update_ha_state()
[ "def", "set_state", "(", "self", ",", "state", ")", ":", "self", ".", "_state", "=", "state", "==", "1", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 59, 4 ]
[ 62, 39 ]
python
en
['en', 'en', 'en']
True
_mock_powerwall_with_fixtures
(hass)
Mock data used to build powerwall state.
Mock data used to build powerwall state.
async def _mock_powerwall_with_fixtures(hass): """Mock data used to build powerwall state.""" meters = await _async_load_json_fixture(hass, "meters.json") sitemaster = await _async_load_json_fixture(hass, "sitemaster.json") site_info = await _async_load_json_fixture(hass, "site_info.json") status = ...
[ "async", "def", "_mock_powerwall_with_fixtures", "(", "hass", ")", ":", "meters", "=", "await", "_async_load_json_fixture", "(", "hass", ",", "\"meters.json\"", ")", "sitemaster", "=", "await", "_async_load_json_fixture", "(", "hass", ",", "\"sitemaster.json\"", ")", ...
[ 22, 0 ]
[ 39, 5 ]
python
en
['en', 'en', 'en']
True
_mock_get_config
()
Return a default powerwall config.
Return a default powerwall config.
def _mock_get_config(): """Return a default powerwall config.""" return {DOMAIN: {CONF_IP_ADDRESS: "1.2.3.4"}}
[ "def", "_mock_get_config", "(", ")", ":", "return", "{", "DOMAIN", ":", "{", "CONF_IP_ADDRESS", ":", "\"1.2.3.4\"", "}", "}" ]
[ 89, 0 ]
[ 91, 49 ]
python
en
['en', 'lb', 'en']
True
XiaomiAqaraFlowHandler.__init__
(self)
Initialize.
Initialize.
def __init__(self): """Initialize.""" self.host = None self.interface = DEFAULT_INTERFACE self.sid = None self.gateways = None self.selected_gateway = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "host", "=", "None", "self", ".", "interface", "=", "DEFAULT_INTERFACE", "self", ".", "sid", "=", "None", "self", ".", "gateways", "=", "None", "self", ".", "selected_gateway", "=", "None" ]
[ 52, 4 ]
[ 58, 36 ]
python
en
['en', 'en', 'it']
False
XiaomiAqaraFlowHandler.async_show_form_step_user
(self, errors)
Show the form belonging to the user step.
Show the form belonging to the user step.
def async_show_form_step_user(self, errors): """Show the form belonging to the user step.""" schema = GATEWAY_CONFIG if (self.host is None and self.sid is None) or errors: schema = GATEWAY_CONFIG_HOST return self.async_show_form(step_id="user", data_schema=schema, errors=err...
[ "def", "async_show_form_step_user", "(", "self", ",", "errors", ")", ":", "schema", "=", "GATEWAY_CONFIG", "if", "(", "self", ".", "host", "is", "None", "and", "self", ".", "sid", "is", "None", ")", "or", "errors", ":", "schema", "=", "GATEWAY_CONFIG_HOST"...
[ 61, 4 ]
[ 67, 86 ]
python
en
['en', 'en', 'en']
True