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
AlarmDecoderSensor.__init__
(self)
Initialize the alarm panel.
Initialize the alarm panel.
def __init__(self): """Initialize the alarm panel.""" self._display = "" self._state = None self._icon = "mdi:alarm-check" self._name = "Alarm Panel Display"
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "_display", "=", "\"\"", "self", ".", "_state", "=", "None", "self", ".", "_icon", "=", "\"mdi:alarm-check\"", "self", ".", "_name", "=", "\"Alarm Panel Display\"" ]
[ 21, 4 ]
[ 26, 42 ]
python
en
['en', 'en', 'en']
True
AlarmDecoderSensor.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self): """Register callbacks.""" self.async_on_remove( self.hass.helpers.dispatcher.async_dispatcher_connect( SIGNAL_PANEL_MESSAGE, self._message_callback ) )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "self", ".", "hass", ".", "helpers", ".", "dispatcher", ".", "async_dispatcher_connect", "(", "SIGNAL_PANEL_MESSAGE", ",", "self", ".", "_message_callback", ")", "...
[ 28, 4 ]
[ 34, 9 ]
python
en
['en', 'no', 'en']
False
AlarmDecoderSensor.icon
(self)
Return the icon if any.
Return the icon if any.
def icon(self): """Return the icon if any.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 42, 4 ]
[ 44, 25 ]
python
en
['en', 'en', 'en']
True
AlarmDecoderSensor.state
(self)
Return the overall state.
Return the overall state.
def state(self): """Return the overall state.""" return self._display
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_display" ]
[ 47, 4 ]
[ 49, 28 ]
python
en
['en', 'en', 'en']
True
AlarmDecoderSensor.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 52, 4 ]
[ 54, 25 ]
python
en
['en', 'en', 'en']
True
AlarmDecoderSensor.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 57, 4 ]
[ 59, 20 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Flo sensors from config entry.
Set up the Flo sensors from config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Flo sensors from config entry.""" devices: List[FloDeviceDataUpdateCoordinator] = hass.data[FLO_DOMAIN][ config_entry.entry_id ]["devices"] entities = [FloPendingAlertsBinarySensor(device) for device in devices] ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "devices", ":", "List", "[", "FloDeviceDataUpdateCoordinator", "]", "=", "hass", ".", "data", "[", "FLO_DOMAIN", "]", "[", "config_entry", ".", "entry_id"...
[ 14, 0 ]
[ 20, 32 ]
python
en
['en', 'en', 'en']
True
FloPendingAlertsBinarySensor.__init__
(self, device)
Initialize the pending alerts binary sensor.
Initialize the pending alerts binary sensor.
def __init__(self, device): """Initialize the pending alerts binary sensor.""" super().__init__("pending_system_alerts", "Pending System Alerts", device)
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "super", "(", ")", ".", "__init__", "(", "\"pending_system_alerts\"", ",", "\"Pending System Alerts\"", ",", "device", ")" ]
[ 26, 4 ]
[ 28, 82 ]
python
en
['en', 'en', 'en']
True
FloPendingAlertsBinarySensor.is_on
(self)
Return true if the Flo device has pending alerts.
Return true if the Flo device has pending alerts.
def is_on(self): """Return true if the Flo device has pending alerts.""" return self._device.has_alerts
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "has_alerts" ]
[ 31, 4 ]
[ 33, 38 ]
python
en
['en', 'en', 'en']
True
FloPendingAlertsBinarySensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" if not self._device.has_alerts: return {} return { "info": self._device.pending_info_alerts_count, "warning": self._device.pending_warning_alerts_count, "critical": self._device....
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "not", "self", ".", "_device", ".", "has_alerts", ":", "return", "{", "}", "return", "{", "\"info\"", ":", "self", ".", "_device", ".", "pending_info_alerts_count", ",", "\"warning\"", ":", "self...
[ 36, 4 ]
[ 44, 9 ]
python
en
['en', 'en', 'en']
True
FloPendingAlertsBinarySensor.device_class
(self)
Return the device class for the binary sensor.
Return the device class for the binary sensor.
def device_class(self): """Return the device class for the binary sensor.""" return DEVICE_CLASS_PROBLEM
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_PROBLEM" ]
[ 47, 4 ]
[ 49, 35 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the London Air sensor.
Set up the London Air sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the London Air sensor.""" data = APIData() data.update() sensors = [] for name in config.get(CONF_LOCATIONS): sensors.append(AirSensor(name, data)) add_entities(sensors, True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "data", "=", "APIData", "(", ")", "data", ".", "update", "(", ")", "sensors", "=", "[", "]", "for", "name", "in", "config", ".", "...
[ 63, 0 ]
[ 71, 31 ]
python
en
['en', 'su', 'en']
True
parse_species
(species_data)
Iterate over list of species at each site.
Iterate over list of species at each site.
def parse_species(species_data): """Iterate over list of species at each site.""" parsed_species_data = [] quality_list = [] for species in species_data: if species["@AirQualityBand"] != "No data": species_dict = {} species_dict["description"] = species["@SpeciesDescripti...
[ "def", "parse_species", "(", "species_data", ")", ":", "parsed_species_data", "=", "[", "]", "quality_list", "=", "[", "]", "for", "species", "in", "species_data", ":", "if", "species", "[", "\"@AirQualityBand\"", "]", "!=", "\"No data\"", ":", "species_dict", ...
[ 151, 0 ]
[ 167, 44 ]
python
en
['en', 'en', 'en']
True
parse_site
(entry_sites_data)
Iterate over all sites at an authority.
Iterate over all sites at an authority.
def parse_site(entry_sites_data): """Iterate over all sites at an authority.""" authority_data = [] for site in entry_sites_data: site_data = {} species_data = [] site_data["updated"] = site["@BulletinDate"] site_data["latitude"] = site["@Latitude"] site_data["longit...
[ "def", "parse_site", "(", "entry_sites_data", ")", ":", "authority_data", "=", "[", "]", "for", "site", "in", "entry_sites_data", ":", "site_data", "=", "{", "}", "species_data", "=", "[", "]", "site_data", "[", "\"updated\"", "]", "=", "site", "[", "\"@Bu...
[ 170, 0 ]
[ 205, 25 ]
python
en
['en', 'en', 'en']
True
parse_api_response
(response)
Parse return dict or list of data from API.
Parse return dict or list of data from API.
def parse_api_response(response): """Parse return dict or list of data from API.""" data = dict.fromkeys(AUTHORITIES) for authority in AUTHORITIES: for entry in response["HourlyAirQualityIndex"]["LocalAuthority"]: if entry["@LocalAuthorityName"] == authority: if isinstan...
[ "def", "parse_api_response", "(", "response", ")", ":", "data", "=", "dict", ".", "fromkeys", "(", "AUTHORITIES", ")", "for", "authority", "in", "AUTHORITIES", ":", "for", "entry", "in", "response", "[", "\"HourlyAirQualityIndex\"", "]", "[", "\"LocalAuthority\"...
[ 208, 0 ]
[ 222, 15 ]
python
en
['en', 'en', 'en']
True
APIData.__init__
(self)
Initialize the AirData object.
Initialize the AirData object.
def __init__(self): """Initialize the AirData object.""" self.data = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "data", "=", "None" ]
[ 77, 4 ]
[ 79, 24 ]
python
en
['en', 'en', 'en']
True
APIData.update
(self)
Get the latest data from TFL.
Get the latest data from TFL.
def update(self): """Get the latest data from TFL.""" response = requests.get(URL, timeout=10) if response.status_code != HTTP_OK: _LOGGER.warning("Invalid response from API") else: self.data = parse_api_response(response.json())
[ "def", "update", "(", "self", ")", ":", "response", "=", "requests", ".", "get", "(", "URL", ",", "timeout", "=", "10", ")", "if", "response", ".", "status_code", "!=", "HTTP_OK", ":", "_LOGGER", ".", "warning", "(", "\"Invalid response from API\"", ")", ...
[ 83, 4 ]
[ 89, 59 ]
python
en
['en', 'en', 'en']
True
AirSensor.__init__
(self, name, APIdata)
Initialize the sensor.
Initialize the sensor.
def __init__(self, name, APIdata): """Initialize the sensor.""" self._name = name self._api_data = APIdata self._site_data = None self._state = None self._updated = None
[ "def", "__init__", "(", "self", ",", "name", ",", "APIdata", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_api_data", "=", "APIdata", "self", ".", "_site_data", "=", "None", "self", ".", "_state", "=", "None", "self", ".", "_updated", "...
[ 97, 4 ]
[ 103, 28 ]
python
en
['en', 'en', 'en']
True
AirSensor.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" ]
[ 106, 4 ]
[ 108, 25 ]
python
en
['en', 'mi', 'en']
True
AirSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 111, 4 ]
[ 113, 26 ]
python
en
['en', 'en', 'en']
True
AirSensor.site_data
(self)
Return the dict of sites data.
Return the dict of sites data.
def site_data(self): """Return the dict of sites data.""" return self._site_data
[ "def", "site_data", "(", "self", ")", ":", "return", "self", ".", "_site_data" ]
[ 116, 4 ]
[ 118, 30 ]
python
en
['en', 'la', 'en']
True
AirSensor.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 self.ICON
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "ICON" ]
[ 121, 4 ]
[ 123, 24 ]
python
en
['en', 'en', 'en']
True
AirSensor.device_state_attributes
(self)
Return other details about the sensor state.
Return other details about the sensor state.
def device_state_attributes(self): """Return other details about the sensor state.""" attrs = {} attrs["updated"] = self._updated attrs["sites"] = len(self._site_data) if self._site_data is not None else 0 attrs["data"] = self._site_data return attrs
[ "def", "device_state_attributes", "(", "self", ")", ":", "attrs", "=", "{", "}", "attrs", "[", "\"updated\"", "]", "=", "self", ".", "_updated", "attrs", "[", "\"sites\"", "]", "=", "len", "(", "self", ".", "_site_data", ")", "if", "self", ".", "_site_...
[ 126, 4 ]
[ 132, 20 ]
python
en
['en', 'en', 'en']
True
AirSensor.update
(self)
Update the sensor.
Update the sensor.
def update(self): """Update the sensor.""" sites_status = [] self._api_data.update() if self._api_data.data: self._site_data = self._api_data.data[self._name] self._updated = self._site_data[0]["updated"] for site in self._site_data: if...
[ "def", "update", "(", "self", ")", ":", "sites_status", "=", "[", "]", "self", ".", "_api_data", ".", "update", "(", ")", "if", "self", ".", "_api_data", ".", "data", ":", "self", ".", "_site_data", "=", "self", ".", "_api_data", ".", "data", "[", ...
[ 134, 4 ]
[ 148, 30 ]
python
en
['en', 'nl', 'en']
True
test_fanentity
()
Test fan entity methods.
Test fan entity methods.
def test_fanentity(): """Test fan entity methods.""" fan = BaseFan() assert fan.state == "off" assert len(fan.speed_list) == 0 assert fan.supported_features == 0 assert fan.capability_attributes == {} # Test set_speed not required with pytest.raises(NotImplementedError): fan.osci...
[ "def", "test_fanentity", "(", ")", ":", "fan", "=", "BaseFan", "(", ")", "assert", "fan", ".", "state", "==", "\"off\"", "assert", "len", "(", "fan", ".", "speed_list", ")", "==", "0", "assert", "fan", ".", "supported_features", "==", "0", "assert", "f...
[ 14, 0 ]
[ 29, 22 ]
python
en
['en', 'fy', 'en']
True
BaseFan.__init__
(self)
Initialize the fan.
Initialize the fan.
def __init__(self): """Initialize the fan."""
[ "def", "__init__", "(", "self", ")", ":" ]
[ 10, 4 ]
[ 11, 33 ]
python
en
['en', 'fy', 'en']
True
test_config_with_sensor_passed_to_config_entry
(hass)
Test that configured options for a sensor are loaded.
Test that configured options for a sensor are loaded.
async def test_config_with_sensor_passed_to_config_entry(hass): """Test that configured options for a sensor are loaded.""" conf = { CONF_SENSOR_ID: "12345abcde", CONF_SHOW_ON_MAP: False, CONF_SCAN_INTERVAL: 600, } with patch.object( hass.config_entries.flow, "async_init...
[ "async", "def", "test_config_with_sensor_passed_to_config_entry", "(", "hass", ")", ":", "conf", "=", "{", "CONF_SENSOR_ID", ":", "\"12345abcde\"", ",", "CONF_SHOW_ON_MAP", ":", "False", ",", "CONF_SCAN_INTERVAL", ":", "600", ",", "}", "with", "patch", ".", "objec...
[ 9, 0 ]
[ 24, 56 ]
python
en
['en', 'en', 'en']
True
test_config_already_registered_not_passed_to_config_entry
(hass)
Test that an already registered sensor does not initiate an import.
Test that an already registered sensor does not initiate an import.
async def test_config_already_registered_not_passed_to_config_entry(hass): """Test that an already registered sensor does not initiate an import.""" conf = {CONF_SENSOR_ID: "12345abcde"} with patch.object( hass.config_entries.flow, "async_init" ) as mock_config_entries, patch.object( lu...
[ "async", "def", "test_config_already_registered_not_passed_to_config_entry", "(", "hass", ")", ":", "conf", "=", "{", "CONF_SENSOR_ID", ":", "\"12345abcde\"", "}", "with", "patch", ".", "object", "(", "hass", ".", "config_entries", ".", "flow", ",", "\"async_init\""...
[ 27, 0 ]
[ 38, 56 ]
python
en
['en', 'en', 'en']
True
test_invalid_pairing_codes
(pairing_code)
Test ensure_pin_format raises for an invalid pin code.
Test ensure_pin_format raises for an invalid pin code.
def test_invalid_pairing_codes(pairing_code): """Test ensure_pin_format raises for an invalid pin code.""" with pytest.raises(aiohomekit.exceptions.MalformedPinError): config_flow.ensure_pin_format(pairing_code)
[ "def", "test_invalid_pairing_codes", "(", "pairing_code", ")", ":", "with", "pytest", ".", "raises", "(", "aiohomekit", ".", "exceptions", ".", "MalformedPinError", ")", ":", "config_flow", ".", "ensure_pin_format", "(", "pairing_code", ")" ]
[ 89, 0 ]
[ 92, 51 ]
python
en
['en', 'en', 'en']
True
test_valid_pairing_codes
(pairing_code)
Test ensure_pin_format corrects format for a valid pin in an alternative format.
Test ensure_pin_format corrects format for a valid pin in an alternative format.
def test_valid_pairing_codes(pairing_code): """Test ensure_pin_format corrects format for a valid pin in an alternative format.""" valid_pin = config_flow.ensure_pin_format(pairing_code).split("-") assert len(valid_pin) == 3 assert len(valid_pin[0]) == 3 assert len(valid_pin[1]) == 2 assert len(...
[ "def", "test_valid_pairing_codes", "(", "pairing_code", ")", ":", "valid_pin", "=", "config_flow", ".", "ensure_pin_format", "(", "pairing_code", ")", ".", "split", "(", "\"-\"", ")", "assert", "len", "(", "valid_pin", ")", "==", "3", "assert", "len", "(", "...
[ 96, 0 ]
[ 102, 33 ]
python
en
['en', 'en', 'en']
True
get_flow_context
(hass, result)
Get the flow context from the result of async_init or async_configure.
Get the flow context from the result of async_init or async_configure.
def get_flow_context(hass, result): """Get the flow context from the result of async_init or async_configure.""" flow = next( flow for flow in hass.config_entries.flow.async_progress() if flow["flow_id"] == result["flow_id"] ) return flow["context"]
[ "def", "get_flow_context", "(", "hass", ",", "result", ")", ":", "flow", "=", "next", "(", "flow", "for", "flow", "in", "hass", ".", "config_entries", ".", "flow", ".", "async_progress", "(", ")", "if", "flow", "[", "\"flow_id\"", "]", "==", "result", ...
[ 105, 0 ]
[ 113, 26 ]
python
en
['en', 'en', 'en']
True
get_device_discovery_info
(device, upper_case_props=False, missing_csharp=False)
Turn a aiohomekit format zeroconf entry into a homeassistant one.
Turn a aiohomekit format zeroconf entry into a homeassistant one.
def get_device_discovery_info(device, upper_case_props=False, missing_csharp=False): """Turn a aiohomekit format zeroconf entry into a homeassistant one.""" record = device.info result = { "host": record["address"], "port": record["port"], "hostname": record["name"], "type": ...
[ "def", "get_device_discovery_info", "(", "device", ",", "upper_case_props", "=", "False", ",", "missing_csharp", "=", "False", ")", ":", "record", "=", "device", ".", "info", "result", "=", "{", "\"host\"", ":", "record", "[", "\"address\"", "]", ",", "\"por...
[ 116, 0 ]
[ 146, 17 ]
python
en
['en', 'en', 'en']
True
setup_mock_accessory
(controller)
Add a bridge accessory to a test controller.
Add a bridge accessory to a test controller.
def setup_mock_accessory(controller): """Add a bridge accessory to a test controller.""" bridge = Accessories() accessory = Accessory.create_with_info( name="Koogeek-LS1-20833F", manufacturer="Koogeek", model="LS1", serial_number="12345", firmware_revision="1.1", ...
[ "def", "setup_mock_accessory", "(", "controller", ")", ":", "bridge", "=", "Accessories", "(", ")", "accessory", "=", "Accessory", ".", "create_with_info", "(", "name", "=", "\"Koogeek-LS1-20833F\"", ",", "manufacturer", "=", "\"Koogeek\"", ",", "model", "=", "\...
[ 149, 0 ]
[ 167, 40 ]
python
en
['en', 'co', 'en']
True
test_discovery_works
(hass, controller, upper_case_props, missing_csharp)
Test a device being discovered.
Test a device being discovered.
async def test_discovery_works(hass, controller, upper_case_props, missing_csharp): """Test a device being discovered.""" device = setup_mock_accessory(controller) discovery_info = get_device_discovery_info(device, upper_case_props, missing_csharp) # Device is discovered result = await hass.config_...
[ "async", "def", "test_discovery_works", "(", "hass", ",", "controller", ",", "upper_case_props", ",", "missing_csharp", ")", ":", "device", "=", "setup_mock_accessory", "(", "controller", ")", "discovery_info", "=", "get_device_discovery_info", "(", "device", ",", "...
[ 172, 0 ]
[ 201, 31 ]
python
en
['de', 'en', 'en']
True
test_abort_duplicate_flow
(hass, controller)
Already paired.
Already paired.
async def test_abort_duplicate_flow(hass, controller): """Already paired.""" device = setup_mock_accessory(controller) discovery_info = get_device_discovery_info(device) # Device is discovered result = await hass.config_entries.flow.async_init( "homekit_controller", context={"source": "zero...
[ "async", "def", "test_abort_duplicate_flow", "(", "hass", ",", "controller", ")", ":", "device", "=", "setup_mock_accessory", "(", "controller", ")", "discovery_info", "=", "get_device_discovery_info", "(", "device", ")", "# Device is discovered", "result", "=", "awai...
[ 204, 0 ]
[ 220, 52 ]
python
en
['fr', 'en', 'en']
False
test_pair_already_paired_1
(hass, controller)
Already paired.
Already paired.
async def test_pair_already_paired_1(hass, controller): """Already paired.""" device = setup_mock_accessory(controller) discovery_info = get_device_discovery_info(device) # Flag device as already paired discovery_info["properties"]["sf"] = 0x0 # Device is discovered result = await hass.con...
[ "async", "def", "test_pair_already_paired_1", "(", "hass", ",", "controller", ")", ":", "device", "=", "setup_mock_accessory", "(", "controller", ")", "discovery_info", "=", "get_device_discovery_info", "(", "device", ")", "# Flag device as already paired", "discovery_inf...
[ 223, 0 ]
[ 236, 47 ]
python
en
['fr', 'en', 'en']
False
test_id_missing
(hass, controller)
Test id is missing.
Test id is missing.
async def test_id_missing(hass, controller): """Test id is missing.""" device = setup_mock_accessory(controller) discovery_info = get_device_discovery_info(device) # Remove id from device del discovery_info["properties"]["id"] # Device is discovered result = await hass.config_entries.flow....
[ "async", "def", "test_id_missing", "(", "hass", ",", "controller", ")", ":", "device", "=", "setup_mock_accessory", "(", "controller", ")", "discovery_info", "=", "get_device_discovery_info", "(", "device", ")", "# Remove id from device", "del", "discovery_info", "[",...
[ 239, 0 ]
[ 252, 51 ]
python
en
['en', 'en', 'en']
True
test_discovery_ignored_model
(hass, controller)
Already paired.
Already paired.
async def test_discovery_ignored_model(hass, controller): """Already paired.""" device = setup_mock_accessory(controller) discovery_info = get_device_discovery_info(device) config_entry = MockConfigEntry(domain=config_flow.HOMEKIT_BRIDGE_DOMAIN, data={}) formatted_mac = device_registry.format_mac("...
[ "async", "def", "test_discovery_ignored_model", "(", "hass", ",", "controller", ")", ":", "device", "=", "setup_mock_accessory", "(", "controller", ")", "discovery_info", "=", "get_device_discovery_info", "(", "device", ")", "config_entry", "=", "MockConfigEntry", "("...
[ 255, 0 ]
[ 284, 46 ]
python
en
['fr', 'en', 'en']
False
test_discovery_invalid_config_entry
(hass, controller)
There is already a config entry for the pairing id but it's invalid.
There is already a config entry for the pairing id but it's invalid.
async def test_discovery_invalid_config_entry(hass, controller): """There is already a config entry for the pairing id but it's invalid.""" MockConfigEntry( domain="homekit_controller", data={"AccessoryPairingID": "00:00:00:00:00:00"}, unique_id="00:00:00:00:00:00", ).add_to_hass(has...
[ "async", "def", "test_discovery_invalid_config_entry", "(", "hass", ",", "controller", ")", ":", "MockConfigEntry", "(", "domain", "=", "\"homekit_controller\"", ",", "data", "=", "{", "\"AccessoryPairingID\"", ":", "\"00:00:00:00:00:00\"", "}", ",", "unique_id", "=",...
[ 287, 0 ]
[ 313, 35 ]
python
en
['en', 'en', 'en']
True
test_discovery_already_configured
(hass, controller)
Already configured.
Already configured.
async def test_discovery_already_configured(hass, controller): """Already configured.""" MockConfigEntry( domain="homekit_controller", data={"AccessoryPairingID": "00:00:00:00:00:00"}, unique_id="00:00:00:00:00:00", ).add_to_hass(hass) device = setup_mock_accessory(controller) ...
[ "async", "def", "test_discovery_already_configured", "(", "hass", ",", "controller", ")", ":", "MockConfigEntry", "(", "domain", "=", "\"homekit_controller\"", ",", "data", "=", "{", "\"AccessoryPairingID\"", ":", "\"00:00:00:00:00:00\"", "}", ",", "unique_id", "=", ...
[ 316, 0 ]
[ 335, 51 ]
python
en
['en', 'gl', 'en']
False
test_pair_abort_errors_on_start
(hass, controller, exception, expected)
Test various pairing errors.
Test various pairing errors.
async def test_pair_abort_errors_on_start(hass, controller, exception, expected): """Test various pairing errors.""" device = setup_mock_accessory(controller) discovery_info = get_device_discovery_info(device) # Device is discovered result = await hass.config_entries.flow.async_init( "home...
[ "async", "def", "test_pair_abort_errors_on_start", "(", "hass", ",", "controller", ",", "exception", ",", "expected", ")", ":", "device", "=", "setup_mock_accessory", "(", "controller", ")", "discovery_info", "=", "get_device_discovery_info", "(", "device", ")", "# ...
[ 339, 0 ]
[ 355, 39 ]
python
en
['en', 'jv', 'en']
True
test_pair_try_later_errors_on_start
(hass, controller, exception, expected)
Test various pairing errors.
Test various pairing errors.
async def test_pair_try_later_errors_on_start(hass, controller, exception, expected): """Test various pairing errors.""" device = setup_mock_accessory(controller) discovery_info = get_device_discovery_info(device) # Device is discovered result = await hass.config_entries.flow.async_init( "...
[ "async", "def", "test_pair_try_later_errors_on_start", "(", "hass", ",", "controller", ",", "exception", ",", "expected", ")", ":", "device", "=", "setup_mock_accessory", "(", "controller", ")", "discovery_info", "=", "get_device_discovery_info", "(", "device", ")", ...
[ 359, 0 ]
[ 390, 51 ]
python
en
['en', 'jv', 'en']
True
test_pair_form_errors_on_start
(hass, controller, exception, expected)
Test various pairing errors.
Test various pairing errors.
async def test_pair_form_errors_on_start(hass, controller, exception, expected): """Test various pairing errors.""" device = setup_mock_accessory(controller) discovery_info = get_device_discovery_info(device) # Device is discovered result = await hass.config_entries.flow.async_init( "homek...
[ "async", "def", "test_pair_form_errors_on_start", "(", "hass", ",", "controller", ",", "exception", ",", "expected", ")", ":", "device", "=", "setup_mock_accessory", "(", "controller", ")", "discovery_info", "=", "get_device_discovery_info", "(", "device", ")", "# D...
[ 394, 0 ]
[ 439, 50 ]
python
en
['en', 'jv', 'en']
True
test_pair_abort_errors_on_finish
(hass, controller, exception, expected)
Test various pairing errors.
Test various pairing errors.
async def test_pair_abort_errors_on_finish(hass, controller, exception, expected): """Test various pairing errors.""" device = setup_mock_accessory(controller) discovery_info = get_device_discovery_info(device) # Device is discovered result = await hass.config_entries.flow.async_init( "home...
[ "async", "def", "test_pair_abort_errors_on_finish", "(", "hass", ",", "controller", ",", "exception", ",", "expected", ")", ":", "device", "=", "setup_mock_accessory", "(", "controller", ")", "discovery_info", "=", "get_device_discovery_info", "(", "device", ")", "#...
[ 443, 0 ]
[ 479, 39 ]
python
en
['en', 'jv', 'en']
True
test_pair_form_errors_on_finish
(hass, controller, exception, expected)
Test various pairing errors.
Test various pairing errors.
async def test_pair_form_errors_on_finish(hass, controller, exception, expected): """Test various pairing errors.""" device = setup_mock_accessory(controller) discovery_info = get_device_discovery_info(device) # Device is discovered result = await hass.config_entries.flow.async_init( "homek...
[ "async", "def", "test_pair_form_errors_on_finish", "(", "hass", ",", "controller", ",", "exception", ",", "expected", ")", ":", "device", "=", "setup_mock_accessory", "(", "controller", ")", "discovery_info", "=", "get_device_discovery_info", "(", "device", ")", "# ...
[ 483, 0 ]
[ 526, 5 ]
python
en
['en', 'jv', 'en']
True
test_user_works
(hass, controller)
Test user initiated disovers devices.
Test user initiated disovers devices.
async def test_user_works(hass, controller): """Test user initiated disovers devices.""" setup_mock_accessory(controller) # Device is discovered result = await hass.config_entries.flow.async_init( "homekit_controller", context={"source": "user"} ) assert result["type"] == "form" as...
[ "async", "def", "test_user_works", "(", "hass", ",", "controller", ")", ":", "setup_mock_accessory", "(", "controller", ")", "# Device is discovered", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "\"homekit_controller\"...
[ 529, 0 ]
[ 560, 50 ]
python
en
['fr', 'en', 'en']
True
test_user_no_devices
(hass, controller)
Test user initiated pairing where no devices discovered.
Test user initiated pairing where no devices discovered.
async def test_user_no_devices(hass, controller): """Test user initiated pairing where no devices discovered.""" result = await hass.config_entries.flow.async_init( "homekit_controller", context={"source": "user"} ) assert result["type"] == "abort" assert result["reason"] == "no_devices"
[ "async", "def", "test_user_no_devices", "(", "hass", ",", "controller", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "\"homekit_controller\"", ",", "context", "=", "{", "\"source\"", ":", "\"user\"", "}"...
[ 563, 0 ]
[ 569, 43 ]
python
en
['en', 'en', 'en']
True
test_user_no_unpaired_devices
(hass, controller)
Test user initiated pairing where no unpaired devices discovered.
Test user initiated pairing where no unpaired devices discovered.
async def test_user_no_unpaired_devices(hass, controller): """Test user initiated pairing where no unpaired devices discovered.""" device = setup_mock_accessory(controller) # Pair the mock device so that it shows as paired in discovery finish_pairing = await device.start_pairing(device.device_id) a...
[ "async", "def", "test_user_no_unpaired_devices", "(", "hass", ",", "controller", ")", ":", "device", "=", "setup_mock_accessory", "(", "controller", ")", "# Pair the mock device so that it shows as paired in discovery", "finish_pairing", "=", "await", "device", ".", "start_...
[ 572, 0 ]
[ 586, 43 ]
python
en
['en', 'en', 'en']
True
test_unignore_works
(hass, controller)
Test rediscovery triggered disovers work.
Test rediscovery triggered disovers work.
async def test_unignore_works(hass, controller): """Test rediscovery triggered disovers work.""" device = setup_mock_accessory(controller) # Device is unignored result = await hass.config_entries.flow.async_init( "homekit_controller", context={"source": "unignore"}, data={"uniqu...
[ "async", "def", "test_unignore_works", "(", "hass", ",", "controller", ")", ":", "device", "=", "setup_mock_accessory", "(", "controller", ")", "# Device is unignored", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "...
[ 589, 0 ]
[ 618, 50 ]
python
en
['en', 'en', 'en']
True
test_unignore_ignores_missing_devices
(hass, controller)
Test rediscovery triggered disovers handle devices that have gone away.
Test rediscovery triggered disovers handle devices that have gone away.
async def test_unignore_ignores_missing_devices(hass, controller): """Test rediscovery triggered disovers handle devices that have gone away.""" setup_mock_accessory(controller) # Device is unignored result = await hass.config_entries.flow.async_init( "homekit_controller", context={"sou...
[ "async", "def", "test_unignore_ignores_missing_devices", "(", "hass", ",", "controller", ")", ":", "setup_mock_accessory", "(", "controller", ")", "# Device is unignored", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "\...
[ 621, 0 ]
[ 633, 43 ]
python
en
['en', 'en', 'en']
True
get_service
(hass, config, discovery_info=None)
Get the Ecobee notification service.
Get the Ecobee notification service.
def get_service(hass, config, discovery_info=None): """Get the Ecobee notification service.""" data = hass.data[DOMAIN] index = config.get(CONF_INDEX) return EcobeeNotificationService(data, index)
[ "def", "get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "index", "=", "config", ".", "get", "(", "CONF_INDEX", ")", "return", "EcobeeNotificationService", "(", ...
[ 13, 0 ]
[ 17, 49 ]
python
en
['en', 'en', 'en']
True
EcobeeNotificationService.__init__
(self, data, thermostat_index)
Initialize the service.
Initialize the service.
def __init__(self, data, thermostat_index): """Initialize the service.""" self.data = data self.thermostat_index = thermostat_index
[ "def", "__init__", "(", "self", ",", "data", ",", "thermostat_index", ")", ":", "self", ".", "data", "=", "data", "self", ".", "thermostat_index", "=", "thermostat_index" ]
[ 23, 4 ]
[ 26, 48 ]
python
en
['en', 'en', 'en']
True
EcobeeNotificationService.send_message
(self, message="", **kwargs)
Send a message.
Send a message.
def send_message(self, message="", **kwargs): """Send a message.""" self.data.ecobee.send_message(self.thermostat_index, message)
[ "def", "send_message", "(", "self", ",", "message", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "self", ".", "data", ".", "ecobee", ".", "send_message", "(", "self", ".", "thermostat_index", ",", "message", ")" ]
[ 28, 4 ]
[ 30, 69 ]
python
en
['en', 'lb', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], )
Set up Canary sensors based on a config entry.
Set up Canary sensors based on a config entry.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], ) -> None: """Set up Canary sensors based on a config entry.""" coordinator: CanaryDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id][ DATA_COORDINATOR ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", "[", "[", "List", "[", "Entity", "]", ",", "bool", "]", ",", "None", "]", ",", ")", "->", "None", ":...
[ 43, 0 ]
[ 71, 37 ]
python
en
['en', 'en', 'en']
True
CanaryCamera.__init__
(self, hass, coordinator, location_id, device, timeout, ffmpeg_args)
Initialize a Canary security camera.
Initialize a Canary security camera.
def __init__(self, hass, coordinator, location_id, device, timeout, ffmpeg_args): """Initialize a Canary security camera.""" super().__init__(coordinator) Camera.__init__(self) self._ffmpeg = hass.data[DATA_FFMPEG] self._ffmpeg_arguments = ffmpeg_args self._location_id = ...
[ "def", "__init__", "(", "self", ",", "hass", ",", "coordinator", ",", "location_id", ",", "device", ",", "timeout", ",", "ffmpeg_args", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "Camera", ".", "__init__", "(", "self", ")", ...
[ 77, 4 ]
[ 89, 40 ]
python
en
['en', 'en', 'en']
True
CanaryCamera.location
(self)
Return information about the location.
Return information about the location.
def location(self): """Return information about the location.""" return self.coordinator.data["locations"][self._location_id]
[ "def", "location", "(", "self", ")", ":", "return", "self", ".", "coordinator", ".", "data", "[", "\"locations\"", "]", "[", "self", ".", "_location_id", "]" ]
[ 92, 4 ]
[ 94, 68 ]
python
en
['en', 'en', 'en']
True
CanaryCamera.name
(self)
Return the name of this device.
Return the name of this device.
def name(self): """Return the name of this device.""" return self._device_name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_device_name" ]
[ 97, 4 ]
[ 99, 32 ]
python
en
['en', 'en', 'en']
True
CanaryCamera.unique_id
(self)
Return the unique ID of this camera.
Return the unique ID of this camera.
def unique_id(self): """Return the unique ID of this camera.""" return str(self._device_id)
[ "def", "unique_id", "(", "self", ")", ":", "return", "str", "(", "self", ".", "_device_id", ")" ]
[ 102, 4 ]
[ 104, 35 ]
python
en
['en', 'la', 'en']
True
CanaryCamera.device_info
(self)
Return the device_info of the device.
Return the device_info of the device.
def device_info(self): """Return the device_info of the device.""" return { "identifiers": {(DOMAIN, str(self._device_id))}, "name": self._device_name, "model": self._device_type_name, "manufacturer": MANUFACTURER, }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "str", "(", "self", ".", "_device_id", ")", ")", "}", ",", "\"name\"", ":", "self", ".", "_device_name", ",", "\"model\"", ":", "self", ".", ...
[ 107, 4 ]
[ 114, 9 ]
python
en
['en', 'en', 'en']
True
CanaryCamera.is_recording
(self)
Return true if the device is recording.
Return true if the device is recording.
def is_recording(self): """Return true if the device is recording.""" return self.location.is_recording
[ "def", "is_recording", "(", "self", ")", ":", "return", "self", ".", "location", ".", "is_recording" ]
[ 117, 4 ]
[ 119, 41 ]
python
en
['en', 'en', 'en']
True
CanaryCamera.motion_detection_enabled
(self)
Return the camera motion detection status.
Return the camera motion detection status.
def motion_detection_enabled(self): """Return the camera motion detection status.""" return not self.location.is_recording
[ "def", "motion_detection_enabled", "(", "self", ")", ":", "return", "not", "self", ".", "location", ".", "is_recording" ]
[ 122, 4 ]
[ 124, 45 ]
python
en
['en', 'en', 'en']
True
CanaryCamera.async_camera_image
(self)
Return a still image response from the camera.
Return a still image response from the camera.
async def async_camera_image(self): """Return a still image response from the camera.""" await self.hass.async_add_executor_job(self.renew_live_stream_session) ffmpeg = ImageFrame(self._ffmpeg.binary, loop=self.hass.loop) image = await asyncio.shield( ffmpeg.get_image( ...
[ "async", "def", "async_camera_image", "(", "self", ")", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "renew_live_stream_session", ")", "ffmpeg", "=", "ImageFrame", "(", "self", ".", "_ffmpeg", ".", "binary", ",", "loop", ...
[ 126, 4 ]
[ 138, 20 ]
python
en
['en', 'en', 'en']
True
CanaryCamera.handle_async_mjpeg_stream
(self, request)
Generate an HTTP MJPEG stream from the camera.
Generate an HTTP MJPEG stream from the camera.
async def handle_async_mjpeg_stream(self, request): """Generate an HTTP MJPEG stream from the camera.""" if self._live_stream_session is None: return stream = CameraMjpeg(self._ffmpeg.binary, loop=self.hass.loop) await stream.open_camera( self._live_stream_sessio...
[ "async", "def", "handle_async_mjpeg_stream", "(", "self", ",", "request", ")", ":", "if", "self", ".", "_live_stream_session", "is", "None", ":", "return", "stream", "=", "CameraMjpeg", "(", "self", ".", "_ffmpeg", ".", "binary", ",", "loop", "=", "self", ...
[ 140, 4 ]
[ 159, 32 ]
python
en
['en', 'en', 'en']
True
CanaryCamera.renew_live_stream_session
(self)
Renew live stream session.
Renew live stream session.
def renew_live_stream_session(self): """Renew live stream session.""" self._live_stream_session = self.coordinator.canary.get_live_stream_session( self._device )
[ "def", "renew_live_stream_session", "(", "self", ")", ":", "self", ".", "_live_stream_session", "=", "self", ".", "coordinator", ".", "canary", ".", "get_live_stream_session", "(", "self", ".", "_device", ")" ]
[ 162, 4 ]
[ 166, 9 ]
python
en
['en', 'sr', 'en']
True
async_setup_services
(hass)
Set up services for deCONZ integration.
Set up services for deCONZ integration.
async def async_setup_services(hass): """Set up services for deCONZ integration.""" if hass.data.get(DECONZ_SERVICES, False): return hass.data[DECONZ_SERVICES] = True async def async_call_deconz_service(service_call): """Call correct deCONZ service.""" service = service_call.se...
[ "async", "def", "async_setup_services", "(", "hass", ")", ":", "if", "hass", ".", "data", ".", "get", "(", "DECONZ_SERVICES", ",", "False", ")", ":", "return", "hass", ".", "data", "[", "DECONZ_SERVICES", "]", "=", "True", "async", "def", "async_call_decon...
[ 46, 0 ]
[ 86, 5 ]
python
en
['en', 'fr', 'en']
True
async_unload_services
(hass)
Unload deCONZ services.
Unload deCONZ services.
async def async_unload_services(hass): """Unload deCONZ services.""" if not hass.data.get(DECONZ_SERVICES): return hass.data[DECONZ_SERVICES] = False hass.services.async_remove(DOMAIN, SERVICE_CONFIGURE_DEVICE) hass.services.async_remove(DOMAIN, SERVICE_DEVICE_REFRESH) hass.services.as...
[ "async", "def", "async_unload_services", "(", "hass", ")", ":", "if", "not", "hass", ".", "data", ".", "get", "(", "DECONZ_SERVICES", ")", ":", "return", "hass", ".", "data", "[", "DECONZ_SERVICES", "]", "=", "False", "hass", ".", "services", ".", "async...
[ 89, 0 ]
[ 98, 71 ]
python
fr
['es', 'fr', 'fr']
True
async_configure_service
(hass, data)
Set attribute of device in deCONZ. Entity is used to resolve to a device path (e.g. '/lights/1'). Field is a string representing either a full path (e.g. '/lights/1/state') when entity is not specified, or a subpath (e.g. '/state') when used together with entity. Data is a json object with what dat...
Set attribute of device in deCONZ.
async def async_configure_service(hass, data): """Set attribute of device in deCONZ. Entity is used to resolve to a device path (e.g. '/lights/1'). Field is a string representing either a full path (e.g. '/lights/1/state') when entity is not specified, or a subpath (e.g. '/state') when used togethe...
[ "async", "def", "async_configure_service", "(", "hass", ",", "data", ")", ":", "gateway", "=", "get_master_gateway", "(", "hass", ")", "if", "CONF_BRIDGE_ID", "in", "data", ":", "gateway", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "normalize_bridge_...
[ 101, 0 ]
[ 132, 54 ]
python
en
['en', 'en', 'en']
True
async_refresh_devices_service
(hass, data)
Refresh available devices from deCONZ.
Refresh available devices from deCONZ.
async def async_refresh_devices_service(hass, data): """Refresh available devices from deCONZ.""" gateway = get_master_gateway(hass) if CONF_BRIDGE_ID in data: gateway = hass.data[DOMAIN][normalize_bridge_id(data[CONF_BRIDGE_ID])] gateway.ignore_state_updates = True await gateway.api.refres...
[ "async", "def", "async_refresh_devices_service", "(", "hass", ",", "data", ")", ":", "gateway", "=", "get_master_gateway", "(", "hass", ")", "if", "CONF_BRIDGE_ID", "in", "data", ":", "gateway", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "normalize_b...
[ 135, 0 ]
[ 148, 85 ]
python
en
['en', 'en', 'en']
True
async_remove_orphaned_entries_service
(hass, data)
Remove orphaned deCONZ entries from device and entity registries.
Remove orphaned deCONZ entries from device and entity registries.
async def async_remove_orphaned_entries_service(hass, data): """Remove orphaned deCONZ entries from device and entity registries.""" gateway = get_master_gateway(hass) if CONF_BRIDGE_ID in data: gateway = hass.data[DOMAIN][normalize_bridge_id(data[CONF_BRIDGE_ID])] entity_registry = await hass....
[ "async", "def", "async_remove_orphaned_entries_service", "(", "hass", ",", "data", ")", ":", "gateway", "=", "get_master_gateway", "(", "hass", ")", "if", "CONF_BRIDGE_ID", "in", "data", ":", "gateway", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "nor...
[ 151, 0 ]
[ 210, 58 ]
python
en
['en', 'en', 'en']
True
build_item_response
( client: XboxLiveClient, device_id: str, tv_configured: bool, media_content_type: str, media_content_id: str, )
Create response payload for the provided media query.
Create response payload for the provided media query.
async def build_item_response( client: XboxLiveClient, device_id: str, tv_configured: bool, media_content_type: str, media_content_id: str, ) -> Optional[BrowseMedia]: """Create response payload for the provided media query.""" apps: InstalledPackagesList = await client.smartglass.get_instal...
[ "async", "def", "build_item_response", "(", "client", ":", "XboxLiveClient", ",", "device_id", ":", "str", ",", "tv_configured", ":", "bool", ",", "media_content_type", ":", "str", ",", "media_content_id", ":", "str", ",", ")", "->", "Optional", "[", "BrowseMe...
[ 37, 0 ]
[ 148, 5 ]
python
en
['en', 'en', 'en']
True
item_payload
(item: InstalledPackage, images: Dict[str, List[Image]])
Create response payload for a single media item.
Create response payload for a single media item.
def item_payload(item: InstalledPackage, images: Dict[str, List[Image]]): """Create response payload for a single media item.""" thumbnail = None image = _find_media_image(images.get(item.one_store_product_id, [])) if image is not None: thumbnail = image.uri if thumbnail[0] == "/": ...
[ "def", "item_payload", "(", "item", ":", "InstalledPackage", ",", "images", ":", "Dict", "[", "str", ",", "List", "[", "Image", "]", "]", ")", ":", "thumbnail", "=", "None", "image", "=", "_find_media_image", "(", "images", ".", "get", "(", "item", "."...
[ 151, 0 ]
[ 168, 5 ]
python
en
['en', 'en', 'en']
True
DilutionFactor.compute
(self, variable_value, dataset, x0_input=None)
:param variable_value: :param dataset: :param x0_input: :return:
def compute(self, variable_value, dataset, x0_input=None): """ :param variable_value: :param dataset: :param x0_input: :return: """ return np.asarray(variable_value['d_factor'])
[ "def", "compute", "(", "self", ",", "variable_value", ",", "dataset", ",", "x0_input", "=", "None", ")", ":", "return", "np", ".", "asarray", "(", "variable_value", "[", "'d_factor'", "]", ")" ]
[ 49, 4 ]
[ 57, 53 ]
python
en
['en', 'error', 'th']
False
LocalDilutionFactor.compute
(self, variable_value, dataset, x0_input=None)
:param variable_value: :param dataset: :param x0_input: :return:
def compute(self, variable_value, dataset, x0_input=None): """ :param variable_value: :param dataset: :param x0_input: :return: """ return np.asarray(variable_value['d_factor'])
[ "def", "compute", "(", "self", ",", "variable_value", ",", "dataset", ",", "x0_input", "=", "None", ")", ":", "return", "np", ".", "asarray", "(", "variable_value", "[", "'d_factor'", "]", ")" ]
[ 91, 4 ]
[ 99, 53 ]
python
en
['en', 'error', 'th']
False
async_setup_entry
(hass, entry, async_add_entities)
Set up SimpliSafe binary sensors based on a config entry.
Set up SimpliSafe binary sensors based on a config entry.
async def async_setup_entry(hass, entry, async_add_entities): """Set up SimpliSafe binary sensors based on a config entry.""" simplisafe = hass.data[DOMAIN][DATA_CLIENT][entry.entry_id] sensors = [] for system in simplisafe.systems.values(): if system.version == 2: LOGGER.info("Skip...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "simplisafe", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_CLIENT", "]", "[", "entry", ".", "entry_id", "]", "sensors", "=", "[", "]", "for",...
[ 41, 0 ]
[ 64, 31 ]
python
en
['en', 'da', 'en']
True
TriggeredBinarySensor.__init__
(self, simplisafe, system, sensor, device_class)
Initialize.
Initialize.
def __init__(self, simplisafe, system, sensor, device_class): """Initialize.""" super().__init__(simplisafe, system, sensor) self._device_class = device_class self._is_on = False
[ "def", "__init__", "(", "self", ",", "simplisafe", ",", "system", ",", "sensor", ",", "device_class", ")", ":", "super", "(", ")", ".", "__init__", "(", "simplisafe", ",", "system", ",", "sensor", ")", "self", ".", "_device_class", "=", "device_class", "...
[ 70, 4 ]
[ 74, 27 ]
python
en
['en', 'en', 'it']
False
TriggeredBinarySensor.device_class
(self)
Return type of sensor.
Return type of sensor.
def device_class(self): """Return type of sensor.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 77, 4 ]
[ 79, 33 ]
python
en
['en', 'id', 'en']
True
TriggeredBinarySensor.is_on
(self)
Return true if the sensor is on.
Return true if the sensor is on.
def is_on(self): """Return true if the sensor is on.""" return self._is_on
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_is_on" ]
[ 82, 4 ]
[ 84, 26 ]
python
en
['en', 'et', 'en']
True
TriggeredBinarySensor.async_update_from_rest_api
(self)
Update the entity with the provided REST API data.
Update the entity with the provided REST API data.
def async_update_from_rest_api(self): """Update the entity with the provided REST API data.""" self._is_on = self._sensor.triggered
[ "def", "async_update_from_rest_api", "(", "self", ")", ":", "self", ".", "_is_on", "=", "self", ".", "_sensor", ".", "triggered" ]
[ 87, 4 ]
[ 89, 44 ]
python
en
['en', 'en', 'en']
True
BatteryBinarySensor.__init__
(self, simplisafe, system, sensor)
Initialize.
Initialize.
def __init__(self, simplisafe, system, sensor): """Initialize.""" super().__init__(simplisafe, system, sensor) self._is_low = False
[ "def", "__init__", "(", "self", ",", "simplisafe", ",", "system", ",", "sensor", ")", ":", "super", "(", ")", ".", "__init__", "(", "simplisafe", ",", "system", ",", "sensor", ")", "self", ".", "_is_low", "=", "False" ]
[ 95, 4 ]
[ 98, 28 ]
python
en
['en', 'en', 'it']
False
BatteryBinarySensor.device_class
(self)
Return type of sensor.
Return type of sensor.
def device_class(self): """Return type of sensor.""" return DEVICE_CLASS_BATTERY
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_BATTERY" ]
[ 101, 4 ]
[ 103, 35 ]
python
en
['en', 'id', 'en']
True
BatteryBinarySensor.unique_id
(self)
Return unique ID of sensor.
Return unique ID of sensor.
def unique_id(self): """Return unique ID of sensor.""" return f"{self._sensor.serial}-battery"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self._sensor.serial}-battery\"" ]
[ 106, 4 ]
[ 108, 47 ]
python
en
['en', 'la', 'en']
True
BatteryBinarySensor.is_on
(self)
Return true if the battery is low.
Return true if the battery is low.
def is_on(self): """Return true if the battery is low.""" return self._is_low
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_is_low" ]
[ 111, 4 ]
[ 113, 27 ]
python
en
['en', 'en', 'en']
True
BatteryBinarySensor.async_update_from_rest_api
(self)
Update the entity with the provided REST API data.
Update the entity with the provided REST API data.
def async_update_from_rest_api(self): """Update the entity with the provided REST API data.""" self._is_low = self._sensor.low_battery
[ "def", "async_update_from_rest_api", "(", "self", ")", ":", "self", ".", "_is_low", "=", "self", ".", "_sensor", ".", "low_battery" ]
[ 116, 4 ]
[ 118, 47 ]
python
en
['en', 'en', 'en']
True
init_sensors_fixture
(hass)
Set up things to be run when tests are started.
Set up things to be run when tests are started.
def init_sensors_fixture(hass): """Set up things to be run when tests are started.""" hass.states.async_set( "test.indoortemp", "20", {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS} ) hass.states.async_set( "test.outdoortemp", "10", {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS} ) hass.states...
[ "def", "init_sensors_fixture", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"test.indoortemp\"", ",", "\"20\"", ",", "{", "ATTR_UNIT_OF_MEASUREMENT", ":", "TEMP_CELSIUS", "}", ")", "hass", ".", "states", ".", "async_set", "(", "\"test...
[ 18, 0 ]
[ 28, 5 ]
python
en
['en', 'en', 'en']
True
test_setup
(hass)
Test the mold indicator sensor setup.
Test the mold indicator sensor setup.
async def test_setup(hass): """Test the mold indicator sensor setup.""" assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "mold_indicator", "indoor_temp_sensor": "test.indoortemp", "outdoor_temp_...
[ "async", "def", "test_setup", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"mold_indicator\"", ",", "\"indoor_temp_sensor\"", ":", "\"test.i...
[ 31, 0 ]
[ 49, 70 ]
python
en
['en', 'ceb', 'en']
True
test_invalidcalib
(hass)
Test invalid sensor values.
Test invalid sensor values.
async def test_invalidcalib(hass): """Test invalid sensor values.""" hass.states.async_set( "test.indoortemp", "10", {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS} ) hass.states.async_set( "test.outdoortemp", "10", {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS} ) hass.states.async_set( ...
[ "async", "def", "test_invalidcalib", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"test.indoortemp\"", ",", "\"10\"", ",", "{", "ATTR_UNIT_OF_MEASUREMENT", ":", "TEMP_CELSIUS", "}", ")", "hass", ".", "states", ".", "async_set", "(", ...
[ 52, 0 ]
[ 84, 61 ]
python
en
['en', 'et', 'en']
True
test_invalidhum
(hass)
Test invalid sensor values.
Test invalid sensor values.
async def test_invalidhum(hass): """Test invalid sensor values.""" hass.states.async_set( "test.indoortemp", "10", {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS} ) hass.states.async_set( "test.outdoortemp", "10", {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS} ) hass.states.async_set( ...
[ "async", "def", "test_invalidhum", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"test.indoortemp\"", ",", "\"10\"", ",", "{", "ATTR_UNIT_OF_MEASUREMENT", ":", "TEMP_CELSIUS", "}", ")", "hass", ".", "states", ".", "async_set", "(", "...
[ 87, 0 ]
[ 140, 61 ]
python
en
['en', 'et', 'en']
True
test_calculation
(hass)
Test the mold indicator internal calculations.
Test the mold indicator internal calculations.
async def test_calculation(hass): """Test the mold indicator internal calculations.""" assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "mold_indicator", "indoor_temp_sensor": "test.indoortemp", ...
[ "async", "def", "test_calculation", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"mold_indicator\"", ",", "\"indoor_temp_sensor\"", ":", "\"...
[ 143, 0 ]
[ 179, 24 ]
python
en
['en', 'en', 'en']
True
test_unknown_sensor
(hass)
Test the sensor_changed function.
Test the sensor_changed function.
async def test_unknown_sensor(hass): """Test the sensor_changed function.""" assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "mold_indicator", "indoor_temp_sensor": "test.indoortemp", "outdoor_...
[ "async", "def", "test_unknown_sensor", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"mold_indicator\"", ",", "\"indoor_temp_sensor\"", ":", ...
[ 182, 0 ]
[ 253, 26 ]
python
en
['en', 'en', 'en']
True
test_sensor_changed
(hass)
Test the sensor_changed function.
Test the sensor_changed function.
async def test_sensor_changed(hass): """Test the sensor_changed function.""" assert await async_setup_component( hass, sensor.DOMAIN, { "sensor": { "platform": "mold_indicator", "indoor_temp_sensor": "test.indoortemp", "outdoor_...
[ "async", "def", "test_sensor_changed", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"mold_indicator\"", ",", "\"indoor_temp_sensor\"", ":", ...
[ 256, 0 ]
[ 290, 65 ]
python
en
['en', 'en', 'en']
True
test_entities_none
()
Test entity ID policy.
Test entity ID policy.
def test_entities_none(): """Test entity ID policy.""" policy = None compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is False
[ "def", "test_entities_none", "(", ")", ":", "policy", "=", "None", "compiled", "=", "compile_entities", "(", "policy", ",", "None", ")", "assert", "compiled", "(", "\"light.kitchen\"", ",", "\"read\"", ")", "is", "False" ]
[ 15, 0 ]
[ 19, 53 ]
python
en
['en', 'cy', 'en']
True
test_entities_empty
()
Test entity ID policy.
Test entity ID policy.
def test_entities_empty(): """Test entity ID policy.""" policy = {} ENTITY_POLICY_SCHEMA(policy) compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is False
[ "def", "test_entities_empty", "(", ")", ":", "policy", "=", "{", "}", "ENTITY_POLICY_SCHEMA", "(", "policy", ")", "compiled", "=", "compile_entities", "(", "policy", ",", "None", ")", "assert", "compiled", "(", "\"light.kitchen\"", ",", "\"read\"", ")", "is", ...
[ 22, 0 ]
[ 27, 53 ]
python
en
['en', 'cy', 'en']
True
test_entities_false
()
Test entity ID policy.
Test entity ID policy.
def test_entities_false(): """Test entity ID policy.""" policy = False with pytest.raises(vol.Invalid): ENTITY_POLICY_SCHEMA(policy)
[ "def", "test_entities_false", "(", ")", ":", "policy", "=", "False", "with", "pytest", ".", "raises", "(", "vol", ".", "Invalid", ")", ":", "ENTITY_POLICY_SCHEMA", "(", "policy", ")" ]
[ 30, 0 ]
[ 34, 36 ]
python
en
['en', 'cy', 'en']
True
test_entities_true
()
Test entity ID policy.
Test entity ID policy.
def test_entities_true(): """Test entity ID policy.""" policy = True ENTITY_POLICY_SCHEMA(policy) compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is True
[ "def", "test_entities_true", "(", ")", ":", "policy", "=", "True", "ENTITY_POLICY_SCHEMA", "(", "policy", ")", "compiled", "=", "compile_entities", "(", "policy", ",", "None", ")", "assert", "compiled", "(", "\"light.kitchen\"", ",", "\"read\"", ")", "is", "Tr...
[ 37, 0 ]
[ 42, 52 ]
python
en
['en', 'cy', 'en']
True
test_entities_domains_true
()
Test entity ID policy.
Test entity ID policy.
def test_entities_domains_true(): """Test entity ID policy.""" policy = {"domains": True} ENTITY_POLICY_SCHEMA(policy) compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is True
[ "def", "test_entities_domains_true", "(", ")", ":", "policy", "=", "{", "\"domains\"", ":", "True", "}", "ENTITY_POLICY_SCHEMA", "(", "policy", ")", "compiled", "=", "compile_entities", "(", "policy", ",", "None", ")", "assert", "compiled", "(", "\"light.kitchen...
[ 45, 0 ]
[ 50, 52 ]
python
en
['en', 'cy', 'en']
True
test_entities_domains_domain_true
()
Test entity ID policy.
Test entity ID policy.
def test_entities_domains_domain_true(): """Test entity ID policy.""" policy = {"domains": {"light": True}} ENTITY_POLICY_SCHEMA(policy) compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is True assert compiled("switch.kitchen", "read") is False
[ "def", "test_entities_domains_domain_true", "(", ")", ":", "policy", "=", "{", "\"domains\"", ":", "{", "\"light\"", ":", "True", "}", "}", "ENTITY_POLICY_SCHEMA", "(", "policy", ")", "compiled", "=", "compile_entities", "(", "policy", ",", "None", ")", "asser...
[ 53, 0 ]
[ 59, 54 ]
python
en
['en', 'cy', 'en']
True
test_entities_domains_domain_false
()
Test entity ID policy.
Test entity ID policy.
def test_entities_domains_domain_false(): """Test entity ID policy.""" policy = {"domains": {"light": False}} with pytest.raises(vol.Invalid): ENTITY_POLICY_SCHEMA(policy)
[ "def", "test_entities_domains_domain_false", "(", ")", ":", "policy", "=", "{", "\"domains\"", ":", "{", "\"light\"", ":", "False", "}", "}", "with", "pytest", ".", "raises", "(", "vol", ".", "Invalid", ")", ":", "ENTITY_POLICY_SCHEMA", "(", "policy", ")" ]
[ 62, 0 ]
[ 66, 36 ]
python
en
['en', 'cy', 'en']
True
test_entities_entity_ids_true
()
Test entity ID policy.
Test entity ID policy.
def test_entities_entity_ids_true(): """Test entity ID policy.""" policy = {"entity_ids": True} ENTITY_POLICY_SCHEMA(policy) compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is True
[ "def", "test_entities_entity_ids_true", "(", ")", ":", "policy", "=", "{", "\"entity_ids\"", ":", "True", "}", "ENTITY_POLICY_SCHEMA", "(", "policy", ")", "compiled", "=", "compile_entities", "(", "policy", ",", "None", ")", "assert", "compiled", "(", "\"light.k...
[ 69, 0 ]
[ 74, 52 ]
python
en
['en', 'cy', 'en']
True
test_entities_entity_ids_false
()
Test entity ID policy.
Test entity ID policy.
def test_entities_entity_ids_false(): """Test entity ID policy.""" policy = {"entity_ids": False} with pytest.raises(vol.Invalid): ENTITY_POLICY_SCHEMA(policy)
[ "def", "test_entities_entity_ids_false", "(", ")", ":", "policy", "=", "{", "\"entity_ids\"", ":", "False", "}", "with", "pytest", ".", "raises", "(", "vol", ".", "Invalid", ")", ":", "ENTITY_POLICY_SCHEMA", "(", "policy", ")" ]
[ 77, 0 ]
[ 81, 36 ]
python
en
['en', 'cy', 'en']
True
test_entities_entity_ids_entity_id_true
()
Test entity ID policy.
Test entity ID policy.
def test_entities_entity_ids_entity_id_true(): """Test entity ID policy.""" policy = {"entity_ids": {"light.kitchen": True}} ENTITY_POLICY_SCHEMA(policy) compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is True assert compiled("switch.kitchen", "read") is False
[ "def", "test_entities_entity_ids_entity_id_true", "(", ")", ":", "policy", "=", "{", "\"entity_ids\"", ":", "{", "\"light.kitchen\"", ":", "True", "}", "}", "ENTITY_POLICY_SCHEMA", "(", "policy", ")", "compiled", "=", "compile_entities", "(", "policy", ",", "None"...
[ 84, 0 ]
[ 90, 54 ]
python
en
['en', 'cy', 'en']
True