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_aprs_listener_rx_msg_ambiguity_invalid
()
Test rx_msg with invalid posambiguity.
Test rx_msg with invalid posambiguity.
def test_aprs_listener_rx_msg_ambiguity_invalid(): """Test rx_msg with invalid posambiguity.""" with patch("aprslib.IS"): callsign = TEST_CALLSIGN password = TEST_PASSWORD host = TEST_HOST server_filter = TEST_FILTER see = Mock() sample_msg = { device...
[ "def", "test_aprs_listener_rx_msg_ambiguity_invalid", "(", ")", ":", "with", "patch", "(", "\"aprslib.IS\"", ")", ":", "callsign", "=", "TEST_CALLSIGN", "password", "=", "TEST_PASSWORD", "host", "=", "TEST_HOST", "server_filter", "=", "TEST_FILTER", "see", "=", "Moc...
[ 239, 0 ]
[ 271, 9 ]
python
en
['en', 'en', 'en']
True
test_aprs_listener_rx_msg_no_position
()
Test rx_msg with non-position report.
Test rx_msg with non-position report.
def test_aprs_listener_rx_msg_no_position(): """Test rx_msg with non-position report.""" with patch("aprslib.IS"): callsign = TEST_CALLSIGN password = TEST_PASSWORD host = TEST_HOST server_filter = TEST_FILTER see = Mock() sample_msg = {device_tracker.ATTR_FORMAT...
[ "def", "test_aprs_listener_rx_msg_no_position", "(", ")", ":", "with", "patch", "(", "\"aprslib.IS\"", ")", ":", "callsign", "=", "TEST_CALLSIGN", "password", "=", "TEST_PASSWORD", "host", "=", "TEST_HOST", "server_filter", "=", "TEST_FILTER", "see", "=", "Mock", ...
[ 274, 0 ]
[ 298, 31 ]
python
en
['en', 'en', 'en']
True
test_setup_scanner
()
Test setup_scanner.
Test setup_scanner.
def test_setup_scanner(): """Test setup_scanner.""" with patch( "homeassistant.components.aprs.device_tracker.AprsListenerThread" ) as listener: hass = get_test_home_assistant() hass.start() config = { "username": TEST_CALLSIGN, "password": TEST_PASSW...
[ "def", "test_setup_scanner", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.aprs.device_tracker.AprsListenerThread\"", ")", "as", "listener", ":", "hass", "=", "get_test_home_assistant", "(", ")", "hass", ".", "start", "(", ")", "config", "=", "{",...
[ 301, 0 ]
[ 324, 9 ]
python
en
['en', 'da', 'en']
False
test_setup_scanner_timeout
()
Test setup_scanner failure from timeout.
Test setup_scanner failure from timeout.
def test_setup_scanner_timeout(): """Test setup_scanner failure from timeout.""" hass = get_test_home_assistant() hass.start() config = { "username": TEST_CALLSIGN, "password": TEST_PASSWORD, "host": "localhost", "timeout": 0.01, "callsigns": ["XX0FOO*", "YY0BAR-...
[ "def", "test_setup_scanner_timeout", "(", ")", ":", "hass", "=", "get_test_home_assistant", "(", ")", "hass", ".", "start", "(", ")", "config", "=", "{", "\"username\"", ":", "TEST_CALLSIGN", ",", "\"password\"", ":", "TEST_PASSWORD", ",", "\"host\"", ":", "\"...
[ 327, 0 ]
[ 344, 19 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Home Connect light.
Set up the Home Connect light.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Home Connect light.""" def get_entities(): """Get a list of entities.""" entities = [] hc_api = hass.data[DOMAIN][config_entry.entry_id] for device_dict in hc_api.devices: entity_dicts...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "def", "get_entities", "(", ")", ":", "\"\"\"Get a list of entities.\"\"\"", "entities", "=", "[", "]", "hc_api", "=", "hass", ".", "data", "[", "DOMAIN",...
[ 32, 0 ]
[ 45, 77 ]
python
en
['en', 'en', 'en']
True
HomeConnectLight.__init__
(self, device, desc, ambient)
Initialize the entity.
Initialize the entity.
def __init__(self, device, desc, ambient): """Initialize the entity.""" super().__init__(device, desc) self._state = None self._brightness = None self._hs_color = None self._ambient = ambient if self._ambient: self._brightness_key = BSH_AMBIENT_LIGHT_B...
[ "def", "__init__", "(", "self", ",", "device", ",", "desc", ",", "ambient", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "desc", ")", "self", ".", "_state", "=", "None", "self", ".", "_brightness", "=", "None", "self", ".", "_h...
[ 51, 4 ]
[ 67, 34 ]
python
en
['en', 'en', 'en']
True
HomeConnectLight.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 bool(self._state)
[ "def", "is_on", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "_state", ")" ]
[ 70, 4 ]
[ 72, 32 ]
python
en
['en', 'en', 'en']
True
HomeConnectLight.brightness
(self)
Return the brightness of the light.
Return the brightness of the light.
def brightness(self): """Return the brightness of the light.""" return self._brightness
[ "def", "brightness", "(", "self", ")", ":", "return", "self", ".", "_brightness" ]
[ 75, 4 ]
[ 77, 31 ]
python
en
['en', 'no', 'en']
True
HomeConnectLight.hs_color
(self)
Return the color property.
Return the color property.
def hs_color(self): """Return the color property.""" return self._hs_color
[ "def", "hs_color", "(", "self", ")", ":", "return", "self", ".", "_hs_color" ]
[ 80, 4 ]
[ 82, 29 ]
python
en
['en', 'en', 'en']
True
HomeConnectLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" if self._ambient: return SUPPORT_BRIGHTNESS | SUPPORT_COLOR return SUPPORT_BRIGHTNESS
[ "def", "supported_features", "(", "self", ")", ":", "if", "self", ".", "_ambient", ":", "return", "SUPPORT_BRIGHTNESS", "|", "SUPPORT_COLOR", "return", "SUPPORT_BRIGHTNESS" ]
[ 85, 4 ]
[ 89, 33 ]
python
en
['da', 'en', 'en']
True
HomeConnectLight.async_turn_on
(self, **kwargs)
Switch the light on, change brightness, change color.
Switch the light on, change brightness, change color.
async def async_turn_on(self, **kwargs): """Switch the light on, change brightness, change color.""" if self._ambient: _LOGGER.debug("Switching ambient light on for: %s", self.name) try: await self.hass.async_add_executor_job( self.device.appli...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_ambient", ":", "_LOGGER", ".", "debug", "(", "\"Switching ambient light on for: %s\"", ",", "self", ".", "name", ")", "try", ":", "await", "self", ".", ...
[ 91, 4 ]
[ 150, 34 ]
python
en
['en', 'en', 'en']
True
HomeConnectLight.async_turn_off
(self, **kwargs)
Switch the light off.
Switch the light off.
async def async_turn_off(self, **kwargs): """Switch the light off.""" _LOGGER.debug("Switching light off for: %s", self.name) try: await self.hass.async_add_executor_job( self.device.appliance.set_setting, self._key, False ) except HomeConnectError...
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Switching light off for: %s\"", ",", "self", ".", "name", ")", "try", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", ...
[ 152, 4 ]
[ 161, 34 ]
python
en
['en', 'en', 'en']
True
HomeConnectLight.async_update
(self)
Update the light's status.
Update the light's status.
async def async_update(self): """Update the light's status.""" if self.device.appliance.status.get(self._key, {}).get(ATTR_VALUE) is True: self._state = True elif self.device.appliance.status.get(self._key, {}).get(ATTR_VALUE) is False: self._state = False else: ...
[ "async", "def", "async_update", "(", "self", ")", ":", "if", "self", ".", "device", ".", "appliance", ".", "status", ".", "get", "(", "self", ".", "_key", ",", "{", "}", ")", ".", "get", "(", "ATTR_VALUE", ")", "is", "True", ":", "self", ".", "_s...
[ 163, 4 ]
[ 194, 74 ]
python
en
['en', 'sn', 'en']
True
parse_junit
(xml)
Generate failed tests as a series of dicts. Ignore skipped tests.
Generate failed tests as a series of dicts. Ignore skipped tests.
def parse_junit(xml): """Generate failed tests as a series of dicts. Ignore skipped tests.""" # NOTE: this is modified from gubernator/view_build.py try: tree = ET.fromstring(xml) except ET.ParseError: print("Malformed xml, skipping") yield from [] #return empty itterator to skip...
[ "def", "parse_junit", "(", "xml", ")", ":", "# NOTE: this is modified from gubernator/view_build.py", "try", ":", "tree", "=", "ET", ".", "fromstring", "(", "xml", ")", "except", "ET", ".", "ParseError", ":", "print", "(", "\"Malformed xml, skipping\"", ")", "yiel...
[ 150, 0 ]
[ 200, 77 ]
python
en
['en', 'en', 'en']
True
row_for_build
(path, started, finished, results)
Generate an dictionary that represents a build as described by TestGrid's job schema. See link for reference. github.com/GoogleCloudPlatform/testgrid/blob/7d818/metadata/job.go#L23-L77 Args: path (string): Path to file data for a build started (dict): Values pulled from started.json fo...
Generate an dictionary that represents a build as described by TestGrid's job schema. See link for reference. github.com/GoogleCloudPlatform/testgrid/blob/7d818/metadata/job.go#L23-L77
def row_for_build(path, started, finished, results): """ Generate an dictionary that represents a build as described by TestGrid's job schema. See link for reference. github.com/GoogleCloudPlatform/testgrid/blob/7d818/metadata/job.go#L23-L77 Args: path (string): Path to file data for a buil...
[ "def", "row_for_build", "(", "path", ",", "started", ",", "finished", ",", "results", ")", ":", "tests", "=", "[", "]", "for", "result", "in", "results", ":", "for", "test", "in", "parse_junit", "(", "result", ")", ":", "if", "'#'", "in", "test", "["...
[ 202, 0 ]
[ 254, 26 ]
python
en
['en', 'error', 'th']
False
DockerList.parse_content
(self, content)
Parse the lines given into a list of dictionaries for each row. This is stored in the ``rows`` attribute. If the ``key_field`` property is set, use this to key a ``data`` dictionary attribute.
Parse the lines given into a list of dictionaries for each row. This is stored in the ``rows`` attribute.
def parse_content(self, content): """ Parse the lines given into a list of dictionaries for each row. This is stored in the ``rows`` attribute. If the ``key_field`` property is set, use this to key a ``data`` dictionary attribute. """ if not (self.key_field and ...
[ "def", "parse_content", "(", "self", ",", "content", ")", ":", "if", "not", "(", "self", ".", "key_field", "and", "self", ".", "attr_name", ")", ":", "raise", "NotImplementedError", "(", "\"'key_field' or 'attr_name' is not defined\"", ")", "self", ".", "rows", ...
[ 52, 4 ]
[ 77, 43 ]
python
en
['en', 'error', 'th']
False
test_inventory_url_from_base_url
(get_proxies, init_session)
Inventory URL is composed correctly from the given base URL.
Inventory URL is composed correctly from the given base URL.
def test_inventory_url_from_base_url(get_proxies, init_session): """ Inventory URL is composed correctly from the given base URL. """ config = Mock(base_url="www.example.com") connection = InsightsConnection(config) assert connection.inventory_url == "https://www.example.com/inventory/v1"
[ "def", "test_inventory_url_from_base_url", "(", "get_proxies", ",", "init_session", ")", ":", "config", "=", "Mock", "(", "base_url", "=", "\"www.example.com\"", ")", "connection", "=", "InsightsConnection", "(", "config", ")", "assert", "connection", ".", "inventor...
[ 11, 0 ]
[ 17, 77 ]
python
en
['en', 'error', 'th']
False
test_inventory_url_from_phase
( try_satellite6_configuration, try_satellite5_configuration, get_proxies, init_session, config_kwargs )
Inventory URL is composed correctly from the default configuration.
Inventory URL is composed correctly from the default configuration.
def test_inventory_url_from_phase( try_satellite6_configuration, try_satellite5_configuration, get_proxies, init_session, config_kwargs ): """ Inventory URL is composed correctly from the default configuration. """ config = InsightsConfig(**config_kwargs) config.load_all() # Dis...
[ "def", "test_inventory_url_from_phase", "(", "try_satellite6_configuration", ",", "try_satellite5_configuration", ",", "get_proxies", ",", "init_session", ",", "config_kwargs", ")", ":", "config", "=", "InsightsConfig", "(", "*", "*", "config_kwargs", ")", "config", "."...
[ 26, 0 ]
[ 40, 108 ]
python
en
['en', 'error', 'th']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the sensor platform.
Set up the sensor platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the sensor platform.""" meter_number = config[CONF_METER_NUMBER] try: meter = Meter(meter_number) except MeterError: _LOGGER.error("Unable to create Oru meter") return add_entities([CurrentEner...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "meter_number", "=", "config", "[", "CONF_METER_NUMBER", "]", "try", ":", "meter", "=", "Meter", "(", "meter_number", ")", "except", "Mete...
[ 23, 0 ]
[ 37, 56 ]
python
en
['en', 'da', 'en']
True
CurrentEnergyUsageSensor.__init__
(self, meter)
Initialize the sensor.
Initialize the sensor.
def __init__(self, meter): """Initialize the sensor.""" self._state = None self._available = None self.meter = meter
[ "def", "__init__", "(", "self", ",", "meter", ")", ":", "self", ".", "_state", "=", "None", "self", ".", "_available", "=", "None", "self", ".", "meter", "=", "meter" ]
[ 46, 4 ]
[ 50, 26 ]
python
en
['en', 'en', 'en']
True
CurrentEnergyUsageSensor.unique_id
(self)
Return a unique, Home Assistant friendly identifier for this entity.
Return a unique, Home Assistant friendly identifier for this entity.
def unique_id(self): """Return a unique, Home Assistant friendly identifier for this entity.""" return self.meter.meter_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "meter", ".", "meter_id" ]
[ 53, 4 ]
[ 55, 34 ]
python
en
['en', 'en', 'en']
True
CurrentEnergyUsageSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return SENSOR_NAME
[ "def", "name", "(", "self", ")", ":", "return", "SENSOR_NAME" ]
[ 58, 4 ]
[ 60, 26 ]
python
en
['en', 'mi', 'en']
True
CurrentEnergyUsageSensor.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" ]
[ 63, 4 ]
[ 65, 26 ]
python
en
['en', 'en', 'en']
True
CurrentEnergyUsageSensor.update
(self)
Fetch new state data for the sensor.
Fetch new state data for the sensor.
def update(self): """Fetch new state data for the sensor.""" try: last_read = self.meter.last_read() self._state = last_read self._available = True _LOGGER.debug( "%s = %s %s", self.name, self._state, self.unit_of_measurement ...
[ "def", "update", "(", "self", ")", ":", "try", ":", "last_read", "=", "self", ".", "meter", ".", "last_read", "(", ")", "self", ".", "_state", "=", "last_read", "self", ".", "_available", "=", "True", "_LOGGER", ".", "debug", "(", "\"%s = %s %s\"", ","...
[ 67, 4 ]
[ 81, 64 ]
python
en
['en', 'en', 'en']
True
mock_dummy_device_from_host_light_fan
()
Mock a valid api_devce.
Mock a valid api_devce.
def mock_dummy_device_from_host_light_fan(): """Mock a valid api_devce.""" device = pywilight.wilight_from_discovery( f"http://{HOST}:45995/wilight.xml", UPNP_MAC_ADDRESS, UPNP_MODEL_NAME_LIGHT_FAN, UPNP_SERIAL, UPNP_MODEL_NUMBER, ) device.set_dummy(True) w...
[ "def", "mock_dummy_device_from_host_light_fan", "(", ")", ":", "device", "=", "pywilight", ".", "wilight_from_discovery", "(", "f\"http://{HOST}:45995/wilight.xml\"", ",", "UPNP_MAC_ADDRESS", ",", "UPNP_MODEL_NAME_LIGHT_FAN", ",", "UPNP_SERIAL", ",", "UPNP_MODEL_NUMBER", ",",...
[ 37, 0 ]
[ 54, 20 ]
python
en
['en', 'ca', 'en']
True
test_loading_light_fan
( hass: HomeAssistant, dummy_device_from_host_light_fan, )
Test the WiLight configuration entry loading.
Test the WiLight configuration entry loading.
async def test_loading_light_fan( hass: HomeAssistant, dummy_device_from_host_light_fan, ) -> None: """Test the WiLight configuration entry loading.""" entry = await setup_integration(hass) assert entry assert entry.unique_id == WILIGHT_ID entity_registry = er.async_get(hass) # First ...
[ "async", "def", "test_loading_light_fan", "(", "hass", ":", "HomeAssistant", ",", "dummy_device_from_host_light_fan", ",", ")", "->", "None", ":", "entry", "=", "await", "setup_integration", "(", "hass", ")", "assert", "entry", "assert", "entry", ".", "unique_id",...
[ 57, 0 ]
[ 76, 48 ]
python
en
['en', 'en', 'en']
True
test_on_off_fan_state
( hass: HomeAssistant, dummy_device_from_host_light_fan )
Test the change of state of the fan switches.
Test the change of state of the fan switches.
async def test_on_off_fan_state( hass: HomeAssistant, dummy_device_from_host_light_fan ) -> None: """Test the change of state of the fan switches.""" await setup_integration(hass) # Turn on await hass.services.async_call( FAN_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: "fan.wl...
[ "async", "def", "test_on_off_fan_state", "(", "hass", ":", "HomeAssistant", ",", "dummy_device_from_host_light_fan", ")", "->", "None", ":", "await", "setup_integration", "(", "hass", ")", "# Turn on", "await", "hass", ".", "services", ".", "async_call", "(", "FAN...
[ 79, 0 ]
[ 123, 35 ]
python
en
['en', 'en', 'en']
True
test_speed_fan_state
( hass: HomeAssistant, dummy_device_from_host_light_fan )
Test the change of speed of the fan switches.
Test the change of speed of the fan switches.
async def test_speed_fan_state( hass: HomeAssistant, dummy_device_from_host_light_fan ) -> None: """Test the change of speed of the fan switches.""" await setup_integration(hass) # Set speed Low await hass.services.async_call( FAN_DOMAIN, SERVICE_SET_PERCENTAGE, {ATTR_PERCEN...
[ "async", "def", "test_speed_fan_state", "(", "hass", ":", "HomeAssistant", ",", "dummy_device_from_host_light_fan", ")", "->", "None", ":", "await", "setup_integration", "(", "hass", ")", "# Set speed Low", "await", "hass", ".", "services", ".", "async_call", "(", ...
[ 126, 0 ]
[ 169, 55 ]
python
en
['en', 'en', 'en']
True
test_direction_fan_state
( hass: HomeAssistant, dummy_device_from_host_light_fan )
Test the change of direction of the fan switches.
Test the change of direction of the fan switches.
async def test_direction_fan_state( hass: HomeAssistant, dummy_device_from_host_light_fan ) -> None: """Test the change of direction of the fan switches.""" await setup_integration(hass) # Set direction Forward await hass.services.async_call( FAN_DOMAIN, SERVICE_SET_DIRECTION, ...
[ "async", "def", "test_direction_fan_state", "(", "hass", ":", "HomeAssistant", ",", "dummy_device_from_host_light_fan", ")", "->", "None", ":", "await", "setup_integration", "(", "hass", ")", "# Set direction Forward", "await", "hass", ".", "services", ".", "async_cal...
[ 172, 0 ]
[ 203, 68 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the file size sensor.
Set up the file size sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the file size sensor.""" setup_reload_service(hass, DOMAIN, PLATFORMS) sensors = [] for path in config.get(CONF_FILE_PATHS): if not hass.config.is_allowed_path(path): _LOGGER.error("Filepath %s is not va...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "setup_reload_service", "(", "hass", ",", "DOMAIN", ",", "PLATFORMS", ")", "sensors", "=", "[", "]", "for", "path", "in", "config", ".",...
[ 25, 0 ]
[ 38, 35 ]
python
en
['en', 'da', 'en']
True
Filesize.__init__
(self, path)
Initialize the data object.
Initialize the data object.
def __init__(self, path): """Initialize the data object.""" self._path = path # Need to check its a valid path self._size = None self._last_updated = None self._name = path.split("/")[-1] self._unit_of_measurement = DATA_MEGABYTES
[ "def", "__init__", "(", "self", ",", "path", ")", ":", "self", ".", "_path", "=", "path", "# Need to check its a valid path", "self", ".", "_size", "=", "None", "self", ".", "_last_updated", "=", "None", "self", ".", "_name", "=", "path", ".", "split", "...
[ 44, 4 ]
[ 50, 50 ]
python
en
['en', 'en', 'en']
True
Filesize.update
(self)
Update the sensor.
Update the sensor.
def update(self): """Update the sensor.""" statinfo = os.stat(self._path) self._size = statinfo.st_size last_updated = datetime.datetime.fromtimestamp(statinfo.st_mtime) self._last_updated = last_updated.isoformat()
[ "def", "update", "(", "self", ")", ":", "statinfo", "=", "os", ".", "stat", "(", "self", ".", "_path", ")", "self", ".", "_size", "=", "statinfo", ".", "st_size", "last_updated", "=", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "statinfo", ...
[ 52, 4 ]
[ 57, 53 ]
python
en
['en', 'nl', 'en']
True
Filesize.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" ]
[ 60, 4 ]
[ 62, 25 ]
python
en
['en', 'mi', 'en']
True
Filesize.native_value
(self)
Return the size of the file in MB.
Return the size of the file in MB.
def native_value(self): """Return the size of the file in MB.""" decimals = 2 state_mb = round(self._size / 1e6, decimals) return state_mb
[ "def", "native_value", "(", "self", ")", ":", "decimals", "=", "2", "state_mb", "=", "round", "(", "self", ".", "_size", "/", "1e6", ",", "decimals", ")", "return", "state_mb" ]
[ 65, 4 ]
[ 69, 23 ]
python
en
['en', 'en', 'en']
True
Filesize.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" ]
[ 72, 4 ]
[ 74, 19 ]
python
en
['en', 'en', 'en']
True
Filesize.extra_state_attributes
(self)
Return other details about the sensor state.
Return other details about the sensor state.
def extra_state_attributes(self): """Return other details about the sensor state.""" return { "path": self._path, "last_updated": self._last_updated, "bytes": self._size, }
[ "def", "extra_state_attributes", "(", "self", ")", ":", "return", "{", "\"path\"", ":", "self", ".", "_path", ",", "\"last_updated\"", ":", "self", ".", "_last_updated", ",", "\"bytes\"", ":", "self", ".", "_size", ",", "}" ]
[ 77, 4 ]
[ 83, 9 ]
python
en
['en', 'en', 'en']
True
Filesize.native_unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement
[ "def", "native_unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 86, 4 ]
[ 88, 40 ]
python
en
['en', 'en', 'en']
True
pywemo_model
()
Pywemo Humidifier models use the fan platform.
Pywemo Humidifier models use the fan platform.
def pywemo_model(): """Pywemo Humidifier models use the fan platform.""" return "Humidifier"
[ "def", "pywemo_model", "(", ")", ":", "return", "\"Humidifier\"" ]
[ 19, 0 ]
[ 21, 23 ]
python
en
['en', 'en', 'en']
True
test_fan_registry_state_callback
( hass, pywemo_registry, pywemo_device, wemo_entity )
Verify that the fan receives state updates from the registry.
Verify that the fan receives state updates from the registry.
async def test_fan_registry_state_callback( hass, pywemo_registry, pywemo_device, wemo_entity ): """Verify that the fan receives state updates from the registry.""" # On state. pywemo_device.get_state.return_value = 1 pywemo_registry.callbacks[pywemo_device.name](pywemo_device, "", "") await has...
[ "async", "def", "test_fan_registry_state_callback", "(", "hass", ",", "pywemo_registry", ",", "pywemo_device", ",", "wemo_entity", ")", ":", "# On state.", "pywemo_device", ".", "get_state", ".", "return_value", "=", "1", "pywemo_registry", ".", "callbacks", "[", "p...
[ 38, 0 ]
[ 52, 68 ]
python
en
['en', 'en', 'en']
True
test_fan_update_entity
(hass, pywemo_registry, pywemo_device, wemo_entity)
Verify that the fan performs state updates.
Verify that the fan performs state updates.
async def test_fan_update_entity(hass, pywemo_registry, pywemo_device, wemo_entity): """Verify that the fan performs state updates.""" await async_setup_component(hass, HA_DOMAIN, {}) # On state. pywemo_device.get_state.return_value = 1 await hass.services.async_call( HA_DOMAIN, SER...
[ "async", "def", "test_fan_update_entity", "(", "hass", ",", "pywemo_registry", ",", "pywemo_device", ",", "wemo_entity", ")", ":", "await", "async_setup_component", "(", "hass", ",", "HA_DOMAIN", ",", "{", "}", ")", "# On state.", "pywemo_device", ".", "get_state"...
[ 55, 0 ]
[ 77, 68 ]
python
en
['en', 'en', 'en']
True
test_available_after_update
( hass, pywemo_registry, pywemo_device, wemo_entity )
Test the avaliability when an On call fails and after an update.
Test the avaliability when an On call fails and after an update.
async def test_available_after_update( hass, pywemo_registry, pywemo_device, wemo_entity ): """Test the avaliability when an On call fails and after an update.""" pywemo_device.set_state.side_effect = ActionException pywemo_device.get_state.return_value = 1 await entity_test_helpers.test_avaliable_a...
[ "async", "def", "test_available_after_update", "(", "hass", ",", "pywemo_registry", ",", "pywemo_device", ",", "wemo_entity", ")", ":", "pywemo_device", ".", "set_state", ".", "side_effect", "=", "ActionException", "pywemo_device", ".", "get_state", ".", "return_value...
[ 80, 0 ]
[ 88, 5 ]
python
en
['en', 'en', 'en']
True
test_fan_reset_filter_service
(hass, pywemo_device, wemo_entity)
Verify that SERVICE_RESET_FILTER_LIFE is registered and works.
Verify that SERVICE_RESET_FILTER_LIFE is registered and works.
async def test_fan_reset_filter_service(hass, pywemo_device, wemo_entity): """Verify that SERVICE_RESET_FILTER_LIFE is registered and works.""" assert await hass.services.async_call( DOMAIN, fan.SERVICE_RESET_FILTER_LIFE, {ATTR_ENTITY_ID: wemo_entity.entity_id}, blocking=True, ...
[ "async", "def", "test_fan_reset_filter_service", "(", "hass", ",", "pywemo_device", ",", "wemo_entity", ")", ":", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "fan", ".", "SERVICE_RESET_FILTER_LIFE", ",", "{", "ATTR_ENTITY_ID"...
[ 91, 0 ]
[ 99, 56 ]
python
en
['en', 'en', 'en']
True
test_fan_set_humidity_service
( hass, pywemo_device, wemo_entity, test_input, expected )
Verify that SERVICE_SET_HUMIDITY is registered and works.
Verify that SERVICE_SET_HUMIDITY is registered and works.
async def test_fan_set_humidity_service( hass, pywemo_device, wemo_entity, test_input, expected ): """Verify that SERVICE_SET_HUMIDITY is registered and works.""" assert await hass.services.async_call( DOMAIN, fan.SERVICE_SET_HUMIDITY, { ATTR_ENTITY_ID: wemo_entity.entity...
[ "async", "def", "test_fan_set_humidity_service", "(", "hass", ",", "pywemo_device", ",", "wemo_entity", ",", "test_input", ",", "expected", ")", ":", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "fan", ".", "SERVICE_SET_HUMI...
[ 113, 0 ]
[ 126, 59 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Danfoss Air HRV switch platform.
Set up the Danfoss Air HRV switch platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Danfoss Air HRV switch platform.""" data = hass.data[DANFOSS_AIR_DOMAIN] switches = [ [ "Danfoss Air Boost", ReadCommand.boost, UpdateCommand.boost_activate, UpdateComm...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "data", "=", "hass", ".", "data", "[", "DANFOSS_AIR_DOMAIN", "]", "switches", "=", "[", "[", "\"Danfoss Air Boost\"", ",", "ReadCommand", ...
[ 12, 0 ]
[ 42, 21 ]
python
en
['en', 'lb', 'en']
True
DanfossAir.__init__
(self, data, name, state_command, on_command, off_command)
Initialize the switch.
Initialize the switch.
def __init__(self, data, name, state_command, on_command, off_command): """Initialize the switch.""" self._data = data self._name = name self._state_command = state_command self._on_command = on_command self._off_command = off_command self._state = None
[ "def", "__init__", "(", "self", ",", "data", ",", "name", ",", "state_command", ",", "on_command", ",", "off_command", ")", ":", "self", ".", "_data", "=", "data", "self", ".", "_name", "=", "name", "self", ".", "_state_command", "=", "state_command", "s...
[ 48, 4 ]
[ 55, 26 ]
python
en
['en', 'en', 'en']
True
DanfossAir.name
(self)
Return the name of the switch.
Return the name of the switch.
def name(self): """Return the name of the switch.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 58, 4 ]
[ 60, 25 ]
python
en
['en', 'en', 'en']
True
DanfossAir.is_on
(self)
Return true if switch is on.
Return true if switch is on.
def is_on(self): """Return true if switch is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 63, 4 ]
[ 65, 26 ]
python
en
['en', 'fy', 'en']
True
DanfossAir.turn_on
(self, **kwargs)
Turn the switch on.
Turn the switch on.
def turn_on(self, **kwargs): """Turn the switch on.""" _LOGGER.debug("Turning on switch with command %s", self._on_command) self._data.update_state(self._on_command, self._state_command)
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Turning on switch with command %s\"", ",", "self", ".", "_on_command", ")", "self", ".", "_data", ".", "update_state", "(", "self", ".", "_on_command", ",", ...
[ 67, 4 ]
[ 70, 70 ]
python
en
['en', 'en', 'en']
True
DanfossAir.turn_off
(self, **kwargs)
Turn the switch off.
Turn the switch off.
def turn_off(self, **kwargs): """Turn the switch off.""" _LOGGER.debug("Turning off switch with command %s", self._off_command) self._data.update_state(self._off_command, self._state_command)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Turning off switch with command %s\"", ",", "self", ".", "_off_command", ")", "self", ".", "_data", ".", "update_state", "(", "self", ".", "_off_command", ","...
[ 72, 4 ]
[ 75, 71 ]
python
en
['en', 'en', 'en']
True
DanfossAir.update
(self)
Update the switch's state.
Update the switch's state.
def update(self): """Update the switch's state.""" self._data.update() self._state = self._data.get_value(self._state_command) if self._state is None: _LOGGER.debug("Could not get data for %s", self._state_command)
[ "def", "update", "(", "self", ")", ":", "self", ".", "_data", ".", "update", "(", ")", "self", ".", "_state", "=", "self", ".", "_data", ".", "get_value", "(", "self", ".", "_state_command", ")", "if", "self", ".", "_state", "is", "None", ":", "_LO...
[ 77, 4 ]
[ 83, 75 ]
python
en
['en', 'en', 'en']
True
async_handle_message
(hass, config, user_id, message, source)
Handle incoming API messages.
Handle incoming API messages.
async def async_handle_message(hass, config, user_id, message, source): """Handle incoming API messages.""" data = RequestData( config, user_id, source, message["requestId"], message.get("devices") ) response = await _process(hass, data, message) if response and "errorCode" in response["pa...
[ "async", "def", "async_handle_message", "(", "hass", ",", "config", ",", "user_id", ",", "message", ",", "source", ")", ":", "data", "=", "RequestData", "(", "config", ",", "user_id", ",", "source", ",", "message", "[", "\"requestId\"", "]", ",", "message"...
[ 23, 0 ]
[ 34, 19 ]
python
en
['en', 'en', 'en']
True
_process
(hass, data, message)
Process a message.
Process a message.
async def _process(hass, data, message): """Process a message.""" inputs: list = message.get("inputs") if len(inputs) != 1: return { "requestId": data.request_id, "payload": {"errorCode": ERR_PROTOCOL_ERROR}, } handler = HANDLERS.get(inputs[0].get("intent")) ...
[ "async", "def", "_process", "(", "hass", ",", "data", ",", "message", ")", ":", "inputs", ":", "list", "=", "message", ".", "get", "(", "\"inputs\"", ")", "if", "len", "(", "inputs", ")", "!=", "1", ":", "return", "{", "\"requestId\"", ":", "data", ...
[ 37, 0 ]
[ 69, 60 ]
python
en
['en', 'mk', 'en']
True
async_devices_sync
(hass, data, payload)
Handle action.devices.SYNC request. https://developers.google.com/assistant/smarthome/develop/process-intents#SYNC
Handle action.devices.SYNC request.
async def async_devices_sync(hass, data, payload): """Handle action.devices.SYNC request. https://developers.google.com/assistant/smarthome/develop/process-intents#SYNC """ hass.bus.async_fire( EVENT_SYNC_RECEIVED, {"request_id": data.request_id, "source": data.source}, context=...
[ "async", "def", "async_devices_sync", "(", "hass", ",", "data", ",", "payload", ")", ":", "hass", ".", "bus", ".", "async_fire", "(", "EVENT_SYNC_RECEIVED", ",", "{", "\"request_id\"", ":", "data", ".", "request_id", ",", "\"source\"", ":", "data", ".", "s...
[ 73, 0 ]
[ 109, 19 ]
python
en
['en', 'en', 'en']
True
async_devices_query
(hass, data, payload)
Handle action.devices.QUERY request. https://developers.google.com/assistant/smarthome/develop/process-intents#QUERY
Handle action.devices.QUERY request.
async def async_devices_query(hass, data, payload): """Handle action.devices.QUERY request. https://developers.google.com/assistant/smarthome/develop/process-intents#QUERY """ payload_devices = payload.get("devices", []) hass.bus.async_fire( EVENT_QUERY_RECEIVED, { "req...
[ "async", "def", "async_devices_query", "(", "hass", ",", "data", ",", "payload", ")", ":", "payload_devices", "=", "payload", ".", "get", "(", "\"devices\"", ",", "[", "]", ")", "hass", ".", "bus", ".", "async_fire", "(", "EVENT_QUERY_RECEIVED", ",", "{", ...
[ 113, 0 ]
[ 147, 31 ]
python
en
['en', 'en', 'en']
True
_entity_execute
(entity, data, executions)
Execute all commands for an entity. Returns a dict if a special result needs to be set.
Execute all commands for an entity.
async def _entity_execute(entity, data, executions): """Execute all commands for an entity. Returns a dict if a special result needs to be set. """ for execution in executions: try: await entity.execute(data, execution) except SmartHomeError as err: return { ...
[ "async", "def", "_entity_execute", "(", "entity", ",", "data", ",", "executions", ")", ":", "for", "execution", "in", "executions", ":", "try", ":", "await", "entity", ".", "execute", "(", "data", ",", "execution", ")", "except", "SmartHomeError", "as", "e...
[ 150, 0 ]
[ 165, 15 ]
python
en
['en', 'en', 'en']
True
handle_devices_execute
(hass, data, payload)
Handle action.devices.EXECUTE request. https://developers.google.com/assistant/smarthome/develop/process-intents#EXECUTE
Handle action.devices.EXECUTE request.
async def handle_devices_execute(hass, data, payload): """Handle action.devices.EXECUTE request. https://developers.google.com/assistant/smarthome/develop/process-intents#EXECUTE """ entities = {} executions = {} results = {} for command in payload["commands"]: hass.bus.async_fire(...
[ "async", "def", "handle_devices_execute", "(", "hass", ",", "data", ",", "payload", ")", ":", "entities", "=", "{", "}", "executions", "=", "{", "}", "results", "=", "{", "}", "for", "command", "in", "payload", "[", "\"commands\"", "]", ":", "hass", "....
[ 169, 0 ]
[ 241, 38 ]
python
en
['en', 'en', 'en']
True
async_devices_disconnect
(hass, data: RequestData, payload)
Handle action.devices.DISCONNECT request. https://developers.google.com/assistant/smarthome/develop/process-intents#DISCONNECT
Handle action.devices.DISCONNECT request.
async def async_devices_disconnect(hass, data: RequestData, payload): """Handle action.devices.DISCONNECT request. https://developers.google.com/assistant/smarthome/develop/process-intents#DISCONNECT """ await data.config.async_disconnect_agent_user(data.context.user_id) return None
[ "async", "def", "async_devices_disconnect", "(", "hass", ",", "data", ":", "RequestData", ",", "payload", ")", ":", "await", "data", ".", "config", ".", "async_disconnect_agent_user", "(", "data", ".", "context", ".", "user_id", ")", "return", "None" ]
[ 245, 0 ]
[ 251, 15 ]
python
en
['en', 'en', 'en']
True
async_devices_identify
(hass, data: RequestData, payload)
Handle action.devices.IDENTIFY request. https://developers.google.com/assistant/smarthome/develop/local#implement_the_identify_handler
Handle action.devices.IDENTIFY request.
async def async_devices_identify(hass, data: RequestData, payload): """Handle action.devices.IDENTIFY request. https://developers.google.com/assistant/smarthome/develop/local#implement_the_identify_handler """ return { "device": { "id": data.config.get_agent_user_id(data.context), ...
[ "async", "def", "async_devices_identify", "(", "hass", ",", "data", ":", "RequestData", ",", "payload", ")", ":", "return", "{", "\"device\"", ":", "{", "\"id\"", ":", "data", ".", "config", ".", "get_agent_user_id", "(", "data", ".", "context", ")", ",", ...
[ 255, 0 ]
[ 272, 5 ]
python
en
['en', 'en', 'en']
True
async_devices_reachable
(hass, data: RequestData, payload)
Handle action.devices.REACHABLE_DEVICES request. https://developers.google.com/actions/smarthome/create#actiondevicesdisconnect
Handle action.devices.REACHABLE_DEVICES request.
async def async_devices_reachable(hass, data: RequestData, payload): """Handle action.devices.REACHABLE_DEVICES request. https://developers.google.com/actions/smarthome/create#actiondevicesdisconnect """ google_ids = {dev["id"] for dev in (data.devices or [])} return { "devices": [ ...
[ "async", "def", "async_devices_reachable", "(", "hass", ",", "data", ":", "RequestData", ",", "payload", ")", ":", "google_ids", "=", "{", "dev", "[", "\"id\"", "]", "for", "dev", "in", "(", "data", ".", "devices", "or", "[", "]", ")", "}", "return", ...
[ 276, 0 ]
[ 289, 5 ]
python
en
['en', 'en', 'en']
True
turned_off_response
(message)
Return a device turned off response.
Return a device turned off response.
def turned_off_response(message): """Return a device turned off response.""" return { "requestId": message.get("requestId"), "payload": {"errorCode": "deviceTurnedOff"}, }
[ "def", "turned_off_response", "(", "message", ")", ":", "return", "{", "\"requestId\"", ":", "message", ".", "get", "(", "\"requestId\"", ")", ",", "\"payload\"", ":", "{", "\"errorCode\"", ":", "\"deviceTurnedOff\"", "}", ",", "}" ]
[ 292, 0 ]
[ 297, 5 ]
python
en
['en', 'en', 'en']
True
get_scanner
(hass, config)
Validate the configuration and return an ubus scanner.
Validate the configuration and return an ubus scanner.
def get_scanner(hass, config): """Validate the configuration and return an ubus scanner.""" dhcp_sw = config[DOMAIN][CONF_DHCP_SOFTWARE] if dhcp_sw == "dnsmasq": scanner = DnsmasqUbusDeviceScanner(config[DOMAIN]) elif dhcp_sw == "odhcpd": scanner = OdhcpdUbusDeviceScanner(config[DOMAIN])...
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "dhcp_sw", "=", "config", "[", "DOMAIN", "]", "[", "CONF_DHCP_SOFTWARE", "]", "if", "dhcp_sw", "==", "\"dnsmasq\"", ":", "scanner", "=", "DnsmasqUbusDeviceScanner", "(", "config", "[", "DOMAIN", "]"...
[ 34, 0 ]
[ 44, 52 ]
python
en
['en', 'en', 'en']
True
_refresh_on_access_denied
(func)
If remove rebooted, it lost our session so rebuild one and try again.
If remove rebooted, it lost our session so rebuild one and try again.
def _refresh_on_access_denied(func): """If remove rebooted, it lost our session so rebuild one and try again.""" def decorator(self, *args, **kwargs): """Wrap the function to refresh session_id on PermissionError.""" try: return func(self, *args, **kwargs) except PermissionE...
[ "def", "_refresh_on_access_denied", "(", "func", ")", ":", "def", "decorator", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrap the function to refresh session_id on PermissionError.\"\"\"", "try", ":", "return", "func", "(", "self", "...
[ 47, 0 ]
[ 63, 20 ]
python
en
['en', 'en', 'en']
True
UbusDeviceScanner.__init__
(self, config)
Initialize the scanner.
Initialize the scanner.
def __init__(self, config): """Initialize the scanner.""" host = config[CONF_HOST] self.username = config[CONF_USERNAME] self.password = config[CONF_PASSWORD] self.parse_api_pattern = re.compile(r"(?P<param>\w*) = (?P<value>.*);") self.last_results = {} self.url ...
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "host", "=", "config", "[", "CONF_HOST", "]", "self", ".", "username", "=", "config", "[", "CONF_USERNAME", "]", "self", ".", "password", "=", "config", "[", "CONF_PASSWORD", "]", "self", ".", "p...
[ 73, 4 ]
[ 86, 59 ]
python
en
['en', 'en', 'en']
True
UbusDeviceScanner.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 self.last_results
[ "def", "scan_devices", "(", "self", ")", ":", "self", ".", "_update_info", "(", ")", "return", "self", ".", "last_results" ]
[ 88, 4 ]
[ 91, 32 ]
python
en
['en', 'en', 'en']
True
UbusDeviceScanner._generate_mac2name
(self)
Return empty MAC to name dict. Overridden if DHCP server is set.
Return empty MAC to name dict. Overridden if DHCP server is set.
def _generate_mac2name(self): """Return empty MAC to name dict. Overridden if DHCP server is set.""" self.mac2name = {}
[ "def", "_generate_mac2name", "(", "self", ")", ":", "self", ".", "mac2name", "=", "{", "}" ]
[ 93, 4 ]
[ 95, 26 ]
python
en
['en', 'en', 'en']
True
UbusDeviceScanner.get_device_name
(self, device)
Return the name of the given device or None if we don't know.
Return the name of the given device or None if we don't know.
def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" if self.mac2name is None: self._generate_mac2name() if self.mac2name is None: # Generation of mac2name dictionary failed return None name = self.mac2...
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "if", "self", ".", "mac2name", "is", "None", ":", "self", ".", "_generate_mac2name", "(", ")", "if", "self", ".", "mac2name", "is", "None", ":", "# Generation of mac2name dictionary failed", "retu...
[ 98, 4 ]
[ 106, 19 ]
python
en
['en', 'en', 'en']
True
UbusDeviceScanner._update_info
(self)
Ensure the information from the router is up to date. Returns boolean if scanning successful.
Ensure the information from the router is up to date.
def _update_info(self): """Ensure the information from the router is up to date. Returns boolean if scanning successful. """ if not self.success_init: return False _LOGGER.info("Checking hostapd") if not self.hostapd: hostapd = self.ubus.get_hos...
[ "def", "_update_info", "(", "self", ")", ":", "if", "not", "self", ".", "success_init", ":", "return", "False", "_LOGGER", ".", "info", "(", "\"Checking hostapd\"", ")", "if", "not", "self", ".", "hostapd", ":", "hostapd", "=", "self", ".", "ubus", ".", ...
[ 109, 4 ]
[ 137, 28 ]
python
en
['en', 'en', 'en']
True
DnsmasqUbusDeviceScanner.__init__
(self, config)
Initialize the scanner.
Initialize the scanner.
def __init__(self, config): """Initialize the scanner.""" super().__init__(config) self.leasefile = None
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "super", "(", ")", ".", "__init__", "(", "config", ")", "self", ".", "leasefile", "=", "None" ]
[ 143, 4 ]
[ 146, 29 ]
python
en
['en', 'en', 'en']
True
test_form
(hass)
Test we get the form.
Test we get the form.
async def test_form(hass): """Test we get the form.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert result["errors...
[ "async", "def", "test_form", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(...
[ 16, 0 ]
[ 41, 41 ]
python
en
['en', 'en', 'en']
True
test_form_error
(hass: HomeAssistant, exc: Exception, base_error: str)
Test form errors.
Test form errors.
async def test_form_error(hass: HomeAssistant, exc: Exception, base_error: str): """Test form errors.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch.object(AylaApi, "async_sign_in", side_effect=exc): result2 = a...
[ "async", "def", "test_form_error", "(", "hass", ":", "HomeAssistant", ",", "exc", ":", "Exception", ",", "base_error", ":", "str", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context...
[ 52, 0 ]
[ 65, 54 ]
python
de
['de', 'ko', 'en']
False
test_reauth_success
(hass: HomeAssistant)
Test reauth flow.
Test reauth flow.
async def test_reauth_success(hass: HomeAssistant): """Test reauth flow.""" with patch("sharkiqpy.AylaApi.async_sign_in", return_value=True): mock_config = MockConfigEntry(domain=DOMAIN, unique_id=UNIQUE_ID, data=CONFIG) mock_config.add_to_hass(hass) result = await hass.config_entries.f...
[ "async", "def", "test_reauth_success", "(", "hass", ":", "HomeAssistant", ")", ":", "with", "patch", "(", "\"sharkiqpy.AylaApi.async_sign_in\"", ",", "return_value", "=", "True", ")", ":", "mock_config", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", ...
[ 68, 0 ]
[ 81, 54 ]
python
en
['en', 'fr', 'en']
True
test_reauth
( hass: HomeAssistant, side_effect: Exception, result_type: str, msg_field: str, msg: str, )
Test reauth failures.
Test reauth failures.
async def test_reauth( hass: HomeAssistant, side_effect: Exception, result_type: str, msg_field: str, msg: str, ): """Test reauth failures.""" with patch("sharkiqpy.AylaApi.async_sign_in", side_effect=side_effect): result = await hass.config_entries.flow.async_init( DOMAI...
[ "async", "def", "test_reauth", "(", "hass", ":", "HomeAssistant", ",", "side_effect", ":", "Exception", ",", "result_type", ":", "str", ",", "msg_field", ":", "str", ",", "msg", ":", "str", ",", ")", ":", "with", "patch", "(", "\"sharkiqpy.AylaApi.async_sign...
[ 92, 0 ]
[ 112, 31 ]
python
en
['ms', 'gd', 'en']
False
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback )
Set up the Pi-hole switch.
Set up the Pi-hole switch.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: """Set up the Pi-hole switch.""" name = entry.data[CONF_NAME] hole_data = hass.data[PIHOLE_DOMAIN][entry.entry_id] switches = [ PiHoleSwitch( hole_data[DATA_KE...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "AddEntitiesCallback", ")", "->", "None", ":", "name", "=", "entry", ".", "data", "[", "CONF_NAME", "]", "hole_data", "=",...
[ 28, 0 ]
[ 54, 5 ]
python
en
['en', 'zu', 'en']
True
PiHoleSwitch.name
(self)
Return the name of the switch.
Return the name of the switch.
def name(self) -> str: """Return the name of the switch.""" return self._name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_name" ]
[ 63, 4 ]
[ 65, 25 ]
python
en
['en', 'en', 'en']
True
PiHoleSwitch.unique_id
(self)
Return the unique id of the switch.
Return the unique id of the switch.
def unique_id(self) -> str: """Return the unique id of the switch.""" return f"{self._server_unique_id}/Switch"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._server_unique_id}/Switch\"" ]
[ 68, 4 ]
[ 70, 49 ]
python
en
['en', 'en', 'en']
True
PiHoleSwitch.is_on
(self)
Return if the service is on.
Return if the service is on.
def is_on(self) -> bool: """Return if the service is on.""" return self.api.data.get("status") == "enabled"
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "api", ".", "data", ".", "get", "(", "\"status\"", ")", "==", "\"enabled\"" ]
[ 73, 4 ]
[ 75, 55 ]
python
en
['en', 'en', 'en']
True
PiHoleSwitch.async_turn_on
(self, **kwargs: Any)
Turn on the service.
Turn on the service.
async def async_turn_on(self, **kwargs: Any) -> None: """Turn on the service.""" try: await self.api.enable() await self.async_update() except HoleError as err: _LOGGER.error("Unable to enable Pi-hole: %s", err)
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "try", ":", "await", "self", ".", "api", ".", "enable", "(", ")", "await", "self", ".", "async_update", "(", ")", "except", "HoleError", "as", ...
[ 77, 4 ]
[ 83, 62 ]
python
en
['en', 'en', 'en']
True
PiHoleSwitch.async_turn_off
(self, **kwargs: Any)
Turn off the service.
Turn off the service.
async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the service.""" await self.async_disable()
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "await", "self", ".", "async_disable", "(", ")" ]
[ 85, 4 ]
[ 87, 34 ]
python
en
['en', 'en', 'en']
True
PiHoleSwitch.async_disable
(self, duration: Any = None)
Disable the service for a given duration.
Disable the service for a given duration.
async def async_disable(self, duration: Any = None) -> None: """Disable the service for a given duration.""" duration_seconds = True # Disable infinitely by default if duration is not None: duration_seconds = duration.total_seconds() _LOGGER.debug( "Disab...
[ "async", "def", "async_disable", "(", "self", ",", "duration", ":", "Any", "=", "None", ")", "->", "None", ":", "duration_seconds", "=", "True", "# Disable infinitely by default", "if", "duration", "is", "not", "None", ":", "duration_seconds", "=", "duration", ...
[ 89, 4 ]
[ 104, 63 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up binary sensors attached to a Konnected device from a config entry.
Set up binary sensors attached to a Konnected device from a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up binary sensors attached to a Konnected device from a config entry.""" data = hass.data[KONNECTED_DOMAIN] device_id = config_entry.data["id"] sensors = [ KonnectedBinarySensor(device_id, pin_num, pin_data) for ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "data", "=", "hass", ".", "data", "[", "KONNECTED_DOMAIN", "]", "device_id", "=", "config_entry", ".", "data", "[", "\"id\"", "]", "sensors", "=", "["...
[ 16, 0 ]
[ 26, 31 ]
python
en
['en', 'en', 'en']
True
KonnectedBinarySensor.__init__
(self, device_id, zone_num, data)
Initialize the Konnected binary sensor.
Initialize the Konnected binary sensor.
def __init__(self, device_id, zone_num, data): """Initialize the Konnected binary sensor.""" self._data = data self._device_id = device_id self._zone_num = zone_num self._state = self._data.get(ATTR_STATE) self._device_class = self._data.get(CONF_TYPE) self._uniqu...
[ "def", "__init__", "(", "self", ",", "device_id", ",", "zone_num", ",", "data", ")", ":", "self", ".", "_data", "=", "data", "self", ".", "_device_id", "=", "device_id", "self", ".", "_zone_num", "=", "zone_num", "self", ".", "_state", "=", "self", "."...
[ 32, 4 ]
[ 40, 46 ]
python
en
['en', 'en', 'en']
True
KonnectedBinarySensor.unique_id
(self)
Return the unique id.
Return the unique id.
def unique_id(self) -> str: """Return the unique id.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_unique_id" ]
[ 43, 4 ]
[ 45, 30 ]
python
en
['en', 'la', 'en']
True
KonnectedBinarySensor.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" ]
[ 48, 4 ]
[ 50, 25 ]
python
en
['en', 'mi', 'en']
True
KonnectedBinarySensor.is_on
(self)
Return the state of the sensor.
Return the state of the sensor.
def is_on(self): """Return the state of the sensor.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 53, 4 ]
[ 55, 26 ]
python
en
['en', 'en', 'en']
True
KonnectedBinarySensor.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 58, 4 ]
[ 60, 20 ]
python
en
['en', 'en', 'en']
True
KonnectedBinarySensor.device_class
(self)
Return the device class.
Return the device class.
def device_class(self): """Return the device class.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 63, 4 ]
[ 65, 33 ]
python
en
['en', 'en', 'en']
True
KonnectedBinarySensor.device_info
(self)
Return the device info.
Return the device info.
def device_info(self): """Return the device info.""" return { "identifiers": {(KONNECTED_DOMAIN, self._device_id)}, }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "KONNECTED_DOMAIN", ",", "self", ".", "_device_id", ")", "}", ",", "}" ]
[ 68, 4 ]
[ 72, 9 ]
python
en
['en', 'en', 'en']
True
KonnectedBinarySensor.async_added_to_hass
(self)
Store entity_id and register state change callback.
Store entity_id and register state change callback.
async def async_added_to_hass(self): """Store entity_id and register state change callback.""" self._data[ATTR_ENTITY_ID] = self.entity_id self.async_on_remove( async_dispatcher_connect( self.hass, f"konnected.{self.entity_id}.update", self.async_set_state ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_data", "[", "ATTR_ENTITY_ID", "]", "=", "self", ".", "entity_id", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "f\"konnected.{self.ent...
[ 74, 4 ]
[ 81, 9 ]
python
en
['en', 'en', 'en']
True
KonnectedBinarySensor.async_set_state
(self, state)
Update the sensor's state.
Update the sensor's state.
def async_set_state(self, state): """Update the sensor's state.""" self._state = state self.async_write_ha_state()
[ "def", "async_set_state", "(", "self", ",", "state", ")", ":", "self", ".", "_state", "=", "state", "self", ".", "async_write_ha_state", "(", ")" ]
[ 84, 4 ]
[ 87, 35 ]
python
en
['en', 'en', 'en']
True
test_manually_configured_platform
(hass)
Test that we do not set up an access point.
Test that we do not set up an access point.
async def test_manually_configured_platform(hass): """Test that we do not set up an access point.""" assert await async_setup_component( hass, CLIMATE_DOMAIN, {CLIMATE_DOMAIN: {"platform": HMIPC_DOMAIN}} ) assert not hass.data.get(HMIPC_DOMAIN)
[ "async", "def", "test_manually_configured_platform", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "CLIMATE_DOMAIN", ",", "{", "CLIMATE_DOMAIN", ":", "{", "\"platform\"", ":", "HMIPC_DOMAIN", "}", "}", ")", "assert", "not", ...
[ 33, 0 ]
[ 38, 42 ]
python
en
['en', 'en', 'en']
True
test_hmip_heating_group_heat
(hass, default_mock_hap_factory)
Test HomematicipHeatingGroup.
Test HomematicipHeatingGroup.
async def test_hmip_heating_group_heat(hass, default_mock_hap_factory): """Test HomematicipHeatingGroup.""" entity_id = "climate.badezimmer" entity_name = "Badezimmer" device_model = None mock_hap = await default_mock_hap_factory.async_get_mock_hap( test_devices=["Wandthermostat", "Heizkörpe...
[ "async", "def", "test_hmip_heating_group_heat", "(", "hass", ",", "default_mock_hap_factory", ")", ":", "entity_id", "=", "\"climate.badezimmer\"", "entity_name", "=", "\"Badezimmer\"", "device_model", "=", "None", "mock_hap", "=", "await", "default_mock_hap_factory", "."...
[ 41, 0 ]
[ 231, 69 ]
python
en
['es', 'en', 'en']
False
test_hmip_heating_group_cool
(hass, default_mock_hap_factory)
Test HomematicipHeatingGroup.
Test HomematicipHeatingGroup.
async def test_hmip_heating_group_cool(hass, default_mock_hap_factory): """Test HomematicipHeatingGroup.""" entity_id = "climate.badezimmer" entity_name = "Badezimmer" device_model = None mock_hap = await default_mock_hap_factory.async_get_mock_hap( test_groups=[entity_name] ) ha_st...
[ "async", "def", "test_hmip_heating_group_cool", "(", "hass", ",", "default_mock_hap_factory", ")", ":", "entity_id", "=", "\"climate.badezimmer\"", "entity_name", "=", "\"Badezimmer\"", "device_model", "=", "None", "mock_hap", "=", "await", "default_mock_hap_factory", "."...
[ 234, 0 ]
[ 351, 48 ]
python
en
['es', 'en', 'en']
False
test_hmip_heating_group_heat_with_switch
(hass, default_mock_hap_factory)
Test HomematicipHeatingGroup.
Test HomematicipHeatingGroup.
async def test_hmip_heating_group_heat_with_switch(hass, default_mock_hap_factory): """Test HomematicipHeatingGroup.""" entity_id = "climate.schlafzimmer" entity_name = "Schlafzimmer" device_model = None mock_hap = await default_mock_hap_factory.async_get_mock_hap( test_devices=["Wandthermos...
[ "async", "def", "test_hmip_heating_group_heat_with_switch", "(", "hass", ",", "default_mock_hap_factory", ")", ":", "entity_id", "=", "\"climate.schlafzimmer\"", "entity_name", "=", "\"Schlafzimmer\"", "device_model", "=", "None", "mock_hap", "=", "await", "default_mock_hap...
[ 354, 0 ]
[ 375, 80 ]
python
en
['es', 'en', 'en']
False
test_hmip_heating_group_heat_with_radiator
(hass, default_mock_hap_factory)
Test HomematicipHeatingGroup.
Test HomematicipHeatingGroup.
async def test_hmip_heating_group_heat_with_radiator(hass, default_mock_hap_factory): """Test HomematicipHeatingGroup.""" entity_id = "climate.vorzimmer" entity_name = "Vorzimmer" device_model = None mock_hap = await default_mock_hap_factory.async_get_mock_hap( test_devices=["Heizkörpertherm...
[ "async", "def", "test_hmip_heating_group_heat_with_radiator", "(", "hass", ",", "default_mock_hap_factory", ")", ":", "entity_id", "=", "\"climate.vorzimmer\"", "entity_name", "=", "\"Vorzimmer\"", "device_model", "=", "None", "mock_hap", "=", "await", "default_mock_hap_fac...
[ 378, 0 ]
[ 398, 80 ]
python
en
['es', 'en', 'en']
False
test_hmip_climate_services
(hass, mock_hap_with_service)
Test HomematicipHeatingGroup.
Test HomematicipHeatingGroup.
async def test_hmip_climate_services(hass, mock_hap_with_service): """Test HomematicipHeatingGroup.""" home = mock_hap_with_service.home await hass.services.async_call( "homematicip_cloud", "activate_eco_mode_with_duration", {"duration": 60, "accesspoint_id": HAPID}, blocki...
[ "async", "def", "test_hmip_climate_services", "(", "hass", ",", "mock_hap_with_service", ")", ":", "home", "=", "mock_hap_with_service", ".", "home", "await", "hass", ".", "services", ".", "async_call", "(", "\"homematicip_cloud\"", ",", "\"activate_eco_mode_with_durati...
[ 401, 0 ]
[ 510, 49 ]
python
en
['es', 'en', 'en']
False
test_hmip_heating_group_services
(hass, default_mock_hap_factory)
Test HomematicipHeatingGroup services.
Test HomematicipHeatingGroup services.
async def test_hmip_heating_group_services(hass, default_mock_hap_factory): """Test HomematicipHeatingGroup services.""" entity_id = "climate.badezimmer" entity_name = "Badezimmer" device_model = None mock_hap = await default_mock_hap_factory.async_get_mock_hap( test_groups=[entity_name] ...
[ "async", "def", "test_hmip_heating_group_services", "(", "hass", ",", "default_mock_hap_factory", ")", ":", "entity_id", "=", "\"climate.badezimmer\"", "entity_name", "=", "\"Badezimmer\"", "device_model", "=", "None", "mock_hap", "=", "await", "default_mock_hap_factory", ...
[ 513, 0 ]
[ 549, 5 ]
python
en
['es', 'en', 'en']
True
legacy_thermostat_fixture
(device_factory)
Fixture returns a legacy thermostat.
Fixture returns a legacy thermostat.
def legacy_thermostat_fixture(device_factory): """Fixture returns a legacy thermostat.""" device = device_factory( "Legacy Thermostat", capabilities=[Capability.thermostat], status={ Attribute.cooling_setpoint: 74, Attribute.heating_setpoint: 68, Attri...
[ "def", "legacy_thermostat_fixture", "(", "device_factory", ")", ":", "device", "=", "device_factory", "(", "\"Legacy Thermostat\"", ",", "capabilities", "=", "[", "Capability", ".", "thermostat", "]", ",", "status", "=", "{", "Attribute", ".", "cooling_setpoint", ...
[ 52, 0 ]
[ 68, 17 ]
python
en
['en', 'en', 'en']
True
basic_thermostat_fixture
(device_factory)
Fixture returns a basic thermostat.
Fixture returns a basic thermostat.
def basic_thermostat_fixture(device_factory): """Fixture returns a basic thermostat.""" device = device_factory( "Basic Thermostat", capabilities=[ Capability.temperature_measurement, Capability.thermostat_cooling_setpoint, Capability.thermostat_heating_setpoi...
[ "def", "basic_thermostat_fixture", "(", "device_factory", ")", ":", "device", "=", "device_factory", "(", "\"Basic Thermostat\"", ",", "capabilities", "=", "[", "Capability", ".", "temperature_measurement", ",", "Capability", ".", "thermostat_cooling_setpoint", ",", "Ca...
[ 72, 0 ]
[ 90, 17 ]
python
en
['en', 'en', 'en']
True
thermostat_fixture
(device_factory)
Fixture returns a fully-featured thermostat.
Fixture returns a fully-featured thermostat.
def thermostat_fixture(device_factory): """Fixture returns a fully-featured thermostat.""" device = device_factory( "Thermostat", capabilities=[ Capability.temperature_measurement, Capability.relative_humidity_measurement, Capability.thermostat_cooling_setpoin...
[ "def", "thermostat_fixture", "(", "device_factory", ")", ":", "device", "=", "device_factory", "(", "\"Thermostat\"", ",", "capabilities", "=", "[", "Capability", ".", "temperature_measurement", ",", "Capability", ".", "relative_humidity_measurement", ",", "Capability",...
[ 94, 0 ]
[ 125, 17 ]
python
en
['en', 'en', 'en']
True
buggy_thermostat_fixture
(device_factory)
Fixture returns a buggy thermostat.
Fixture returns a buggy thermostat.
def buggy_thermostat_fixture(device_factory): """Fixture returns a buggy thermostat.""" device = device_factory( "Buggy Thermostat", capabilities=[ Capability.temperature_measurement, Capability.thermostat_cooling_setpoint, Capability.thermostat_heating_setpoi...
[ "def", "buggy_thermostat_fixture", "(", "device_factory", ")", ":", "device", "=", "device_factory", "(", "\"Buggy Thermostat\"", ",", "capabilities", "=", "[", "Capability", ".", "temperature_measurement", ",", "Capability", ".", "thermostat_cooling_setpoint", ",", "Ca...
[ 129, 0 ]
[ 146, 17 ]
python
en
['en', 'en', 'en']
True