Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
test_update_sensor
(hass)
Test async_update for sensor.
Test async_update for sensor.
async def test_update_sensor(hass): """Test async_update for sensor.""" entry = MockConfigEntry( domain=DOMAIN, data={CONF_HOST: HOST, CONF_PORT: PORT}, unique_id=f"{HOST}:{PORT}", ) starting_time = static_datetime() timestamp = future_timestamp(100) with patch("homeass...
[ "async", "def", "test_update_sensor", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "CONF_HOST", ":", "HOST", ",", "CONF_PORT", ":", "PORT", "}", ",", "unique_id", "=", "f\"{HOST}:{PORT}\"", ",...
[ 97, 0 ]
[ 136, 43 ]
python
en
['en', 'no', 'en']
True
test_update_sensor_network_errors
(hass)
Test async_update for sensor.
Test async_update for sensor.
async def test_update_sensor_network_errors(hass): """Test async_update for sensor.""" entry = MockConfigEntry( domain=DOMAIN, data={CONF_HOST: HOST, CONF_PORT: PORT}, unique_id=f"{HOST}:{PORT}", ) starting_time = static_datetime() timestamp = future_timestamp(100) with...
[ "async", "def", "test_update_sensor_network_errors", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "CONF_HOST", ":", "HOST", ",", "CONF_PORT", ":", "PORT", "}", ",", "unique_id", "=", "f\"{HOST}:...
[ 139, 0 ]
[ 217, 43 ]
python
en
['en', 'no', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Fritzbox smarthome thermostat from config_entry.
Set up the Fritzbox smarthome thermostat from config_entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Fritzbox smarthome thermostat from config_entry.""" entities = [] devices = hass.data[FRITZBOX_DOMAIN][CONF_DEVICES] fritz = hass.data[FRITZBOX_DOMAIN][CONF_CONNECTIONS][config_entry.entry_id] for device in await has...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "entities", "=", "[", "]", "devices", "=", "hass", ".", "data", "[", "FRITZBOX_DOMAIN", "]", "[", "CONF_DEVICES", "]", "fritz", "=", "hass", ".", "d...
[ 49, 0 ]
[ 60, 32 ]
python
en
['en', 'en', 'en']
True
FritzboxThermostat.__init__
(self, device, fritz)
Initialize the thermostat.
Initialize the thermostat.
def __init__(self, device, fritz): """Initialize the thermostat.""" self._device = device self._fritz = fritz self._current_temperature = self._device.actual_temperature self._target_temperature = self._device.target_temperature self._comfort_temperature = self._device.co...
[ "def", "__init__", "(", "self", ",", "device", ",", "fritz", ")", ":", "self", ".", "_device", "=", "device", "self", ".", "_fritz", "=", "fritz", "self", ".", "_current_temperature", "=", "self", ".", "_device", ".", "actual_temperature", "self", ".", "...
[ 66, 4 ]
[ 73, 60 ]
python
en
['en', 'en', 'en']
True
FritzboxThermostat.device_info
(self)
Return device specific attributes.
Return device specific attributes.
def device_info(self): """Return device specific attributes.""" return { "name": self.name, "identifiers": {(FRITZBOX_DOMAIN, self._device.ain)}, "manufacturer": self._device.manufacturer, "model": self._device.productname, "sw_version": self._...
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"name\"", ":", "self", ".", "name", ",", "\"identifiers\"", ":", "{", "(", "FRITZBOX_DOMAIN", ",", "self", ".", "_device", ".", "ain", ")", "}", ",", "\"manufacturer\"", ":", "self", ".", "_...
[ 76, 4 ]
[ 84, 9 ]
python
en
['fr', 'it', 'en']
False
FritzboxThermostat.unique_id
(self)
Return the unique ID of the device.
Return the unique ID of the device.
def unique_id(self): """Return the unique ID of the device.""" return self._device.ain
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "ain" ]
[ 87, 4 ]
[ 89, 31 ]
python
en
['en', 'en', 'en']
True
FritzboxThermostat.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" ]
[ 92, 4 ]
[ 94, 28 ]
python
en
['en', 'en', 'en']
True
FritzboxThermostat.available
(self)
Return if thermostat is available.
Return if thermostat is available.
def available(self): """Return if thermostat is available.""" return self._device.present
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "present" ]
[ 97, 4 ]
[ 99, 35 ]
python
en
['en', 'en', 'en']
True
FritzboxThermostat.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self._device.name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "name" ]
[ 102, 4 ]
[ 104, 32 ]
python
en
['en', 'en', 'en']
True
FritzboxThermostat.temperature_unit
(self)
Return the unit of measurement that is used.
Return the unit of measurement that is used.
def temperature_unit(self): """Return the unit of measurement that is used.""" return TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_CELSIUS" ]
[ 107, 4 ]
[ 109, 27 ]
python
en
['en', 'en', 'en']
True
FritzboxThermostat.precision
(self)
Return precision 0.5.
Return precision 0.5.
def precision(self): """Return precision 0.5.""" return PRECISION_HALVES
[ "def", "precision", "(", "self", ")", ":", "return", "PRECISION_HALVES" ]
[ 112, 4 ]
[ 114, 31 ]
python
en
['es', 'it', 'en']
False
FritzboxThermostat.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" return self._current_temperature
[ "def", "current_temperature", "(", "self", ")", ":", "return", "self", ".", "_current_temperature" ]
[ 117, 4 ]
[ 119, 40 ]
python
en
['en', 'la', 'en']
True
FritzboxThermostat.target_temperature
(self)
Return the temperature we try to reach.
Return the temperature we try to reach.
def target_temperature(self): """Return the temperature we try to reach.""" if self._target_temperature == ON_API_TEMPERATURE: return ON_REPORT_SET_TEMPERATURE if self._target_temperature == OFF_API_TEMPERATURE: return OFF_REPORT_SET_TEMPERATURE return self._targe...
[ "def", "target_temperature", "(", "self", ")", ":", "if", "self", ".", "_target_temperature", "==", "ON_API_TEMPERATURE", ":", "return", "ON_REPORT_SET_TEMPERATURE", "if", "self", ".", "_target_temperature", "==", "OFF_API_TEMPERATURE", ":", "return", "OFF_REPORT_SET_TE...
[ 122, 4 ]
[ 128, 39 ]
python
en
['en', 'en', 'en']
True
FritzboxThermostat.set_temperature
(self, **kwargs)
Set new target temperature.
Set new target temperature.
def set_temperature(self, **kwargs): """Set new target temperature.""" if ATTR_HVAC_MODE in kwargs: hvac_mode = kwargs.get(ATTR_HVAC_MODE) self.set_hvac_mode(hvac_mode) elif ATTR_TEMPERATURE in kwargs: temperature = kwargs.get(ATTR_TEMPERATURE) sel...
[ "def", "set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_HVAC_MODE", "in", "kwargs", ":", "hvac_mode", "=", "kwargs", ".", "get", "(", "ATTR_HVAC_MODE", ")", "self", ".", "set_hvac_mode", "(", "hvac_mode", ")", "elif", "ATTR_TE...
[ 130, 4 ]
[ 137, 60 ]
python
en
['en', 'ca', 'en']
True
FritzboxThermostat.hvac_mode
(self)
Return the current operation mode.
Return the current operation mode.
def hvac_mode(self): """Return the current operation mode.""" if ( self._target_temperature == OFF_REPORT_SET_TEMPERATURE or self._target_temperature == OFF_API_TEMPERATURE ): return HVAC_MODE_OFF return HVAC_MODE_HEAT
[ "def", "hvac_mode", "(", "self", ")", ":", "if", "(", "self", ".", "_target_temperature", "==", "OFF_REPORT_SET_TEMPERATURE", "or", "self", ".", "_target_temperature", "==", "OFF_API_TEMPERATURE", ")", ":", "return", "HVAC_MODE_OFF", "return", "HVAC_MODE_HEAT" ]
[ 140, 4 ]
[ 148, 29 ]
python
en
['en', 'en', 'en']
True
FritzboxThermostat.hvac_modes
(self)
Return the list of available operation modes.
Return the list of available operation modes.
def hvac_modes(self): """Return the list of available operation modes.""" return OPERATION_LIST
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "OPERATION_LIST" ]
[ 151, 4 ]
[ 153, 29 ]
python
en
['en', 'en', 'en']
True
FritzboxThermostat.set_hvac_mode
(self, hvac_mode)
Set new operation mode.
Set new operation mode.
def set_hvac_mode(self, hvac_mode): """Set new operation mode.""" if hvac_mode == HVAC_MODE_OFF: self.set_temperature(temperature=OFF_REPORT_SET_TEMPERATURE) else: self.set_temperature(temperature=self._comfort_temperature)
[ "def", "set_hvac_mode", "(", "self", ",", "hvac_mode", ")", ":", "if", "hvac_mode", "==", "HVAC_MODE_OFF", ":", "self", ".", "set_temperature", "(", "temperature", "=", "OFF_REPORT_SET_TEMPERATURE", ")", "else", ":", "self", ".", "set_temperature", "(", "tempera...
[ 155, 4 ]
[ 160, 71 ]
python
en
['en', 'ny', 'en']
True
FritzboxThermostat.preset_mode
(self)
Return current preset mode.
Return current preset mode.
def preset_mode(self): """Return current preset mode.""" if self._target_temperature == self._comfort_temperature: return PRESET_COMFORT if self._target_temperature == self._eco_temperature: return PRESET_ECO
[ "def", "preset_mode", "(", "self", ")", ":", "if", "self", ".", "_target_temperature", "==", "self", ".", "_comfort_temperature", ":", "return", "PRESET_COMFORT", "if", "self", ".", "_target_temperature", "==", "self", ".", "_eco_temperature", ":", "return", "PR...
[ 163, 4 ]
[ 168, 29 ]
python
en
['en', 'ca', 'en']
True
FritzboxThermostat.preset_modes
(self)
Return supported preset modes.
Return supported preset modes.
def preset_modes(self): """Return supported preset modes.""" return [PRESET_ECO, PRESET_COMFORT]
[ "def", "preset_modes", "(", "self", ")", ":", "return", "[", "PRESET_ECO", ",", "PRESET_COMFORT", "]" ]
[ 171, 4 ]
[ 173, 43 ]
python
en
['en', 'en', 'en']
True
FritzboxThermostat.set_preset_mode
(self, preset_mode)
Set preset mode.
Set preset mode.
def set_preset_mode(self, preset_mode): """Set preset mode.""" if preset_mode == PRESET_COMFORT: self.set_temperature(temperature=self._comfort_temperature) elif preset_mode == PRESET_ECO: self.set_temperature(temperature=self._eco_temperature)
[ "def", "set_preset_mode", "(", "self", ",", "preset_mode", ")", ":", "if", "preset_mode", "==", "PRESET_COMFORT", ":", "self", ".", "set_temperature", "(", "temperature", "=", "self", ".", "_comfort_temperature", ")", "elif", "preset_mode", "==", "PRESET_ECO", "...
[ 175, 4 ]
[ 180, 67 ]
python
de
['de', 'pt', 'it']
False
FritzboxThermostat.min_temp
(self)
Return the minimum temperature.
Return the minimum temperature.
def min_temp(self): """Return the minimum temperature.""" return MIN_TEMPERATURE
[ "def", "min_temp", "(", "self", ")", ":", "return", "MIN_TEMPERATURE" ]
[ 183, 4 ]
[ 185, 30 ]
python
en
['en', 'la', 'en']
True
FritzboxThermostat.max_temp
(self)
Return the maximum temperature.
Return the maximum temperature.
def max_temp(self): """Return the maximum temperature.""" return MAX_TEMPERATURE
[ "def", "max_temp", "(", "self", ")", ":", "return", "MAX_TEMPERATURE" ]
[ 188, 4 ]
[ 190, 30 ]
python
en
['en', 'la', 'en']
True
FritzboxThermostat.device_state_attributes
(self)
Return the device specific state attributes.
Return the device specific state attributes.
def device_state_attributes(self): """Return the device specific state attributes.""" attrs = { ATTR_STATE_BATTERY_LOW: self._device.battery_low, ATTR_STATE_DEVICE_LOCKED: self._device.device_lock, ATTR_STATE_LOCKED: self._device.lock, } # the followi...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attrs", "=", "{", "ATTR_STATE_BATTERY_LOW", ":", "self", ".", "_device", ".", "battery_low", ",", "ATTR_STATE_DEVICE_LOCKED", ":", "self", ".", "_device", ".", "device_lock", ",", "ATTR_STATE_LOCKED", ":", ...
[ 193, 4 ]
[ 211, 20 ]
python
en
['en', 'en', 'en']
True
FritzboxThermostat.update
(self)
Update the data from the thermostat.
Update the data from the thermostat.
def update(self): """Update the data from the thermostat.""" try: self._device.update() self._current_temperature = self._device.actual_temperature self._target_temperature = self._device.target_temperature self._comfort_temperature = self._device.comfort_...
[ "def", "update", "(", "self", ")", ":", "try", ":", "self", ".", "_device", ".", "update", "(", ")", "self", ".", "_current_temperature", "=", "self", ".", "_device", ".", "actual_temperature", "self", ".", "_target_temperature", "=", "self", ".", "_device...
[ 213, 4 ]
[ 223, 31 ]
python
en
['en', 'en', 'en']
True
_get_dyson_purecool_device
()
Return a valid device provide by Dyson web services.
Return a valid device provide by Dyson web services.
def _get_dyson_purecool_device(): """Return a valid device provide by Dyson web services.""" device = mock.Mock(spec=DysonPureCool) load_mock_device(device) return device
[ "def", "_get_dyson_purecool_device", "(", ")", ":", "device", "=", "mock", ".", "Mock", "(", "spec", "=", "DysonPureCool", ")", "load_mock_device", "(", "device", ")", "return", "device" ]
[ 26, 0 ]
[ 30, 17 ]
python
en
['en', 'en', 'en']
True
_get_config
()
Return a config dictionary.
Return a config dictionary.
def _get_config(): """Return a config dictionary.""" return { dyson_parent.DOMAIN: { dyson_parent.CONF_USERNAME: "email", dyson_parent.CONF_PASSWORD: "password", dyson_parent.CONF_LANGUAGE: "GB", dyson_parent.CONF_DEVICES: [ {"device_id": "...
[ "def", "_get_config", "(", ")", ":", "return", "{", "dyson_parent", ".", "DOMAIN", ":", "{", "dyson_parent", ".", "CONF_USERNAME", ":", "\"email\"", ",", "dyson_parent", ".", "CONF_PASSWORD", ":", "\"password\"", ",", "dyson_parent", ".", "CONF_LANGUAGE", ":", ...
[ 33, 0 ]
[ 44, 5 ]
python
en
['en', 'pt', 'en']
True
_get_device_without_state
()
Return a valid device provide by Dyson web services.
Return a valid device provide by Dyson web services.
def _get_device_without_state(): """Return a valid device provide by Dyson web services.""" device = mock.Mock(spec=DysonPureCoolLink) device.name = "Device_name" device.state = None device.environmental_state = None return device
[ "def", "_get_device_without_state", "(", ")", ":", "device", "=", "mock", ".", "Mock", "(", "spec", "=", "DysonPureCoolLink", ")", "device", ".", "name", "=", "\"Device_name\"", "device", ".", "state", "=", "None", "device", ".", "environmental_state", "=", ...
[ 47, 0 ]
[ 53, 17 ]
python
en
['en', 'en', 'en']
True
_get_with_state
()
Return a valid device with state values.
Return a valid device with state values.
def _get_with_state(): """Return a valid device with state values.""" device = mock.Mock() load_mock_device(device) device.name = "Device_name" device.state.filter_life = 100 device.environmental_state.dust = 5 device.environmental_state.humidity = 45 device.environmental_state.temperatu...
[ "def", "_get_with_state", "(", ")", ":", "device", "=", "mock", ".", "Mock", "(", ")", "load_mock_device", "(", "device", ")", "device", ".", "name", "=", "\"Device_name\"", "device", ".", "state", ".", "filter_life", "=", "100", "device", ".", "environmen...
[ 56, 0 ]
[ 67, 17 ]
python
en
['en', 'en', 'en']
True
_get_purecool_device
()
Return a valid device with filters life state values.
Return a valid device with filters life state values.
def _get_purecool_device(): """Return a valid device with filters life state values.""" device = mock.Mock(spec=DysonPureCool) load_mock_device(device) device.name = "PureCool" device.state.carbon_filter_state = "0096" device.state.hepa_filter_state = "0056" device.environmental_state.dust =...
[ "def", "_get_purecool_device", "(", ")", ":", "device", "=", "mock", ".", "Mock", "(", "spec", "=", "DysonPureCool", ")", "load_mock_device", "(", "device", ")", "device", ".", "name", "=", "\"PureCool\"", "device", ".", "state", ".", "carbon_filter_state", ...
[ 70, 0 ]
[ 82, 17 ]
python
en
['en', 'en', 'en']
True
_get_purecool_humidify_device
()
Return a valid device with filters life state values.
Return a valid device with filters life state values.
def _get_purecool_humidify_device(): """Return a valid device with filters life state values.""" device = mock.Mock(spec=DysonPureCool) load_mock_device(device) device.name = "PureCool_Humidify" device.state.carbon_filter_state = "INV" device.state.hepa_filter_state = "0075" device.environme...
[ "def", "_get_purecool_humidify_device", "(", ")", ":", "device", "=", "mock", ".", "Mock", "(", "spec", "=", "DysonPureCool", ")", "load_mock_device", "(", "device", ")", "device", ".", "name", "=", "\"PureCool_Humidify\"", "device", ".", "state", ".", "carbon...
[ 85, 0 ]
[ 97, 17 ]
python
en
['en', 'en', 'en']
True
_get_with_standby_monitoring
()
Return a valid device with state but with standby monitoring disable.
Return a valid device with state but with standby monitoring disable.
def _get_with_standby_monitoring(): """Return a valid device with state but with standby monitoring disable.""" device = mock.Mock() load_mock_device(device) device.name = "Device_name" device.environmental_state.humidity = 0 device.environmental_state.temperature = 0 return device
[ "def", "_get_with_standby_monitoring", "(", ")", ":", "device", "=", "mock", ".", "Mock", "(", ")", "load_mock_device", "(", "device", ")", "device", ".", "name", "=", "\"Device_name\"", "device", ".", "environmental_state", ".", "humidity", "=", "0", "device"...
[ 100, 0 ]
[ 108, 17 ]
python
en
['en', 'en', 'en']
True
test_purecool_component_setup_only_once
(devices, login, hass)
Test if entities are created only once.
Test if entities are created only once.
async def test_purecool_component_setup_only_once(devices, login, hass): """Test if entities are created only once.""" config = _get_config() await async_setup_component(hass, dyson_parent.DOMAIN, config) await hass.async_block_till_done() discovery.load_platform(hass, "sensor", dyson_parent.DOMAIN,...
[ "async", "def", "test_purecool_component_setup_only_once", "(", "devices", ",", "login", ",", "hass", ")", ":", "config", "=", "_get_config", "(", ")", "await", "async_setup_component", "(", "hass", ",", "dyson_parent", ".", "DOMAIN", ",", "config", ")", "await"...
[ 300, 0 ]
[ 308, 58 ]
python
en
['en', 'en', 'en']
True
test_dyson_purecool_filter_state_sensor
(devices, login, hass)
Test filter sensor with values.
Test filter sensor with values.
async def test_dyson_purecool_filter_state_sensor(devices, login, hass): """Test filter sensor with values.""" config = _get_config() await async_setup_component(hass, dyson_parent.DOMAIN, config) await hass.async_block_till_done() state = hass.states.get("sensor.purecool_hepa_filter_remaining_life...
[ "async", "def", "test_dyson_purecool_filter_state_sensor", "(", "devices", ",", "login", ",", "hass", ")", ":", "config", "=", "_get_config", "(", ")", "await", "async_setup_component", "(", "hass", ",", "dyson_parent", ".", "DOMAIN", ",", "config", ")", "await"...
[ 316, 0 ]
[ 332, 64 ]
python
en
['en', 'en', 'en']
True
test_dyson_purecool_humidify_filter_state_sensor
(devices, login, hass)
Test filter sensor with values.
Test filter sensor with values.
async def test_dyson_purecool_humidify_filter_state_sensor(devices, login, hass): """Test filter sensor with values.""" config = _get_config() await async_setup_component(hass, dyson_parent.DOMAIN, config) await hass.async_block_till_done() state = hass.states.get("sensor.purecool_humidify_combi_fi...
[ "async", "def", "test_dyson_purecool_humidify_filter_state_sensor", "(", "devices", ",", "login", ",", "hass", ")", ":", "config", "=", "_get_config", "(", ")", "await", "async_setup_component", "(", "hass", ",", "dyson_parent", ".", "DOMAIN", ",", "config", ")", ...
[ 340, 0 ]
[ 350, 72 ]
python
en
['en', 'en', 'en']
True
DysonTest.setUp
(self)
Set up things to be run when tests are started.
Set up things to be run when tests are started.
def setUp(self): # pylint: disable=invalid-name """Set up things to be run when tests are started.""" self.hass = get_test_home_assistant() self.addCleanup(self.tear_down_cleanup)
[ "def", "setUp", "(", "self", ")", ":", "# pylint: disable=invalid-name", "self", ".", "hass", "=", "get_test_home_assistant", "(", ")", "self", ".", "addCleanup", "(", "self", ".", "tear_down_cleanup", ")" ]
[ 114, 4 ]
[ 117, 47 ]
python
en
['en', 'en', 'en']
True
DysonTest.tear_down_cleanup
(self)
Stop everything that was started.
Stop everything that was started.
def tear_down_cleanup(self): """Stop everything that was started.""" self.hass.stop()
[ "def", "tear_down_cleanup", "(", "self", ")", ":", "self", ".", "hass", ".", "stop", "(", ")" ]
[ 119, 4 ]
[ 121, 24 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_setup_component_with_no_devices
(self)
Test setup component with no devices.
Test setup component with no devices.
def test_setup_component_with_no_devices(self): """Test setup component with no devices.""" self.hass.data[dyson.DYSON_DEVICES] = [] add_entities = mock.MagicMock() dyson.setup_platform(self.hass, None, add_entities) add_entities.assert_not_called()
[ "def", "test_setup_component_with_no_devices", "(", "self", ")", ":", "self", ".", "hass", ".", "data", "[", "dyson", ".", "DYSON_DEVICES", "]", "=", "[", "]", "add_entities", "=", "mock", ".", "MagicMock", "(", ")", "dyson", ".", "setup_platform", "(", "s...
[ 123, 4 ]
[ 128, 40 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_setup_component
(self)
Test setup component with devices.
Test setup component with devices.
def test_setup_component(self): """Test setup component with devices.""" def _add_device(devices): assert len(devices) == 5 assert devices[0].name == "Device_name Filter Life" assert devices[1].name == "Device_name Dust" assert devices[2].name == "Device_...
[ "def", "test_setup_component", "(", "self", ")", ":", "def", "_add_device", "(", "devices", ")", ":", "assert", "len", "(", "devices", ")", "==", "5", "assert", "devices", "[", "0", "]", ".", "name", "==", "\"Device_name Filter Life\"", "assert", "devices", ...
[ 130, 4 ]
[ 147, 76 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_filter_life_sensor
(self)
Test filter life sensor with no value.
Test filter life sensor with no value.
def test_dyson_filter_life_sensor(self): """Test filter life sensor with no value.""" sensor = dyson.DysonFilterLifeSensor(_get_device_without_state()) sensor.hass = self.hass sensor.entity_id = "sensor.dyson_1" assert not sensor.should_poll assert sensor.state is None ...
[ "def", "test_dyson_filter_life_sensor", "(", "self", ")", ":", "sensor", "=", "dyson", ".", "DysonFilterLifeSensor", "(", "_get_device_without_state", "(", ")", ")", "sensor", ".", "hass", "=", "self", ".", "hass", "sensor", ".", "entity_id", "=", "\"sensor.dyso...
[ 149, 4 ]
[ 159, 36 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_filter_life_sensor_with_values
(self)
Test filter sensor with values.
Test filter sensor with values.
def test_dyson_filter_life_sensor_with_values(self): """Test filter sensor with values.""" sensor = dyson.DysonFilterLifeSensor(_get_with_state()) sensor.hass = self.hass sensor.entity_id = "sensor.dyson_1" assert not sensor.should_poll assert sensor.state == 100 ...
[ "def", "test_dyson_filter_life_sensor_with_values", "(", "self", ")", ":", "sensor", "=", "dyson", ".", "DysonFilterLifeSensor", "(", "_get_with_state", "(", ")", ")", "sensor", ".", "hass", "=", "self", ".", "hass", "sensor", ".", "entity_id", "=", "\"sensor.dy...
[ 161, 4 ]
[ 171, 36 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_dust_sensor
(self)
Test dust sensor with no value.
Test dust sensor with no value.
def test_dyson_dust_sensor(self): """Test dust sensor with no value.""" sensor = dyson.DysonDustSensor(_get_device_without_state()) sensor.hass = self.hass sensor.entity_id = "sensor.dyson_1" assert not sensor.should_poll assert sensor.state is None assert sensor....
[ "def", "test_dyson_dust_sensor", "(", "self", ")", ":", "sensor", "=", "dyson", ".", "DysonDustSensor", "(", "_get_device_without_state", "(", ")", ")", "sensor", ".", "hass", "=", "self", ".", "hass", "sensor", ".", "entity_id", "=", "\"sensor.dyson_1\"", "as...
[ 173, 4 ]
[ 182, 51 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_dust_sensor_with_values
(self)
Test dust sensor with values.
Test dust sensor with values.
def test_dyson_dust_sensor_with_values(self): """Test dust sensor with values.""" sensor = dyson.DysonDustSensor(_get_with_state()) sensor.hass = self.hass sensor.entity_id = "sensor.dyson_1" assert not sensor.should_poll assert sensor.state == 5 assert sensor.uni...
[ "def", "test_dyson_dust_sensor_with_values", "(", "self", ")", ":", "sensor", "=", "dyson", ".", "DysonDustSensor", "(", "_get_with_state", "(", ")", ")", "sensor", ".", "hass", "=", "self", ".", "hass", "sensor", ".", "entity_id", "=", "\"sensor.dyson_1\"", "...
[ 184, 4 ]
[ 193, 51 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_humidity_sensor
(self)
Test humidity sensor with no value.
Test humidity sensor with no value.
def test_dyson_humidity_sensor(self): """Test humidity sensor with no value.""" sensor = dyson.DysonHumiditySensor(_get_device_without_state()) sensor.hass = self.hass sensor.entity_id = "sensor.dyson_1" assert not sensor.should_poll assert sensor.state is None as...
[ "def", "test_dyson_humidity_sensor", "(", "self", ")", ":", "sensor", "=", "dyson", ".", "DysonHumiditySensor", "(", "_get_device_without_state", "(", ")", ")", "sensor", ".", "hass", "=", "self", ".", "hass", "sensor", ".", "entity_id", "=", "\"sensor.dyson_1\"...
[ 195, 4 ]
[ 204, 51 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_humidity_sensor_with_values
(self)
Test humidity sensor with values.
Test humidity sensor with values.
def test_dyson_humidity_sensor_with_values(self): """Test humidity sensor with values.""" sensor = dyson.DysonHumiditySensor(_get_with_state()) sensor.hass = self.hass sensor.entity_id = "sensor.dyson_1" assert not sensor.should_poll assert sensor.state == 45 asse...
[ "def", "test_dyson_humidity_sensor_with_values", "(", "self", ")", ":", "sensor", "=", "dyson", ".", "DysonHumiditySensor", "(", "_get_with_state", "(", ")", ")", "sensor", ".", "hass", "=", "self", ".", "hass", "sensor", ".", "entity_id", "=", "\"sensor.dyson_1...
[ 206, 4 ]
[ 215, 51 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_humidity_standby_monitoring
(self)
Test humidity sensor while device is in standby monitoring.
Test humidity sensor while device is in standby monitoring.
def test_dyson_humidity_standby_monitoring(self): """Test humidity sensor while device is in standby monitoring.""" sensor = dyson.DysonHumiditySensor(_get_with_standby_monitoring()) sensor.hass = self.hass sensor.entity_id = "sensor.dyson_1" assert not sensor.should_poll ...
[ "def", "test_dyson_humidity_standby_monitoring", "(", "self", ")", ":", "sensor", "=", "dyson", ".", "DysonHumiditySensor", "(", "_get_with_standby_monitoring", "(", ")", ")", "sensor", ".", "hass", "=", "self", ".", "hass", "sensor", ".", "entity_id", "=", "\"s...
[ 217, 4 ]
[ 226, 51 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_temperature_sensor
(self)
Test temperature sensor with no value.
Test temperature sensor with no value.
def test_dyson_temperature_sensor(self): """Test temperature sensor with no value.""" sensor = dyson.DysonTemperatureSensor(_get_device_without_state(), TEMP_CELSIUS) sensor.hass = self.hass sensor.entity_id = "sensor.dyson_1" assert not sensor.should_poll assert sensor.s...
[ "def", "test_dyson_temperature_sensor", "(", "self", ")", ":", "sensor", "=", "dyson", ".", "DysonTemperatureSensor", "(", "_get_device_without_state", "(", ")", ",", "TEMP_CELSIUS", ")", "sensor", ".", "hass", "=", "self", ".", "hass", "sensor", ".", "entity_id...
[ 228, 4 ]
[ 237, 51 ]
python
en
['en', 'ca', 'en']
True
DysonTest.test_dyson_temperature_sensor_with_values
(self)
Test temperature sensor with values.
Test temperature sensor with values.
def test_dyson_temperature_sensor_with_values(self): """Test temperature sensor with values.""" sensor = dyson.DysonTemperatureSensor(_get_with_state(), TEMP_CELSIUS) sensor.hass = self.hass sensor.entity_id = "sensor.dyson_1" assert not sensor.should_poll assert sensor.s...
[ "def", "test_dyson_temperature_sensor_with_values", "(", "self", ")", ":", "sensor", "=", "dyson", ".", "DysonTemperatureSensor", "(", "_get_with_state", "(", ")", ",", "TEMP_CELSIUS", ")", "sensor", ".", "hass", "=", "self", ".", "hass", "sensor", ".", "entity_...
[ 239, 4 ]
[ 257, 51 ]
python
en
['en', 'la', 'en']
True
DysonTest.test_dyson_temperature_standby_monitoring
(self)
Test temperature sensor while device is in standby monitoring.
Test temperature sensor while device is in standby monitoring.
def test_dyson_temperature_standby_monitoring(self): """Test temperature sensor while device is in standby monitoring.""" sensor = dyson.DysonTemperatureSensor( _get_with_standby_monitoring(), TEMP_CELSIUS ) sensor.hass = self.hass sensor.entity_id = "sensor.dyson_1" ...
[ "def", "test_dyson_temperature_standby_monitoring", "(", "self", ")", ":", "sensor", "=", "dyson", ".", "DysonTemperatureSensor", "(", "_get_with_standby_monitoring", "(", ")", ",", "TEMP_CELSIUS", ")", "sensor", ".", "hass", "=", "self", ".", "hass", "sensor", "....
[ 259, 4 ]
[ 270, 51 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_air_quality_sensor
(self)
Test air quality sensor with no value.
Test air quality sensor with no value.
def test_dyson_air_quality_sensor(self): """Test air quality sensor with no value.""" sensor = dyson.DysonAirQualitySensor(_get_device_without_state()) sensor.hass = self.hass sensor.entity_id = "sensor.dyson_1" assert not sensor.should_poll assert sensor.state is None ...
[ "def", "test_dyson_air_quality_sensor", "(", "self", ")", ":", "sensor", "=", "dyson", ".", "DysonAirQualitySensor", "(", "_get_device_without_state", "(", ")", ")", "sensor", ".", "hass", "=", "self", ".", "hass", "sensor", ".", "entity_id", "=", "\"sensor.dyso...
[ 272, 4 ]
[ 281, 51 ]
python
en
['en', 'pt', 'en']
True
DysonTest.test_dyson_air_quality_sensor_with_values
(self)
Test air quality sensor with values.
Test air quality sensor with values.
def test_dyson_air_quality_sensor_with_values(self): """Test air quality sensor with values.""" sensor = dyson.DysonAirQualitySensor(_get_with_state()) sensor.hass = self.hass sensor.entity_id = "sensor.dyson_1" assert not sensor.should_poll assert sensor.state == 2 ...
[ "def", "test_dyson_air_quality_sensor_with_values", "(", "self", ")", ":", "sensor", "=", "dyson", ".", "DysonAirQualitySensor", "(", "_get_with_state", "(", ")", ")", "sensor", ".", "hass", "=", "self", ".", "hass", "sensor", ".", "entity_id", "=", "\"sensor.dy...
[ 283, 4 ]
[ 292, 51 ]
python
en
['en', 'en', 'en']
True
patch_debounce
()
Return patch for debounce method.
Return patch for debounce method.
def patch_debounce(): """Return patch for debounce method.""" return patch( "homeassistant.components.homekit.accessories.debounce", lambda f: lambda *args, **kwargs: f(*args, **kwargs), )
[ "def", "patch_debounce", "(", ")", ":", "return", "patch", "(", "\"homeassistant.components.homekit.accessories.debounce\"", ",", "lambda", "f", ":", "lambda", "*", "args", ",", "*", "*", "kwargs", ":", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", ...
[ 6, 0 ]
[ 11, 5 ]
python
en
['en', 'nl', 'en']
True
mock_turbo_jpeg
( first_width=None, second_width=None, first_height=None, second_height=None )
Mock a TurboJPEG instance.
Mock a TurboJPEG instance.
def mock_turbo_jpeg( first_width=None, second_width=None, first_height=None, second_height=None ): """Mock a TurboJPEG instance.""" mocked_turbo_jpeg = Mock() mocked_turbo_jpeg.decode_header.side_effect = [ (first_width, first_height, 0, 0), (second_width, second_height, 0, 0), ] ...
[ "def", "mock_turbo_jpeg", "(", "first_width", "=", "None", ",", "second_width", "=", "None", ",", "first_height", "=", "None", ",", "second_height", "=", "None", ")", ":", "mocked_turbo_jpeg", "=", "Mock", "(", ")", "mocked_turbo_jpeg", ".", "decode_header", "...
[ 14, 0 ]
[ 24, 28 ]
python
en
['en', 'haw', 'en']
True
test_intent_set_color
(hass)
Test the set color intent.
Test the set color intent.
async def test_intent_set_color(hass): """Test the set color intent.""" hass.states.async_set( "light.hello_2", "off", {ATTR_SUPPORTED_FEATURES: light.SUPPORT_COLOR} ) hass.states.async_set("switch.hello", "off") calls = async_mock_service(hass, light.DOMAIN, light.SERVICE_TURN_ON) await...
[ "async", "def", "test_intent_set_color", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"light.hello_2\"", ",", "\"off\"", ",", "{", "ATTR_SUPPORTED_FEATURES", ":", "light", ".", "SUPPORT_COLOR", "}", ")", "hass", ".", "states", ".", ...
[ 9, 0 ]
[ 32, 61 ]
python
en
['en', 'fr', 'en']
True
test_intent_set_color_tests_feature
(hass)
Test the set color intent.
Test the set color intent.
async def test_intent_set_color_tests_feature(hass): """Test the set color intent.""" hass.states.async_set("light.hello", "off") calls = async_mock_service(hass, light.DOMAIN, light.SERVICE_TURN_ON) await intent.async_setup_intents(hass) try: await hass.helpers.intent.async_handle( ...
[ "async", "def", "test_intent_set_color_tests_feature", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"light.hello\"", ",", "\"off\"", ")", "calls", "=", "async_mock_service", "(", "hass", ",", "light", ".", "DOMAIN", ",", "light", ".",...
[ 35, 0 ]
[ 51, 26 ]
python
en
['en', 'fr', 'en']
True
test_intent_set_color_and_brightness
(hass)
Test the set color intent.
Test the set color intent.
async def test_intent_set_color_and_brightness(hass): """Test the set color intent.""" hass.states.async_set( "light.hello_2", "off", {ATTR_SUPPORTED_FEATURES: (light.SUPPORT_COLOR | light.SUPPORT_BRIGHTNESS)}, ) hass.states.async_set("switch.hello", "off") calls = async_mock...
[ "async", "def", "test_intent_set_color_and_brightness", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"light.hello_2\"", ",", "\"off\"", ",", "{", "ATTR_SUPPORTED_FEATURES", ":", "(", "light", ".", "SUPPORT_COLOR", "|", "light", ".", "SU...
[ 54, 0 ]
[ 87, 57 ]
python
en
['en', 'fr', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Set up Velbus light based on config_entry.
Set up Velbus light based on config_entry.
async def async_setup_entry(hass, entry, async_add_entities): """Set up Velbus light based on config_entry.""" cntrl = hass.data[DOMAIN][entry.entry_id]["cntrl"] modules_data = hass.data[DOMAIN][entry.entry_id]["light"] entities = [] for address, channel in modules_data: module = cntrl.get_m...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "cntrl", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "[", "\"cntrl\"", "]", "modules_data", "=", "hass", ".", "data...
[ 23, 0 ]
[ 31, 32 ]
python
en
['en', 'en', 'en']
True
VelbusLight.name
(self)
Return the display name of this entity.
Return the display name of this entity.
def name(self): """Return the display name of this entity.""" if self._module.light_is_buttonled(self._channel): return f"LED {self._module.get_name(self._channel)}" return self._module.get_name(self._channel)
[ "def", "name", "(", "self", ")", ":", "if", "self", ".", "_module", ".", "light_is_buttonled", "(", "self", ".", "_channel", ")", ":", "return", "f\"LED {self._module.get_name(self._channel)}\"", "return", "self", ".", "_module", ".", "get_name", "(", "self", ...
[ 38, 4 ]
[ 42, 51 ]
python
en
['en', 'en', 'en']
True
VelbusLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" if self._module.light_is_buttonled(self._channel): return SUPPORT_FLASH return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
[ "def", "supported_features", "(", "self", ")", ":", "if", "self", ".", "_module", ".", "light_is_buttonled", "(", "self", ".", "_channel", ")", ":", "return", "SUPPORT_FLASH", "return", "SUPPORT_BRIGHTNESS", "|", "SUPPORT_TRANSITION" ]
[ 45, 4 ]
[ 49, 54 ]
python
en
['da', 'en', 'en']
True
VelbusLight.entity_registry_enabled_default
(self)
Disable Button LEDs by default.
Disable Button LEDs by default.
def entity_registry_enabled_default(self): """Disable Button LEDs by default.""" if self._module.light_is_buttonled(self._channel): return False return True
[ "def", "entity_registry_enabled_default", "(", "self", ")", ":", "if", "self", ".", "_module", ".", "light_is_buttonled", "(", "self", ".", "_channel", ")", ":", "return", "False", "return", "True" ]
[ 52, 4 ]
[ 56, 19 ]
python
en
['en', 'fr', 'en']
True
VelbusLight.is_on
(self)
Return true if the light is on.
Return true if the light is on.
def is_on(self): """Return true if the light is on.""" return self._module.is_on(self._channel)
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_module", ".", "is_on", "(", "self", ".", "_channel", ")" ]
[ 59, 4 ]
[ 61, 48 ]
python
en
['en', 'en', 'en']
True
VelbusLight.brightness
(self)
Return the brightness of the light.
Return the brightness of the light.
def brightness(self): """Return the brightness of the light.""" return int((self._module.get_dimmer_state(self._channel) * 255) / 100)
[ "def", "brightness", "(", "self", ")", ":", "return", "int", "(", "(", "self", ".", "_module", ".", "get_dimmer_state", "(", "self", ".", "_channel", ")", "*", "255", ")", "/", "100", ")" ]
[ 64, 4 ]
[ 66, 78 ]
python
en
['en', 'no', 'en']
True
VelbusLight.turn_on
(self, **kwargs)
Instruct the Velbus light to turn on.
Instruct the Velbus light to turn on.
def turn_on(self, **kwargs): """Instruct the Velbus light to turn on.""" if self._module.light_is_buttonled(self._channel): if ATTR_FLASH in kwargs: if kwargs[ATTR_FLASH] == FLASH_LONG: attr, *args = "set_led_state", self._channel, "slow" e...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_module", ".", "light_is_buttonled", "(", "self", ".", "_channel", ")", ":", "if", "ATTR_FLASH", "in", "kwargs", ":", "if", "kwargs", "[", "ATTR_FLASH", "]", "==", ...
[ 68, 4 ]
[ 102, 61 ]
python
en
['en', 'en', 'en']
True
VelbusLight.turn_off
(self, **kwargs)
Instruct the velbus light to turn off.
Instruct the velbus light to turn off.
def turn_off(self, **kwargs): """Instruct the velbus light to turn off.""" if self._module.light_is_buttonled(self._channel): attr, *args = "set_led_state", self._channel, "off" else: attr, *args = ( "set_dimmer_state", self._channel, ...
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_module", ".", "light_is_buttonled", "(", "self", ".", "_channel", ")", ":", "attr", ",", "", "*", "args", "=", "\"set_led_state\"", ",", "self", ".", "_channel", ...
[ 104, 4 ]
[ 118, 61 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Twitch platform.
Set up the Twitch platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Twitch platform.""" channels = config[CONF_CHANNELS] client_id = config[CONF_CLIENT_ID] oauth_token = config.get(CONF_TOKEN) client = TwitchClient(client_id, oauth_token) try: client.ingests.get_server_li...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "channels", "=", "config", "[", "CONF_CHANNELS", "]", "client_id", "=", "config", "[", "CONF_CLIENT_ID", "]", "oauth_token", "=", "config", ...
[ 40, 0 ]
[ 55, 88 ]
python
en
['en', 'lv', 'en']
True
TwitchSensor.__init__
(self, channel, client)
Initialize the sensor.
Initialize the sensor.
def __init__(self, channel, client): """Initialize the sensor.""" self._client = client self._channel = channel self._oauth_enabled = client._oauth_token is not None self._state = None self._preview = None self._game = None self._title = None self....
[ "def", "__init__", "(", "self", ",", "channel", ",", "client", ")", ":", "self", ".", "_client", "=", "client", "self", ".", "_channel", "=", "channel", "self", ".", "_oauth_enabled", "=", "client", ".", "_oauth_token", "is", "not", "None", "self", ".", ...
[ 61, 4 ]
[ 72, 31 ]
python
en
['en', 'en', 'en']
True
TwitchSensor.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._channel.display_name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_channel", ".", "display_name" ]
[ 75, 4 ]
[ 77, 41 ]
python
en
['en', 'mi', 'en']
True
TwitchSensor.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" ]
[ 80, 4 ]
[ 82, 26 ]
python
en
['en', 'en', 'en']
True
TwitchSensor.entity_picture
(self)
Return preview of current game.
Return preview of current game.
def entity_picture(self): """Return preview of current game.""" return self._preview
[ "def", "entity_picture", "(", "self", ")", ":", "return", "self", ".", "_preview" ]
[ 85, 4 ]
[ 87, 28 ]
python
en
['en', 'en', 'en']
True
TwitchSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" attr = dict(self._statistics) if self._oauth_enabled: attr.update(self._subscription) attr.update(self._follow) if self._state == STATE_STREAMING: attr.update({ATTR_GAME: self._gam...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attr", "=", "dict", "(", "self", ".", "_statistics", ")", "if", "self", ".", "_oauth_enabled", ":", "attr", ".", "update", "(", "self", ".", "_subscription", ")", "attr", ".", "update", "(", "self...
[ 90, 4 ]
[ 100, 19 ]
python
en
['en', 'en', 'en']
True
TwitchSensor.unique_id
(self)
Return unique ID for this sensor.
Return unique ID for this sensor.
def unique_id(self): """Return unique ID for this sensor.""" return self._channel.id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_channel", ".", "id" ]
[ 103, 4 ]
[ 105, 31 ]
python
en
['en', 'la', 'en']
True
TwitchSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 108, 4 ]
[ 110, 19 ]
python
en
['en', 'en', 'en']
True
TwitchSensor.update
(self)
Update device state.
Update device state.
def update(self): """Update device state.""" channel = self._client.channels.get_by_id(self._channel.id) self._statistics = { ATTR_FOLLOWING: channel.followers, ATTR_VIEWS: channel.views, } if self._oauth_enabled: user = self._client.users.ge...
[ "def", "update", "(", "self", ")", ":", "channel", "=", "self", ".", "_client", ".", "channels", ".", "get_by_id", "(", "self", ".", "_channel", ".", "id", ")", "self", ".", "_statistics", "=", "{", "ATTR_FOLLOWING", ":", "channel", ".", "followers", "...
[ 112, 4 ]
[ 152, 39 ]
python
en
['fr', 'en', 'en']
True
valid_integration_path
(integration_path)
Test if it's a valid integration.
Test if it's a valid integration.
def valid_integration_path(integration_path): """Test if it's a valid integration.""" path = pathlib.Path(integration_path) if not path.is_dir(): raise argparse.ArgumentTypeError(f"{integration_path} is not a directory.") return path
[ "def", "valid_integration_path", "(", "integration_path", ")", ":", "path", "=", "pathlib", ".", "Path", "(", "integration_path", ")", "if", "not", "path", ".", "is_dir", "(", ")", ":", "raise", "argparse", ".", "ArgumentTypeError", "(", "f\"{integration_path} i...
[ 39, 0 ]
[ 45, 15 ]
python
en
['en', 'en', 'en']
True
get_config
()
Return config.
Return config.
def get_config() -> Config: """Return config.""" parser = argparse.ArgumentParser(description="Hassfest") parser.add_argument( "--action", type=str, choices=["validate", "generate"], default=None ) parser.add_argument( "--integration-path", action="append", type=valid...
[ "def", "get_config", "(", ")", "->", "Config", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Hassfest\"", ")", "parser", ".", "add_argument", "(", "\"--action\"", ",", "type", "=", "str", ",", "choices", "=", "[", "\"va...
[ 48, 0 ]
[ 86, 5 ]
python
en
['en', 'la', 'en']
False
main
()
Validate manifests.
Validate manifests.
def main(): """Validate manifests.""" try: config = get_config() except RuntimeError as err: print(err) return 1 plugins = [*INTEGRATION_PLUGINS] if config.requirements: plugins.append(requirements) if config.specific_integrations: integrations = {} ...
[ "def", "main", "(", ")", ":", "try", ":", "config", "=", "get_config", "(", ")", "except", "RuntimeError", "as", "err", ":", "print", "(", "err", ")", "return", "1", "plugins", "=", "[", "*", "INTEGRATION_PLUGINS", "]", "if", "config", ".", "requiremen...
[ 89, 0 ]
[ 173, 12 ]
python
bg
['en', 'et', 'bg']
False
print_integrations_status
(config, integrations, *, show_fixable_errors=True)
Print integration status.
Print integration status.
def print_integrations_status(config, integrations, *, show_fixable_errors=True): """Print integration status.""" for integration in sorted(integrations, key=lambda itg: itg.domain): extra = f" - {integration.path}" if config.specific_integrations else "" print(f"Integration {integration.domain}...
[ "def", "print_integrations_status", "(", "config", ",", "integrations", ",", "*", ",", "show_fixable_errors", "=", "True", ")", ":", "for", "integration", "in", "sorted", "(", "integrations", ",", "key", "=", "lambda", "itg", ":", "itg", ".", "domain", ")", ...
[ 176, 0 ]
[ 186, 15 ]
python
en
['en', 'ja', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the trend sensors.
Set up the trend sensors.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the trend sensors.""" setup_reload_service(hass, DOMAIN, PLATFORMS) sensors = [] for device_id, device_config in config[CONF_SENSORS].items(): entity_id = device_config[ATTR_ENTITY_ID] attribute = device_co...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "setup_reload_service", "(", "hass", ",", "DOMAIN", ",", "PLATFORMS", ")", "sensors", "=", "[", "]", "for", "device_id", ",", "device_conf...
[ 66, 0 ]
[ 100, 25 ]
python
en
['en', 'ca', 'en']
True
SensorTrend.__init__
( self, hass, device_id, friendly_name, entity_id, attribute, device_class, invert, max_samples, min_gradient, sample_duration, )
Initialize the sensor.
Initialize the sensor.
def __init__( self, hass, device_id, friendly_name, entity_id, attribute, device_class, invert, max_samples, min_gradient, sample_duration, ): """Initialize the sensor.""" self._hass = hass self.entity_id...
[ "def", "__init__", "(", "self", ",", "hass", ",", "device_id", ",", "friendly_name", ",", "entity_id", ",", "attribute", ",", "device_class", ",", "invert", ",", "max_samples", ",", "min_gradient", ",", "sample_duration", ",", ")", ":", "self", ".", "_hass",...
[ 106, 4 ]
[ 131, 48 ]
python
en
['en', 'en', 'en']
True
SensorTrend.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" ]
[ 134, 4 ]
[ 136, 25 ]
python
en
['en', 'mi', 'en']
True
SensorTrend.is_on
(self)
Return true if sensor is on.
Return true if sensor is on.
def is_on(self): """Return true if sensor is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 139, 4 ]
[ 141, 26 ]
python
en
['en', 'et', 'en']
True
SensorTrend.device_class
(self)
Return the sensor class of the sensor.
Return the sensor class of the sensor.
def device_class(self): """Return the sensor class of the sensor.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 144, 4 ]
[ 146, 33 ]
python
en
['en', 'sq', 'en']
True
SensorTrend.device_state_attributes
(self)
Return the state attributes of the sensor.
Return the state attributes of the sensor.
def device_state_attributes(self): """Return the state attributes of the sensor.""" return { ATTR_ENTITY_ID: self._entity_id, ATTR_FRIENDLY_NAME: self._name, ATTR_GRADIENT: self._gradient, ATTR_INVERT: self._invert, ATTR_MIN_GRADIENT: self._min...
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ENTITY_ID", ":", "self", ".", "_entity_id", ",", "ATTR_FRIENDLY_NAME", ":", "self", ".", "_name", ",", "ATTR_GRADIENT", ":", "self", ".", "_gradient", ",", "ATTR_INVERT", ":", "self"...
[ 149, 4 ]
[ 159, 9 ]
python
en
['en', 'en', 'en']
True
SensorTrend.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 162, 4 ]
[ 164, 20 ]
python
en
['en', 'en', 'en']
True
SensorTrend.async_added_to_hass
(self)
Complete device setup after being added to hass.
Complete device setup after being added to hass.
async def async_added_to_hass(self): """Complete device setup after being added to hass.""" @callback def trend_sensor_state_listener(event): """Handle state changes on the observed device.""" new_state = event.data.get("new_state") if new_state is None: ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "@", "callback", "def", "trend_sensor_state_listener", "(", "event", ")", ":", "\"\"\"Handle state changes on the observed device.\"\"\"", "new_state", "=", "event", ".", "data", ".", "get", "(", "\"new_sta...
[ 166, 4 ]
[ 191, 9 ]
python
en
['en', 'en', 'en']
True
SensorTrend.async_update
(self)
Get the latest data and update the states.
Get the latest data and update the states.
async def async_update(self): """Get the latest data and update the states.""" # Remove outdated samples if self._sample_duration > 0: cutoff = utcnow().timestamp() - self._sample_duration while self.samples and self.samples[0][0] < cutoff: self.samples.po...
[ "async", "def", "async_update", "(", "self", ")", ":", "# Remove outdated samples", "if", "self", ".", "_sample_duration", ">", "0", ":", "cutoff", "=", "utcnow", "(", ")", ".", "timestamp", "(", ")", "-", "self", ".", "_sample_duration", "while", "self", ...
[ 193, 4 ]
[ 214, 41 ]
python
en
['en', 'en', 'en']
True
SensorTrend._calculate_gradient
(self)
Compute the linear trend gradient of the current samples. This need run inside executor.
Compute the linear trend gradient of the current samples.
def _calculate_gradient(self): """Compute the linear trend gradient of the current samples. This need run inside executor. """ timestamps = np.array([t for t, _ in self.samples]) values = np.array([s for _, s in self.samples]) coeffs = np.polyfit(timestamps, values, 1) ...
[ "def", "_calculate_gradient", "(", "self", ")", ":", "timestamps", "=", "np", ".", "array", "(", "[", "t", "for", "t", ",", "_", "in", "self", ".", "samples", "]", ")", "values", "=", "np", ".", "array", "(", "[", "s", "for", "_", ",", "s", "in...
[ 216, 4 ]
[ 224, 34 ]
python
en
['en', 'en', 'en']
True
convert_pid
(value)
Convert pid from hex string to integer.
Convert pid from hex string to integer.
def convert_pid(value): """Convert pid from hex string to integer.""" return int(value, 16)
[ "def", "convert_pid", "(", "value", ")", ":", "return", "int", "(", "value", ",", "16", ")" ]
[ 36, 0 ]
[ 38, 25 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Torque platform.
Set up the Torque platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Torque platform.""" vehicle = config.get(CONF_NAME) email = config.get(CONF_EMAIL) sensors = {} hass.http.register_view( TorqueReceiveDataView(email, vehicle, sensors, add_entities) ) return True
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "vehicle", "=", "config", ".", "get", "(", "CONF_NAME", ")", "email", "=", "config", ".", "get", "(", "CONF_EMAIL", ")", "sensors", "=...
[ 41, 0 ]
[ 50, 15 ]
python
en
['en', 'lv', 'en']
True
TorqueReceiveDataView.__init__
(self, email, vehicle, sensors, add_entities)
Initialize a Torque view.
Initialize a Torque view.
def __init__(self, email, vehicle, sensors, add_entities): """Initialize a Torque view.""" self.email = email self.vehicle = vehicle self.sensors = sensors self.add_entities = add_entities
[ "def", "__init__", "(", "self", ",", "email", ",", "vehicle", ",", "sensors", ",", "add_entities", ")", ":", "self", ".", "email", "=", "email", "self", ".", "vehicle", "=", "vehicle", "self", ".", "sensors", "=", "sensors", "self", ".", "add_entities", ...
[ 59, 4 ]
[ 64, 40 ]
python
en
['es', 'en', 'en']
True
TorqueReceiveDataView.get
(self, request)
Handle Torque data request.
Handle Torque data request.
def get(self, request): """Handle Torque data request.""" hass = request.app["hass"] data = request.query if self.email is not None and self.email != data[SENSOR_EMAIL_FIELD]: return names = {} units = {} for key in data: is_name = NAME_K...
[ "def", "get", "(", "self", ",", "request", ")", ":", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "data", "=", "request", ".", "query", "if", "self", ".", "email", "is", "not", "None", "and", "self", ".", "email", "!=", "data", "[", ...
[ 67, 4 ]
[ 105, 20 ]
python
en
['fr', 'nl', 'en']
False
TorqueSensor.__init__
(self, name, unit)
Initialize the sensor.
Initialize the sensor.
def __init__(self, name, unit): """Initialize the sensor.""" self._name = name self._unit = unit self._state = None
[ "def", "__init__", "(", "self", ",", "name", ",", "unit", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_unit", "=", "unit", "self", ".", "_state", "=", "None" ]
[ 111, 4 ]
[ 115, 26 ]
python
en
['en', 'en', 'en']
True
TorqueSensor.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" ]
[ 118, 4 ]
[ 120, 25 ]
python
en
['en', 'mi', 'en']
True
TorqueSensor.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return self._unit
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit" ]
[ 123, 4 ]
[ 125, 25 ]
python
en
['en', 'la', 'en']
True
TorqueSensor.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" ]
[ 128, 4 ]
[ 130, 26 ]
python
en
['en', 'en', 'en']
True
TorqueSensor.icon
(self)
Return the default icon of the sensor.
Return the default icon of the sensor.
def icon(self): """Return the default icon of the sensor.""" return "mdi:car"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:car\"" ]
[ 133, 4 ]
[ 135, 24 ]
python
en
['en', 'en', 'en']
True
TorqueSensor.async_on_update
(self, value)
Receive an update.
Receive an update.
def async_on_update(self, value): """Receive an update.""" self._state = value self.async_write_ha_state()
[ "def", "async_on_update", "(", "self", ",", "value", ")", ":", "self", ".", "_state", "=", "value", "self", ".", "async_write_ha_state", "(", ")" ]
[ 138, 4 ]
[ 141, 35 ]
python
en
['en', 'lb', 'en']
True
CloudGoogleConfig.__init__
(self, hass, config, cloud_user, prefs: CloudPreferences, cloud)
Initialize the Google config.
Initialize the Google config.
def __init__(self, hass, config, cloud_user, prefs: CloudPreferences, cloud): """Initialize the Google config.""" super().__init__(hass) self._config = config self._user = cloud_user self._prefs = prefs self._cloud = cloud self._cur_entity_prefs = self._prefs.goog...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ",", "cloud_user", ",", "prefs", ":", "CloudPreferences", ",", "cloud", ")", ":", "super", "(", ")", ".", "__init__", "(", "hass", ")", "self", ".", "_config", "=", "config", "self", ".", "_...
[ 30, 4 ]
[ 40, 37 ]
python
en
['en', 'en', 'en']
True
CloudGoogleConfig.enabled
(self)
Return if Google is enabled.
Return if Google is enabled.
def enabled(self): """Return if Google is enabled.""" return self._cloud.is_logged_in and self._prefs.google_enabled
[ "def", "enabled", "(", "self", ")", ":", "return", "self", ".", "_cloud", ".", "is_logged_in", "and", "self", ".", "_prefs", ".", "google_enabled" ]
[ 43, 4 ]
[ 45, 70 ]
python
en
['en', 'en', 'en']
True
CloudGoogleConfig.entity_config
(self)
Return entity config.
Return entity config.
def entity_config(self): """Return entity config.""" return self._config.get(CONF_ENTITY_CONFIG) or {}
[ "def", "entity_config", "(", "self", ")", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_ENTITY_CONFIG", ")", "or", "{", "}" ]
[ 48, 4 ]
[ 50, 57 ]
python
en
['en', 'cy', 'en']
True
CloudGoogleConfig.secure_devices_pin
(self)
Return entity config.
Return entity config.
def secure_devices_pin(self): """Return entity config.""" return self._prefs.google_secure_devices_pin
[ "def", "secure_devices_pin", "(", "self", ")", ":", "return", "self", ".", "_prefs", ".", "google_secure_devices_pin" ]
[ 53, 4 ]
[ 55, 52 ]
python
en
['en', 'cy', 'en']
True