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
SpeedtestSensor.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" ]
[ 26, 4 ]
[ 28, 25 ]
python
en
['en', 'mi', 'en']
True
SpeedtestSensor.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 31, 4 ]
[ 33, 26 ]
python
en
['en', 'en', 'en']
True
SpeedtestSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return DATA_RATE_MEGABITS_PER_SECOND
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "DATA_RATE_MEGABITS_PER_SECOND" ]
[ 36, 4 ]
[ 38, 44 ]
python
en
['en', 'en', 'en']
True
SpeedtestSensor.icon
(self)
Return icon.
Return icon.
def icon(self): """Return icon.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 41, 4 ]
[ 43, 19 ]
python
en
['en', 'la', 'en']
False
SpeedtestSensor.should_poll
(self)
Return the polling requirement for this sensor.
Return the polling requirement for this sensor.
def should_poll(self): """Return the polling requirement for this sensor.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 46, 4 ]
[ 48, 20 ]
python
en
['en', 'en', 'en']
True
SpeedtestSensor.async_added_to_hass
(self)
Handle entity which will be added.
Handle entity which will be added.
async def async_added_to_hass(self): """Handle entity which will be added.""" await super().async_added_to_hass() self.async_on_remove( async_dispatcher_connect( self.hass, DATA_UPDATED, self._schedule_immediate_update ) ) state = await s...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "DATA_UPDATED", ",", "self", ".", ...
[ 50, 4 ]
[ 63, 33 ]
python
en
['en', 'en', 'en']
True
SpeedtestSensor.update
(self)
Get the latest data and update the states.
Get the latest data and update the states.
def update(self): """Get the latest data and update the states.""" data = self.speedtest_client.data if data is None: return self._state = data["download"]
[ "def", "update", "(", "self", ")", ":", "data", "=", "self", ".", "speedtest_client", ".", "data", "if", "data", "is", "None", ":", "return", "self", ".", "_state", "=", "data", "[", "\"download\"", "]" ]
[ 65, 4 ]
[ 70, 38 ]
python
en
['en', 'en', 'en']
True
mock_mikrotik_api
()
Mock an api.
Mock an api.
def mock_mikrotik_api(): """Mock an api.""" with patch("librouteros.connect"): yield
[ "def", "mock_mikrotik_api", "(", ")", ":", "with", "patch", "(", "\"librouteros.connect\"", ")", ":", "yield" ]
[ 55, 0 ]
[ 58, 13 ]
python
en
['en', 'su', 'en']
True
mock_api_authentication_error
()
Mock an api.
Mock an api.
def mock_api_authentication_error(): """Mock an api.""" with patch( "librouteros.connect", side_effect=librouteros.exceptions.TrapError("invalid user name or password"), ): yield
[ "def", "mock_api_authentication_error", "(", ")", ":", "with", "patch", "(", "\"librouteros.connect\"", ",", "side_effect", "=", "librouteros", ".", "exceptions", ".", "TrapError", "(", "\"invalid user name or password\"", ")", ",", ")", ":", "yield" ]
[ 62, 0 ]
[ 68, 13 ]
python
en
['en', 'su', 'en']
True
mock_api_connection_error
()
Mock an api.
Mock an api.
def mock_api_connection_error(): """Mock an api.""" with patch( "librouteros.connect", side_effect=librouteros.exceptions.ConnectionClosed ): yield
[ "def", "mock_api_connection_error", "(", ")", ":", "with", "patch", "(", "\"librouteros.connect\"", ",", "side_effect", "=", "librouteros", ".", "exceptions", ".", "ConnectionClosed", ")", ":", "yield" ]
[ 72, 0 ]
[ 77, 13 ]
python
en
['en', 'su', 'en']
True
test_import
(hass, api)
Test import step.
Test import step.
async def test_import(hass, api): """Test import step.""" result = await hass.config_entries.flow.async_init( mikrotik.DOMAIN, context={"source": "import"}, data=DEMO_CONFIG ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["title"] == "Home router" asser...
[ "async", "def", "test_import", "(", "hass", ",", "api", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "mikrotik", ".", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"import\"", "}", ",", ...
[ 80, 0 ]
[ 93, 51 ]
python
de
['de', 'sd', 'en']
False
test_flow_works
(hass, api)
Test config flow.
Test config flow.
async def test_flow_works(hass, api): """Test config flow.""" result = await hass.config_entries.flow.async_init( mikrotik.DOMAIN, context={"source": "user"} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "user" result = await hass.config_entrie...
[ "async", "def", "test_flow_works", "(", "hass", ",", "api", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "mikrotik", ".", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"user\"", "}", ")"...
[ 96, 0 ]
[ 115, 44 ]
python
da
['de', 'da', 'en']
False
test_options
(hass)
Test updating options.
Test updating options.
async def test_options(hass): """Test updating options.""" entry = MockConfigEntry(domain=mikrotik.DOMAIN, data=DEMO_CONFIG_ENTRY) entry.add_to_hass(hass) result = await hass.config_entries.options.async_init(entry.entry_id) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert resu...
[ "async", "def", "test_options", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "mikrotik", ".", "DOMAIN", ",", "data", "=", "DEMO_CONFIG_ENTRY", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "result", "=", "await", "hass"...
[ 118, 0 ]
[ 142, 5 ]
python
en
['en', 'en', 'en']
True
test_host_already_configured
(hass, auth_error)
Test host already configured.
Test host already configured.
async def test_host_already_configured(hass, auth_error): """Test host already configured.""" entry = MockConfigEntry(domain=mikrotik.DOMAIN, data=DEMO_CONFIG_ENTRY) entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( mikrotik.DOMAIN, context={"source": "user"} ) ...
[ "async", "def", "test_host_already_configured", "(", "hass", ",", "auth_error", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "mikrotik", ".", "DOMAIN", ",", "data", "=", "DEMO_CONFIG_ENTRY", ")", "entry", ".", "add_to_hass", "(", "hass", ")",...
[ 145, 0 ]
[ 158, 51 ]
python
en
['en', 'ga', 'en']
True
test_name_exists
(hass, api)
Test name already configured.
Test name already configured.
async def test_name_exists(hass, api): """Test name already configured.""" entry = MockConfigEntry(domain=mikrotik.DOMAIN, data=DEMO_CONFIG_ENTRY) entry.add_to_hass(hass) user_input = DEMO_USER_INPUT.copy() user_input[CONF_HOST] = "0.0.0.1" result = await hass.config_entries.flow.async_init( ...
[ "async", "def", "test_name_exists", "(", "hass", ",", "api", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "mikrotik", ".", "DOMAIN", ",", "data", "=", "DEMO_CONFIG_ENTRY", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "user_input", ...
[ 161, 0 ]
[ 177, 57 ]
python
en
['en', 'el-Latn', 'en']
True
test_connection_error
(hass, conn_error)
Test error when connection is unsuccessful.
Test error when connection is unsuccessful.
async def test_connection_error(hass, conn_error): """Test error when connection is unsuccessful.""" result = await hass.config_entries.flow.async_init( mikrotik.DOMAIN, context={"source": "user"} ) result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=D...
[ "async", "def", "test_connection_error", "(", "hass", ",", "conn_error", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "mikrotik", ".", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"user\"",...
[ 180, 0 ]
[ 190, 57 ]
python
en
['en', 'en', 'en']
True
test_wrong_credentials
(hass, auth_error)
Test error when credentials are wrong.
Test error when credentials are wrong.
async def test_wrong_credentials(hass, auth_error): """Test error when credentials are wrong.""" result = await hass.config_entries.flow.async_init( mikrotik.DOMAIN, context={"source": "user"} ) result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=DEMO_...
[ "async", "def", "test_wrong_credentials", "(", "hass", ",", "auth_error", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "mikrotik", ".", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"user\""...
[ 193, 0 ]
[ 207, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Load a config entry.
Load a config entry.
async def async_setup_entry(hass, entry, async_add_entities): """Load a config entry.""" coordinator = hass.data[DOMAIN][entry.entry_id] async_add_entities([AtagThermostat(coordinator, CLIMATE)])
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "coordinator", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "async_add_entities", "(", "[", "AtagThermostat", "(", "coor...
[ 32, 0 ]
[ 35, 62 ]
python
en
['en', 'en', 'en']
True
AtagThermostat.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self): """Return the list of supported features.""" return SUPPORT_FLAGS
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_FLAGS" ]
[ 42, 4 ]
[ 44, 28 ]
python
en
['en', 'en', 'en']
True
AtagThermostat.hvac_mode
(self)
Return hvac operation ie. heat, cool mode.
Return hvac operation ie. heat, cool mode.
def hvac_mode(self) -> Optional[str]: """Return hvac operation ie. heat, cool mode.""" if self.coordinator.atag.climate.hvac_mode in HVAC_MODES: return self.coordinator.atag.climate.hvac_mode return None
[ "def", "hvac_mode", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "self", ".", "coordinator", ".", "atag", ".", "climate", ".", "hvac_mode", "in", "HVAC_MODES", ":", "return", "self", ".", "coordinator", ".", "atag", ".", "climate", "...
[ 47, 4 ]
[ 51, 19 ]
python
bg
['en', 'bg', 'bg']
True
AtagThermostat.hvac_modes
(self)
Return the list of available hvac operation modes.
Return the list of available hvac operation modes.
def hvac_modes(self) -> List[str]: """Return the list of available hvac operation modes.""" return HVAC_MODES
[ "def", "hvac_modes", "(", "self", ")", "->", "List", "[", "str", "]", ":", "return", "HVAC_MODES" ]
[ 54, 4 ]
[ 56, 25 ]
python
en
['en', 'en', 'en']
True
AtagThermostat.hvac_action
(self)
Return the current running hvac operation.
Return the current running hvac operation.
def hvac_action(self) -> Optional[str]: """Return the current running hvac operation.""" if self.coordinator.atag.climate.status: return CURRENT_HVAC_HEAT return CURRENT_HVAC_IDLE
[ "def", "hvac_action", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "self", ".", "coordinator", ".", "atag", ".", "climate", ".", "status", ":", "return", "CURRENT_HVAC_HEAT", "return", "CURRENT_HVAC_IDLE" ]
[ 59, 4 ]
[ 63, 32 ]
python
en
['en', 'is', 'en']
True
AtagThermostat.temperature_unit
(self)
Return the unit of measurement.
Return the unit of measurement.
def temperature_unit(self): """Return the unit of measurement.""" return self.coordinator.atag.climate.temp_unit
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "self", ".", "coordinator", ".", "atag", ".", "climate", ".", "temp_unit" ]
[ 66, 4 ]
[ 68, 54 ]
python
en
['en', 'la', 'en']
True
AtagThermostat.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self) -> Optional[float]: """Return the current temperature.""" return self.coordinator.atag.climate.temperature
[ "def", "current_temperature", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "return", "self", ".", "coordinator", ".", "atag", ".", "climate", ".", "temperature" ]
[ 71, 4 ]
[ 73, 56 ]
python
en
['en', 'la', 'en']
True
AtagThermostat.target_temperature
(self)
Return the temperature we try to reach.
Return the temperature we try to reach.
def target_temperature(self) -> Optional[float]: """Return the temperature we try to reach.""" return self.coordinator.atag.climate.target_temperature
[ "def", "target_temperature", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "return", "self", ".", "coordinator", ".", "atag", ".", "climate", ".", "target_temperature" ]
[ 76, 4 ]
[ 78, 63 ]
python
en
['en', 'en', 'en']
True
AtagThermostat.preset_mode
(self)
Return the current preset mode, e.g., auto, manual, fireplace, extend, etc.
Return the current preset mode, e.g., auto, manual, fireplace, extend, etc.
def preset_mode(self) -> Optional[str]: """Return the current preset mode, e.g., auto, manual, fireplace, extend, etc.""" return self.coordinator.atag.climate.preset_mode
[ "def", "preset_mode", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "coordinator", ".", "atag", ".", "climate", ".", "preset_mode" ]
[ 81, 4 ]
[ 83, 56 ]
python
en
['en', 'en', 'en']
True
AtagThermostat.preset_modes
(self)
Return a list of available preset modes.
Return a list of available preset modes.
def preset_modes(self) -> Optional[List[str]]: """Return a list of available preset modes.""" return SUPPORT_PRESET
[ "def", "preset_modes", "(", "self", ")", "->", "Optional", "[", "List", "[", "str", "]", "]", ":", "return", "SUPPORT_PRESET" ]
[ 86, 4 ]
[ 88, 29 ]
python
en
['en', 'en', 'en']
True
AtagThermostat.async_set_temperature
(self, **kwargs)
Set new target temperature.
Set new target temperature.
async def async_set_temperature(self, **kwargs) -> None: """Set new target temperature.""" await self.coordinator.atag.climate.set_temp(kwargs.get(ATTR_TEMPERATURE)) self.async_write_ha_state()
[ "async", "def", "async_set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "coordinator", ".", "atag", ".", "climate", ".", "set_temp", "(", "kwargs", ".", "get", "(", "ATTR_TEMPERATURE", ")", ")", "self"...
[ 90, 4 ]
[ 93, 35 ]
python
en
['en', 'ca', 'en']
True
AtagThermostat.async_set_hvac_mode
(self, hvac_mode: str)
Set new target hvac mode.
Set new target hvac mode.
async def async_set_hvac_mode(self, hvac_mode: str) -> None: """Set new target hvac mode.""" await self.coordinator.atag.climate.set_hvac_mode(hvac_mode) self.async_write_ha_state()
[ "async", "def", "async_set_hvac_mode", "(", "self", ",", "hvac_mode", ":", "str", ")", "->", "None", ":", "await", "self", ".", "coordinator", ".", "atag", ".", "climate", ".", "set_hvac_mode", "(", "hvac_mode", ")", "self", ".", "async_write_ha_state", "(",...
[ 95, 4 ]
[ 98, 35 ]
python
da
['da', 'su', 'en']
False
AtagThermostat.async_set_preset_mode
(self, preset_mode: str)
Set new preset mode.
Set new preset mode.
async def async_set_preset_mode(self, preset_mode: str) -> None: """Set new preset mode.""" await self.coordinator.atag.climate.set_preset_mode(preset_mode) self.async_write_ha_state()
[ "async", "def", "async_set_preset_mode", "(", "self", ",", "preset_mode", ":", "str", ")", "->", "None", ":", "await", "self", ".", "coordinator", ".", "atag", ".", "climate", ".", "set_preset_mode", "(", "preset_mode", ")", "self", ".", "async_write_ha_state"...
[ 100, 4 ]
[ 103, 35 ]
python
en
['en', 'sr', 'en']
True
async_setup
(hass: HomeAssistantType, config: ConfigType)
Set up the counters.
Set up the counters.
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: """Set up the counters.""" component = EntityComponent(_LOGGER, DOMAIN, hass) id_manager = collection.IDManager() yaml_collection = collection.YamlCollection( logging.getLogger(f"{__name__}.yaml_collection"), id_manager...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "component", "=", "EntityComponent", "(", "_LOGGER", ",", "DOMAIN", ",", "hass", ")", "id_manager", "=", "collection", ".", "IDMan...
[ 102, 0 ]
[ 150, 15 ]
python
en
['en', 'en', 'en']
True
CounterStorageCollection._process_create_data
(self, data: Dict)
Validate the config is valid.
Validate the config is valid.
async def _process_create_data(self, data: Dict) -> Dict: """Validate the config is valid.""" return self.CREATE_SCHEMA(data)
[ "async", "def", "_process_create_data", "(", "self", ",", "data", ":", "Dict", ")", "->", "Dict", ":", "return", "self", ".", "CREATE_SCHEMA", "(", "data", ")" ]
[ 159, 4 ]
[ 161, 39 ]
python
en
['en', 'en', 'en']
True
CounterStorageCollection._get_suggested_id
(self, info: Dict)
Suggest an ID based on the config.
Suggest an ID based on the config.
def _get_suggested_id(self, info: Dict) -> str: """Suggest an ID based on the config.""" return info[CONF_NAME]
[ "def", "_get_suggested_id", "(", "self", ",", "info", ":", "Dict", ")", "->", "str", ":", "return", "info", "[", "CONF_NAME", "]" ]
[ 164, 4 ]
[ 166, 30 ]
python
en
['en', 'en', 'en']
True
CounterStorageCollection._update_data
(self, data: dict, update_data: Dict)
Return a new updated data object.
Return a new updated data object.
async def _update_data(self, data: dict, update_data: Dict) -> Dict: """Return a new updated data object.""" update_data = self.UPDATE_SCHEMA(update_data) return {**data, **update_data}
[ "async", "def", "_update_data", "(", "self", ",", "data", ":", "dict", ",", "update_data", ":", "Dict", ")", "->", "Dict", ":", "update_data", "=", "self", ".", "UPDATE_SCHEMA", "(", "update_data", ")", "return", "{", "*", "*", "data", ",", "*", "*", ...
[ 168, 4 ]
[ 171, 38 ]
python
en
['en', 'en', 'en']
True
Counter.__init__
(self, config: Dict)
Initialize a counter.
Initialize a counter.
def __init__(self, config: Dict): """Initialize a counter.""" self._config: Dict = config self._state: Optional[int] = config[CONF_INITIAL] self.editable: bool = True
[ "def", "__init__", "(", "self", ",", "config", ":", "Dict", ")", ":", "self", ".", "_config", ":", "Dict", "=", "config", "self", ".", "_state", ":", "Optional", "[", "int", "]", "=", "config", "[", "CONF_INITIAL", "]", "self", ".", "editable", ":", ...
[ 177, 4 ]
[ 181, 34 ]
python
en
['es', 'en', 'en']
True
Counter.from_yaml
(cls, config: Dict)
Create counter instance from yaml config.
Create counter instance from yaml config.
def from_yaml(cls, config: Dict) -> "Counter": """Create counter instance from yaml config.""" counter = cls(config) counter.editable = False counter.entity_id = ENTITY_ID_FORMAT.format(config[CONF_ID]) return counter
[ "def", "from_yaml", "(", "cls", ",", "config", ":", "Dict", ")", "->", "\"Counter\"", ":", "counter", "=", "cls", "(", "config", ")", "counter", ".", "editable", "=", "False", "counter", ".", "entity_id", "=", "ENTITY_ID_FORMAT", ".", "format", "(", "con...
[ 184, 4 ]
[ 189, 22 ]
python
en
['en', 'en', 'en']
True
Counter.should_poll
(self)
If entity should be polled.
If entity should be polled.
def should_poll(self) -> bool: """If entity should be polled.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 192, 4 ]
[ 194, 20 ]
python
en
['en', 'en', 'en']
True
Counter.name
(self)
Return name of the counter.
Return name of the counter.
def name(self) -> Optional[str]: """Return name of the counter.""" return self._config.get(CONF_NAME)
[ "def", "name", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_NAME", ")" ]
[ 197, 4 ]
[ 199, 42 ]
python
en
['en', 'en', 'en']
True
Counter.icon
(self)
Return the icon to be used for this entity.
Return the icon to be used for this entity.
def icon(self) -> Optional[str]: """Return the icon to be used for this entity.""" return self._config.get(CONF_ICON)
[ "def", "icon", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_ICON", ")" ]
[ 202, 4 ]
[ 204, 42 ]
python
en
['en', 'en', 'en']
True
Counter.state
(self)
Return the current value of the counter.
Return the current value of the counter.
def state(self) -> Optional[int]: """Return the current value of the counter.""" return self._state
[ "def", "state", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "return", "self", ".", "_state" ]
[ 207, 4 ]
[ 209, 26 ]
python
en
['en', 'en', 'en']
True
Counter.state_attributes
(self)
Return the state attributes.
Return the state attributes.
def state_attributes(self) -> Dict: """Return the state attributes.""" ret = { ATTR_EDITABLE: self.editable, ATTR_INITIAL: self._config[CONF_INITIAL], ATTR_STEP: self._config[CONF_STEP], } if self._config[CONF_MINIMUM] is not None: ret[CONF...
[ "def", "state_attributes", "(", "self", ")", "->", "Dict", ":", "ret", "=", "{", "ATTR_EDITABLE", ":", "self", ".", "editable", ",", "ATTR_INITIAL", ":", "self", ".", "_config", "[", "CONF_INITIAL", "]", ",", "ATTR_STEP", ":", "self", ".", "_config", "["...
[ 212, 4 ]
[ 223, 18 ]
python
en
['en', 'en', 'en']
True
Counter.unique_id
(self)
Return unique id of the entity.
Return unique id of the entity.
def unique_id(self) -> Optional[str]: """Return unique id of the entity.""" return self._config[CONF_ID]
[ "def", "unique_id", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "_config", "[", "CONF_ID", "]" ]
[ 226, 4 ]
[ 228, 36 ]
python
en
['en', 'en', 'en']
True
Counter.compute_next_state
(self, state)
Keep the state within the range of min/max values.
Keep the state within the range of min/max values.
def compute_next_state(self, state) -> int: """Keep the state within the range of min/max values.""" if self._config[CONF_MINIMUM] is not None: state = max(self._config[CONF_MINIMUM], state) if self._config[CONF_MAXIMUM] is not None: state = min(self._config[CONF_MAXIMUM]...
[ "def", "compute_next_state", "(", "self", ",", "state", ")", "->", "int", ":", "if", "self", ".", "_config", "[", "CONF_MINIMUM", "]", "is", "not", "None", ":", "state", "=", "max", "(", "self", ".", "_config", "[", "CONF_MINIMUM", "]", ",", "state", ...
[ 230, 4 ]
[ 237, 20 ]
python
en
['en', 'en', 'en']
True
Counter.async_added_to_hass
(self)
Call when entity about to be added to Home Assistant.
Call when entity about to be added to Home Assistant.
async def async_added_to_hass(self) -> None: """Call when entity about to be added to Home Assistant.""" await super().async_added_to_hass() # __init__ will set self._state to self._initial, only override # if needed. if self._config[CONF_RESTORE]: state = await self....
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "# __init__ will set self._state to self._initial, only override", "# if needed.", "if", "self", ".", "_config", "[", "CONF_RE...
[ 239, 4 ]
[ 251, 73 ]
python
en
['en', 'en', 'en']
True
Counter.async_decrement
(self)
Decrement the counter.
Decrement the counter.
def async_decrement(self) -> None: """Decrement the counter.""" self._state = self.compute_next_state(self._state - self._config[CONF_STEP]) self.async_write_ha_state()
[ "def", "async_decrement", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "self", ".", "compute_next_state", "(", "self", ".", "_state", "-", "self", ".", "_config", "[", "CONF_STEP", "]", ")", "self", ".", "async_write_ha_state", "(", "...
[ 254, 4 ]
[ 257, 35 ]
python
en
['en', 'en', 'en']
True
Counter.async_increment
(self)
Increment a counter.
Increment a counter.
def async_increment(self) -> None: """Increment a counter.""" self._state = self.compute_next_state(self._state + self._config[CONF_STEP]) self.async_write_ha_state()
[ "def", "async_increment", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "self", ".", "compute_next_state", "(", "self", ".", "_state", "+", "self", ".", "_config", "[", "CONF_STEP", "]", ")", "self", ".", "async_write_ha_state", "(", "...
[ 260, 4 ]
[ 263, 35 ]
python
en
['es', 'en', 'en']
True
Counter.async_reset
(self)
Reset a counter.
Reset a counter.
def async_reset(self) -> None: """Reset a counter.""" self._state = self.compute_next_state(self._config[CONF_INITIAL]) self.async_write_ha_state()
[ "def", "async_reset", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "self", ".", "compute_next_state", "(", "self", ".", "_config", "[", "CONF_INITIAL", "]", ")", "self", ".", "async_write_ha_state", "(", ")" ]
[ 266, 4 ]
[ 269, 35 ]
python
en
['en', 'en', 'en']
True
Counter.async_configure
(self, **kwargs)
Change the counter's settings with a service.
Change the counter's settings with a service.
def async_configure(self, **kwargs) -> None: """Change the counter's settings with a service.""" new_state = kwargs.pop(VALUE, self._state) self._config = {**self._config, **kwargs} self._state = self.compute_next_state(new_state) self.async_write_ha_state()
[ "def", "async_configure", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "new_state", "=", "kwargs", ".", "pop", "(", "VALUE", ",", "self", ".", "_state", ")", "self", ".", "_config", "=", "{", "*", "*", "self", ".", "_config", ",", ...
[ 272, 4 ]
[ 277, 35 ]
python
en
['en', 'en', 'en']
True
Counter.async_update_config
(self, config: Dict)
Change the counter's settings WS CRUD.
Change the counter's settings WS CRUD.
async def async_update_config(self, config: Dict) -> None: """Change the counter's settings WS CRUD.""" self._config = config self._state = self.compute_next_state(self._state) self.async_write_ha_state()
[ "async", "def", "async_update_config", "(", "self", ",", "config", ":", "Dict", ")", "->", "None", ":", "self", ".", "_config", "=", "config", "self", ".", "_state", "=", "self", ".", "compute_next_state", "(", "self", ".", "_state", ")", "self", ".", ...
[ 279, 4 ]
[ 283, 35 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Insteon binary sensors from a config entry.
Set up the Insteon binary sensors from a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Insteon binary sensors from a config entry.""" def add_entities(discovery_info=None): """Add the Insteon entities for the platform.""" async_add_insteon_entities( hass, BINARY_SENSOR_DOMAI...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "def", "add_entities", "(", "discovery_info", "=", "None", ")", ":", "\"\"\"Add the Insteon entities for the platform.\"\"\"", "async_add_insteon_entities", "(", "h...
[ 50, 0 ]
[ 65, 18 ]
python
en
['en', 'en', 'en']
True
InsteonBinarySensorEntity.__init__
(self, device, group)
Initialize the INSTEON binary sensor.
Initialize the INSTEON binary sensor.
def __init__(self, device, group): """Initialize the INSTEON binary sensor.""" super().__init__(device, group) self._sensor_type = SENSOR_TYPES.get(self._insteon_device_group.name)
[ "def", "__init__", "(", "self", ",", "device", ",", "group", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "group", ")", "self", ".", "_sensor_type", "=", "SENSOR_TYPES", ".", "get", "(", "self", ".", "_insteon_device_group", ".", "...
[ 71, 4 ]
[ 74, 77 ]
python
en
['en', 'pl', 'en']
True
InsteonBinarySensorEntity.device_class
(self)
Return the class of this sensor.
Return the class of this sensor.
def device_class(self): """Return the class of this sensor.""" return self._sensor_type
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_sensor_type" ]
[ 77, 4 ]
[ 79, 32 ]
python
en
['en', 'en', 'en']
True
InsteonBinarySensorEntity.is_on
(self)
Return the boolean response if the node is on.
Return the boolean response if the node is on.
def is_on(self): """Return the boolean response if the node is on.""" return bool(self._insteon_device_group.value)
[ "def", "is_on", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "_insteon_device_group", ".", "value", ")" ]
[ 82, 4 ]
[ 84, 53 ]
python
en
['en', 'en', 'en']
True
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", "(...
[ 9, 0 ]
[ 46, 48 ]
python
en
['en', 'en', 'en']
True
test_form_invalid_credentials
(hass)
Test if we get the error message on invalid credentials.
Test if we get the error message on invalid credentials.
async def test_form_invalid_credentials(hass): """Test if we get the error message on invalid credentials.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) as...
[ "async", "def", "test_form_invalid_credentials", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", ...
[ 49, 0 ]
[ 67, 59 ]
python
en
['en', 'en', 'en']
True
test_form_already_configured
(hass)
Test if we get the error message on already configured.
Test if we get the error message on already configured.
async def test_form_already_configured(hass): """Test if we get the error message on already configured.""" with patch( "homeassistant.components.devolo_home_control.config_flow.Mydevolo.get_gateway_ids", return_value=["1234567"], ), patch( "homeassistant.components.devolo_home_contr...
[ "async", "def", "test_form_already_configured", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.devolo_home_control.config_flow.Mydevolo.get_gateway_ids\"", ",", "return_value", "=", "[", "\"1234567\"", "]", ",", ")", ",", "patch", "(", "\"homeass...
[ 70, 0 ]
[ 86, 55 ]
python
en
['en', 'en', 'en']
True
test_form_advanced_options
(hass)
Test if we get the advanced options if user has enabled it.
Test if we get the advanced options if user has enabled it.
async def test_form_advanced_options(hass): """Test if we get the advanced options if user has enabled it.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "user", "show_advanced_options": True} ) assert result["type"] == "form" assert result["errors"] == {} ...
[ "async", "def", "test_form_advanced_options", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"user\"", ",", "\"show_advanced_options\"", ...
[ 89, 0 ]
[ 129, 48 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities )
Set up ESPHome lights based on a config entry.
Set up ESPHome lights based on a config entry.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities ) -> None: """Set up ESPHome lights based on a config entry.""" await platform_async_setup_entry( hass, entry, async_add_entities, component_key="light", info_type=LightInfo, ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "await", "platform_async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ",", "comp...
[ 33, 0 ]
[ 45, 5 ]
python
en
['en', 'da', 'en']
True
EsphomeLight.is_on
(self)
Return true if the switch is on.
Return true if the switch is on.
def is_on(self) -> Optional[bool]: """Return true if the switch is on.""" return self._state.state
[ "def", "is_on", "(", "self", ")", "->", "Optional", "[", "bool", "]", ":", "return", "self", ".", "_state", ".", "state" ]
[ 63, 4 ]
[ 65, 32 ]
python
en
['en', 'en', 'en']
True
EsphomeLight.async_turn_on
(self, **kwargs)
Turn the entity on.
Turn the entity on.
async def async_turn_on(self, **kwargs) -> None: """Turn the entity on.""" data = {"key": self._static_info.key, "state": True} if ATTR_HS_COLOR in kwargs: hue, sat = kwargs[ATTR_HS_COLOR] red, green, blue = color_util.color_hsv_to_RGB(hue, sat, 100) data["rgb...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "data", "=", "{", "\"key\"", ":", "self", ".", "_static_info", ".", "key", ",", "\"state\"", ":", "True", "}", "if", "ATTR_HS_COLOR", "in", "kwargs", ":", ...
[ 67, 4 ]
[ 86, 48 ]
python
en
['en', 'en', 'en']
True
EsphomeLight.async_turn_off
(self, **kwargs)
Turn the entity off.
Turn the entity off.
async def async_turn_off(self, **kwargs) -> None: """Turn the entity off.""" data = {"key": self._static_info.key, "state": False} if ATTR_FLASH in kwargs: data["flash_length"] = FLASH_LENGTHS[kwargs[ATTR_FLASH]] if ATTR_TRANSITION in kwargs: data["transition_leng...
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "data", "=", "{", "\"key\"", ":", "self", ".", "_static_info", ".", "key", ",", "\"state\"", ":", "False", "}", "if", "ATTR_FLASH", "in", "kwargs", ":", "...
[ 88, 4 ]
[ 95, 48 ]
python
en
['en', 'en', 'en']
True
EsphomeLight.brightness
(self)
Return the brightness of this light between 0..255.
Return the brightness of this light between 0..255.
def brightness(self) -> Optional[int]: """Return the brightness of this light between 0..255.""" return round(self._state.brightness * 255)
[ "def", "brightness", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "return", "round", "(", "self", ".", "_state", ".", "brightness", "*", "255", ")" ]
[ 98, 4 ]
[ 100, 50 ]
python
en
['en', 'en', 'en']
True
EsphomeLight.hs_color
(self)
Return the hue and saturation color value [float, float].
Return the hue and saturation color value [float, float].
def hs_color(self) -> Optional[Tuple[float, float]]: """Return the hue and saturation color value [float, float].""" return color_util.color_RGB_to_hs( self._state.red * 255, self._state.green * 255, self._state.blue * 255 )
[ "def", "hs_color", "(", "self", ")", "->", "Optional", "[", "Tuple", "[", "float", ",", "float", "]", "]", ":", "return", "color_util", ".", "color_RGB_to_hs", "(", "self", ".", "_state", ".", "red", "*", "255", ",", "self", ".", "_state", ".", "gree...
[ 103, 4 ]
[ 107, 9 ]
python
en
['en', 'en', 'en']
True
EsphomeLight.color_temp
(self)
Return the CT color value in mireds.
Return the CT color value in mireds.
def color_temp(self) -> Optional[float]: """Return the CT color value in mireds.""" return self._state.color_temperature
[ "def", "color_temp", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "return", "self", ".", "_state", ".", "color_temperature" ]
[ 110, 4 ]
[ 112, 44 ]
python
en
['en', 'en', 'en']
True
EsphomeLight.white_value
(self)
Return the white value of this light between 0..255.
Return the white value of this light between 0..255.
def white_value(self) -> Optional[int]: """Return the white value of this light between 0..255.""" return round(self._state.white * 255)
[ "def", "white_value", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "return", "round", "(", "self", ".", "_state", ".", "white", "*", "255", ")" ]
[ 115, 4 ]
[ 117, 45 ]
python
en
['en', 'en', 'en']
True
EsphomeLight.effect
(self)
Return the current effect.
Return the current effect.
def effect(self) -> Optional[str]: """Return the current effect.""" return self._state.effect
[ "def", "effect", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "_state", ".", "effect" ]
[ 120, 4 ]
[ 122, 33 ]
python
en
['en', 'en', 'en']
True
EsphomeLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self) -> int: """Flag supported features.""" flags = SUPPORT_FLASH if self._static_info.supports_brightness: flags |= SUPPORT_BRIGHTNESS flags |= SUPPORT_TRANSITION if self._static_info.supports_rgb: flags |= SUPPORT_COLOR ...
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "flags", "=", "SUPPORT_FLASH", "if", "self", ".", "_static_info", ".", "supports_brightness", ":", "flags", "|=", "SUPPORT_BRIGHTNESS", "flags", "|=", "SUPPORT_TRANSITION", "if", "self", ".", "_sta...
[ 125, 4 ]
[ 139, 20 ]
python
en
['da', 'en', 'en']
True
EsphomeLight.effect_list
(self)
Return the list of supported effects.
Return the list of supported effects.
def effect_list(self) -> List[str]: """Return the list of supported effects.""" return self._static_info.effects
[ "def", "effect_list", "(", "self", ")", "->", "List", "[", "str", "]", ":", "return", "self", ".", "_static_info", ".", "effects" ]
[ 142, 4 ]
[ 144, 40 ]
python
en
['en', 'en', 'en']
True
EsphomeLight.min_mireds
(self)
Return the coldest color_temp that this light supports.
Return the coldest color_temp that this light supports.
def min_mireds(self) -> float: """Return the coldest color_temp that this light supports.""" return self._static_info.min_mireds
[ "def", "min_mireds", "(", "self", ")", "->", "float", ":", "return", "self", ".", "_static_info", ".", "min_mireds" ]
[ 147, 4 ]
[ 149, 43 ]
python
en
['en', 'en', 'en']
True
EsphomeLight.max_mireds
(self)
Return the warmest color_temp that this light supports.
Return the warmest color_temp that this light supports.
def max_mireds(self) -> float: """Return the warmest color_temp that this light supports.""" return self._static_info.max_mireds
[ "def", "max_mireds", "(", "self", ")", "->", "float", ":", "return", "self", ".", "_static_info", ".", "max_mireds" ]
[ 152, 4 ]
[ 154, 43 ]
python
en
['en', 'en', 'en']
True
set_default_port
(schema: Dict)
Set the default port based on the Hub version.
Set the default port based on the Hub version.
def set_default_port(schema: Dict) -> Dict: """Set the default port based on the Hub version.""" # If the ip_port is found do nothing # If it is not found the set the default ip_port = schema.get(CONF_IP_PORT) if not ip_port: hub_version = schema.get(CONF_HUB_VERSION) # Found hub_ver...
[ "def", "set_default_port", "(", "schema", ":", "Dict", ")", "->", "Dict", ":", "# If the ip_port is found do nothing", "# If it is not found the set the default", "ip_port", "=", "schema", ".", "get", "(", "CONF_IP_PORT", ")", "if", "not", "ip_port", ":", "hub_version...
[ 53, 0 ]
[ 62, 17 ]
python
en
['en', 'da', 'en']
True
normalize_byte_entry_to_int
(entry: [int, bytes, str])
Format a hex entry value.
Format a hex entry value.
def normalize_byte_entry_to_int(entry: [int, bytes, str]): """Format a hex entry value.""" if isinstance(entry, int): if entry in range(0, 256): return entry raise ValueError("Must be single byte") if isinstance(entry, str): if entry[0:2].lower() == "0x": entr...
[ "def", "normalize_byte_entry_to_int", "(", "entry", ":", "[", "int", ",", "bytes", ",", "str", "]", ")", ":", "if", "isinstance", "(", "entry", ",", "int", ")", ":", "if", "entry", "in", "range", "(", "0", ",", "256", ")", ":", "return", "entry", "...
[ 162, 0 ]
[ 177, 49 ]
python
en
['en', 'en', 'en']
True
add_device_override
(config_data, new_override)
Add a new device override.
Add a new device override.
def add_device_override(config_data, new_override): """Add a new device override.""" try: address = str(Address(new_override[CONF_ADDRESS])) cat = normalize_byte_entry_to_int(new_override[CONF_CAT]) subcat = normalize_byte_entry_to_int(new_override[CONF_SUBCAT]) except ValueError as ...
[ "def", "add_device_override", "(", "config_data", ",", "new_override", ")", ":", "try", ":", "address", "=", "str", "(", "Address", "(", "new_override", "[", "CONF_ADDRESS", "]", ")", ")", "cat", "=", "normalize_byte_entry_to_int", "(", "new_override", "[", "C...
[ 180, 0 ]
[ 205, 22 ]
python
en
['en', 'en', 'en']
True
add_x10_device
(config_data, new_x10)
Add a new X10 device to X10 device list.
Add a new X10 device to X10 device list.
def add_x10_device(config_data, new_x10): """Add a new X10 device to X10 device list.""" curr_device = {} x10_devices = config_data.get(CONF_X10, []) for x10_device in x10_devices: if ( x10_device[CONF_HOUSECODE] == new_x10[CONF_HOUSECODE] and x10_device[CONF_UNITCODE] ==...
[ "def", "add_x10_device", "(", "config_data", ",", "new_x10", ")", ":", "curr_device", "=", "{", "}", "x10_devices", "=", "config_data", ".", "get", "(", "CONF_X10", ",", "[", "]", ")", "for", "x10_device", "in", "x10_devices", ":", "if", "(", "x10_device",...
[ 208, 0 ]
[ 229, 22 ]
python
en
['en', 'pl', 'en']
True
build_device_override_schema
( address=vol.UNDEFINED, cat=vol.UNDEFINED, subcat=vol.UNDEFINED, firmware=vol.UNDEFINED, )
Build the device override schema for config flow.
Build the device override schema for config flow.
def build_device_override_schema( address=vol.UNDEFINED, cat=vol.UNDEFINED, subcat=vol.UNDEFINED, firmware=vol.UNDEFINED, ): """Build the device override schema for config flow.""" return vol.Schema( { vol.Required(CONF_ADDRESS, default=address): str, vol.Optional...
[ "def", "build_device_override_schema", "(", "address", "=", "vol", ".", "UNDEFINED", ",", "cat", "=", "vol", ".", "UNDEFINED", ",", "subcat", "=", "vol", ".", "UNDEFINED", ",", "firmware", "=", "vol", ".", "UNDEFINED", ",", ")", ":", "return", "vol", "."...
[ 232, 0 ]
[ 245, 5 ]
python
en
['en', 'en', 'en']
True
build_x10_schema
( housecode=vol.UNDEFINED, unitcode=vol.UNDEFINED, platform=vol.UNDEFINED, dim_steps=22, )
Build the X10 schema for config flow.
Build the X10 schema for config flow.
def build_x10_schema( housecode=vol.UNDEFINED, unitcode=vol.UNDEFINED, platform=vol.UNDEFINED, dim_steps=22, ): """Build the X10 schema for config flow.""" return vol.Schema( { vol.Required(CONF_HOUSECODE, default=housecode): vol.In(HC_LOOKUP.keys()), vol.Required...
[ "def", "build_x10_schema", "(", "housecode", "=", "vol", ".", "UNDEFINED", ",", "unitcode", "=", "vol", ".", "UNDEFINED", ",", "platform", "=", "vol", ".", "UNDEFINED", ",", "dim_steps", "=", "22", ",", ")", ":", "return", "vol", ".", "Schema", "(", "{...
[ 248, 0 ]
[ 262, 5 ]
python
en
['en', 'en', 'en']
True
build_plm_schema
(device=vol.UNDEFINED)
Build the PLM schema for config flow.
Build the PLM schema for config flow.
def build_plm_schema(device=vol.UNDEFINED): """Build the PLM schema for config flow.""" return vol.Schema({vol.Required(CONF_DEVICE, default=device): str})
[ "def", "build_plm_schema", "(", "device", "=", "vol", ".", "UNDEFINED", ")", ":", "return", "vol", ".", "Schema", "(", "{", "vol", ".", "Required", "(", "CONF_DEVICE", ",", "default", "=", "device", ")", ":", "str", "}", ")" ]
[ 265, 0 ]
[ 267, 71 ]
python
en
['en', 'en', 'en']
True
build_hub_schema
( hub_version, host=vol.UNDEFINED, port=vol.UNDEFINED, username=vol.UNDEFINED, password=vol.UNDEFINED, )
Build the Hub schema for config flow.
Build the Hub schema for config flow.
def build_hub_schema( hub_version, host=vol.UNDEFINED, port=vol.UNDEFINED, username=vol.UNDEFINED, password=vol.UNDEFINED, ): """Build the Hub schema for config flow.""" if port == vol.UNDEFINED: port = PORT_HUB_V2 if hub_version == 2 else PORT_HUB_V1 schema = { vol.Requi...
[ "def", "build_hub_schema", "(", "hub_version", ",", "host", "=", "vol", ".", "UNDEFINED", ",", "port", "=", "vol", ".", "UNDEFINED", ",", "username", "=", "vol", ".", "UNDEFINED", ",", "password", "=", "vol", ".", "UNDEFINED", ",", ")", ":", "if", "por...
[ 270, 0 ]
[ 287, 29 ]
python
en
['en', 'en', 'en']
True
build_remove_override_schema
(data)
Build the schema to remove device overrides in config flow options.
Build the schema to remove device overrides in config flow options.
def build_remove_override_schema(data): """Build the schema to remove device overrides in config flow options.""" selection = [] for override in data: selection.append(override[CONF_ADDRESS]) return vol.Schema({vol.Required(CONF_ADDRESS): vol.In(selection)})
[ "def", "build_remove_override_schema", "(", "data", ")", ":", "selection", "=", "[", "]", "for", "override", "in", "data", ":", "selection", ".", "append", "(", "override", "[", "CONF_ADDRESS", "]", ")", "return", "vol", ".", "Schema", "(", "{", "vol", "...
[ 290, 0 ]
[ 295, 70 ]
python
en
['en', 'en', 'en']
True
build_remove_x10_schema
(data)
Build the schema to remove an X10 device in config flow options.
Build the schema to remove an X10 device in config flow options.
def build_remove_x10_schema(data): """Build the schema to remove an X10 device in config flow options.""" selection = [] for device in data: housecode = device[CONF_HOUSECODE].upper() unitcode = device[CONF_UNITCODE] selection.append(f"Housecode: {housecode}, Unitcode: {unitcode}") ...
[ "def", "build_remove_x10_schema", "(", "data", ")", ":", "selection", "=", "[", "]", "for", "device", "in", "data", ":", "housecode", "=", "device", "[", "CONF_HOUSECODE", "]", ".", "upper", "(", ")", "unitcode", "=", "device", "[", "CONF_UNITCODE", "]", ...
[ 298, 0 ]
[ 305, 69 ]
python
en
['en', 'en', 'en']
True
convert_yaml_to_config_flow
(yaml_config)
Convert the YAML based configuration to a config flow configuration.
Convert the YAML based configuration to a config flow configuration.
def convert_yaml_to_config_flow(yaml_config): """Convert the YAML based configuration to a config flow configuration.""" config = {} if yaml_config.get(CONF_HOST): hub_version = yaml_config.get(CONF_HUB_VERSION, 2) default_port = PORT_HUB_V2 if hub_version == 2 else PORT_HUB_V1 confi...
[ "def", "convert_yaml_to_config_flow", "(", "yaml_config", ")", ":", "config", "=", "{", "}", "if", "yaml_config", ".", "get", "(", "CONF_HOST", ")", ":", "hub_version", "=", "yaml_config", ".", "get", "(", "CONF_HUB_VERSION", ",", "2", ")", "default_port", "...
[ 308, 0 ]
[ 334, 26 ]
python
en
['en', 'en', 'en']
True
mock_controller_connect
()
Mock a successful connection.
Mock a successful connection.
def mock_controller_connect(): """Mock a successful connection.""" with patch("homeassistant.components.freebox.router.Freepybox") as service_mock: service_mock.return_value.open = AsyncMock() service_mock.return_value.system.get_config = AsyncMock( return_value={ "ma...
[ "def", "mock_controller_connect", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.freebox.router.Freepybox\"", ")", "as", "service_mock", ":", "service_mock", ".", "return_value", ".", "open", "=", "AsyncMock", "(", ")", "service_mock", ".", "return_v...
[ 21, 0 ]
[ 35, 26 ]
python
en
['en', 'en', 'en']
True
test_user
(hass)
Test user config.
Test user config.
async def test_user(hass): """Test user config.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "user" # test with all provided result = await hass....
[ "async", "def", "test_user", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ")", "assert", "result", "[", "\"ty...
[ 38, 0 ]
[ 53, 38 ]
python
en
['en', 'da', 'en']
True
test_import
(hass)
Test import step.
Test import step.
async def test_import(hass): """Test import step.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_IMPORT}, data={CONF_HOST: HOST, CONF_PORT: PORT}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] ==...
[ "async", "def", "test_import", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_IMPORT", "}", ",", "data", "=", "{", "CONF_HO...
[ 56, 0 ]
[ 64, 38 ]
python
de
['de', 'sd', 'en']
False
test_discovery
(hass)
Test discovery step.
Test discovery step.
async def test_discovery(hass): """Test discovery step.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_DISCOVERY}, data={CONF_HOST: HOST, CONF_PORT: PORT}, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["ste...
[ "async", "def", "test_discovery", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_DISCOVERY", "}", ",", "data", "=", "{", "C...
[ 67, 0 ]
[ 75, 38 ]
python
en
['en', 'en', 'en']
True
test_link
(hass, connect)
Test linking.
Test linking.
async def test_link(hass, connect): """Test linking.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: HOST, CONF_PORT: PORT}, ) result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) asse...
[ "async", "def", "test_link", "(", "hass", ",", "connect", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ",", "data", "=", ...
[ 78, 0 ]
[ 91, 44 ]
python
en
['en', 'en', 'en']
False
test_abort_if_already_setup
(hass)
Test we abort if component is already setup.
Test we abort if component is already setup.
async def test_abort_if_already_setup(hass): """Test we abort if component is already setup.""" MockConfigEntry( domain=DOMAIN, data={CONF_HOST: HOST, CONF_PORT: PORT}, unique_id=HOST ).add_to_hass(hass) # Should fail, same HOST (import) result = await hass.config_entries.flow.async_init( ...
[ "async", "def", "test_abort_if_already_setup", "(", "hass", ")", ":", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "CONF_HOST", ":", "HOST", ",", "CONF_PORT", ":", "PORT", "}", ",", "unique_id", "=", "HOST", ")", ".", "add_to_has...
[ 94, 0 ]
[ 116, 51 ]
python
en
['en', 'en', 'en']
True
test_on_link_failed
(hass)
Test when we have errors during linking the router.
Test when we have errors during linking the router.
async def test_on_link_failed(hass): """Test when we have errors during linking the router.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: HOST, CONF_PORT: PORT}, ) with patch( "homeassistant.components.fr...
[ "async", "def", "test_on_link_failed", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ",", "data", "=", "{", "C...
[ 119, 0 ]
[ 149, 54 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up Tasmota binary sensor dynamically through discovery.
Set up Tasmota binary sensor dynamically through discovery.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up Tasmota binary sensor dynamically through discovery.""" @callback def async_discover(tasmota_entity, discovery_hash): """Discover and add a Tasmota binary sensor.""" async_add_entities( [ ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "@", "callback", "def", "async_discover", "(", "tasmota_entity", ",", "discovery_hash", ")", ":", "\"\"\"Discover and add a Tasmota binary sensor.\"\"\"", "async_ad...
[ 13, 0 ]
[ 33, 5 ]
python
en
['en', 'pt', 'en']
True
TasmotaBinarySensor.__init__
(self, **kwds)
Initialize the Tasmota binary sensor.
Initialize the Tasmota binary sensor.
def __init__(self, **kwds): """Initialize the Tasmota binary sensor.""" self._delay_listener = None self._state = None super().__init__( discovery_update=self.discovery_update, **kwds, )
[ "def", "__init__", "(", "self", ",", "*", "*", "kwds", ")", ":", "self", ".", "_delay_listener", "=", "None", "self", ".", "_state", "=", "None", "super", "(", ")", ".", "__init__", "(", "discovery_update", "=", "self", ".", "discovery_update", ",", "*...
[ 43, 4 ]
[ 51, 9 ]
python
en
['en', 'pl', 'en']
True
TasmotaBinarySensor.off_delay_listener
(self, now)
Switch device off after a delay.
Switch device off after a delay.
def off_delay_listener(self, now): """Switch device off after a delay.""" self._delay_listener = None self._state = False self.async_write_ha_state()
[ "def", "off_delay_listener", "(", "self", ",", "now", ")", ":", "self", ".", "_delay_listener", "=", "None", "self", ".", "_state", "=", "False", "self", ".", "async_write_ha_state", "(", ")" ]
[ 54, 4 ]
[ 58, 35 ]
python
en
['en', 'en', 'en']
True
TasmotaBinarySensor.state_updated
(self, state, **kwargs)
Handle state updates.
Handle state updates.
def state_updated(self, state, **kwargs): """Handle state updates.""" self._state = state if self._delay_listener is not None: self._delay_listener() self._delay_listener = None off_delay = self._tasmota_entity.off_delay if self._state and off_delay is n...
[ "def", "state_updated", "(", "self", ",", "state", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_state", "=", "state", "if", "self", ".", "_delay_listener", "is", "not", "None", ":", "self", ".", "_delay_listener", "(", ")", "self", ".", "_delay_li...
[ 61, 4 ]
[ 75, 35 ]
python
en
['en', 'en', 'en']
True
TasmotaBinarySensor.force_update
(self)
Force update.
Force update.
def force_update(self): """Force update.""" return True
[ "def", "force_update", "(", "self", ")", ":", "return", "True" ]
[ 78, 4 ]
[ 80, 19 ]
python
en
['en', 'en', 'en']
False
TasmotaBinarySensor.is_on
(self)
Return true if the binary sensor is on.
Return true if the binary sensor is on.
def is_on(self): """Return true if the binary sensor is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 83, 4 ]
[ 85, 26 ]
python
en
['en', 'fy', 'en']
True
fbresnet_augmentor
(isTrain)
Augmentor used in fb.resnet.torch, for BGR images in range [0,255].
Augmentor used in fb.resnet.torch, for BGR images in range [0,255].
def fbresnet_augmentor(isTrain): """ Augmentor used in fb.resnet.torch, for BGR images in range [0,255]. """ if isTrain: augmentors = [ GoogleNetResize(), imgaug.RandomOrderAug( [imgaug.BrightnessScale((0.6, 1.4), clip=False), imgaug.Contr...
[ "def", "fbresnet_augmentor", "(", "isTrain", ")", ":", "if", "isTrain", ":", "augmentors", "=", "[", "GoogleNetResize", "(", ")", ",", "imgaug", ".", "RandomOrderAug", "(", "[", "imgaug", ".", "BrightnessScale", "(", "(", "0.6", ",", "1.4", ")", ",", "cl...
[ 48, 0 ]
[ 76, 21 ]
python
en
['en', 'error', 'th']
False
default_collate
(batch)
Puts each data field into a tensor with outer dimension batch size
Puts each data field into a tensor with outer dimension batch size
def default_collate(batch): "Puts each data field into a tensor with outer dimension batch size" error_msg = "batch must contain tensors, numbers, dicts or lists; found {}" elem_type = type(batch[0]) if torch.is_tensor(batch[0]): out = None if _use_shared_memory: # If we're ...
[ "def", "default_collate", "(", "batch", ")", ":", "error_msg", "=", "\"batch must contain tensors, numbers, dicts or lists; found {}\"", "elem_type", "=", "type", "(", "batch", "[", "0", "]", ")", "if", "torch", ".", "is_tensor", "(", "batch", "[", "0", "]", ")"...
[ 93, 0 ]
[ 131, 55 ]
python
en
['en', 'en', 'en']
True
choice
(options, random_state)
options: 1-D array-like or int random_state: an object of numpy.random.RandomState
options: 1-D array-like or int random_state: an object of numpy.random.RandomState
def choice(options, random_state): ''' options: 1-D array-like or int random_state: an object of numpy.random.RandomState ''' return random_state.choice(options)
[ "def", "choice", "(", "options", ",", "random_state", ")", ":", "return", "random_state", ".", "choice", "(", "options", ")" ]
[ 10, 0 ]
[ 15, 39 ]
python
en
['en', 'error', 'th']
False
randint
(lower, upper, random_state)
Generate a random integer from `lower` (inclusive) to `upper` (exclusive). lower: an int that represent an lower bound upper: an int that represent an upper bound random_state: an object of numpy.random.RandomState
Generate a random integer from `lower` (inclusive) to `upper` (exclusive). lower: an int that represent an lower bound upper: an int that represent an upper bound random_state: an object of numpy.random.RandomState
def randint(lower, upper, random_state): ''' Generate a random integer from `lower` (inclusive) to `upper` (exclusive). lower: an int that represent an lower bound upper: an int that represent an upper bound random_state: an object of numpy.random.RandomState ''' return random_state.randint(...
[ "def", "randint", "(", "lower", ",", "upper", ",", "random_state", ")", ":", "return", "random_state", ".", "randint", "(", "lower", ",", "upper", ")" ]
[ 18, 0 ]
[ 25, 45 ]
python
en
['en', 'error', 'th']
False
uniform
(low, high, random_state)
low: an float that represent an lower bound high: an float that represent an upper bound random_state: an object of numpy.random.RandomState
low: an float that represent an lower bound high: an float that represent an upper bound random_state: an object of numpy.random.RandomState
def uniform(low, high, random_state): ''' low: an float that represent an lower bound high: an float that represent an upper bound random_state: an object of numpy.random.RandomState ''' assert high >= low, 'Upper bound must be larger than lower bound' return random_state.uniform(low, high)
[ "def", "uniform", "(", "low", ",", "high", ",", "random_state", ")", ":", "assert", "high", ">=", "low", ",", "'Upper bound must be larger than lower bound'", "return", "random_state", ".", "uniform", "(", "low", ",", "high", ")" ]
[ 28, 0 ]
[ 35, 42 ]
python
en
['en', 'error', 'th']
False
quniform
(low, high, q, random_state)
low: an float that represent an lower bound high: an float that represent an upper bound q: sample step random_state: an object of numpy.random.RandomState
low: an float that represent an lower bound high: an float that represent an upper bound q: sample step random_state: an object of numpy.random.RandomState
def quniform(low, high, q, random_state): ''' low: an float that represent an lower bound high: an float that represent an upper bound q: sample step random_state: an object of numpy.random.RandomState ''' return np.clip(np.round(uniform(low, high, random_state) / q) * q, low, high)
[ "def", "quniform", "(", "low", ",", "high", ",", "q", ",", "random_state", ")", ":", "return", "np", ".", "clip", "(", "np", ".", "round", "(", "uniform", "(", "low", ",", "high", ",", "random_state", ")", "/", "q", ")", "*", "q", ",", "low", "...
[ 38, 0 ]
[ 45, 81 ]
python
en
['en', 'error', 'th']
False