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
RepetierSensor.async_added_to_hass
(self)
Connect update callbacks.
Connect update callbacks.
async def async_added_to_hass(self): """Connect update callbacks.""" self.async_on_remove( async_dispatcher_connect(self.hass, UPDATE_SIGNAL, self.update_callback) )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "UPDATE_SIGNAL", ",", "self", ".", "update_callback", ")", ")" ]
[ 102, 4 ]
[ 106, 9 ]
python
en
['en', 'en', 'en']
True
RepetierSensor._get_data
(self)
Return new data from the api cache.
Return new data from the api cache.
def _get_data(self): """Return new data from the api cache.""" data = self._api.get_data(self._printer_id, self._sensor_type, self._temp_id) if data is None: _LOGGER.debug( "Data not found for %s and %s", self._sensor_type, self._temp_id ) self...
[ "def", "_get_data", "(", "self", ")", ":", "data", "=", "self", ".", "_api", ".", "get_data", "(", "self", ".", "_printer_id", ",", "self", ".", "_sensor_type", ",", "self", ".", "_temp_id", ")", "if", "data", "is", "None", ":", "_LOGGER", ".", "debu...
[ 108, 4 ]
[ 118, 19 ]
python
en
['en', 'en', 'en']
True
RepetierSensor.update
(self)
Update the sensor.
Update the sensor.
def update(self): """Update the sensor.""" data = self._get_data() if data is None: return state = data.pop("state") _LOGGER.debug("Printer %s State %s", self._name, state) self._attributes.update(data) self._state = state
[ "def", "update", "(", "self", ")", ":", "data", "=", "self", ".", "_get_data", "(", ")", "if", "data", "is", "None", ":", "return", "state", "=", "data", ".", "pop", "(", "\"state\"", ")", "_LOGGER", ".", "debug", "(", "\"Printer %s State %s\"", ",", ...
[ 120, 4 ]
[ 128, 27 ]
python
en
['en', 'nl', 'en']
True
RepetierTempSensor.state
(self)
Return sensor state.
Return sensor state.
def state(self): """Return sensor state.""" if self._state is None: return None return round(self._state, 2)
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_state", "is", "None", ":", "return", "None", "return", "round", "(", "self", ".", "_state", ",", "2", ")" ]
[ 135, 4 ]
[ 139, 36 ]
python
en
['en', 'bs', 'en']
True
RepetierTempSensor.update
(self)
Update the sensor.
Update the sensor.
def update(self): """Update the sensor.""" data = self._get_data() if data is None: return state = data.pop("state") temp_set = data["temp_set"] _LOGGER.debug("Printer %s Setpoint: %s, Temp: %s", self._name, temp_set, state) self._attributes.update(dat...
[ "def", "update", "(", "self", ")", ":", "data", "=", "self", ".", "_get_data", "(", ")", "if", "data", "is", "None", ":", "return", "state", "=", "data", ".", "pop", "(", "\"state\"", ")", "temp_set", "=", "data", "[", "\"temp_set\"", "]", "_LOGGER",...
[ 141, 4 ]
[ 150, 27 ]
python
en
['en', 'nl', 'en']
True
RepetierJobSensor.state
(self)
Return sensor state.
Return sensor state.
def state(self): """Return sensor state.""" if self._state is None: return None return round(self._state, 2)
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_state", "is", "None", ":", "return", "None", "return", "round", "(", "self", ".", "_state", ",", "2", ")" ]
[ 157, 4 ]
[ 161, 36 ]
python
en
['en', 'bs', 'en']
True
RepetierJobEndSensor.device_class
(self)
Return the device class.
Return the device class.
def device_class(self): """Return the device class.""" return DEVICE_CLASS_TIMESTAMP
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_TIMESTAMP" ]
[ 168, 4 ]
[ 170, 37 ]
python
en
['en', 'en', 'en']
True
RepetierJobEndSensor.update
(self)
Update the sensor.
Update the sensor.
def update(self): """Update the sensor.""" data = self._get_data() if data is None: return job_name = data["job_name"] start = data["start"] print_time = data["print_time"] from_start = data["from_start"] time_end = start + round(print_time, 0)...
[ "def", "update", "(", "self", ")", ":", "data", "=", "self", ".", "_get_data", "(", ")", "if", "data", "is", "None", ":", "return", "job_name", "=", "data", "[", "\"job_name\"", "]", "start", "=", "data", "[", "\"start\"", "]", "print_time", "=", "da...
[ 172, 4 ]
[ 189, 9 ]
python
en
['en', 'nl', 'en']
True
RepetierJobStartSensor.device_class
(self)
Return the device class.
Return the device class.
def device_class(self): """Return the device class.""" return DEVICE_CLASS_TIMESTAMP
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_TIMESTAMP" ]
[ 196, 4 ]
[ 198, 37 ]
python
en
['en', 'en', 'en']
True
RepetierJobStartSensor.update
(self)
Update the sensor.
Update the sensor.
def update(self): """Update the sensor.""" data = self._get_data() if data is None: return job_name = data["job_name"] start = data["start"] from_start = data["from_start"] self._state = datetime.utcfromtimestamp(start).isoformat() elapsed_secs...
[ "def", "update", "(", "self", ")", ":", "data", "=", "self", ".", "_get_data", "(", ")", "if", "data", "is", "None", ":", "return", "job_name", "=", "data", "[", "\"job_name\"", "]", "start", "=", "data", "[", "\"start\"", "]", "from_start", "=", "da...
[ 200, 4 ]
[ 214, 9 ]
python
en
['en', 'nl', 'en']
True
test_not_setup_views_if_onboarded
(hass, hass_storage)
Test if onboarding is done, we don't setup views.
Test if onboarding is done, we don't setup views.
async def test_not_setup_views_if_onboarded(hass, hass_storage): """Test if onboarding is done, we don't setup views.""" mock_storage(hass_storage, {"done": onboarding.STEPS}) with patch("homeassistant.components.onboarding.views.async_setup") as mock_setup: assert await async_setup_component(hass,...
[ "async", "def", "test_not_setup_views_if_onboarded", "(", "hass", ",", "hass_storage", ")", ":", "mock_storage", "(", "hass_storage", ",", "{", "\"done\"", ":", "onboarding", ".", "STEPS", "}", ")", "with", "patch", "(", "\"homeassistant.components.onboarding.views.as...
[ 13, 0 ]
[ 22, 46 ]
python
en
['en', 'en', 'en']
True
test_setup_views_if_not_onboarded
(hass)
Test if onboarding is not done, we setup views.
Test if onboarding is not done, we setup views.
async def test_setup_views_if_not_onboarded(hass): """Test if onboarding is not done, we setup views.""" with patch( "homeassistant.components.onboarding.views.async_setup", return_value=mock_coro(), ) as mock_setup: assert await async_setup_component(hass, "onboarding", {}) ass...
[ "async", "def", "test_setup_views_if_not_onboarded", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.onboarding.views.async_setup\"", ",", "return_value", "=", "mock_coro", "(", ")", ",", ")", "as", "mock_setup", ":", "assert", "await", "async...
[ 25, 0 ]
[ 36, 50 ]
python
en
['en', 'en', 'en']
True
test_is_onboarded
()
Test the is onboarded function.
Test the is onboarded function.
async def test_is_onboarded(): """Test the is onboarded function.""" hass = Mock() hass.data = {} assert onboarding.async_is_onboarded(hass) hass.data[onboarding.DOMAIN] = True assert onboarding.async_is_onboarded(hass) hass.data[onboarding.DOMAIN] = {"done": []} assert not onboarding...
[ "async", "def", "test_is_onboarded", "(", ")", ":", "hass", "=", "Mock", "(", ")", "hass", ".", "data", "=", "{", "}", "assert", "onboarding", ".", "async_is_onboarded", "(", "hass", ")", "hass", ".", "data", "[", "onboarding", ".", "DOMAIN", "]", "=",...
[ 39, 0 ]
[ 50, 50 ]
python
en
['en', 'en', 'en']
True
test_is_user_onboarded
()
Test the is onboarded function.
Test the is onboarded function.
async def test_is_user_onboarded(): """Test the is onboarded function.""" hass = Mock() hass.data = {} assert onboarding.async_is_user_onboarded(hass) hass.data[onboarding.DOMAIN] = True assert onboarding.async_is_user_onboarded(hass) hass.data[onboarding.DOMAIN] = {"done": []} assert...
[ "async", "def", "test_is_user_onboarded", "(", ")", ":", "hass", "=", "Mock", "(", ")", "hass", ".", "data", "=", "{", "}", "assert", "onboarding", ".", "async_is_user_onboarded", "(", "hass", ")", "hass", ".", "data", "[", "onboarding", ".", "DOMAIN", "...
[ 53, 0 ]
[ 64, 55 ]
python
en
['en', 'en', 'en']
True
test_having_owner_finishes_user_step
(hass, hass_storage)
If owner user already exists, mark user step as complete.
If owner user already exists, mark user step as complete.
async def test_having_owner_finishes_user_step(hass, hass_storage): """If owner user already exists, mark user step as complete.""" MockUser(is_owner=True).add_to_hass(hass) with patch( "homeassistant.components.onboarding.views.async_setup" ) as mock_setup, patch.object(onboarding, "STEPS", [o...
[ "async", "def", "test_having_owner_finishes_user_step", "(", "hass", ",", "hass_storage", ")", ":", "MockUser", "(", "is_owner", "=", "True", ")", ".", "add_to_hass", "(", "hass", ")", "with", "patch", "(", "\"homeassistant.components.onboarding.views.async_setup\"", ...
[ 67, 0 ]
[ 81, 39 ]
python
en
['en', 'en', 'en']
True
test_migration
(hass, hass_storage)
Test migrating onboarding to new version.
Test migrating onboarding to new version.
async def test_migration(hass, hass_storage): """Test migrating onboarding to new version.""" hass_storage[onboarding.STORAGE_KEY] = {"version": 1, "data": {"done": ["user"]}} assert await async_setup_component(hass, "onboarding", {}) assert onboarding.async_is_onboarded(hass)
[ "async", "def", "test_migration", "(", "hass", ",", "hass_storage", ")", ":", "hass_storage", "[", "onboarding", ".", "STORAGE_KEY", "]", "=", "{", "\"version\"", ":", "1", ",", "\"data\"", ":", "{", "\"done\"", ":", "[", "\"user\"", "]", "}", "}", "asse...
[ 84, 0 ]
[ 88, 46 ]
python
en
['en', 'en', 'en']
True
NewDateTime.now
(cls, *args, **kwargs)
Overload datetime.datetime.now.
Overload datetime.datetime.now.
def now(cls, *args, **kwargs): # pylint: disable=signature-differs """Overload datetime.datetime.now.""" return cls(2020, 4, 25, 12, tzinfo=datetime.timezone.utc)
[ "def", "now", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=signature-differs", "return", "cls", "(", "2020", ",", "4", ",", "25", ",", "12", ",", "tzinfo", "=", "datetime", ".", "timezone", ".", "utc", ")" ]
[ 9, 4 ]
[ 11, 65 ]
python
en
['en', 'en', 'en']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Add fans for a config entry.
Add fans for a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Add fans for a config entry.""" broker = hass.data[DOMAIN][DATA_BROKERS][config_entry.entry_id] async_add_entities( [ SmartThingsFan(device) for device in broker.devices.values() if broker.any...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "broker", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_BROKERS", "]", "[", "config_entry", ".", "entry_id", "]", "async_add_entities", "(", ...
[ 21, 0 ]
[ 30, 5 ]
python
en
['en', 'en', 'en']
True
get_capabilities
(capabilities: Sequence[str])
Return all capabilities supported if minimum required are present.
Return all capabilities supported if minimum required are present.
def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]: """Return all capabilities supported if minimum required are present.""" supported = [Capability.switch, Capability.fan_speed] # Must have switch and fan_speed if all(capability in capabilities for capability in supported): ...
[ "def", "get_capabilities", "(", "capabilities", ":", "Sequence", "[", "str", "]", ")", "->", "Optional", "[", "Sequence", "[", "str", "]", "]", ":", "supported", "=", "[", "Capability", ".", "switch", ",", "Capability", ".", "fan_speed", "]", "# Must have ...
[ 33, 0 ]
[ 38, 24 ]
python
en
['en', 'en', 'en']
True
SmartThingsFan.async_set_speed
(self, speed: str)
Set the speed of the fan.
Set the speed of the fan.
async def async_set_speed(self, speed: str): """Set the speed of the fan.""" value = SPEED_TO_VALUE[speed] await self._device.set_fan_speed(value, set_status=True) # State is set optimistically in the command above, therefore update # the entity state ahead of receiving the confi...
[ "async", "def", "async_set_speed", "(", "self", ",", "speed", ":", "str", ")", ":", "value", "=", "SPEED_TO_VALUE", "[", "speed", "]", "await", "self", ".", "_device", ".", "set_fan_speed", "(", "value", ",", "set_status", "=", "True", ")", "# State is set...
[ 44, 4 ]
[ 50, 35 ]
python
en
['en', 'en', 'en']
True
SmartThingsFan.async_turn_on
(self, speed: str = None, **kwargs)
Turn the fan on.
Turn the fan on.
async def async_turn_on(self, speed: str = None, **kwargs) -> None: """Turn the fan on.""" if speed is not None: value = SPEED_TO_VALUE[speed] await self._device.set_fan_speed(value, set_status=True) else: await self._device.switch_on(set_status=True) ...
[ "async", "def", "async_turn_on", "(", "self", ",", "speed", ":", "str", "=", "None", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "speed", "is", "not", "None", ":", "value", "=", "SPEED_TO_VALUE", "[", "speed", "]", "await", "self", ".", ...
[ 52, 4 ]
[ 61, 35 ]
python
en
['en', 'fy', 'en']
True
SmartThingsFan.async_turn_off
(self, **kwargs)
Turn the fan off.
Turn the fan off.
async def async_turn_off(self, **kwargs) -> None: """Turn the fan off.""" await self._device.switch_off(set_status=True) # State is set optimistically in the command above, therefore update # the entity state ahead of receiving the confirming push updates self.async_write_ha_stat...
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_device", ".", "switch_off", "(", "set_status", "=", "True", ")", "# State is set optimistically in the command above, therefore update", "# the en...
[ 63, 4 ]
[ 68, 35 ]
python
en
['en', 'fy', 'en']
True
SmartThingsFan.is_on
(self)
Return true if fan is on.
Return true if fan is on.
def is_on(self) -> bool: """Return true if fan is on.""" return self._device.status.switch
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_device", ".", "status", ".", "switch" ]
[ 71, 4 ]
[ 73, 41 ]
python
en
['en', 'fy', 'en']
True
SmartThingsFan.speed
(self)
Return the current speed.
Return the current speed.
def speed(self) -> str: """Return the current speed.""" return VALUE_TO_SPEED[self._device.status.fan_speed]
[ "def", "speed", "(", "self", ")", "->", "str", ":", "return", "VALUE_TO_SPEED", "[", "self", ".", "_device", ".", "status", ".", "fan_speed", "]" ]
[ 76, 4 ]
[ 78, 60 ]
python
en
['en', 'en', 'en']
True
SmartThingsFan.speed_list
(self)
Get the list of available speeds.
Get the list of available speeds.
def speed_list(self) -> list: """Get the list of available speeds.""" return [SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
[ "def", "speed_list", "(", "self", ")", "->", "list", ":", "return", "[", "SPEED_OFF", ",", "SPEED_LOW", ",", "SPEED_MEDIUM", ",", "SPEED_HIGH", "]" ]
[ 81, 4 ]
[ 83, 63 ]
python
en
['en', 'en', 'en']
True
SmartThingsFan.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self) -> int: """Flag supported features.""" return SUPPORT_SET_SPEED
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_SET_SPEED" ]
[ 86, 4 ]
[ 88, 32 ]
python
en
['da', 'en', 'en']
True
cls
()
Patch debounce decorator during import of type_thermostats.
Patch debounce decorator during import of type_thermostats.
def cls(): """Patch debounce decorator during import of type_thermostats.""" patcher = patch_debounce() patcher.start() _import = __import__( "homeassistant.components.homekit.type_thermostats", fromlist=["WaterHeater", "Thermostat"], ) patcher_tuple = namedtuple("Cls", ["water_h...
[ "def", "cls", "(", ")", ":", "patcher", "=", "patch_debounce", "(", ")", "patcher", ".", "start", "(", ")", "_import", "=", "__import__", "(", "\"homeassistant.components.homekit.type_thermostats\"", ",", "fromlist", "=", "[", "\"WaterHeater\"", ",", "\"Thermostat...
[ 63, 0 ]
[ 73, 18 ]
python
en
['en', 'en', 'en']
True
test_thermostat
(hass, hk_driver, cls, events)
Test if accessory and HA are updated accordingly.
Test if accessory and HA are updated accordingly.
async def test_thermostat(hass, hk_driver, cls, events): """Test if accessory and HA are updated accordingly.""" entity_id = "climate.test" hass.states.async_set( entity_id, HVAC_MODE_OFF, { ATTR_SUPPORTED_FEATURES: SUPPORT_TARGET_TEMPERATURE, ATTR_HVAC_MODES...
[ "async", "def", "test_thermostat", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "entity_id", "=", "\"climate.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_OFF", ",", "{", "ATTR_SUPPORTED_FEATURES", "...
[ 76, 0 ]
[ 413, 74 ]
python
en
['en', 'en', 'en']
True
test_thermostat_auto
(hass, hk_driver, cls, events)
Test if accessory and HA are updated accordingly.
Test if accessory and HA are updated accordingly.
async def test_thermostat_auto(hass, hk_driver, cls, events): """Test if accessory and HA are updated accordingly.""" entity_id = "climate.test" # support_auto = True hass.states.async_set( entity_id, HVAC_MODE_OFF, { ATTR_SUPPORTED_FEATURES: SUPPORT_TARGET_TEMPERATU...
[ "async", "def", "test_thermostat_auto", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "entity_id", "=", "\"climate.test\"", "# support_auto = True", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_OFF", ",", "{", ...
[ 416, 0 ]
[ 567, 5 ]
python
en
['en', 'en', 'en']
True
test_thermostat_humidity
(hass, hk_driver, cls, events)
Test if accessory and HA are updated accordingly with humidity.
Test if accessory and HA are updated accordingly with humidity.
async def test_thermostat_humidity(hass, hk_driver, cls, events): """Test if accessory and HA are updated accordingly with humidity.""" entity_id = "climate.test" # support_auto = True hass.states.async_set(entity_id, HVAC_MODE_OFF, {ATTR_SUPPORTED_FEATURES: 4}) await hass.async_block_till_done() ...
[ "async", "def", "test_thermostat_humidity", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "entity_id", "=", "\"climate.test\"", "# support_auto = True", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_OFF", ",", "...
[ 570, 0 ]
[ 626, 47 ]
python
en
['en', 'en', 'en']
True
test_thermostat_power_state
(hass, hk_driver, cls, events)
Test if accessory and HA are updated accordingly.
Test if accessory and HA are updated accordingly.
async def test_thermostat_power_state(hass, hk_driver, cls, events): """Test if accessory and HA are updated accordingly.""" entity_id = "climate.test" # SUPPORT_ON_OFF = True hass.states.async_set( entity_id, HVAC_MODE_HEAT, { ATTR_SUPPORTED_FEATURES: 4096, ...
[ "async", "def", "test_thermostat_power_state", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "entity_id", "=", "\"climate.test\"", "# SUPPORT_ON_OFF = True", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_HEAT", ",...
[ 629, 0 ]
[ 746, 47 ]
python
en
['en', 'en', 'en']
True
test_thermostat_fahrenheit
(hass, hk_driver, cls, events)
Test if accessory and HA are updated accordingly.
Test if accessory and HA are updated accordingly.
async def test_thermostat_fahrenheit(hass, hk_driver, cls, events): """Test if accessory and HA are updated accordingly.""" entity_id = "climate.test" # support_ = True hass.states.async_set( entity_id, HVAC_MODE_OFF, { ATTR_SUPPORTED_FEATURES: SUPPORT_TARGET_TEMPERA...
[ "async", "def", "test_thermostat_fahrenheit", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "entity_id", "=", "\"climate.test\"", "# support_ = True", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_OFF", ",", "{"...
[ 749, 0 ]
[ 855, 72 ]
python
en
['en', 'en', 'en']
True
test_thermostat_get_temperature_range
(hass, hk_driver, cls)
Test if temperature range is evaluated correctly.
Test if temperature range is evaluated correctly.
async def test_thermostat_get_temperature_range(hass, hk_driver, cls): """Test if temperature range is evaluated correctly.""" entity_id = "climate.test" hass.states.async_set(entity_id, HVAC_MODE_OFF) await hass.async_block_till_done() acc = cls.thermostat(hass, hk_driver, "Climate", entity_id, 2,...
[ "async", "def", "test_thermostat_get_temperature_range", "(", "hass", ",", "hk_driver", ",", "cls", ")", ":", "entity_id", "=", "\"climate.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_OFF", ")", "await", "hass", ".", "async...
[ 858, 0 ]
[ 877, 54 ]
python
en
['en', 'en', 'en']
True
test_thermostat_temperature_step_whole
(hass, hk_driver, cls)
Test climate device with single digit precision.
Test climate device with single digit precision.
async def test_thermostat_temperature_step_whole(hass, hk_driver, cls): """Test climate device with single digit precision.""" entity_id = "climate.test" hass.states.async_set(entity_id, HVAC_MODE_OFF, {ATTR_TARGET_TEMP_STEP: 1}) await hass.async_block_till_done() acc = cls.thermostat(hass, hk_driv...
[ "async", "def", "test_thermostat_temperature_step_whole", "(", "hass", ",", "hk_driver", ",", "cls", ")", ":", "entity_id", "=", "\"climate.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_OFF", ",", "{", "ATTR_TARGET_TEMP_STEP", ...
[ 880, 0 ]
[ 892, 64 ]
python
en
['en', 'en', 'en']
True
test_thermostat_restore
(hass, hk_driver, cls, events)
Test setting up an entity from state in the event registry.
Test setting up an entity from state in the event registry.
async def test_thermostat_restore(hass, hk_driver, cls, events): """Test setting up an entity from state in the event registry.""" hass.state = CoreState.not_running registry = await entity_registry.async_get_registry(hass) registry.async_get_or_create( "climate", "generic", "1234", suggested_...
[ "async", "def", "test_thermostat_restore", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "hass", ".", "state", "=", "CoreState", ".", "not_running", "registry", "=", "await", "entity_registry", ".", "async_get_registry", "(", "hass", ")",...
[ 895, 0 ]
[ 937, 5 ]
python
en
['en', 'en', 'en']
True
test_thermostat_hvac_modes
(hass, hk_driver, cls)
Test if unsupported HVAC modes are deactivated in HomeKit.
Test if unsupported HVAC modes are deactivated in HomeKit.
async def test_thermostat_hvac_modes(hass, hk_driver, cls): """Test if unsupported HVAC modes are deactivated in HomeKit.""" entity_id = "climate.test" hass.states.async_set( entity_id, HVAC_MODE_OFF, {ATTR_HVAC_MODES: [HVAC_MODE_HEAT, HVAC_MODE_OFF]} ) await hass.async_block_till_done() ...
[ "async", "def", "test_thermostat_hvac_modes", "(", "hass", ",", "hk_driver", ",", "cls", ")", ":", "entity_id", "=", "\"climate.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_OFF", ",", "{", "ATTR_HVAC_MODES", ":", "[", "HV...
[ 940, 0 ]
[ 970, 47 ]
python
en
['en', 'en', 'en']
True
test_thermostat_hvac_modes_with_auto_heat_cool
(hass, hk_driver, cls)
Test we get heat cool over auto.
Test we get heat cool over auto.
async def test_thermostat_hvac_modes_with_auto_heat_cool(hass, hk_driver, cls): """Test we get heat cool over auto.""" entity_id = "climate.test" hass.states.async_set( entity_id, HVAC_MODE_OFF, { ATTR_HVAC_MODES: [ HVAC_MODE_HEAT_COOL, HV...
[ "async", "def", "test_thermostat_hvac_modes_with_auto_heat_cool", "(", "hass", ",", "hk_driver", ",", "cls", ")", ":", "entity_id", "=", "\"climate.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_OFF", ",", "{", "ATTR_HVAC_MODES",...
[ 973, 0 ]
[ 1033, 47 ]
python
en
['nl', 'en', 'en']
True
test_thermostat_hvac_modes_with_auto_no_heat_cool
(hass, hk_driver, cls)
Test we get auto when there is no heat cool.
Test we get auto when there is no heat cool.
async def test_thermostat_hvac_modes_with_auto_no_heat_cool(hass, hk_driver, cls): """Test we get auto when there is no heat cool.""" entity_id = "climate.test" hass.states.async_set( entity_id, HVAC_MODE_HEAT, {ATTR_HVAC_MODES: [HVAC_MODE_AUTO, HVAC_MODE_HEAT, HVAC_MODE_OFF]}, ...
[ "async", "def", "test_thermostat_hvac_modes_with_auto_no_heat_cool", "(", "hass", ",", "hk_driver", ",", "cls", ")", ":", "entity_id", "=", "\"climate.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_HEAT", ",", "{", "ATTR_HVAC_MOD...
[ 1036, 0 ]
[ 1089, 47 ]
python
en
['en', 'en', 'en']
True
test_thermostat_hvac_modes_with_auto_only
(hass, hk_driver, cls)
Test if unsupported HVAC modes are deactivated in HomeKit.
Test if unsupported HVAC modes are deactivated in HomeKit.
async def test_thermostat_hvac_modes_with_auto_only(hass, hk_driver, cls): """Test if unsupported HVAC modes are deactivated in HomeKit.""" entity_id = "climate.test" hass.states.async_set( entity_id, HVAC_MODE_AUTO, {ATTR_HVAC_MODES: [HVAC_MODE_AUTO, HVAC_MODE_OFF]} ) await hass.async_blo...
[ "async", "def", "test_thermostat_hvac_modes_with_auto_only", "(", "hass", ",", "hk_driver", ",", "cls", ")", ":", "entity_id", "=", "\"climate.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_AUTO", ",", "{", "ATTR_HVAC_MODES", "...
[ 1092, 0 ]
[ 1122, 47 ]
python
en
['en', 'en', 'en']
True
test_thermostat_hvac_modes_without_off
(hass, hk_driver, cls)
Test a thermostat that has no off.
Test a thermostat that has no off.
async def test_thermostat_hvac_modes_without_off(hass, hk_driver, cls): """Test a thermostat that has no off.""" entity_id = "climate.test" hass.states.async_set( entity_id, HVAC_MODE_AUTO, {ATTR_HVAC_MODES: [HVAC_MODE_AUTO, HVAC_MODE_HEAT]} ) await hass.async_block_till_done() acc = c...
[ "async", "def", "test_thermostat_hvac_modes_without_off", "(", "hass", ",", "hk_driver", ",", "cls", ")", ":", "entity_id", "=", "\"climate.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_AUTO", ",", "{", "ATTR_HVAC_MODES", ":",...
[ 1125, 0 ]
[ 1159, 47 ]
python
en
['en', 'en', 'en']
True
test_thermostat_without_target_temp_only_range
(hass, hk_driver, cls, events)
Test a thermostat that only supports a range.
Test a thermostat that only supports a range.
async def test_thermostat_without_target_temp_only_range(hass, hk_driver, cls, events): """Test a thermostat that only supports a range.""" entity_id = "climate.test" # support_auto = True hass.states.async_set( entity_id, HVAC_MODE_OFF, {ATTR_SUPPORTED_FEATURES: SUPPORT_TARGET_...
[ "async", "def", "test_thermostat_without_target_temp_only_range", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "entity_id", "=", "\"climate.test\"", "# support_auto = True", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC...
[ 1162, 0 ]
[ 1341, 82 ]
python
en
['en', 'en', 'en']
True
test_water_heater
(hass, hk_driver, cls, events)
Test if accessory and HA are updated accordingly.
Test if accessory and HA are updated accordingly.
async def test_water_heater(hass, hk_driver, cls, events): """Test if accessory and HA are updated accordingly.""" entity_id = "water_heater.test" hass.states.async_set(entity_id, HVAC_MODE_HEAT) await hass.async_block_till_done() acc = cls.water_heater(hass, hk_driver, "WaterHeater", entity_id, 2,...
[ "async", "def", "test_water_heater", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "entity_id", "=", "\"water_heater.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_HEAT", ")", "await", "hass", ".", "...
[ 1344, 0 ]
[ 1415, 47 ]
python
en
['en', 'en', 'en']
True
test_water_heater_fahrenheit
(hass, hk_driver, cls, events)
Test if accessory and HA are update accordingly.
Test if accessory and HA are update accordingly.
async def test_water_heater_fahrenheit(hass, hk_driver, cls, events): """Test if accessory and HA are update accordingly.""" entity_id = "water_heater.test" hass.states.async_set(entity_id, HVAC_MODE_HEAT) await hass.async_block_till_done() with patch.object(hass.config.units, CONF_TEMPERATURE_UNIT...
[ "async", "def", "test_water_heater_fahrenheit", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "entity_id", "=", "\"water_heater.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_HEAT", ")", "await", "hass",...
[ 1418, 0 ]
[ 1447, 52 ]
python
en
['en', 'en', 'en']
True
test_water_heater_get_temperature_range
(hass, hk_driver, cls)
Test if temperature range is evaluated correctly.
Test if temperature range is evaluated correctly.
async def test_water_heater_get_temperature_range(hass, hk_driver, cls): """Test if temperature range is evaluated correctly.""" entity_id = "water_heater.test" hass.states.async_set(entity_id, HVAC_MODE_HEAT) await hass.async_block_till_done() acc = cls.thermostat(hass, hk_driver, "WaterHeater", e...
[ "async", "def", "test_water_heater_get_temperature_range", "(", "hass", ",", "hk_driver", ",", "cls", ")", ":", "entity_id", "=", "\"water_heater.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_HEAT", ")", "await", "hass", ".", ...
[ 1450, 0 ]
[ 1469, 54 ]
python
en
['en', 'en', 'en']
True
test_water_heater_restore
(hass, hk_driver, cls, events)
Test setting up an entity from state in the event registry.
Test setting up an entity from state in the event registry.
async def test_water_heater_restore(hass, hk_driver, cls, events): """Test setting up an entity from state in the event registry.""" hass.state = CoreState.not_running registry = await entity_registry.async_get_registry(hass) registry.async_get_or_create( "water_heater", "generic", "1234", sug...
[ "async", "def", "test_water_heater_restore", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "hass", ".", "state", "=", "CoreState", ".", "not_running", "registry", "=", "await", "entity_registry", ".", "async_get_registry", "(", "hass", ")...
[ 1472, 0 ]
[ 1512, 5 ]
python
en
['en', 'en', 'en']
True
test_thermostat_with_no_modes_when_we_first_see
(hass, hk_driver, cls, events)
Test if a thermostat that is not ready when we first see it.
Test if a thermostat that is not ready when we first see it.
async def test_thermostat_with_no_modes_when_we_first_see(hass, hk_driver, cls, events): """Test if a thermostat that is not ready when we first see it.""" entity_id = "climate.test" # support_auto = True hass.states.async_set( entity_id, HVAC_MODE_OFF, { ATTR_SUPPOR...
[ "async", "def", "test_thermostat_with_no_modes_when_we_first_see", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "entity_id", "=", "\"climate.test\"", "# support_auto = True", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVA...
[ 1515, 0 ]
[ 1565, 44 ]
python
en
['en', 'en', 'en']
True
test_thermostat_with_no_off_after_recheck
(hass, hk_driver, cls, events)
Test if a thermostat that is not ready when we first see it that actually does not have off.
Test if a thermostat that is not ready when we first see it that actually does not have off.
async def test_thermostat_with_no_off_after_recheck(hass, hk_driver, cls, events): """Test if a thermostat that is not ready when we first see it that actually does not have off.""" entity_id = "climate.test" # support_auto = True hass.states.async_set( entity_id, HVAC_MODE_COOL, ...
[ "async", "def", "test_thermostat_with_no_off_after_recheck", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "entity_id", "=", "\"climate.test\"", "# support_auto = True", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE...
[ 1568, 0 ]
[ 1618, 44 ]
python
en
['en', 'en', 'en']
True
test_thermostat_with_temp_clamps
(hass, hk_driver, cls, events)
Test that tempatures are clamped to valid values to prevent homekit crash.
Test that tempatures are clamped to valid values to prevent homekit crash.
async def test_thermostat_with_temp_clamps(hass, hk_driver, cls, events): """Test that tempatures are clamped to valid values to prevent homekit crash.""" entity_id = "climate.test" hass.states.async_set( entity_id, HVAC_MODE_COOL, { ATTR_SUPPORTED_FEATURES: SUPPORT_TARG...
[ "async", "def", "test_thermostat_with_temp_clamps", "(", "hass", ",", "hk_driver", ",", "cls", ",", "events", ")", ":", "entity_id", "=", "\"climate.test\"", "hass", ".", "states", ".", "async_set", "(", "entity_id", ",", "HVAC_MODE_COOL", ",", "{", "ATTR_SUPPOR...
[ 1621, 0 ]
[ 1672, 44 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up Pilight Binary Sensor.
Set up Pilight Binary Sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up Pilight Binary Sensor.""" disarm = config.get(CONF_DISARM_AFTER_TRIGGER) if disarm: add_entities( [ PilightTriggerSensor( hass=hass, name=config.get(CONF...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "disarm", "=", "config", ".", "get", "(", "CONF_DISARM_AFTER_TRIGGER", ")", "if", "disarm", ":", "add_entities", "(", "[", "PilightTriggerSe...
[ 39, 0 ]
[ 68, 9 ]
python
en
['en', 'su', 'en']
True
PilightBinarySensor.__init__
(self, hass, name, variable, payload, on_value, off_value)
Initialize the sensor.
Initialize the sensor.
def __init__(self, hass, name, variable, payload, on_value, off_value): """Initialize the sensor.""" self._state = False self._hass = hass self._name = name self._variable = variable self._payload = payload self._on_value = on_value self._off_value = off_v...
[ "def", "__init__", "(", "self", ",", "hass", ",", "name", ",", "variable", ",", "payload", ",", "on_value", ",", "off_value", ")", ":", "self", ".", "_state", "=", "False", "self", ".", "_hass", "=", "hass", "self", ".", "_name", "=", "name", "self",...
[ 74, 4 ]
[ 84, 57 ]
python
en
['en', 'en', 'en']
True
PilightBinarySensor.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" ]
[ 87, 4 ]
[ 89, 25 ]
python
en
['en', 'mi', 'en']
True
PilightBinarySensor.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" ]
[ 92, 4 ]
[ 94, 26 ]
python
en
['en', 'fy', 'en']
True
PilightBinarySensor._handle_code
(self, call)
Handle received code by the pilight-daemon. If the code matches the defined payload of this sensor the sensor state is changed accordingly.
Handle received code by the pilight-daemon.
def _handle_code(self, call): """Handle received code by the pilight-daemon. If the code matches the defined payload of this sensor the sensor state is changed accordingly. """ # Check if received code matches defined playoad # True if payload is contained in received co...
[ "def", "_handle_code", "(", "self", ",", "call", ")", ":", "# Check if received code matches defined playoad", "# True if payload is contained in received code dict", "payload_ok", "=", "True", "for", "key", "in", "self", ".", "_payload", ":", "if", "key", "not", "in", ...
[ 96, 4 ]
[ 117, 43 ]
python
en
['en', 'en', 'en']
True
PilightTriggerSensor.__init__
( self, hass, name, variable, payload, on_value, off_value, rst_dly_sec=30 )
Initialize the sensor.
Initialize the sensor.
def __init__( self, hass, name, variable, payload, on_value, off_value, rst_dly_sec=30 ): """Initialize the sensor.""" self._state = False self._hass = hass self._name = name self._variable = variable self._payload = payload self._on_value = on_value ...
[ "def", "__init__", "(", "self", ",", "hass", ",", "name", ",", "variable", ",", "payload", ",", "on_value", ",", "off_value", ",", "rst_dly_sec", "=", "30", ")", ":", "self", ".", "_state", "=", "False", "self", ".", "_hass", "=", "hass", "self", "."...
[ 123, 4 ]
[ 138, 57 ]
python
en
['en', 'en', 'en']
True
PilightTriggerSensor.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" ]
[ 141, 4 ]
[ 143, 25 ]
python
en
['en', 'mi', 'en']
True
PilightTriggerSensor.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" ]
[ 146, 4 ]
[ 148, 26 ]
python
en
['en', 'fy', 'en']
True
PilightTriggerSensor._handle_code
(self, call)
Handle received code by the pilight-daemon. If the code matches the defined payload of this sensor the sensor state is changed accordingly.
Handle received code by the pilight-daemon.
def _handle_code(self, call): """Handle received code by the pilight-daemon. If the code matches the defined payload of this sensor the sensor state is changed accordingly. """ # Check if received code matches defined payload # True if payload is contained in received co...
[ "def", "_handle_code", "(", "self", ",", "call", ")", ":", "# Check if received code matches defined payload", "# True if payload is contained in received code dict", "payload_ok", "=", "True", "for", "key", "in", "self", ".", "_payload", ":", "if", "key", "not", "in", ...
[ 155, 4 ]
[ 181, 43 ]
python
en
['en', 'en', 'en']
True
get_model_detection_function
(model)
Get a tf.function for detection.
Get a tf.function for detection.
def get_model_detection_function(model): """Get a tf.function for detection.""" @tf.function def detect_fn(image): """Detect objects in image.""" image, shapes = model.preprocess(image) prediction_dict = model.predict(image, shapes) detections = model.postprocess(prediction...
[ "def", "get_model_detection_function", "(", "model", ")", ":", "@", "tf", ".", "function", "def", "detect_fn", "(", "image", ")", ":", "\"\"\"Detect objects in image.\"\"\"", "image", ",", "shapes", "=", "model", ".", "preprocess", "(", "image", ")", "prediction...
[ 82, 0 ]
[ 95, 20 ]
python
en
['da', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the TensorFlow image processing platform.
Set up the TensorFlow image processing platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the TensorFlow image processing platform.""" model_config = config[CONF_MODEL] model_dir = model_config.get(CONF_MODEL_DIR) or hass.config.path("tensorflow") labels = model_config.get(CONF_LABELS) or hass.config.path( ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "model_config", "=", "config", "[", "CONF_MODEL", "]", "model_dir", "=", "model_config", ".", "get", "(", "CONF_MODEL_DIR", ")", "or", "ha...
[ 98, 0 ]
[ 199, 26 ]
python
en
['en', 'jv', 'en']
True
TensorFlowImageProcessor.__init__
( self, hass, camera_entity, name, category_index, config, )
Initialize the TensorFlow entity.
Initialize the TensorFlow entity.
def __init__( self, hass, camera_entity, name, category_index, config, ): """Initialize the TensorFlow entity.""" model_config = config.get(CONF_MODEL) self.hass = hass self._camera_entity = camera_entity if name: se...
[ "def", "__init__", "(", "self", ",", "hass", ",", "camera_entity", ",", "name", ",", "category_index", ",", "config", ",", ")", ":", "model_config", "=", "config", ".", "get", "(", "CONF_MODEL", ")", "self", ".", "hass", "=", "hass", "self", ".", "_cam...
[ 205, 4 ]
[ 263, 30 ]
python
en
['en', 'pl', 'en']
True
TensorFlowImageProcessor.camera_entity
(self)
Return camera entity id from process pictures.
Return camera entity id from process pictures.
def camera_entity(self): """Return camera entity id from process pictures.""" return self._camera_entity
[ "def", "camera_entity", "(", "self", ")", ":", "return", "self", ".", "_camera_entity" ]
[ 266, 4 ]
[ 268, 34 ]
python
en
['en', 'en', 'en']
True
TensorFlowImageProcessor.name
(self)
Return the name of the image processor.
Return the name of the image processor.
def name(self): """Return the name of the image processor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 271, 4 ]
[ 273, 25 ]
python
en
['en', 'en', 'en']
True
TensorFlowImageProcessor.state
(self)
Return the state of the entity.
Return the state of the entity.
def state(self): """Return the state of the entity.""" return self._total_matches
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_total_matches" ]
[ 276, 4 ]
[ 278, 34 ]
python
en
['en', 'en', 'en']
True
TensorFlowImageProcessor.device_state_attributes
(self)
Return device specific state attributes.
Return device specific state attributes.
def device_state_attributes(self): """Return device specific state attributes.""" return { ATTR_MATCHES: self._matches, ATTR_SUMMARY: { category: len(values) for category, values in self._matches.items() }, ATTR_TOTAL_MATCHES: self._total_m...
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_MATCHES", ":", "self", ".", "_matches", ",", "ATTR_SUMMARY", ":", "{", "category", ":", "len", "(", "values", ")", "for", "category", ",", "values", "in", "self", ".", "_matches"...
[ 281, 4 ]
[ 290, 9 ]
python
en
['fr', 'en', 'en']
True
TensorFlowImageProcessor.process_image
(self, image)
Process the image.
Process the image.
def process_image(self, image): """Process the image.""" model = self.hass.data[DOMAIN][CONF_MODEL] if not model: _LOGGER.debug("Model not yet ready.") return start = time.perf_counter() try: import cv2 # pylint: disable=import-error, import-...
[ "def", "process_image", "(", "self", ",", "image", ")", ":", "model", "=", "self", ".", "hass", ".", "data", "[", "DOMAIN", "]", "[", "CONF_MODEL", "]", "if", "not", "model", ":", "_LOGGER", ".", "debug", "(", "\"Model not yet ready.\"", ")", "return", ...
[ 334, 4 ]
[ 428, 56 ]
python
en
['en', 'en', 'en']
True
XLMTokenizationTest.test_full_tokenizer
(self)
Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
def test_full_tokenizer(self): """ Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt """ tokenizer = XLMTokenizer(self.vocab_file, self.merges_file) text = "lower" bpe_tokens = ["low", "er</w>"] tokens = tokenizer.tokenize(text) self.assertLi...
[ "def", "test_full_tokenizer", "(", "self", ")", ":", "tokenizer", "=", "XLMTokenizer", "(", "self", ".", "vocab_file", ",", "self", ".", "merges_file", ")", "text", "=", "\"lower\"", "bpe_tokens", "=", "[", "\"low\"", ",", "\"er</w>\"", "]", "tokens", "=", ...
[ 73, 4 ]
[ 84, 93 ]
python
en
['en', 'no', 'en']
True
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], )
Set up the sensor config entry.
Set up the sensor config entry.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], ) -> None: """Set up the sensor config entry.""" controller_data = get_controller_data(hass, entry) async_add_entities( [ VeraSensor(device, control...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", "[", "[", "List", "[", "Entity", "]", ",", "bool", "]", ",", "None", "]", ",", ")", "->", "None", ":", ...
[ 19, 0 ]
[ 31, 5 ]
python
en
['en', 'pt', 'en']
True
VeraSensor.__init__
( self, vera_device: veraApi.VeraSensor, controller_data: ControllerData )
Initialize the sensor.
Initialize the sensor.
def __init__( self, vera_device: veraApi.VeraSensor, controller_data: ControllerData ): """Initialize the sensor.""" self.current_value = None self._temperature_units = None self.last_changed_time = None VeraDevice.__init__(self, vera_device, controller_data) ...
[ "def", "__init__", "(", "self", ",", "vera_device", ":", "veraApi", ".", "VeraSensor", ",", "controller_data", ":", "ControllerData", ")", ":", "self", ".", "current_value", "=", "None", "self", ".", "_temperature_units", "=", "None", "self", ".", "last_change...
[ 37, 4 ]
[ 45, 62 ]
python
en
['en', 'en', 'en']
True
VeraSensor.state
(self)
Return the name of the sensor.
Return the name of the sensor.
def state(self) -> str: """Return the name of the sensor.""" return self.current_value
[ "def", "state", "(", "self", ")", "->", "str", ":", "return", "self", ".", "current_value" ]
[ 48, 4 ]
[ 50, 33 ]
python
en
['en', 'mi', 'en']
True
VeraSensor.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) -> Optional[str]: """Return the unit of measurement of this entity, if any.""" if self.vera_device.category == veraApi.CATEGORY_TEMPERATURE_SENSOR: return self._temperature_units if self.vera_device.category == veraApi.CATEGORY_LIGHT_SENSOR: ...
[ "def", "unit_of_measurement", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "self", ".", "vera_device", ".", "category", "==", "veraApi", ".", "CATEGORY_TEMPERATURE_SENSOR", ":", "return", "self", ".", "_temperature_units", "if", "self", ".",...
[ 53, 4 ]
[ 65, 26 ]
python
en
['en', 'en', 'en']
True
VeraSensor.update
(self)
Update the state.
Update the state.
def update(self) -> None: """Update the state.""" if self.vera_device.category == veraApi.CATEGORY_TEMPERATURE_SENSOR: self.current_value = self.vera_device.temperature vera_temp_units = self.vera_device.vera_controller.temperature_units if vera_temp_units == "F": ...
[ "def", "update", "(", "self", ")", "->", "None", ":", "if", "self", ".", "vera_device", ".", "category", "==", "veraApi", ".", "CATEGORY_TEMPERATURE_SENSOR", ":", "self", ".", "current_value", "=", "self", ".", "vera_device", ".", "temperature", "vera_temp_uni...
[ 67, 4 ]
[ 102, 42 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up a sensor for a Hydrawise device.
Set up a sensor for a Hydrawise device.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up a sensor for a Hydrawise device.""" hydrawise = hass.data[DATA_HYDRAWISE].data sensors = [] for sensor_type in config.get(CONF_MONITORED_CONDITIONS): if sensor_type == "status": sensors.append( ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "hydrawise", "=", "hass", ".", "data", "[", "DATA_HYDRAWISE", "]", ".", "data", "sensors", "=", "[", "]", "for", "sensor_type", "in", ...
[ 22, 0 ]
[ 37, 31 ]
python
en
['en', 'en', 'en']
True
HydrawiseBinarySensor.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" ]
[ 44, 4 ]
[ 46, 26 ]
python
en
['en', 'fy', 'en']
True
HydrawiseBinarySensor.update
(self)
Get the latest data and updates the state.
Get the latest data and updates the state.
def update(self): """Get the latest data and updates the state.""" _LOGGER.debug("Updating Hydrawise binary sensor: %s", self._name) mydata = self.hass.data[DATA_HYDRAWISE].data if self._sensor_type == "status": self._state = mydata.status == "All good!" elif self._se...
[ "def", "update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Updating Hydrawise binary sensor: %s\"", ",", "self", ".", "_name", ")", "mydata", "=", "self", ".", "hass", ".", "data", "[", "DATA_HYDRAWISE", "]", ".", "data", "if", "self", ".", ...
[ 48, 4 ]
[ 56, 56 ]
python
en
['en', 'en', 'en']
True
test_config_flow
(hass)
Test we can finish a config flow.
Test we can finish a config flow.
async def test_config_flow(hass): """Test we can finish a config flow.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM result = await hass.config_entries.flow.async_configure(result["f...
[ "async", "def", "test_config_flow", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ")", "assert", "result", "[", ...
[ 8, 0 ]
[ 20, 16 ]
python
en
['en', 'en', 'en']
True
test_already_setup
(hass)
Test we abort if already setup.
Test we abort if already setup.
async def test_already_setup(hass): """Test we abort if already setup.""" MockConfigEntry( domain=DOMAIN, data={}, ).add_to_hass(hass) # Should fail, same NAME result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) assert result...
[ "async", "def", "test_already_setup", "(", "hass", ")", ":", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "}", ",", ")", ".", "add_to_hass", "(", "hass", ")", "# Should fail, same NAME", "result", "=", "await", "hass", ".", "conf...
[ 23, 0 ]
[ 35, 56 ]
python
en
['en', 'zu', 'en']
True
Speedometer.__call__
(self, param)
Callback to Show speed.
Callback to Show speed.
def __call__(self, param): """Callback to Show speed.""" count = param.nbatch if self.last_count > count: self.init = False self.last_count = count self.data_in_time += param.data_in_time self.data_transfer_time += param.data_transfer_time self.forward...
[ "def", "__call__", "(", "self", ",", "param", ")", ":", "count", "=", "param", ".", "nbatch", "if", "self", ".", "last_count", ">", "count", ":", "self", ".", "init", "=", "False", "self", ".", "last_count", "=", "count", "self", ".", "data_in_time", ...
[ 32, 4 ]
[ 101, 34 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Fixer.io sensor.
Set up the Fixer.io sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Fixer.io sensor.""" api_key = config.get(CONF_API_KEY) name = config.get(CONF_NAME) target = config.get(CONF_TARGET) try: Fixerio(symbols=[target], access_key=api_key).latest() except FixerioException: ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "api_key", "=", "config", ".", "get", "(", "CONF_API_KEY", ")", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "target", "=...
[ 37, 0 ]
[ 51, 64 ]
python
en
['en', 'ca', 'en']
True
ExchangeRateSensor.__init__
(self, data, name, target)
Initialize the sensor.
Initialize the sensor.
def __init__(self, data, name, target): """Initialize the sensor.""" self.data = data self._target = target self._name = name self._state = None
[ "def", "__init__", "(", "self", ",", "data", ",", "name", ",", "target", ")", ":", "self", ".", "data", "=", "data", "self", ".", "_target", "=", "target", "self", ".", "_name", "=", "name", "self", ".", "_state", "=", "None" ]
[ 57, 4 ]
[ 62, 26 ]
python
en
['en', 'en', 'en']
True
ExchangeRateSensor.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" ]
[ 65, 4 ]
[ 67, 25 ]
python
en
['en', 'mi', 'en']
True
ExchangeRateSensor.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 self._target
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_target" ]
[ 70, 4 ]
[ 72, 27 ]
python
en
['en', 'en', 'en']
True
ExchangeRateSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 75, 4 ]
[ 77, 26 ]
python
en
['en', 'en', 'en']
True
ExchangeRateSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" if self.data.rate is not None: return { ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_EXCHANGE_RATE: self.data.rate["rates"][self._target], ATTR_TARGET: self._target, }
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "data", ".", "rate", "is", "not", "None", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", ",", "ATTR_EXCHANGE_RATE", ":", "self", ".", "data", ".", "rate", "[", "\"rate...
[ 80, 4 ]
[ 87, 13 ]
python
en
['en', 'en', 'en']
True
ExchangeRateSensor.icon
(self)
Return the icon to use in the frontend, if any.
Return the icon to use in the frontend, if any.
def icon(self): """Return the icon to use in the frontend, if any.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 90, 4 ]
[ 92, 19 ]
python
en
['en', 'en', 'en']
True
ExchangeRateSensor.update
(self)
Get the latest data and updates the states.
Get the latest data and updates the states.
def update(self): """Get the latest data and updates the states.""" self.data.update() self._state = round(self.data.rate["rates"][self._target], 3)
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "update", "(", ")", "self", ".", "_state", "=", "round", "(", "self", ".", "data", ".", "rate", "[", "\"rates\"", "]", "[", "self", ".", "_target", "]", ",", "3", ")" ]
[ 94, 4 ]
[ 97, 69 ]
python
en
['en', 'en', 'en']
True
ExchangeData.__init__
(self, target_currency, api_key)
Initialize the data object.
Initialize the data object.
def __init__(self, target_currency, api_key): """Initialize the data object.""" self.api_key = api_key self.rate = None self.target_currency = target_currency self.exchange = Fixerio(symbols=[self.target_currency], access_key=self.api_key)
[ "def", "__init__", "(", "self", ",", "target_currency", ",", "api_key", ")", ":", "self", ".", "api_key", "=", "api_key", "self", ".", "rate", "=", "None", "self", ".", "target_currency", "=", "target_currency", "self", ".", "exchange", "=", "Fixerio", "("...
[ 103, 4 ]
[ 109, 88 ]
python
en
['en', 'en', 'en']
True
ExchangeData.update
(self)
Get the latest data from Fixer.io.
Get the latest data from Fixer.io.
def update(self): """Get the latest data from Fixer.io.""" self.rate = self.exchange.latest()
[ "def", "update", "(", "self", ")", ":", "self", ".", "rate", "=", "self", ".", "exchange", ".", "latest", "(", ")" ]
[ 111, 4 ]
[ 113, 42 ]
python
en
['en', 'en', 'en']
True
test_async_browse_media
(hass)
Test browse media.
Test browse media.
async def test_async_browse_media(hass): """Test browse media.""" local_media = hass.config.path("media") await async_process_ha_core_config( hass, {"media_dirs": {"local": local_media, "recordings": local_media}} ) await hass.async_block_till_done() assert await async_setup_component(h...
[ "async", "def", "test_async_browse_media", "(", "hass", ")", ":", "local_media", "=", "hass", ".", "config", ".", "path", "(", "\"media\"", ")", "await", "async_process_ha_core_config", "(", "hass", ",", "{", "\"media_dirs\"", ":", "{", "\"local\"", ":", "loca...
[ 9, 0 ]
[ 62, 16 ]
python
en
['en', 'da', 'en']
True
test_media_view
(hass, hass_client)
Test media view.
Test media view.
async def test_media_view(hass, hass_client): """Test media view.""" local_media = hass.config.path("media") await async_process_ha_core_config( hass, {"media_dirs": {"local": local_media, "recordings": local_media}} ) await hass.async_block_till_done() assert await async_setup_componen...
[ "async", "def", "test_media_view", "(", "hass", ",", "hass_client", ")", ":", "local_media", "=", "hass", ".", "config", ".", "path", "(", "\"media\"", ")", "await", "async_process_ha_core_config", "(", "hass", ",", "{", "\"media_dirs\"", ":", "{", "\"local\""...
[ 65, 0 ]
[ 98, 29 ]
python
en
['en', 'en', 'en']
True
check_environment
()
check if paramiko is installed
check if paramiko is installed
def check_environment(): '''check if paramiko is installed''' try: import paramiko except: install_package_command('paramiko') import paramiko return paramiko
[ "def", "check_environment", "(", ")", ":", "try", ":", "import", "paramiko", "except", ":", "install_package_command", "(", "'paramiko'", ")", "import", "paramiko", "return", "paramiko" ]
[ 7, 0 ]
[ 14, 19 ]
python
en
['en', 'en', 'en']
True
copy_remote_directory_to_local
(sftp, remote_path, local_path)
copy remote directory to local machine
copy remote directory to local machine
def copy_remote_directory_to_local(sftp, remote_path, local_path): '''copy remote directory to local machine''' try: os.makedirs(local_path, exist_ok=True) files = sftp.listdir(remote_path) for file in files: remote_full_path = os.path.join(remote_path, file) loca...
[ "def", "copy_remote_directory_to_local", "(", "sftp", ",", "remote_path", ",", "local_path", ")", ":", "try", ":", "os", ".", "makedirs", "(", "local_path", ",", "exist_ok", "=", "True", ")", "files", "=", "sftp", ".", "listdir", "(", "remote_path", ")", "...
[ 16, 0 ]
[ 30, 12 ]
python
en
['en', 'en', 'en']
True
create_ssh_sftp_client
(host_ip, port, username, password, ssh_key_path, passphrase)
create ssh client
create ssh client
def create_ssh_sftp_client(host_ip, port, username, password, ssh_key_path, passphrase): '''create ssh client''' try: paramiko = check_environment() conn = paramiko.Transport(host_ip, port) if ssh_key_path is not None: ssh_key = paramiko.RSAKey.from_private_key_file(ssh_key_p...
[ "def", "create_ssh_sftp_client", "(", "host_ip", ",", "port", ",", "username", ",", "password", ",", "ssh_key_path", ",", "passphrase", ")", ":", "try", ":", "paramiko", "=", "check_environment", "(", ")", "conn", "=", "paramiko", ".", "Transport", "(", "hos...
[ 32, 0 ]
[ 45, 63 ]
python
en
['en', 'fr', 'en']
True
remove_remote_directory
(sftp, directory)
remove a directory in remote machine
remove a directory in remote machine
def remove_remote_directory(sftp, directory): '''remove a directory in remote machine''' try: files = sftp.listdir(directory) for file in files: filepath = '/'.join([directory, file]) try: sftp.remove(filepath) except IOError: r...
[ "def", "remove_remote_directory", "(", "sftp", ",", "directory", ")", ":", "try", ":", "files", "=", "sftp", ".", "listdir", "(", "directory", ")", "for", "file", "in", "files", ":", "filepath", "=", "'/'", ".", "join", "(", "[", "directory", ",", "fil...
[ 47, 0 ]
[ 59, 24 ]
python
en
['en', 'it', 'en']
True
get_scanner
(hass, config)
Validate the configuration and return an Actiontec scanner.
Validate the configuration and return an Actiontec scanner.
def get_scanner(hass, config): """Validate the configuration and return an Actiontec scanner.""" scanner = ActiontecDeviceScanner(config[DOMAIN]) return scanner if scanner.success_init else None
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "scanner", "=", "ActiontecDeviceScanner", "(", "config", "[", "DOMAIN", "]", ")", "return", "scanner", "if", "scanner", ".", "success_init", "else", "None" ]
[ 35, 0 ]
[ 38, 52 ]
python
en
['en', 'en', 'en']
True
ActiontecDeviceScanner.__init__
(self, config)
Initialize the scanner.
Initialize the scanner.
def __init__(self, config): """Initialize the scanner.""" self.host = config[CONF_HOST] self.username = config[CONF_USERNAME] self.password = config[CONF_PASSWORD] self.last_results = [] data = self.get_actiontec_data() self.success_init = data is not None ...
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "self", ".", "host", "=", "config", "[", "CONF_HOST", "]", "self", ".", "username", "=", "config", "[", "CONF_USERNAME", "]", "self", ".", "password", "=", "config", "[", "CONF_PASSWORD", "]", "s...
[ 47, 4 ]
[ 55, 42 ]
python
en
['en', 'en', 'en']
True
ActiontecDeviceScanner.scan_devices
(self)
Scan for new devices and return a list with found device IDs.
Scan for new devices and return a list with found device IDs.
def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" self._update_info() return [client.mac for client in self.last_results]
[ "def", "scan_devices", "(", "self", ")", ":", "self", ".", "_update_info", "(", ")", "return", "[", "client", ".", "mac", "for", "client", "in", "self", ".", "last_results", "]" ]
[ 57, 4 ]
[ 60, 59 ]
python
en
['en', 'en', 'en']
True
ActiontecDeviceScanner.get_device_name
(self, device)
Return the name of the given device or None if we don't know.
Return the name of the given device or None if we don't know.
def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" if not self.last_results: return None for client in self.last_results: if client.mac == device: return client.ip return None
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "if", "not", "self", ".", "last_results", ":", "return", "None", "for", "client", "in", "self", ".", "last_results", ":", "if", "client", ".", "mac", "==", "device", ":", "return", "client",...
[ 62, 4 ]
[ 69, 19 ]
python
en
['en', 'en', 'en']
True
ActiontecDeviceScanner._update_info
(self)
Ensure the information from the router is up to date. Return boolean if scanning successful.
Ensure the information from the router is up to date.
def _update_info(self): """Ensure the information from the router is up to date. Return boolean if scanning successful. """ _LOGGER.info("Scanning") if not self.success_init: return False now = dt_util.now() actiontec_data = self.get_actiontec_data()...
[ "def", "_update_info", "(", "self", ")", ":", "_LOGGER", ".", "info", "(", "\"Scanning\"", ")", "if", "not", "self", ".", "success_init", ":", "return", "False", "now", "=", "dt_util", ".", "now", "(", ")", "actiontec_data", "=", "self", ".", "get_action...
[ 71, 4 ]
[ 90, 19 ]
python
en
['en', 'en', 'en']
True
ActiontecDeviceScanner.get_actiontec_data
(self)
Retrieve data from Actiontec MI424WR and return parsed result.
Retrieve data from Actiontec MI424WR and return parsed result.
def get_actiontec_data(self): """Retrieve data from Actiontec MI424WR and return parsed result.""" try: telnet = telnetlib.Telnet(self.host) telnet.read_until(b"Username: ") telnet.write((f"{self.username}\n").encode("ascii")) telnet.read_until(b"Password:...
[ "def", "get_actiontec_data", "(", "self", ")", ":", "try", ":", "telnet", "=", "telnetlib", ".", "Telnet", "(", "self", ".", "host", ")", "telnet", ".", "read_until", "(", "b\"Username: \"", ")", "telnet", ".", "write", "(", "(", "f\"{self.username}\\n\"", ...
[ 92, 4 ]
[ 122, 22 ]
python
en
['en', 'en', 'en']
True
test_fail_setup_if_no_command_topic
(hass, mqtt_mock)
Test if setup fails with no command topic.
Test if setup fails with no command topic.
async def test_fail_setup_if_no_command_topic(hass, mqtt_mock): """Test if setup fails with no command topic.""" assert await async_setup_component( hass, light.DOMAIN, {light.DOMAIN: {"platform": "mqtt", "schema": "json", "name": "test"}}, ) await hass.async_block_till_done() ...
[ "async", "def", "test_fail_setup_if_no_command_topic", "(", "hass", ",", "mqtt_mock", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "light", ".", "DOMAIN", ",", "{", "light", ".", "DOMAIN", ":", "{", "\"platform\"", ":", "\"mqtt\"", "...
[ 153, 0 ]
[ 161, 48 ]
python
en
['en', 'en', 'en']
True