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
create_temperature_sensor_service
(accessory)
Define temperature characteristics.
Define temperature characteristics.
def create_temperature_sensor_service(accessory): """Define temperature characteristics.""" service = accessory.add_service(ServicesTypes.TEMPERATURE_SENSOR) cur_state = service.add_char(CharacteristicsTypes.TEMPERATURE_CURRENT) cur_state.value = 0
[ "def", "create_temperature_sensor_service", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "TEMPERATURE_SENSOR", ")", "cur_state", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "TEMPERATURE_...
[ 24, 0 ]
[ 29, 23 ]
python
en
['en', 'ca', 'en']
True
create_humidity_sensor_service
(accessory)
Define humidity characteristics.
Define humidity characteristics.
def create_humidity_sensor_service(accessory): """Define humidity characteristics.""" service = accessory.add_service(ServicesTypes.HUMIDITY_SENSOR) cur_state = service.add_char(CharacteristicsTypes.RELATIVE_HUMIDITY_CURRENT) cur_state.value = 0
[ "def", "create_humidity_sensor_service", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "HUMIDITY_SENSOR", ")", "cur_state", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "RELATIVE_HUMIDITY_...
[ 32, 0 ]
[ 37, 23 ]
python
en
['en', 'sw', 'en']
True
create_light_level_sensor_service
(accessory)
Define light level characteristics.
Define light level characteristics.
def create_light_level_sensor_service(accessory): """Define light level characteristics.""" service = accessory.add_service(ServicesTypes.LIGHT_SENSOR) cur_state = service.add_char(CharacteristicsTypes.LIGHT_LEVEL_CURRENT) cur_state.value = 0
[ "def", "create_light_level_sensor_service", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "LIGHT_SENSOR", ")", "cur_state", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "LIGHT_LEVEL_CURREN...
[ 40, 0 ]
[ 45, 23 ]
python
bg
['es', 'bg', 'en']
False
create_carbon_dioxide_level_sensor_service
(accessory)
Define carbon dioxide level characteristics.
Define carbon dioxide level characteristics.
def create_carbon_dioxide_level_sensor_service(accessory): """Define carbon dioxide level characteristics.""" service = accessory.add_service(ServicesTypes.CARBON_DIOXIDE_SENSOR) cur_state = service.add_char(CharacteristicsTypes.CARBON_DIOXIDE_LEVEL) cur_state.value = 0
[ "def", "create_carbon_dioxide_level_sensor_service", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "CARBON_DIOXIDE_SENSOR", ")", "cur_state", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "...
[ 48, 0 ]
[ 53, 23 ]
python
fr
['fr', 'fr', 'en']
True
create_battery_level_sensor
(accessory)
Define battery level characteristics.
Define battery level characteristics.
def create_battery_level_sensor(accessory): """Define battery level characteristics.""" service = accessory.add_service(ServicesTypes.BATTERY_SERVICE) cur_state = service.add_char(CharacteristicsTypes.BATTERY_LEVEL) cur_state.value = 100 low_battery = service.add_char(CharacteristicsTypes.STATUS_L...
[ "def", "create_battery_level_sensor", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "BATTERY_SERVICE", ")", "cur_state", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "BATTERY_LEVEL", ")"...
[ 56, 0 ]
[ 69, 18 ]
python
en
['en', 'bg', 'en']
True
test_temperature_sensor_read_state
(hass, utcnow)
Test reading the state of a HomeKit temperature sensor accessory.
Test reading the state of a HomeKit temperature sensor accessory.
async def test_temperature_sensor_read_state(hass, utcnow): """Test reading the state of a HomeKit temperature sensor accessory.""" helper = await setup_test_component( hass, create_temperature_sensor_service, suffix="temperature" ) helper.characteristics[TEMPERATURE].value = 10 state = awa...
[ "async", "def", "test_temperature_sensor_read_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_temperature_sensor_service", ",", "suffix", "=", "\"temperature\"", ")", "helper", ".", "characteristi...
[ 72, 0 ]
[ 86, 71 ]
python
en
['en', 'en', 'en']
True
test_temperature_sensor_not_added_twice
(hass, utcnow)
A standalone temperature sensor should not get a characteristic AND a service entity.
A standalone temperature sensor should not get a characteristic AND a service entity.
async def test_temperature_sensor_not_added_twice(hass, utcnow): """A standalone temperature sensor should not get a characteristic AND a service entity.""" helper = await setup_test_component( hass, create_temperature_sensor_service, suffix="temperature" ) for state in hass.states.async_all():...
[ "async", "def", "test_temperature_sensor_not_added_twice", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_temperature_sensor_service", ",", "suffix", "=", "\"temperature\"", ")", "for", "state", "in", ...
[ 89, 0 ]
[ 96, 50 ]
python
en
['en', 'en', 'en']
True
test_humidity_sensor_read_state
(hass, utcnow)
Test reading the state of a HomeKit humidity sensor accessory.
Test reading the state of a HomeKit humidity sensor accessory.
async def test_humidity_sensor_read_state(hass, utcnow): """Test reading the state of a HomeKit humidity sensor accessory.""" helper = await setup_test_component( hass, create_humidity_sensor_service, suffix="humidity" ) helper.characteristics[HUMIDITY].value = 10 state = await helper.poll_...
[ "async", "def", "test_humidity_sensor_read_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_humidity_sensor_service", ",", "suffix", "=", "\"humidity\"", ")", "helper", ".", "characteristics", "[...
[ 99, 0 ]
[ 113, 68 ]
python
en
['en', 'en', 'en']
True
test_light_level_sensor_read_state
(hass, utcnow)
Test reading the state of a HomeKit temperature sensor accessory.
Test reading the state of a HomeKit temperature sensor accessory.
async def test_light_level_sensor_read_state(hass, utcnow): """Test reading the state of a HomeKit temperature sensor accessory.""" helper = await setup_test_component( hass, create_light_level_sensor_service, suffix="light_level" ) helper.characteristics[LIGHT_LEVEL].value = 10 state = awa...
[ "async", "def", "test_light_level_sensor_read_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_light_level_sensor_service", ",", "suffix", "=", "\"light_level\"", ")", "helper", ".", "characteristi...
[ 116, 0 ]
[ 130, 71 ]
python
en
['en', 'en', 'en']
True
test_carbon_dioxide_level_sensor_read_state
(hass, utcnow)
Test reading the state of a HomeKit carbon dioxide sensor accessory.
Test reading the state of a HomeKit carbon dioxide sensor accessory.
async def test_carbon_dioxide_level_sensor_read_state(hass, utcnow): """Test reading the state of a HomeKit carbon dioxide sensor accessory.""" helper = await setup_test_component( hass, create_carbon_dioxide_level_sensor_service, suffix="co2" ) helper.characteristics[CARBON_DIOXIDE_LEVEL].valu...
[ "async", "def", "test_carbon_dioxide_level_sensor_read_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_carbon_dioxide_level_sensor_service", ",", "suffix", "=", "\"co2\"", ")", "helper", ".", "cha...
[ 133, 0 ]
[ 145, 30 ]
python
en
['en', 'en', 'en']
True
test_battery_level_sensor
(hass, utcnow)
Test reading the state of a HomeKit battery level sensor.
Test reading the state of a HomeKit battery level sensor.
async def test_battery_level_sensor(hass, utcnow): """Test reading the state of a HomeKit battery level sensor.""" helper = await setup_test_component( hass, create_battery_level_sensor, suffix="battery" ) helper.characteristics[BATTERY_LEVEL].value = 100 state = await helper.poll_and_get_s...
[ "async", "def", "test_battery_level_sensor", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_battery_level_sensor", ",", "suffix", "=", "\"battery\"", ")", "helper", ".", "characteristics", "[", "BATT...
[ 148, 0 ]
[ 164, 67 ]
python
en
['en', 'en', 'en']
True
test_battery_charging
(hass, utcnow)
Test reading the state of a HomeKit battery's charging state.
Test reading the state of a HomeKit battery's charging state.
async def test_battery_charging(hass, utcnow): """Test reading the state of a HomeKit battery's charging state.""" helper = await setup_test_component( hass, create_battery_level_sensor, suffix="battery" ) helper.characteristics[BATTERY_LEVEL].value = 0 helper.characteristics[CHARGING_STATE...
[ "async", "def", "test_battery_charging", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_battery_level_sensor", ",", "suffix", "=", "\"battery\"", ")", "helper", ".", "characteristics", "[", "BATTERY_...
[ 167, 0 ]
[ 180, 64 ]
python
en
['en', 'en', 'en']
True
test_battery_low
(hass, utcnow)
Test reading the state of a HomeKit battery's low state.
Test reading the state of a HomeKit battery's low state.
async def test_battery_low(hass, utcnow): """Test reading the state of a HomeKit battery's low state.""" helper = await setup_test_component( hass, create_battery_level_sensor, suffix="battery" ) helper.characteristics[LO_BATT].value = 0 helper.characteristics[BATTERY_LEVEL].value = 1 s...
[ "async", "def", "test_battery_low", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_battery_level_sensor", ",", "suffix", "=", "\"battery\"", ")", "helper", ".", "characteristics", "[", "LO_BATT", "...
[ 183, 0 ]
[ 196, 58 ]
python
en
['en', 'en', 'en']
True
create_switch_with_sensor
(accessory)
Define battery level characteristics.
Define battery level characteristics.
def create_switch_with_sensor(accessory): """Define battery level characteristics.""" service = accessory.add_service(ServicesTypes.OUTLET) realtime_energy = service.add_char( CharacteristicsTypes.Vendor.KOOGEEK_REALTIME_ENERGY ) realtime_energy.value = 0 realtime_energy.format = "float...
[ "def", "create_switch_with_sensor", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "OUTLET", ")", "realtime_energy", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "Vendor", ".", "KOOGEEK...
[ 199, 0 ]
[ 212, 18 ]
python
en
['en', 'bg', 'en']
True
test_switch_with_sensor
(hass, utcnow)
Test a switch service that has a sensor characteristic is correctly handled.
Test a switch service that has a sensor characteristic is correctly handled.
async def test_switch_with_sensor(hass, utcnow): """Test a switch service that has a sensor characteristic is correctly handled.""" helper = await setup_test_component(hass, create_switch_with_sensor) outlet = helper.accessory.services.first(service_type=ServicesTypes.OUTLET) # Helper will be for the p...
[ "async", "def", "test_switch_with_sensor", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_switch_with_sensor", ")", "outlet", "=", "helper", ".", "accessory", ".", "services", ".", "first", "(", ...
[ 215, 0 ]
[ 238, 30 ]
python
en
['en', 'en', 'en']
True
test_sensor_unavailable
(hass, utcnow)
Test a sensor becoming unavailable.
Test a sensor becoming unavailable.
async def test_sensor_unavailable(hass, utcnow): """Test a sensor becoming unavailable.""" helper = await setup_test_component(hass, create_switch_with_sensor) # Find the energy sensor and mark it as offline outlet = helper.accessory.services.first(service_type=ServicesTypes.OUTLET) realtime_energy...
[ "async", "def", "test_sensor_unavailable", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_switch_with_sensor", ")", "# Find the energy sensor and mark it as offline", "outlet", "=", "helper", ".", "accesso...
[ 241, 0 ]
[ 265, 39 ]
python
en
['es', 'en', 'it']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the cloud binary sensors.
Set up the cloud binary sensors.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the cloud binary sensors.""" if discovery_info is None: return cloud = hass.data[DOMAIN] async_add_entities([CloudRemoteBinary(cloud)])
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "cloud", "=", "hass", ".", "data", "[", "DOMAIN", "]", "async_ad...
[ 14, 0 ]
[ 20, 50 ]
python
en
['en', 'bg', 'en']
True
CloudRemoteBinary.__init__
(self, cloud)
Initialize the binary sensor.
Initialize the binary sensor.
def __init__(self, cloud): """Initialize the binary sensor.""" self.cloud = cloud self._unsub_dispatcher = None
[ "def", "__init__", "(", "self", ",", "cloud", ")", ":", "self", ".", "cloud", "=", "cloud", "self", ".", "_unsub_dispatcher", "=", "None" ]
[ 31, 4 ]
[ 34, 37 ]
python
en
['en', 'haw', 'en']
True
CloudRemoteBinary.is_on
(self)
Return true if the binary sensor is on.
Return true if the binary sensor is on.
def is_on(self) -> bool: """Return true if the binary sensor is on.""" return self.cloud.remote.is_connected
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "cloud", ".", "remote", ".", "is_connected" ]
[ 37, 4 ]
[ 39, 45 ]
python
en
['en', 'fy', 'en']
True
CloudRemoteBinary.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return self.cloud.remote.certificate is not None
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "cloud", ".", "remote", ".", "certificate", "is", "not", "None" ]
[ 42, 4 ]
[ 44, 56 ]
python
en
['en', 'en', 'en']
True
CloudRemoteBinary.async_added_to_hass
(self)
Register update dispatcher.
Register update dispatcher.
async def async_added_to_hass(self): """Register update dispatcher.""" async def async_state_update(data): """Update callback.""" await asyncio.sleep(WAIT_UNTIL_CHANGE) self.async_write_ha_state() self._unsub_dispatcher = async_dispatcher_connect( ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "async", "def", "async_state_update", "(", "data", ")", ":", "\"\"\"Update callback.\"\"\"", "await", "asyncio", ".", "sleep", "(", "WAIT_UNTIL_CHANGE", ")", "self", ".", "async_write_ha_state", "(", ")...
[ 46, 4 ]
[ 56, 9 ]
python
de
['it', 'de', 'en']
False
CloudRemoteBinary.async_will_remove_from_hass
(self)
Register update dispatcher.
Register update dispatcher.
async def async_will_remove_from_hass(self): """Register update dispatcher.""" if self._unsub_dispatcher is not None: self._unsub_dispatcher() self._unsub_dispatcher = None
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", ":", "if", "self", ".", "_unsub_dispatcher", "is", "not", "None", ":", "self", ".", "_unsub_dispatcher", "(", ")", "self", ".", "_unsub_dispatcher", "=", "None" ]
[ 58, 4 ]
[ 62, 41 ]
python
de
['it', 'de', 'en']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the template sensors.
Set up the template sensors.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the template sensors.""" await async_setup_reload_service(hass, DOMAIN, PLATFORMS) name = config.get(CONF_NAME) entity_id = config.get(CONF_ENTITY_ID) filters = [ FILTERS[_filter.pop(CONF_FILT...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "await", "async_setup_reload_service", "(", "hass", ",", "DOMAIN", ",", "PLATFORMS", ")", "name", "=", "config", ".", "...
[ 165, 0 ]
[ 178, 64 ]
python
en
['en', 'en', 'en']
True
SensorFilter.__init__
(self, name, entity_id, filters)
Initialize the sensor.
Initialize the sensor.
def __init__(self, name, entity_id, filters): """Initialize the sensor.""" self._name = name self._entity = entity_id self._unit_of_measurement = None self._state = None self._filters = filters self._icon = None self._device_class = None
[ "def", "__init__", "(", "self", ",", "name", ",", "entity_id", ",", "filters", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_entity", "=", "entity_id", "self", ".", "_unit_of_measurement", "=", "None", "self", ".", "_state", "=", "None", ...
[ 184, 4 ]
[ 192, 33 ]
python
en
['en', 'en', 'en']
True
SensorFilter._update_filter_sensor_state_event
(self, event)
Handle device state changes.
Handle device state changes.
def _update_filter_sensor_state_event(self, event): """Handle device state changes.""" _LOGGER.debug("Update filter on event: %s", event) self._update_filter_sensor_state(event.data.get("new_state"))
[ "def", "_update_filter_sensor_state_event", "(", "self", ",", "event", ")", ":", "_LOGGER", ".", "debug", "(", "\"Update filter on event: %s\"", ",", "event", ")", "self", ".", "_update_filter_sensor_state", "(", "event", ".", "data", ".", "get", "(", "\"new_state...
[ 195, 4 ]
[ 198, 69 ]
python
en
['ro', 'en', 'en']
True
SensorFilter._update_filter_sensor_state
(self, new_state, update_ha=True)
Process device state changes.
Process device state changes.
def _update_filter_sensor_state(self, new_state, update_ha=True): """Process device state changes.""" if new_state is None: _LOGGER.warning( "While updating filter %s, the new_state is None", self._name ) self._state = None self.async_write...
[ "def", "_update_filter_sensor_state", "(", "self", ",", "new_state", ",", "update_ha", "=", "True", ")", ":", "if", "new_state", "is", "None", ":", "_LOGGER", ".", "warning", "(", "\"While updating filter %s, the new_state is None\"", ",", "self", ".", "_name", ")...
[ 201, 4 ]
[ 256, 39 ]
python
en
['es', 'en', 'en']
True
SensorFilter.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self): """Register callbacks.""" if "recorder" in self.hass.config.components: history_list = [] largest_window_items = 0 largest_window_time = timedelta(0) # Determine the largest window_size by type for filt in...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "if", "\"recorder\"", "in", "self", ".", "hass", ".", "config", ".", "components", ":", "history_list", "=", "[", "]", "largest_window_items", "=", "0", "largest_window_time", "=", "timedelta", "(",...
[ 258, 4 ]
[ 326, 9 ]
python
en
['en', 'no', 'en']
False
SensorFilter.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" ]
[ 329, 4 ]
[ 331, 25 ]
python
en
['en', 'mi', 'en']
True
SensorFilter.native_value
(self)
Return the state of the sensor.
Return the state of the sensor.
def native_value(self): """Return the state of the sensor.""" return self._state
[ "def", "native_value", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 334, 4 ]
[ 336, 26 ]
python
en
['en', 'en', 'en']
True
SensorFilter.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 self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 339, 4 ]
[ 341, 25 ]
python
en
['en', 'en', 'en']
True
SensorFilter.native_unit_of_measurement
(self)
Return the unit_of_measurement of the device.
Return the unit_of_measurement of the device.
def native_unit_of_measurement(self): """Return the unit_of_measurement of the device.""" return self._unit_of_measurement
[ "def", "native_unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 344, 4 ]
[ 346, 40 ]
python
en
['en', 'en', 'en']
True
SensorFilter.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 349, 4 ]
[ 351, 20 ]
python
en
['en', 'en', 'en']
True
SensorFilter.extra_state_attributes
(self)
Return the state attributes of the sensor.
Return the state attributes of the sensor.
def extra_state_attributes(self): """Return the state attributes of the sensor.""" return {ATTR_ENTITY_ID: self._entity}
[ "def", "extra_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ENTITY_ID", ":", "self", ".", "_entity", "}" ]
[ 354, 4 ]
[ 356, 45 ]
python
en
['en', 'en', 'en']
True
SensorFilter.device_class
(self)
Return device class.
Return device class.
def device_class(self): """Return device class.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 359, 4 ]
[ 361, 33 ]
python
en
['es', 'zh', 'en']
False
FilterState.__init__
(self, state)
Initialize with HA State object.
Initialize with HA State object.
def __init__(self, state): """Initialize with HA State object.""" self.timestamp = state.last_updated try: self.state = float(state.state) except ValueError: self.state = state.state
[ "def", "__init__", "(", "self", ",", "state", ")", ":", "self", ".", "timestamp", "=", "state", ".", "last_updated", "try", ":", "self", ".", "state", "=", "float", "(", "state", ".", "state", ")", "except", "ValueError", ":", "self", ".", "state", "...
[ 367, 4 ]
[ 373, 36 ]
python
en
['en', 'en', 'en']
True
FilterState.set_precision
(self, precision)
Set precision of Number based states.
Set precision of Number based states.
def set_precision(self, precision): """Set precision of Number based states.""" if isinstance(self.state, Number): value = round(float(self.state), precision) self.state = int(value) if precision == 0 else value
[ "def", "set_precision", "(", "self", ",", "precision", ")", ":", "if", "isinstance", "(", "self", ".", "state", ",", "Number", ")", ":", "value", "=", "round", "(", "float", "(", "self", ".", "state", ")", ",", "precision", ")", "self", ".", "state",...
[ 375, 4 ]
[ 379, 64 ]
python
en
['en', 'en', 'en']
True
FilterState.__str__
(self)
Return state as the string representation of FilterState.
Return state as the string representation of FilterState.
def __str__(self): """Return state as the string representation of FilterState.""" return str(self.state)
[ "def", "__str__", "(", "self", ")", ":", "return", "str", "(", "self", ".", "state", ")" ]
[ 381, 4 ]
[ 383, 30 ]
python
en
['en', 'en', 'en']
True
FilterState.__repr__
(self)
Return timestamp and state as the representation of FilterState.
Return timestamp and state as the representation of FilterState.
def __repr__(self): """Return timestamp and state as the representation of FilterState.""" return f"{self.timestamp} : {self.state}"
[ "def", "__repr__", "(", "self", ")", ":", "return", "f\"{self.timestamp} : {self.state}\"" ]
[ 385, 4 ]
[ 387, 49 ]
python
en
['en', 'en', 'en']
True
Filter.__init__
( self, name, window_size: int = 1, precision: int | None = None, entity: str | None = None, )
Initialize common attributes. :param window_size: size of the sliding window that holds previous values :param precision: round filtered value to precision value :param entity: used for debugging only
Initialize common attributes.
def __init__( self, name, window_size: int = 1, precision: int | None = None, entity: str | None = None, ): """Initialize common attributes. :param window_size: size of the sliding window that holds previous values :param precision: round filtered val...
[ "def", "__init__", "(", "self", ",", "name", ",", "window_size", ":", "int", "=", "1", ",", "precision", ":", "int", "|", "None", "=", "None", ",", "entity", ":", "str", "|", "None", "=", "None", ",", ")", ":", "if", "isinstance", "(", "window_size...
[ 393, 4 ]
[ 418, 33 ]
python
en
['en', 'en', 'en']
True
Filter.window_size
(self)
Return window size.
Return window size.
def window_size(self): """Return window size.""" return self._window_size
[ "def", "window_size", "(", "self", ")", ":", "return", "self", ".", "_window_size" ]
[ 421, 4 ]
[ 423, 32 ]
python
en
['en', 'pl', 'en']
True
Filter.name
(self)
Return filter name.
Return filter name.
def name(self): """Return filter name.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 426, 4 ]
[ 428, 25 ]
python
en
['en', 'no', 'en']
True
Filter.skip_processing
(self)
Return whether the current filter_state should be skipped.
Return whether the current filter_state should be skipped.
def skip_processing(self): """Return whether the current filter_state should be skipped.""" return self._skip_processing
[ "def", "skip_processing", "(", "self", ")", ":", "return", "self", ".", "_skip_processing" ]
[ 431, 4 ]
[ 433, 36 ]
python
en
['en', 'en', 'en']
True
Filter._filter_state
(self, new_state)
Implement filter.
Implement filter.
def _filter_state(self, new_state): """Implement filter.""" raise NotImplementedError()
[ "def", "_filter_state", "(", "self", ",", "new_state", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 435, 4 ]
[ 437, 35 ]
python
en
['en', 'en', 'en']
False
Filter.filter_state
(self, new_state)
Implement a common interface for filters.
Implement a common interface for filters.
def filter_state(self, new_state): """Implement a common interface for filters.""" fstate = FilterState(new_state) if self._only_numbers and not isinstance(fstate.state, Number): raise ValueError(f"State <{fstate.state}> is not a Number") filtered = self._filter_state(fstate...
[ "def", "filter_state", "(", "self", ",", "new_state", ")", ":", "fstate", "=", "FilterState", "(", "new_state", ")", "if", "self", ".", "_only_numbers", "and", "not", "isinstance", "(", "fstate", ".", "state", ",", "Number", ")", ":", "raise", "ValueError"...
[ 439, 4 ]
[ 452, 24 ]
python
en
['en', 'en', 'en']
True
test_pumps
(spa, setup_entry, hass, pump_id, pump_state, entity_suffix)
Test pump entities.
Test pump entities.
async def test_pumps(spa, setup_entry, hass, pump_id, pump_state, entity_suffix): """Test pump entities.""" status = await spa.get_status_full() pump = next(pump for pump in status.pumps if pump.id == pump_id) entity_id = f"switch.{spa.brand}_{spa.model}_{entity_suffix}" state = hass.states.get(en...
[ "async", "def", "test_pumps", "(", "spa", ",", "setup_entry", ",", "hass", ",", "pump_id", ",", "pump_state", ",", "entity_suffix", ")", ":", "status", "=", "await", "spa", ".", "get_status_full", "(", ")", "pump", "=", "next", "(", "pump", "for", "pump"...
[ 15, 0 ]
[ 51, 35 ]
python
af
['nl', 'af', 'en']
False
get_scanner
(hass, config)
Validate the configuration and return Synology SRM scanner.
Validate the configuration and return Synology SRM scanner.
def get_scanner(hass, config): """Validate the configuration and return Synology SRM scanner.""" scanner = SynologySrmDeviceScanner(config[DOMAIN]) return scanner if scanner.success_init else None
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "scanner", "=", "SynologySrmDeviceScanner", "(", "config", "[", "DOMAIN", "]", ")", "return", "scanner", "if", "scanner", ".", "success_init", "else", "None" ]
[ 70, 0 ]
[ 74, 52 ]
python
en
['en', 'en', 'en']
True
SynologySrmDeviceScanner.__init__
(self, config)
Initialize the scanner.
Initialize the scanner.
def __init__(self, config): """Initialize the scanner.""" self.client = synology_srm.Client( host=config[CONF_HOST], port=config[CONF_PORT], username=config[CONF_USERNAME], password=config[CONF_PASSWORD], https=config[CONF_SSL], ) ...
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "self", ".", "client", "=", "synology_srm", ".", "Client", "(", "host", "=", "config", "[", "CONF_HOST", "]", ",", "port", "=", "config", "[", "CONF_PORT", "]", ",", "username", "=", "config", ...
[ 80, 4 ]
[ 97, 56 ]
python
en
['en', 'en', 'en']
True
SynologySrmDeviceScanner.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 [device["mac"] for device in self.devices]
[ "def", "scan_devices", "(", "self", ")", ":", "self", ".", "_update_info", "(", ")", "return", "[", "device", "[", "\"mac\"", "]", "for", "device", "in", "self", ".", "devices", "]" ]
[ 99, 4 ]
[ 103, 57 ]
python
en
['en', 'en', 'en']
True
SynologySrmDeviceScanner.get_extra_attributes
(self, device)
Get the extra attributes of a device.
Get the extra attributes of a device.
def get_extra_attributes(self, device) -> dict: """Get the extra attributes of a device.""" device = next( (result for result in self.devices if result["mac"] == device), None ) filtered_attributes: dict[str, str] = {} if not device: return filtered_attrib...
[ "def", "get_extra_attributes", "(", "self", ",", "device", ")", "->", "dict", ":", "device", "=", "next", "(", "(", "result", "for", "result", "in", "self", ".", "devices", "if", "result", "[", "\"mac\"", "]", "==", "device", ")", ",", "None", ")", "...
[ 105, 4 ]
[ 119, 34 ]
python
en
['en', 'en', 'en']
True
SynologySrmDeviceScanner.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.""" filter_named = [ result["hostname"] for result in self.devices if result["mac"] == device ] if filter_named: return filter_named[0] return None
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "filter_named", "=", "[", "result", "[", "\"hostname\"", "]", "for", "result", "in", "self", ".", "devices", "if", "result", "[", "\"mac\"", "]", "==", "device", "]", "if", "filter_named", "...
[ 121, 4 ]
[ 130, 19 ]
python
en
['en', 'en', 'en']
True
SynologySrmDeviceScanner._update_info
(self)
Check the router for connected devices.
Check the router for connected devices.
def _update_info(self): """Check the router for connected devices.""" _LOGGER.debug("Scanning for connected devices") try: self.devices = self.client.core.get_network_nsm_device({"is_online": True}) except synology_srm.http.SynologyException as ex: _LOGGER.error(...
[ "def", "_update_info", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Scanning for connected devices\"", ")", "try", ":", "self", ".", "devices", "=", "self", ".", "client", ".", "core", ".", "get_network_nsm_device", "(", "{", "\"is_online\"", ":", ...
[ 132, 4 ]
[ 144, 19 ]
python
en
['en', 'en', 'en']
True
get_next_departure
( schedule: Any, start_station_id: Any, end_station_id: Any, offset: cv.time_period, include_tomorrow: bool = False, )
Get the next departure for the given schedule.
Get the next departure for the given schedule.
def get_next_departure( schedule: Any, start_station_id: Any, end_station_id: Any, offset: cv.time_period, include_tomorrow: bool = False, ) -> dict: """Get the next departure for the given schedule.""" now = dt_util.now().replace(tzinfo=None) + offset now_date = now.strftime(dt_util.DAT...
[ "def", "get_next_departure", "(", "schedule", ":", "Any", ",", "start_station_id", ":", "Any", ",", "end_station_id", ":", "Any", ",", "offset", ":", "cv", ".", "time_period", ",", "include_tomorrow", ":", "bool", "=", "False", ",", ")", "->", "dict", ":",...
[ 271, 0 ]
[ 480, 5 ]
python
en
['en', 'en', 'en']
True
setup_platform
( hass: HomeAssistant, config: ConfigType, add_entities: Callable[[list], None], discovery_info: DiscoveryInfoType | None = None, )
Set up the GTFS sensor.
Set up the GTFS sensor.
def setup_platform( hass: HomeAssistant, config: ConfigType, add_entities: Callable[[list], None], discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the GTFS sensor.""" gtfs_dir = hass.config.path(DEFAULT_PATH) data = config[CONF_DATA] origin = config.get(CONF_ORIGIN)...
[ "def", "setup_platform", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ",", "add_entities", ":", "Callable", "[", "[", "list", "]", ",", "None", "]", ",", "discovery_info", ":", "DiscoveryInfoType", "|", "None", "=", "None", ",", ")"...
[ 483, 0 ]
[ 517, 5 ]
python
en
['en', 'bg', 'en']
True
GTFSDepartureSensor.__init__
( self, gtfs: Any, name: Any | None, origin: Any, destination: Any, offset: datetime.timedelta, include_tomorrow: bool, )
Initialize the sensor.
Initialize the sensor.
def __init__( self, gtfs: Any, name: Any | None, origin: Any, destination: Any, offset: datetime.timedelta, include_tomorrow: bool, ) -> None: """Initialize the sensor.""" self._pygtfs = gtfs self.origin = origin self.destinatio...
[ "def", "__init__", "(", "self", ",", "gtfs", ":", "Any", ",", "name", ":", "Any", "|", "None", ",", "origin", ":", "Any", ",", "destination", ":", "Any", ",", "offset", ":", "datetime", ".", "timedelta", ",", "include_tomorrow", ":", "bool", ",", ")"...
[ 525, 4 ]
[ 556, 21 ]
python
en
['en', 'en', 'en']
True
GTFSDepartureSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self) -> str: """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_name" ]
[ 559, 4 ]
[ 561, 25 ]
python
en
['en', 'mi', 'en']
True
GTFSDepartureSensor.native_value
(self)
Return the state of the sensor.
Return the state of the sensor.
def native_value(self) -> str | None: """Return the state of the sensor.""" return self._state
[ "def", "native_value", "(", "self", ")", "->", "str", "|", "None", ":", "return", "self", ".", "_state" ]
[ 564, 4 ]
[ 566, 26 ]
python
en
['en', 'en', 'en']
True
GTFSDepartureSensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_available" ]
[ 569, 4 ]
[ 571, 30 ]
python
en
['en', 'en', 'en']
True
GTFSDepartureSensor.extra_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def extra_state_attributes(self) -> dict: """Return the state attributes.""" return self._attributes
[ "def", "extra_state_attributes", "(", "self", ")", "->", "dict", ":", "return", "self", ".", "_attributes" ]
[ 574, 4 ]
[ 576, 31 ]
python
en
['en', 'en', 'en']
True
GTFSDepartureSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self) -> str: """Icon to use in the frontend, if any.""" return self._icon
[ "def", "icon", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_icon" ]
[ 579, 4 ]
[ 581, 25 ]
python
en
['en', 'en', 'en']
True
GTFSDepartureSensor.update
(self)
Get the latest data from GTFS and update the states.
Get the latest data from GTFS and update the states.
def update(self) -> None: """Get the latest data from GTFS and update the states.""" with self.lock: # Fetch valid stop information once if not self._origin: stops = self._pygtfs.stops_by_id(self.origin) if not stops: self._avai...
[ "def", "update", "(", "self", ")", "->", "None", ":", "with", "self", ".", "lock", ":", "# Fetch valid stop information once", "if", "not", "self", ".", "_origin", ":", "stops", "=", "self", ".", "_pygtfs", ".", "stops_by_id", "(", "self", ".", "origin", ...
[ 583, 4 ]
[ 666, 50 ]
python
en
['en', 'en', 'en']
True
GTFSDepartureSensor.update_attributes
(self)
Update state attributes.
Update state attributes.
def update_attributes(self) -> None: """Update state attributes.""" # Add departure information if self._departure: self._attributes[ATTR_ARRIVAL] = dt_util.as_utc( self._departure["arrival_time"] ).isoformat() self._attributes[ATTR_DAY] = sel...
[ "def", "update_attributes", "(", "self", ")", "->", "None", ":", "# Add departure information", "if", "self", ".", "_departure", ":", "self", ".", "_attributes", "[", "ATTR_ARRIVAL", "]", "=", "dt_util", ".", "as_utc", "(", "self", ".", "_departure", "[", "\...
[ 668, 4 ]
[ 802, 36 ]
python
en
['en', 'co', 'en']
True
GTFSDepartureSensor.dict_for_table
(resource: Any)
Return a dictionary for the SQLAlchemy resource given.
Return a dictionary for the SQLAlchemy resource given.
def dict_for_table(resource: Any) -> dict: """Return a dictionary for the SQLAlchemy resource given.""" return { col: getattr(resource, col) for col in resource.__table__.columns.keys() }
[ "def", "dict_for_table", "(", "resource", ":", "Any", ")", "->", "dict", ":", "return", "{", "col", ":", "getattr", "(", "resource", ",", "col", ")", "for", "col", "in", "resource", ".", "__table__", ".", "columns", ".", "keys", "(", ")", "}" ]
[ 805, 4 ]
[ 809, 9 ]
python
en
['en', 'en', 'en']
True
GTFSDepartureSensor.append_keys
(self, resource: dict, prefix: str | None = None)
Properly format key val pairs to append to attributes.
Properly format key val pairs to append to attributes.
def append_keys(self, resource: dict, prefix: str | None = None) -> None: """Properly format key val pairs to append to attributes.""" for attr, val in resource.items(): if val == "" or val is None or attr == "feed_id": continue key = attr if prefix an...
[ "def", "append_keys", "(", "self", ",", "resource", ":", "dict", ",", "prefix", ":", "str", "|", "None", "=", "None", ")", "->", "None", ":", "for", "attr", ",", "val", "in", "resource", ".", "items", "(", ")", ":", "if", "val", "==", "\"\"", "or...
[ 811, 4 ]
[ 820, 39 ]
python
en
['en', 'en', 'en']
True
GTFSDepartureSensor.remove_keys
(self, prefix: str)
Remove attributes whose key starts with prefix.
Remove attributes whose key starts with prefix.
def remove_keys(self, prefix: str) -> None: """Remove attributes whose key starts with prefix.""" self._attributes = { k: v for k, v in self._attributes.items() if not k.startswith(prefix) }
[ "def", "remove_keys", "(", "self", ",", "prefix", ":", "str", ")", "->", "None", ":", "self", ".", "_attributes", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "self", ".", "_attributes", ".", "items", "(", ")", "if", "not", "k", ".", "s...
[ 822, 4 ]
[ 826, 9 ]
python
en
['en', 'it', 'en']
True
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback )
Set up RainMachine sensors based on a config entry.
Set up RainMachine sensors based on a config entry.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: """Set up RainMachine sensors based on a config entry.""" controller = hass.data[DOMAIN][DATA_CONTROLLER][entry.entry_id] coordinators = hass.data[DOMAIN][DATA_COORDINATOR][entry.entr...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "AddEntitiesCallback", ")", "->", "None", ":", "controller", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_CONT...
[ 84, 0 ]
[ 110, 5 ]
python
en
['en', 'en', 'en']
True
ProvisionSettingsSensor.update_from_latest_data
(self)
Update the state.
Update the state.
def update_from_latest_data(self) -> None: """Update the state.""" if self.entity_description.key == TYPE_FLOW_SENSOR_CLICK_M3: self._attr_native_value = self.coordinator.data["system"].get( "flowSensorClicksPerCubicMeter" ) elif self.entity_description.ke...
[ "def", "update_from_latest_data", "(", "self", ")", "->", "None", ":", "if", "self", ".", "entity_description", ".", "key", "==", "TYPE_FLOW_SENSOR_CLICK_M3", ":", "self", ".", "_attr_native_value", "=", "self", ".", "coordinator", ".", "data", "[", "\"system\""...
[ 117, 4 ]
[ 140, 13 ]
python
en
['en', 'en', 'en']
True
UniversalRestrictionsSensor.update_from_latest_data
(self)
Update the state.
Update the state.
def update_from_latest_data(self) -> None: """Update the state.""" if self.entity_description.key == TYPE_FREEZE_TEMP: self._attr_native_value = self.coordinator.data["freezeProtectTemp"]
[ "def", "update_from_latest_data", "(", "self", ")", "->", "None", ":", "if", "self", ".", "entity_description", ".", "key", "==", "TYPE_FREEZE_TEMP", ":", "self", ".", "_attr_native_value", "=", "self", ".", "coordinator", ".", "data", "[", "\"freezeProtectTemp\...
[ 147, 4 ]
[ 150, 80 ]
python
en
['en', 'en', 'en']
True
DemoConfigFlow.async_get_options_flow
(config_entry)
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return OptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "OptionsFlowHandler", "(", "config_entry", ")" ]
[ 23, 4 ]
[ 25, 47 ]
python
en
['en', 'en', 'en']
True
DemoConfigFlow.async_step_import
(self, import_info)
Set the config entry up from yaml.
Set the config entry up from yaml.
async def async_step_import(self, import_info): """Set the config entry up from yaml.""" return self.async_create_entry(title="Demo", data={})
[ "async", "def", "async_step_import", "(", "self", ",", "import_info", ")", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"Demo\"", ",", "data", "=", "{", "}", ")" ]
[ 27, 4 ]
[ 29, 61 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.__init__
(self, config_entry)
Initialize options flow.
Initialize options flow.
def __init__(self, config_entry): """Initialize options flow.""" self.config_entry = config_entry self.options = dict(config_entry.options)
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry", "self", ".", "options", "=", "dict", "(", "config_entry", ".", "options", ")" ]
[ 35, 4 ]
[ 38, 49 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.async_step_init
(self, user_input=None)
Manage the options.
Manage the options.
async def async_step_init(self, user_input=None): """Manage the options.""" return await self.async_step_options_1()
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "return", "await", "self", ".", "async_step_options_1", "(", ")" ]
[ 40, 4 ]
[ 42, 48 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.async_step_options_1
(self, user_input=None)
Manage the options.
Manage the options.
async def async_step_options_1(self, user_input=None): """Manage the options.""" if user_input is not None: self.options.update(user_input) return await self.async_step_options_2() return self.async_show_form( step_id="options_1", data_schema=vol....
[ "async", "def", "async_step_options_1", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "self", ".", "options", ".", "update", "(", "user_input", ")", "return", "await", "self", ".", "async_step_options_2"...
[ 44, 4 ]
[ 65, 9 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.async_step_options_2
(self, user_input=None)
Manage the options 2.
Manage the options 2.
async def async_step_options_2(self, user_input=None): """Manage the options 2.""" if user_input is not None: self.options.update(user_input) return await self._update_options() return self.async_show_form( step_id="options_2", data_schema=vol.Sch...
[ "async", "def", "async_step_options_2", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "self", ".", "options", ".", "update", "(", "user_input", ")", "return", "await", "self", ".", "_update_options", "...
[ 67, 4 ]
[ 96, 9 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler._update_options
(self)
Update config entry options.
Update config entry options.
async def _update_options(self): """Update config entry options.""" return self.async_create_entry(title="", data=self.options)
[ "async", "def", "_update_options", "(", "self", ")", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "self", ".", "options", ")" ]
[ 98, 4 ]
[ 100, 67 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_step_user
( self, user_input: dict[str, Any] | None = None )
Handle the initial step.
Handle the initial step.
async def async_step_user( self, user_input: dict[str, Any] | None = None ) -> FlowResult: """Handle the initial step.""" if user_input is None: return self.async_show_form(step_id="user", data_schema=DATA_SCHEMA) errors = {} session = async_get_clientsession(se...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", ":", "dict", "[", "str", ",", "Any", "]", "|", "None", "=", "None", ")", "->", "FlowResult", ":", "if", "user_input", "is", "None", ":", "return", "self", ".", "async_show_form", "(", "...
[ 32, 4 ]
[ 64, 9 ]
python
en
['en', 'en', 'en']
True
test_new_users_available
(hass, entry, setup_plex_server)
Test setting up when new users available on Plex server.
Test setting up when new users available on Plex server.
async def test_new_users_available(hass, entry, setup_plex_server): """Test setting up when new users available on Plex server.""" MONITORED_USERS = {"User 1": {"enabled": True}} OPTIONS_WITH_USERS = copy.deepcopy(DEFAULT_OPTIONS) OPTIONS_WITH_USERS[MP_DOMAIN][CONF_MONITORED_USERS] = MONITORED_USERS ...
[ "async", "def", "test_new_users_available", "(", "hass", ",", "entry", ",", "setup_plex_server", ")", ":", "MONITORED_USERS", "=", "{", "\"User 1\"", ":", "{", "\"enabled\"", ":", "True", "}", "}", "OPTIONS_WITH_USERS", "=", "copy", ".", "deepcopy", "(", "DEFA...
[ 32, 0 ]
[ 47, 34 ]
python
en
['en', 'en', 'en']
True
test_new_ignored_users_available
( hass, caplog, entry, mock_websocket, setup_plex_server, requests_mock, session_new_user, )
Test setting up when new users available on Plex server but are ignored.
Test setting up when new users available on Plex server but are ignored.
async def test_new_ignored_users_available( hass, caplog, entry, mock_websocket, setup_plex_server, requests_mock, session_new_user, ): """Test setting up when new users available on Plex server but are ignored.""" MONITORED_USERS = {"User 1": {"enabled": True}} OPTIONS_WITH_USER...
[ "async", "def", "test_new_ignored_users_available", "(", "hass", ",", "caplog", ",", "entry", ",", "mock_websocket", ",", "setup_plex_server", ",", "requests_mock", ",", "session_new_user", ",", ")", ":", "MONITORED_USERS", "=", "{", "\"User 1\"", ":", "{", "\"ena...
[ 50, 0 ]
[ 97, 52 ]
python
en
['en', 'en', 'en']
True
test_network_error_during_refresh
(hass, caplog, mock_plex_server)
Test network failures during refreshes.
Test network failures during refreshes.
async def test_network_error_during_refresh(hass, caplog, mock_plex_server): """Test network failures during refreshes.""" server_id = mock_plex_server.machine_identifier loaded_server = hass.data[DOMAIN][SERVERS][server_id] active_sessions = mock_plex_server._plex_server.sessions() await wait_for_...
[ "async", "def", "test_network_error_during_refresh", "(", "hass", ",", "caplog", ",", "mock_plex_server", ")", ":", "server_id", "=", "mock_plex_server", ".", "machine_identifier", "loaded_server", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "SERVERS", "]",...
[ 100, 0 ]
[ 117, 5 ]
python
en
['fr', 'en', 'en']
True
test_gdm_client_failure
(hass, mock_websocket, setup_plex_server)
Test connection failure to a GDM discovered client.
Test connection failure to a GDM discovered client.
async def test_gdm_client_failure(hass, mock_websocket, setup_plex_server): """Test connection failure to a GDM discovered client.""" with patch( "homeassistant.components.plex.server.PlexClient", side_effect=ConnectionError ): mock_plex_server = await setup_plex_server(disable_gdm=False) ...
[ "async", "def", "test_gdm_client_failure", "(", "hass", ",", "mock_websocket", ",", "setup_plex_server", ")", ":", "with", "patch", "(", "\"homeassistant.components.plex.server.PlexClient\"", ",", "side_effect", "=", "ConnectionError", ")", ":", "mock_plex_server", "=", ...
[ 120, 0 ]
[ 136, 42 ]
python
en
['en', 'en', 'en']
True
test_mark_sessions_idle
( hass, mock_plex_server, mock_websocket, requests_mock, empty_payload )
Test marking media_players as idle when sessions end.
Test marking media_players as idle when sessions end.
async def test_mark_sessions_idle( hass, mock_plex_server, mock_websocket, requests_mock, empty_payload ): """Test marking media_players as idle when sessions end.""" await wait_for_debouncer(hass) active_sessions = mock_plex_server._plex_server.sessions() sensor = hass.states.get("sensor.plex_ple...
[ "async", "def", "test_mark_sessions_idle", "(", "hass", ",", "mock_plex_server", ",", "mock_websocket", ",", "requests_mock", ",", "empty_payload", ")", ":", "await", "wait_for_debouncer", "(", "hass", ")", "active_sessions", "=", "mock_plex_server", ".", "_plex_serve...
[ 139, 0 ]
[ 159, 30 ]
python
en
['en', 'en', 'en']
True
test_ignore_plex_web_client
(hass, entry, setup_plex_server)
Test option to ignore Plex Web clients.
Test option to ignore Plex Web clients.
async def test_ignore_plex_web_client(hass, entry, setup_plex_server): """Test option to ignore Plex Web clients.""" OPTIONS = copy.deepcopy(DEFAULT_OPTIONS) OPTIONS[MP_DOMAIN][CONF_IGNORE_PLEX_WEB_CLIENTS] = True entry.options = OPTIONS mock_plex_server = await setup_plex_server( config_en...
[ "async", "def", "test_ignore_plex_web_client", "(", "hass", ",", "entry", ",", "setup_plex_server", ")", ":", "OPTIONS", "=", "copy", ".", "deepcopy", "(", "DEFAULT_OPTIONS", ")", "OPTIONS", "[", "MP_DOMAIN", "]", "[", "CONF_IGNORE_PLEX_WEB_CLIENTS", "]", "=", "...
[ 162, 0 ]
[ 179, 54 ]
python
en
['en', 'fr', 'en']
True
test_media_lookups
(hass, mock_plex_server, requests_mock, playqueue_created)
Test media lookups to Plex server.
Test media lookups to Plex server.
async def test_media_lookups(hass, mock_plex_server, requests_mock, playqueue_created): """Test media lookups to Plex server.""" server_id = mock_plex_server.machine_identifier loaded_server = hass.data[DOMAIN][SERVERS][server_id] # Plex Key searches media_player_id = hass.states.async_entity_ids("...
[ "async", "def", "test_media_lookups", "(", "hass", ",", "mock_plex_server", ",", "requests_mock", ",", "playqueue_created", ")", ":", "server_id", "=", "mock_plex_server", ".", "machine_identifier", "loaded_server", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[...
[ 182, 0 ]
[ 391, 13 ]
python
en
['en', 'et', 'en']
True
ConfigurationCommand.list_config_values
(self, options, args)
List config key-value pairs across different config files
List config key-value pairs across different config files
def list_config_values(self, options, args): # type: (Values, List[str]) -> None """List config key-value pairs across different config files""" self._get_n_args(args, "debug", n=0) self.print_env_var_values() # Iterate over config files and print if they exist, and the ...
[ "def", "list_config_values", "(", "self", ",", "options", ",", "args", ")", ":", "# type: (Values, List[str]) -> None", "self", ".", "_get_n_args", "(", "args", ",", "\"debug\"", ",", "n", "=", "0", ")", "self", ".", "print_env_var_values", "(", ")", "# Iterat...
[ 195, 4 ]
[ 211, 62 ]
python
en
['fr', 'en', 'en']
True
ConfigurationCommand.print_config_file_values
(self, variant)
Get key-value pairs from the file of a variant
Get key-value pairs from the file of a variant
def print_config_file_values(self, variant): # type: (Kind) -> None """Get key-value pairs from the file of a variant""" for name, value in self.configuration.\ get_values_in_config(variant).items(): with indent_log(): write_output("%s: %s", name, valu...
[ "def", "print_config_file_values", "(", "self", ",", "variant", ")", ":", "# type: (Kind) -> None", "for", "name", ",", "value", "in", "self", ".", "configuration", ".", "get_values_in_config", "(", "variant", ")", ".", "items", "(", ")", ":", "with", "indent_...
[ 213, 4 ]
[ 219, 51 ]
python
en
['en', 'en', 'en']
True
ConfigurationCommand.print_env_var_values
(self)
Get key-values pairs present as environment variables
Get key-values pairs present as environment variables
def print_env_var_values(self): # type: () -> None """Get key-values pairs present as environment variables""" write_output("%s:", 'env_var') with indent_log(): for key, value in sorted(self.configuration.get_environ_vars()): env_var = 'PIP_{}'.format(key.uppe...
[ "def", "print_env_var_values", "(", "self", ")", ":", "# type: () -> None", "write_output", "(", "\"%s:\"", ",", "'env_var'", ")", "with", "indent_log", "(", ")", ":", "for", "key", ",", "value", "in", "sorted", "(", "self", ".", "configuration", ".", "get_e...
[ 221, 4 ]
[ 228, 53 ]
python
en
['fr', 'en', 'en']
True
ConfigurationCommand._get_n_args
(self, args, example, n)
Helper to make sure the command got the right number of arguments
Helper to make sure the command got the right number of arguments
def _get_n_args(self, args, example, n): # type: (List[str], str, int) -> Any """Helper to make sure the command got the right number of arguments """ if len(args) != n: msg = ( 'Got unexpected number of arguments, expected {}. ' '(example: "{}...
[ "def", "_get_n_args", "(", "self", ",", "args", ",", "example", ",", "n", ")", ":", "# type: (List[str], str, int) -> Any", "if", "len", "(", "args", ")", "!=", "n", ":", "msg", "=", "(", "'Got unexpected number of arguments, expected {}. '", "'(example: \"{} config...
[ 246, 4 ]
[ 260, 23 ]
python
en
['en', 'en', 'en']
True
test_plex_play_media
( hass, config_entry, config, )
Test playing media via the Plex integration.
Test playing media via the Plex integration.
async def test_plex_play_media( hass, config_entry, config, ): """Test playing media via the Plex integration.""" await setup_platform(hass, config_entry, config) media_player = "media_player.zone_a" media_content_id = ( '{"library_name": "Music", "artist_name": "Artist", "album_name...
[ "async", "def", "test_plex_play_media", "(", "hass", ",", "config_entry", ",", "config", ",", ")", ":", "await", "setup_platform", "(", "hass", ",", "config_entry", ",", "config", ")", "media_player", "=", "\"media_player.zone_a\"", "media_content_id", "=", "(", ...
[ 19, 0 ]
[ 66, 31 ]
python
en
['en', 'hmn', 'en']
True
TestTypeHolderDefault.testTypeHolderDefault
(self)
Test TypeHolderDefault
Test TypeHolderDefault
def testTypeHolderDefault(self): """Test TypeHolderDefault""" # required_vars are set to None now until swagger-parser/swagger-core fixes # https://github.com/swagger-api/swagger-parser/issues/971 array_item = [1, 2, 3] model = TypeHolderDefault(array_item=array_item) sel...
[ "def", "testTypeHolderDefault", "(", "self", ")", ":", "# required_vars are set to None now until swagger-parser/swagger-core fixes", "# https://github.com/swagger-api/swagger-parser/issues/971", "array_item", "=", "[", "1", ",", "2", ",", "3", "]", "model", "=", "TypeHolderDef...
[ 29, 4 ]
[ 36, 47 ]
python
en
['en', 'no', 'en']
False
get_engine
(hass, config, discovery_info=None)
Set up Pico speech component.
Set up Pico speech component.
def get_engine(hass, config, discovery_info=None): """Set up Pico speech component.""" if shutil.which("pico2wave") is None: _LOGGER.error("'pico2wave' was not found") return False return PicoProvider(config[CONF_LANG])
[ "def", "get_engine", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "if", "shutil", ".", "which", "(", "\"pico2wave\"", ")", "is", "None", ":", "_LOGGER", ".", "error", "(", "\"'pico2wave' was not found\"", ")", "return", "False", ...
[ 22, 0 ]
[ 27, 42 ]
python
en
['en', 'pt', 'en']
True
PicoProvider.__init__
(self, lang)
Initialize Pico TTS provider.
Initialize Pico TTS provider.
def __init__(self, lang): """Initialize Pico TTS provider.""" self._lang = lang self.name = "PicoTTS"
[ "def", "__init__", "(", "self", ",", "lang", ")", ":", "self", ".", "_lang", "=", "lang", "self", ".", "name", "=", "\"PicoTTS\"" ]
[ 33, 4 ]
[ 36, 29 ]
python
it
['it', 'it', 'it']
True
PicoProvider.default_language
(self)
Return the default language.
Return the default language.
def default_language(self): """Return the default language.""" return self._lang
[ "def", "default_language", "(", "self", ")", ":", "return", "self", ".", "_lang" ]
[ 39, 4 ]
[ 41, 25 ]
python
en
['en', 'et', 'en']
True
PicoProvider.supported_languages
(self)
Return list of supported languages.
Return list of supported languages.
def supported_languages(self): """Return list of supported languages.""" return SUPPORT_LANGUAGES
[ "def", "supported_languages", "(", "self", ")", ":", "return", "SUPPORT_LANGUAGES" ]
[ 44, 4 ]
[ 46, 32 ]
python
en
['en', 'en', 'en']
True
PicoProvider.get_tts_audio
(self, message, language, options=None)
Load TTS using pico2wave.
Load TTS using pico2wave.
def get_tts_audio(self, message, language, options=None): """Load TTS using pico2wave.""" with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as tmpf: fname = tmpf.name cmd = ["pico2wave", "--wave", fname, "-l", language, message] subprocess.call(cmd) data ...
[ "def", "get_tts_audio", "(", "self", ",", "message", ",", "language", ",", "options", "=", "None", ")", ":", "with", "tempfile", ".", "NamedTemporaryFile", "(", "suffix", "=", "\".wav\"", ",", "delete", "=", "False", ")", "as", "tmpf", ":", "fname", "=",...
[ 48, 4 ]
[ 67, 27 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Dlib Face detection platform.
Set up the Dlib Face detection platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Dlib Face detection platform.""" entities = [] for camera in config[CONF_SOURCE]: entities.append( DlibFaceIdentifyEntity( camera[CONF_ENTITY_ID], config[CONF_FACES], ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "entities", "=", "[", "]", "for", "camera", "in", "config", "[", "CONF_SOURCE", "]", ":", "entities", ".", "append", "(", "DlibFaceIdent...
[ 32, 0 ]
[ 45, 26 ]
python
en
['en', 'da', 'en']
True
DlibFaceIdentifyEntity.__init__
(self, camera_entity, faces, name, tolerance)
Initialize Dlib face identify entry.
Initialize Dlib face identify entry.
def __init__(self, camera_entity, faces, name, tolerance): """Initialize Dlib face identify entry.""" super().__init__() self._camera = camera_entity if name: self._name = name else: self._name = f"Dlib Face {split_entity_id(camera_entity)[1]}" ...
[ "def", "__init__", "(", "self", ",", "camera_entity", ",", "faces", ",", "name", ",", "tolerance", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_camera", "=", "camera_entity", "if", "name", ":", "self", ".", "_name", "=", "na...
[ 51, 4 ]
[ 71, 35 ]
python
en
['en', 'en', 'en']
True
DlibFaceIdentifyEntity.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
[ "def", "camera_entity", "(", "self", ")", ":", "return", "self", ".", "_camera" ]
[ 74, 4 ]
[ 76, 27 ]
python
en
['en', 'en', 'en']
True
DlibFaceIdentifyEntity.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 79, 4 ]
[ 81, 25 ]
python
en
['en', 'en', 'en']
True
DlibFaceIdentifyEntity.process_image
(self, image)
Process image.
Process image.
def process_image(self, image): """Process image.""" fak_file = io.BytesIO(image) fak_file.name = "snapshot.jpg" fak_file.seek(0) image = face_recognition.load_image_file(fak_file) unknowns = face_recognition.face_encodings(image) found = [] for unknown...
[ "def", "process_image", "(", "self", ",", "image", ")", ":", "fak_file", "=", "io", ".", "BytesIO", "(", "image", ")", "fak_file", ".", "name", "=", "\"snapshot.jpg\"", "fak_file", ".", "seek", "(", "0", ")", "image", "=", "face_recognition", ".", "load_...
[ 83, 4 ]
[ 102, 48 ]
python
en
['en', 'ny', 'en']
False
listify
(maybe_list)
Return list version of whatever value is passed in. This is used to provide a consistent way of interacting with the JSON results from the API. There are several attributes that will either missing if there are no values, a single dictionary if there is only one value, and a list if there are multiple....
Return list version of whatever value is passed in.
def listify(maybe_list): """Return list version of whatever value is passed in. This is used to provide a consistent way of interacting with the JSON results from the API. There are several attributes that will either missing if there are no values, a single dictionary if there is only one value, and ...
[ "def", "listify", "(", "maybe_list", ")", ":", "if", "maybe_list", "is", "None", ":", "return", "[", "]", "if", "isinstance", "(", "maybe_list", ",", "list", ")", ":", "return", "maybe_list", "return", "[", "maybe_list", "]" ]
[ 30, 0 ]
[ 42, 23 ]
python
en
['en', 'en', 'en']
True
maybe_first
(maybe_list)
Return the first item out of a list or returns back the input.
Return the first item out of a list or returns back the input.
def maybe_first(maybe_list): """Return the first item out of a list or returns back the input.""" if isinstance(maybe_list, list) and maybe_list: return maybe_list[0] return maybe_list
[ "def", "maybe_first", "(", "maybe_list", ")", ":", "if", "isinstance", "(", "maybe_list", ",", "list", ")", "and", "maybe_list", ":", "return", "maybe_list", "[", "0", "]", "return", "maybe_list" ]
[ 45, 0 ]
[ 50, 21 ]
python
en
['en', 'en', 'en']
True