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
TwitterNotificationService.media_info
(self, media_path)
Determine mime type and Twitter media category for given media.
Determine mime type and Twitter media category for given media.
def media_info(self, media_path): """Determine mime type and Twitter media category for given media.""" (media_type, _) = mimetypes.guess_type(media_path) media_category = self.media_category_for_type(media_type) _LOGGER.debug( "media %s is mime type %s and translates to %s",...
[ "def", "media_info", "(", "self", ",", "media_path", ")", ":", "(", "media_type", ",", "_", ")", "=", "mimetypes", ".", "guess_type", "(", "media_path", ")", "media_category", "=", "self", ".", "media_category_for_type", "(", "media_type", ")", "_LOGGER", "....
[ 142, 4 ]
[ 152, 41 ]
python
en
['en', 'en', 'en']
True
TwitterNotificationService.upload_media_init
(self, media_type, media_category, total_bytes)
Upload media, INIT phase.
Upload media, INIT phase.
def upload_media_init(self, media_type, media_category, total_bytes): """Upload media, INIT phase.""" return self.api.request( "media/upload", { "command": "INIT", "media_type": media_type, "media_category": media_category, ...
[ "def", "upload_media_init", "(", "self", ",", "media_type", ",", "media_category", ",", "total_bytes", ")", ":", "return", "self", ".", "api", ".", "request", "(", "\"media/upload\"", ",", "{", "\"command\"", ":", "\"INIT\"", ",", "\"media_type\"", ":", "media...
[ 154, 4 ]
[ 164, 9 ]
python
en
['en', 'zu', 'en']
True
TwitterNotificationService.upload_media_chunked
(self, file, total_bytes, media_id)
Upload media, chunked append.
Upload media, chunked append.
def upload_media_chunked(self, file, total_bytes, media_id): """Upload media, chunked append.""" segment_id = 0 bytes_sent = 0 while bytes_sent < total_bytes: chunk = file.read(4 * 1024 * 1024) resp = self.upload_media_append(chunk, media_id, segment_id) ...
[ "def", "upload_media_chunked", "(", "self", ",", "file", ",", "total_bytes", ",", "media_id", ")", ":", "segment_id", "=", "0", "bytes_sent", "=", "0", "while", "bytes_sent", "<", "total_bytes", ":", "chunk", "=", "file", ".", "read", "(", "4", "*", "102...
[ 166, 4 ]
[ 179, 23 ]
python
en
['en', 'en', 'sw']
True
TwitterNotificationService.upload_media_append
(self, chunk, media_id, segment_id)
Upload media, APPEND phase.
Upload media, APPEND phase.
def upload_media_append(self, chunk, media_id, segment_id): """Upload media, APPEND phase.""" return self.api.request( "media/upload", {"command": "APPEND", "media_id": media_id, "segment_index": segment_id}, {"media": chunk}, )
[ "def", "upload_media_append", "(", "self", ",", "chunk", ",", "media_id", ",", "segment_id", ")", ":", "return", "self", ".", "api", ".", "request", "(", "\"media/upload\"", ",", "{", "\"command\"", ":", "\"APPEND\"", ",", "\"media_id\"", ":", "media_id", ",...
[ 181, 4 ]
[ 187, 9 ]
python
en
['en', 'da', 'en']
True
TwitterNotificationService.upload_media_finalize
(self, media_id)
Upload media, FINALIZE phase.
Upload media, FINALIZE phase.
def upload_media_finalize(self, media_id): """Upload media, FINALIZE phase.""" return self.api.request( "media/upload", {"command": "FINALIZE", "media_id": media_id} )
[ "def", "upload_media_finalize", "(", "self", ",", "media_id", ")", ":", "return", "self", ".", "api", ".", "request", "(", "\"media/upload\"", ",", "{", "\"command\"", ":", "\"FINALIZE\"", ",", "\"media_id\"", ":", "media_id", "}", ")" ]
[ 189, 4 ]
[ 193, 9 ]
python
en
['en', 'zu', 'en']
True
TwitterNotificationService.check_status_until_done
(self, media_id, callback, *args)
Upload media, STATUS phase.
Upload media, STATUS phase.
def check_status_until_done(self, media_id, callback, *args): """Upload media, STATUS phase.""" resp = self.api.request( "media/upload", {"command": "STATUS", "media_id": media_id}, method_override="GET", ) if resp.status_code != HTTP_OK: _...
[ "def", "check_status_until_done", "(", "self", ",", "media_id", ",", "callback", ",", "*", "args", ")", ":", "resp", "=", "self", ".", "api", ".", "request", "(", "\"media/upload\"", ",", "{", "\"command\"", ":", "\"STATUS\"", ",", "\"media_id\"", ":", "me...
[ 195, 4 ]
[ 218, 58 ]
python
en
['en', 'zu', 'en']
True
TwitterNotificationService.media_category_for_type
(media_type)
Determine Twitter media category by mime type.
Determine Twitter media category by mime type.
def media_category_for_type(media_type): """Determine Twitter media category by mime type.""" if media_type is None: return None if media_type.startswith("image/gif"): return "tweet_gif" if media_type.startswith("video/"): return "tweet_video" ...
[ "def", "media_category_for_type", "(", "media_type", ")", ":", "if", "media_type", "is", "None", ":", "return", "None", "if", "media_type", ".", "startswith", "(", "\"image/gif\"", ")", ":", "return", "\"tweet_gif\"", "if", "media_type", ".", "startswith", "(", ...
[ 221, 4 ]
[ 233, 19 ]
python
en
['en', 'en', 'en']
True
TwitterNotificationService.log_bytes_sent
(bytes_sent, total_bytes)
Log upload progress.
Log upload progress.
def log_bytes_sent(bytes_sent, total_bytes): """Log upload progress.""" _LOGGER.debug("%s of %s bytes uploaded", str(bytes_sent), str(total_bytes))
[ "def", "log_bytes_sent", "(", "bytes_sent", ",", "total_bytes", ")", ":", "_LOGGER", ".", "debug", "(", "\"%s of %s bytes uploaded\"", ",", "str", "(", "bytes_sent", ")", ",", "str", "(", "total_bytes", ")", ")" ]
[ 236, 4 ]
[ 238, 83 ]
python
bg
['da', 'bg', 'en']
False
TwitterNotificationService.log_error_resp
(resp)
Log error response.
Log error response.
def log_error_resp(resp): """Log error response.""" obj = json.loads(resp.text) error_message = obj["errors"] _LOGGER.error("Error %s: %s", resp.status_code, error_message)
[ "def", "log_error_resp", "(", "resp", ")", ":", "obj", "=", "json", ".", "loads", "(", "resp", ".", "text", ")", "error_message", "=", "obj", "[", "\"errors\"", "]", "_LOGGER", ".", "error", "(", "\"Error %s: %s\"", ",", "resp", ".", "status_code", ",", ...
[ 241, 4 ]
[ 245, 70 ]
python
be
['da', 'be', 'en']
False
TwitterNotificationService.log_error_resp_append
(resp)
Log error response, during upload append phase.
Log error response, during upload append phase.
def log_error_resp_append(resp): """Log error response, during upload append phase.""" obj = json.loads(resp.text) error_message = obj["errors"][0]["message"] error_code = obj["errors"][0]["code"] _LOGGER.error( "Error %s: %s (Code %s)", resp.status_code, error_messag...
[ "def", "log_error_resp_append", "(", "resp", ")", ":", "obj", "=", "json", ".", "loads", "(", "resp", ".", "text", ")", "error_message", "=", "obj", "[", "\"errors\"", "]", "[", "0", "]", "[", "\"message\"", "]", "error_code", "=", "obj", "[", "\"error...
[ 248, 4 ]
[ 255, 9 ]
python
da
['da', 'da', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up sensors for device.
Set up sensors for device.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up sensors for device.""" coordinator = hass.data[DOMAIN][config_entry.entry_id][EVENTS_COORDINATOR] sensors = [ RiscoSensor(coordinator, id, [], name, config_entry.entry_id) for id, name in CATEGORIES.items() ] ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "coordinator", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "[", "EVENTS_COORDINATOR", "]", "sensors", "=", ...
[ 29, 0 ]
[ 41, 31 ]
python
en
['en', 'en', 'en']
True
RiscoSensor.__init__
(self, coordinator, category_id, excludes, name, entry_id)
Initialize sensor.
Initialize sensor.
def __init__(self, coordinator, category_id, excludes, name, entry_id) -> None: """Initialize sensor.""" super().__init__(coordinator) self._event = None self._category_id = category_id self._excludes = excludes self._name = name self._entry_id = entry_id ...
[ "def", "__init__", "(", "self", ",", "coordinator", ",", "category_id", ",", "excludes", ",", "name", ",", "entry_id", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "_event", "=", "None", "self", ".",...
[ 47, 4 ]
[ 55, 36 ]
python
en
['en', 'ro', 'it']
False
RiscoSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return f"Risco {self.coordinator.risco.site_name} {self._name} Events"
[ "def", "name", "(", "self", ")", ":", "return", "f\"Risco {self.coordinator.risco.site_name} {self._name} Events\"" ]
[ 58, 4 ]
[ 60, 78 ]
python
en
['en', 'mi', 'en']
True
RiscoSensor.unique_id
(self)
Return a unique id for this sensor.
Return a unique id for this sensor.
def unique_id(self): """Return a unique id for this sensor.""" return f"events_{self._name}_{self.coordinator.risco.site_uuid}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"events_{self._name}_{self.coordinator.risco.site_uuid}\"" ]
[ 63, 4 ]
[ 65, 72 ]
python
en
['en', 'ca', 'en']
True
RiscoSensor.async_added_to_hass
(self)
When entity is added to hass.
When entity is added to hass.
async def async_added_to_hass(self): """When entity is added to hass.""" self._entity_registry = ( await self.hass.helpers.entity_registry.async_get_registry() ) self.async_on_remove( self.coordinator.async_add_listener(self._refresh_from_coordinator) ) ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_entity_registry", "=", "(", "await", "self", ".", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ")", ")", "self", ".", "async_on_remove", "(", "sel...
[ 67, 4 ]
[ 75, 54 ]
python
en
['en', 'en', 'en']
True
RiscoSensor.state
(self)
Value of sensor.
Value of sensor.
def state(self): """Value of sensor.""" if self._event is None: return None return self._event.time
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_event", "is", "None", ":", "return", "None", "return", "self", ".", "_event", ".", "time" ]
[ 89, 4 ]
[ 94, 31 ]
python
en
['en', 'pt', 'en']
True
RiscoSensor.device_state_attributes
(self)
State attributes.
State attributes.
def device_state_attributes(self): """State attributes.""" if self._event is None: return None attrs = {atr: getattr(self._event, atr, None) for atr in EVENT_ATTRIBUTES} if self._event.zone_id is not None: zone_unique_id = binary_sensor_unique_id( ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "_event", "is", "None", ":", "return", "None", "attrs", "=", "{", "atr", ":", "getattr", "(", "self", ".", "_event", ",", "atr", ",", "None", ")", "for", "atr", "in", "EVENT_...
[ 97, 4 ]
[ 113, 20 ]
python
en
['en', 'en', 'en']
False
RiscoSensor.device_class
(self)
Device class of sensor.
Device class of sensor.
def device_class(self): """Device class of sensor.""" return DEVICE_CLASS_TIMESTAMP
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_TIMESTAMP" ]
[ 116, 4 ]
[ 118, 37 ]
python
en
['en', 'ro', 'en']
True
test_setup_missing_config
(hass)
Test setup with configuration missing required entries.
Test setup with configuration missing required entries.
async def test_setup_missing_config(hass): """Test setup with configuration missing required entries.""" with assert_setup_component(0): assert await async_setup_component( hass, DOMAIN, {"sensor": {"platform": "mhz19"}} )
[ "async", "def", "test_setup_missing_config", "(", "hass", ")", ":", "with", "assert_setup_component", "(", "0", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"mhz19\"", ...
[ 17, 0 ]
[ 22, 9 ]
python
en
['en', 'en', 'en']
True
test_setup_failed_connect
(mock_co2, hass)
Test setup when connection error occurs.
Test setup when connection error occurs.
async def test_setup_failed_connect(mock_co2, hass): """Test setup when connection error occurs.""" assert not mhz19.setup_platform( hass, {"platform": "mhz19", mhz19.CONF_SERIAL_DEVICE: "test.serial"}, None, )
[ "async", "def", "test_setup_failed_connect", "(", "mock_co2", ",", "hass", ")", ":", "assert", "not", "mhz19", ".", "setup_platform", "(", "hass", ",", "{", "\"platform\"", ":", "\"mhz19\"", ",", "mhz19", ".", "CONF_SERIAL_DEVICE", ":", "\"test.serial\"", "}", ...
[ 26, 0 ]
[ 32, 5 ]
python
en
['en', 'en', 'en']
True
test_setup_connected
(hass)
Test setup when connection succeeds.
Test setup when connection succeeds.
async def test_setup_connected(hass): """Test setup when connection succeeds.""" with patch.multiple( "pmsensor.co2sensor", read_mh_z19=DEFAULT, read_mh_z19_with_temperature=DEFAULT, ): read_mh_z19_with_temperature.return_value = None mock_add = Mock() assert ...
[ "async", "def", "test_setup_connected", "(", "hass", ")", ":", "with", "patch", ".", "multiple", "(", "\"pmsensor.co2sensor\"", ",", "read_mh_z19", "=", "DEFAULT", ",", "read_mh_z19_with_temperature", "=", "DEFAULT", ",", ")", ":", "read_mh_z19_with_temperature", "....
[ 35, 0 ]
[ 53, 35 ]
python
en
['en', 'fr', 'en']
True
aiohttp_client_update_oserror
(mock_function)
Test MHZClient when library throws OSError.
Test MHZClient when library throws OSError.
async def aiohttp_client_update_oserror(mock_function): """Test MHZClient when library throws OSError.""" client = mhz19.MHZClient(co2sensor, "test.serial") client.update() assert {} == client.data
[ "async", "def", "aiohttp_client_update_oserror", "(", "mock_function", ")", ":", "client", "=", "mhz19", ".", "MHZClient", "(", "co2sensor", ",", "\"test.serial\"", ")", "client", ".", "update", "(", ")", "assert", "{", "}", "==", "client", ".", "data" ]
[ 60, 0 ]
[ 64, 28 ]
python
en
['en', 'en', 'en']
True
aiohttp_client_update_ppm_overflow
(mock_function)
Test MHZClient when ppm is too high.
Test MHZClient when ppm is too high.
async def aiohttp_client_update_ppm_overflow(mock_function): """Test MHZClient when ppm is too high.""" client = mhz19.MHZClient(co2sensor, "test.serial") client.update() assert client.data.get("co2") is None
[ "async", "def", "aiohttp_client_update_ppm_overflow", "(", "mock_function", ")", ":", "client", "=", "mhz19", ".", "MHZClient", "(", "co2sensor", ",", "\"test.serial\"", ")", "client", ".", "update", "(", ")", "assert", "client", ".", "data", ".", "get", "(", ...
[ 68, 0 ]
[ 72, 41 ]
python
en
['en', 'en', 'en']
True
aiohttp_client_update_good_read
(mock_function)
Test MHZClient when ppm is too high.
Test MHZClient when ppm is too high.
async def aiohttp_client_update_good_read(mock_function): """Test MHZClient when ppm is too high.""" client = mhz19.MHZClient(co2sensor, "test.serial") client.update() assert {"temperature": 24, "co2": 1000} == client.data
[ "async", "def", "aiohttp_client_update_good_read", "(", "mock_function", ")", ":", "client", "=", "mhz19", ".", "MHZClient", "(", "co2sensor", ",", "\"test.serial\"", ")", "client", ".", "update", "(", ")", "assert", "{", "\"temperature\"", ":", "24", ",", "\"...
[ 76, 0 ]
[ 80, 58 ]
python
en
['en', 'en', 'en']
True
test_co2_sensor
(mock_function)
Test CO2 sensor.
Test CO2 sensor.
async def test_co2_sensor(mock_function): """Test CO2 sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_CO2, None, "name") sensor.update() assert sensor.name == "name: CO2" assert sensor.state == 1000 assert sensor.unit_of_measurem...
[ "async", "def", "test_co2_sensor", "(", "mock_function", ")", ":", "client", "=", "mhz19", ".", "MHZClient", "(", "co2sensor", ",", "\"test.serial\"", ")", "sensor", "=", "mhz19", ".", "MHZ19Sensor", "(", "client", ",", "mhz19", ".", "SENSOR_CO2", ",", "None...
[ 84, 0 ]
[ 94, 64 ]
python
en
['en', 'st', 'en']
True
test_temperature_sensor
(mock_function)
Test temperature sensor.
Test temperature sensor.
async def test_temperature_sensor(mock_function): """Test temperature sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_TEMPERATURE, None, "name") sensor.update() assert sensor.name == "name: Temperature" assert sensor.state == 24 ...
[ "async", "def", "test_temperature_sensor", "(", "mock_function", ")", ":", "client", "=", "mhz19", ".", "MHZClient", "(", "co2sensor", ",", "\"test.serial\"", ")", "sensor", "=", "mhz19", ".", "MHZ19Sensor", "(", "client", ",", "mhz19", ".", "SENSOR_TEMPERATURE"...
[ 98, 0 ]
[ 108, 72 ]
python
en
['en', 'la', 'en']
True
test_temperature_sensor_f
(mock_function)
Test temperature sensor.
Test temperature sensor.
async def test_temperature_sensor_f(mock_function): """Test temperature sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor( client, mhz19.SENSOR_TEMPERATURE, TEMP_FAHRENHEIT, "name" ) sensor.update() assert sensor.state == 75.2
[ "async", "def", "test_temperature_sensor_f", "(", "mock_function", ")", ":", "client", "=", "mhz19", ".", "MHZClient", "(", "co2sensor", ",", "\"test.serial\"", ")", "sensor", "=", "mhz19", ".", "MHZ19Sensor", "(", "client", ",", "mhz19", ".", "SENSOR_TEMPERATUR...
[ 112, 0 ]
[ 120, 31 ]
python
en
['en', 'la', 'en']
True
get_arguments
()
Get parsed passed in arguments.
Get parsed passed in arguments.
def get_arguments() -> argparse.Namespace: """Get parsed passed in arguments.""" parser = get_base_arg_parser() parser.add_argument( "--target", type=str, default="core", choices=["core", "frontend"], ) return parser.parse_args()
[ "def", "get_arguments", "(", ")", "->", "argparse", ".", "Namespace", ":", "parser", "=", "get_base_arg_parser", "(", ")", "parser", ".", "add_argument", "(", "\"--target\"", ",", "type", "=", "str", ",", "default", "=", "\"core\"", ",", "choices", "=", "[...
[ 10, 0 ]
[ 19, 30 ]
python
en
['en', 'la', 'en']
True
find_extra
(base, translations, path_prefix, missing_keys)
Find all keys that are in translations but not in base.
Find all keys that are in translations but not in base.
def find_extra(base, translations, path_prefix, missing_keys): """Find all keys that are in translations but not in base.""" for key, value in translations.items(): cur_path = f"{path_prefix}::{key}" if path_prefix else key # Value is either a dict or a string if isinstance(value, dict)...
[ "def", "find_extra", "(", "base", ",", "translations", ",", "path_prefix", ",", "missing_keys", ")", ":", "for", "key", ",", "value", "in", "translations", ".", "items", "(", ")", ":", "cur_path", "=", "f\"{path_prefix}::{key}\"", "if", "path_prefix", "else", ...
[ 22, 0 ]
[ 33, 41 ]
python
en
['en', 'en', 'en']
True
find_core
()
Find all missing keys in core.
Find all missing keys in core.
def find_core(): """Find all missing keys in core.""" missing_keys = [] for int_dir in INTEGRATIONS_DIR.iterdir(): strings = int_dir / "strings.json" if not strings.is_file(): continue translations = int_dir / "translations" / "en.json" strings_json = json.loa...
[ "def", "find_core", "(", ")", ":", "missing_keys", "=", "[", "]", "for", "int_dir", "in", "INTEGRATIONS_DIR", ".", "iterdir", "(", ")", ":", "strings", "=", "int_dir", "/", "\"strings.json\"", "if", "not", "strings", ".", "is_file", "(", ")", ":", "conti...
[ 36, 0 ]
[ 58, 23 ]
python
en
['en', 'fy', 'en']
True
find_frontend
()
Find all missing keys in frontend.
Find all missing keys in frontend.
def find_frontend(): """Find all missing keys in frontend.""" if not FRONTEND_DIR.is_dir(): raise ExitApp(f"Unable to find frontend at {FRONTEND_DIR}") source = FRONTEND_DIR / "src/translations/en.json" translated = FRONTEND_DIR / "translations/en.json" missing_keys = [] find_extra( ...
[ "def", "find_frontend", "(", ")", ":", "if", "not", "FRONTEND_DIR", ".", "is_dir", "(", ")", ":", "raise", "ExitApp", "(", "f\"Unable to find frontend at {FRONTEND_DIR}\"", ")", "source", "=", "FRONTEND_DIR", "/", "\"src/translations/en.json\"", "translated", "=", "...
[ 61, 0 ]
[ 76, 23 ]
python
en
['en', 'en', 'en']
True
run
()
Clean translations.
Clean translations.
def run(): """Clean translations.""" args = get_arguments() if args.target == "frontend": missing_keys = find_frontend() lokalise = get_api(FRONTEND_PROJECT_ID) else: missing_keys = find_core() lokalise = get_api(CORE_PROJECT_ID) if not missing_keys: print("N...
[ "def", "run", "(", ")", ":", "args", "=", "get_arguments", "(", ")", "if", "args", ".", "target", "==", "\"frontend\"", ":", "missing_keys", "=", "find_frontend", "(", ")", "lokalise", "=", "get_api", "(", "FRONTEND_PROJECT_ID", ")", "else", ":", "missing_...
[ 79, 0 ]
[ 114, 12 ]
python
en
['en', 'bg', 'en']
False
LimbDarkening_2Pam.define_special_variable_properties
(self, ndim, output_lists, var)
:param ndim: :param output_lists: :param var: :return:
def define_special_variable_properties(self, ndim, output_lists, var): """ :param ndim: :param output_lists: :param var: :return: """ if 'ld_c1' in self.fix_list or \ 'ld_c2' in self.fix_list: return ndim, output_lists, False for ...
[ "def", "define_special_variable_properties", "(", "self", ",", "ndim", ",", "output_lists", ",", "var", ")", ":", "if", "'ld_c1'", "in", "self", ".", "fix_list", "or", "'ld_c2'", "in", "self", ".", "fix_list", ":", "return", "ndim", ",", "output_lists", ",",...
[ 88, 4 ]
[ 156, 39 ]
python
en
['en', 'error', 'th']
False
apply_application_controller_patch
(zha_gateway)
Apply patches to ZHA objects.
Apply patches to ZHA objects.
def apply_application_controller_patch(zha_gateway): """Apply patches to ZHA objects.""" # Patch handle_message until zigpy can provide an event here def handle_message(sender, profile, cluster, src_ep, dst_ep, message): """Handle message from a device.""" if ( sender.ieee in zha...
[ "def", "apply_application_controller_patch", "(", "zha_gateway", ")", ":", "# Patch handle_message until zigpy can provide an event here", "def", "handle_message", "(", "sender", ",", "profile", ",", "cluster", ",", "src_ep", ",", "dst_ep", ",", "message", ")", ":", "\"...
[ 3, 0 ]
[ 17, 70 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the myStrom switch/plug integration.
Set up the myStrom switch/plug integration.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the myStrom switch/plug integration.""" name = config.get(CONF_NAME) host = config.get(CONF_HOST) try: plug = _MyStromSwitch(host) await plug.get_state() except MyStromConnectionError as...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "host", "=", "config", ".", "get", "(", "CONF_HOST", ")",...
[ 24, 0 ]
[ 36, 51 ]
python
en
['en', 'ja', 'en']
True
MyStromSwitch.__init__
(self, plug, name)
Initialize the myStrom switch/plug.
Initialize the myStrom switch/plug.
def __init__(self, plug, name): """Initialize the myStrom switch/plug.""" self._name = name self.plug = plug self._available = True self.relay = None
[ "def", "__init__", "(", "self", ",", "plug", ",", "name", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "plug", "=", "plug", "self", ".", "_available", "=", "True", "self", ".", "relay", "=", "None" ]
[ 42, 4 ]
[ 47, 25 ]
python
en
['en', 'pl', 'en']
True
MyStromSwitch.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" ]
[ 50, 4 ]
[ 52, 25 ]
python
en
['en', 'en', 'en']
True
MyStromSwitch.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 bool(self.relay)
[ "def", "is_on", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "relay", ")" ]
[ 55, 4 ]
[ 57, 31 ]
python
en
['en', 'fy', 'en']
True
MyStromSwitch.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return self.plug._mac
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "plug", ".", "_mac" ]
[ 60, 4 ]
[ 62, 29 ]
python
ca
['fr', 'ca', 'en']
False
MyStromSwitch.current_power_w
(self)
Return the current power consumption in W.
Return the current power consumption in W.
def current_power_w(self): """Return the current power consumption in W.""" return self.plug.consumption
[ "def", "current_power_w", "(", "self", ")", ":", "return", "self", ".", "plug", ".", "consumption" ]
[ 65, 4 ]
[ 67, 36 ]
python
en
['en', 'en', 'en']
True
MyStromSwitch.available
(self)
Could the device be accessed during the last update call.
Could the device be accessed during the last update call.
def available(self): """Could the device be accessed during the last update call.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 70, 4 ]
[ 72, 30 ]
python
en
['en', 'en', 'en']
True
MyStromSwitch.async_turn_on
(self, **kwargs)
Turn the switch on.
Turn the switch on.
async def async_turn_on(self, **kwargs): """Turn the switch on.""" try: await self.plug.turn_on() except MyStromConnectionError: _LOGGER.error("No route to myStrom plug")
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "try", ":", "await", "self", ".", "plug", ".", "turn_on", "(", ")", "except", "MyStromConnectionError", ":", "_LOGGER", ".", "error", "(", "\"No route to myStrom plug\"", ")" ]
[ 74, 4 ]
[ 79, 53 ]
python
en
['en', 'en', 'en']
True
MyStromSwitch.async_turn_off
(self, **kwargs)
Turn the switch off.
Turn the switch off.
async def async_turn_off(self, **kwargs): """Turn the switch off.""" try: await self.plug.turn_off() except MyStromConnectionError: _LOGGER.error("No route to myStrom plug")
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "try", ":", "await", "self", ".", "plug", ".", "turn_off", "(", ")", "except", "MyStromConnectionError", ":", "_LOGGER", ".", "error", "(", "\"No route to myStrom plug\"", ")" ...
[ 81, 4 ]
[ 86, 53 ]
python
en
['en', 'en', 'en']
True
MyStromSwitch.async_update
(self)
Get the latest data from the device and update the data.
Get the latest data from the device and update the data.
async def async_update(self): """Get the latest data from the device and update the data.""" try: await self.plug.get_state() self.relay = self.plug.relay self._available = True except MyStromConnectionError: self._available = False _LO...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "await", "self", ".", "plug", ".", "get_state", "(", ")", "self", ".", "relay", "=", "self", ".", "plug", ".", "relay", "self", ".", "_available", "=", "True", "except", "MyStromConnect...
[ 88, 4 ]
[ 96, 53 ]
python
en
['en', 'en', 'en']
True
mock_client_fixture
(request)
Patch the InfluxDBClient object with mock for version under test.
Patch the InfluxDBClient object with mock for version under test.
def mock_client_fixture(request): """Patch the InfluxDBClient object with mock for version under test.""" if request.param == API_VERSION_2: client_target = f"{INFLUXDB_CLIENT_PATH}V2" else: client_target = INFLUXDB_CLIENT_PATH with patch(client_target) as client: yield client
[ "def", "mock_client_fixture", "(", "request", ")", ":", "if", "request", ".", "param", "==", "API_VERSION_2", ":", "client_target", "=", "f\"{INFLUXDB_CLIENT_PATH}V2\"", "else", ":", "client_target", "=", "INFLUXDB_CLIENT_PATH", "with", "patch", "(", "client_target", ...
[ 68, 0 ]
[ 76, 20 ]
python
en
['en', 'en', 'en']
True
mock_client_close
()
Mock close method of clients at module scope.
Mock close method of clients at module scope.
def mock_client_close(): """Mock close method of clients at module scope.""" with patch(f"{INFLUXDB_CLIENT_PATH}.close") as close_v1, patch( f"{INFLUXDB_CLIENT_PATH}V2.close" ) as close_v2: yield (close_v1, close_v2)
[ "def", "mock_client_close", "(", ")", ":", "with", "patch", "(", "f\"{INFLUXDB_CLIENT_PATH}.close\"", ")", "as", "close_v1", ",", "patch", "(", "f\"{INFLUXDB_CLIENT_PATH}V2.close\"", ")", "as", "close_v2", ":", "yield", "(", "close_v1", ",", "close_v2", ")" ]
[ 80, 0 ]
[ 85, 34 ]
python
en
['en', 'en', 'en']
True
_make_v1_resultset
(*args)
Create a mock V1 resultset.
Create a mock V1 resultset.
def _make_v1_resultset(*args): """Create a mock V1 resultset.""" for arg in args: yield {"value": arg}
[ "def", "_make_v1_resultset", "(", "*", "args", ")", ":", "for", "arg", "in", "args", ":", "yield", "{", "\"value\"", ":", "arg", "}" ]
[ 88, 0 ]
[ 91, 28 ]
python
en
['en', 'no', 'en']
True
_make_v1_databases_resultset
()
Create a mock V1 'show databases' resultset.
Create a mock V1 'show databases' resultset.
def _make_v1_databases_resultset(): """Create a mock V1 'show databases' resultset.""" for name in [DEFAULT_DATABASE, "db2"]: yield {"name": name}
[ "def", "_make_v1_databases_resultset", "(", ")", ":", "for", "name", "in", "[", "DEFAULT_DATABASE", ",", "\"db2\"", "]", ":", "yield", "{", "\"name\"", ":", "name", "}" ]
[ 94, 0 ]
[ 97, 28 ]
python
en
['en', 'no', 'en']
True
_make_v2_resultset
(*args)
Create a mock V2 resultset.
Create a mock V2 resultset.
def _make_v2_resultset(*args): """Create a mock V2 resultset.""" tables = [] for arg in args: values = {"_value": arg} record = Record(values) tables.append(Table([record])) return tables
[ "def", "_make_v2_resultset", "(", "*", "args", ")", ":", "tables", "=", "[", "]", "for", "arg", "in", "args", ":", "values", "=", "{", "\"_value\"", ":", "arg", "}", "record", "=", "Record", "(", "values", ")", "tables", ".", "append", "(", "Table", ...
[ 100, 0 ]
[ 109, 17 ]
python
en
['en', 'no', 'en']
True
_make_v2_buckets_resultset
()
Create a mock V2 'buckets()' resultset.
Create a mock V2 'buckets()' resultset.
def _make_v2_buckets_resultset(): """Create a mock V2 'buckets()' resultset.""" records = [] for name in [DEFAULT_BUCKET, "bucket2"]: records.append(Record({"name": name})) return [Table(records)]
[ "def", "_make_v2_buckets_resultset", "(", ")", ":", "records", "=", "[", "]", "for", "name", "in", "[", "DEFAULT_BUCKET", ",", "\"bucket2\"", "]", ":", "records", ".", "append", "(", "Record", "(", "{", "\"name\"", ":", "name", "}", ")", ")", "return", ...
[ 112, 0 ]
[ 118, 27 ]
python
en
['en', 'sv', 'en']
True
_set_query_mock_v1
( mock_influx_client, return_value=None, query_exception=None, side_effect=None )
Set return value or side effect for the V1 client.
Set return value or side effect for the V1 client.
def _set_query_mock_v1( mock_influx_client, return_value=None, query_exception=None, side_effect=None ): """Set return value or side effect for the V1 client.""" query_api = mock_influx_client.return_value.query if side_effect: query_api.side_effect = side_effect else: if return_val...
[ "def", "_set_query_mock_v1", "(", "mock_influx_client", ",", "return_value", "=", "None", ",", "query_exception", "=", "None", ",", "side_effect", "=", "None", ")", ":", "query_api", "=", "mock_influx_client", ".", "return_value", ".", "query", "if", "side_effect"...
[ 121, 0 ]
[ 148, 20 ]
python
en
['en', 'da', 'en']
True
_set_query_mock_v2
( mock_influx_client, return_value=None, query_exception=None, side_effect=None )
Set return value or side effect for the V2 client.
Set return value or side effect for the V2 client.
def _set_query_mock_v2( mock_influx_client, return_value=None, query_exception=None, side_effect=None ): """Set return value or side effect for the V2 client.""" query_api = mock_influx_client.return_value.query_api.return_value.query if side_effect: query_api.side_effect = side_effect else:...
[ "def", "_set_query_mock_v2", "(", "mock_influx_client", ",", "return_value", "=", "None", ",", "query_exception", "=", "None", ",", "side_effect", "=", "None", ")", ":", "query_api", "=", "mock_influx_client", ".", "return_value", ".", "query_api", ".", "return_va...
[ 151, 0 ]
[ 174, 20 ]
python
en
['en', 'da', 'en']
True
_setup
(hass, config_ext, queries, expected_sensors)
Create client and test expected sensors.
Create client and test expected sensors.
async def _setup(hass, config_ext, queries, expected_sensors): """Create client and test expected sensors.""" config = { DOMAIN: config_ext, sensor.DOMAIN: {"platform": DOMAIN}, } influx_config = config[sensor.DOMAIN] influx_config.update(config_ext) influx_config.update(queries)...
[ "async", "def", "_setup", "(", "hass", ",", "config_ext", ",", "queries", ",", "expected_sensors", ")", ":", "config", "=", "{", "DOMAIN", ":", "config_ext", ",", "sensor", ".", "DOMAIN", ":", "{", "\"platform\"", ":", "DOMAIN", "}", ",", "}", "influx_co...
[ 177, 0 ]
[ 196, 18 ]
python
en
['en', 'en', 'en']
True
test_minimal_config
(hass, mock_client, config_ext, queries, set_query_mock)
Test the minimal config and defaults.
Test the minimal config and defaults.
async def test_minimal_config(hass, mock_client, config_ext, queries, set_query_mock): """Test the minimal config and defaults.""" set_query_mock(mock_client) await _setup(hass, config_ext, queries, ["sensor.test"])
[ "async", "def", "test_minimal_config", "(", "hass", ",", "mock_client", ",", "config_ext", ",", "queries", ",", "set_query_mock", ")", ":", "set_query_mock", "(", "mock_client", ")", "await", "_setup", "(", "hass", ",", "config_ext", ",", "queries", ",", "[", ...
[ 207, 0 ]
[ 210, 60 ]
python
en
['en', 'en', 'en']
True
test_full_config
(hass, mock_client, config_ext, queries, set_query_mock)
Test the full config.
Test the full config.
async def test_full_config(hass, mock_client, config_ext, queries, set_query_mock): """Test the full config.""" set_query_mock(mock_client) await _setup(hass, config_ext, queries, ["sensor.test"])
[ "async", "def", "test_full_config", "(", "hass", ",", "mock_client", ",", "config_ext", ",", "queries", ",", "set_query_mock", ")", ":", "set_query_mock", "(", "mock_client", ")", "await", "_setup", "(", "hass", ",", "config_ext", ",", "queries", ",", "[", "...
[ 275, 0 ]
[ 278, 60 ]
python
en
['en', 'en', 'en']
True
test_config_failure
(hass, config_ext)
Test an invalid config.
Test an invalid config.
async def test_config_failure(hass, config_ext): """Test an invalid config.""" config = {"platform": DOMAIN} config.update(config_ext) with pytest.raises(Invalid): PLATFORM_SCHEMA(config)
[ "async", "def", "test_config_failure", "(", "hass", ",", "config_ext", ")", ":", "config", "=", "{", "\"platform\"", ":", "DOMAIN", "}", "config", ".", "update", "(", "config_ext", ")", "with", "pytest", ".", "raises", "(", "Invalid", ")", ":", "PLATFORM_S...
[ 282, 0 ]
[ 288, 31 ]
python
en
['en', 'en', 'en']
True
test_state_matches_query_result
( hass, mock_client, config_ext, queries, set_query_mock, make_resultset )
Test state of sensor matches respone from query api.
Test state of sensor matches respone from query api.
async def test_state_matches_query_result( hass, mock_client, config_ext, queries, set_query_mock, make_resultset ): """Test state of sensor matches respone from query api.""" set_query_mock(mock_client, return_value=make_resultset(42)) sensors = await _setup(hass, config_ext, queries, ["sensor.test"])...
[ "async", "def", "test_state_matches_query_result", "(", "hass", ",", "mock_client", ",", "config_ext", ",", "queries", ",", "set_query_mock", ",", "make_resultset", ")", ":", "set_query_mock", "(", "mock_client", ",", "return_value", "=", "make_resultset", "(", "42"...
[ 311, 0 ]
[ 319, 35 ]
python
en
['en', 'en', 'en']
True
test_state_matches_first_query_result_for_multiple_return
( hass, caplog, mock_client, config_ext, queries, set_query_mock, make_resultset )
Test state of sensor matches respone from query api.
Test state of sensor matches respone from query api.
async def test_state_matches_first_query_result_for_multiple_return( hass, caplog, mock_client, config_ext, queries, set_query_mock, make_resultset ): """Test state of sensor matches respone from query api.""" set_query_mock(mock_client, return_value=make_resultset(42, "not used")) sensors = await _set...
[ "async", "def", "test_state_matches_first_query_result_for_multiple_return", "(", "hass", ",", "caplog", ",", "mock_client", ",", "config_ext", ",", "queries", ",", "set_query_mock", ",", "make_resultset", ")", ":", "set_query_mock", "(", "mock_client", ",", "return_val...
[ 342, 0 ]
[ 352, 5 ]
python
en
['en', 'en', 'en']
True
test_state_for_no_results
( hass, caplog, mock_client, config_ext, queries, set_query_mock )
Test state of sensor matches respone from query api.
Test state of sensor matches respone from query api.
async def test_state_for_no_results( hass, caplog, mock_client, config_ext, queries, set_query_mock ): """Test state of sensor matches respone from query api.""" set_query_mock(mock_client) sensors = await _setup(hass, config_ext, queries, ["sensor.test"]) assert sensors[0].state == STATE_UNKNOWN ...
[ "async", "def", "test_state_for_no_results", "(", "hass", ",", "caplog", ",", "mock_client", ",", "config_ext", ",", "queries", ",", "set_query_mock", ")", ":", "set_query_mock", "(", "mock_client", ")", "sensors", "=", "await", "_setup", "(", "hass", ",", "co...
[ 368, 0 ]
[ 378, 5 ]
python
en
['en', 'en', 'en']
True
test_error_querying_influx
( hass, caplog, mock_client, config_ext, queries, set_query_mock, query_exception )
Test behavior of sensor when influx returns error.
Test behavior of sensor when influx returns error.
async def test_error_querying_influx( hass, caplog, mock_client, config_ext, queries, set_query_mock, query_exception ): """Test behavior of sensor when influx returns error.""" set_query_mock(mock_client, query_exception=query_exception) sensors = await _setup(hass, config_ext, queries, ["sensor.test"...
[ "async", "def", "test_error_querying_influx", "(", "hass", ",", "caplog", ",", "mock_client", ",", "config_ext", ",", "queries", ",", "set_query_mock", ",", "query_exception", ")", ":", "set_query_mock", "(", "mock_client", ",", "query_exception", "=", "query_except...
[ 429, 0 ]
[ 439, 5 ]
python
en
['en', 'nl', 'en']
True
test_error_rendering_template
( hass, caplog, mock_client, config_ext, queries, set_query_mock, make_resultset )
Test behavior of sensor with error rendering template.
Test behavior of sensor with error rendering template.
async def test_error_rendering_template( hass, caplog, mock_client, config_ext, queries, set_query_mock, make_resultset ): """Test behavior of sensor with error rendering template.""" set_query_mock(mock_client, return_value=make_resultset(42)) sensors = await _setup(hass, config_ext, queries, ["sensor...
[ "async", "def", "test_error_rendering_template", "(", "hass", ",", "caplog", ",", "mock_client", ",", "config_ext", ",", "queries", ",", "set_query_mock", ",", "make_resultset", ")", ":", "set_query_mock", "(", "mock_client", ",", "return_value", "=", "make_resultse...
[ 471, 0 ]
[ 481, 5 ]
python
en
['en', 'nl', 'en']
True
test_connection_error_at_startup
( hass, caplog, mock_client, config_ext, queries, set_query_mock, test_exception, make_resultset, )
Test behavior of sensor when influx returns error.
Test behavior of sensor when influx returns error.
async def test_connection_error_at_startup( hass, caplog, mock_client, config_ext, queries, set_query_mock, test_exception, make_resultset, ): """Test behavior of sensor when influx returns error.""" query_api = set_query_mock(mock_client, side_effect=test_exception) expected...
[ "async", "def", "test_connection_error_at_startup", "(", "hass", ",", "caplog", ",", "mock_client", ",", "config_ext", ",", "queries", ",", "set_query_mock", ",", "test_exception", ",", "make_resultset", ",", ")", ":", "query_api", "=", "set_query_mock", "(", "moc...
[ 530, 0 ]
[ 557, 55 ]
python
en
['en', 'nl', 'en']
True
test_data_repository_not_found
( hass, caplog, mock_client, config_ext, queries, set_query_mock, )
Test sensor is not setup when bucket not available.
Test sensor is not setup when bucket not available.
async def test_data_repository_not_found( hass, caplog, mock_client, config_ext, queries, set_query_mock, ): """Test sensor is not setup when bucket not available.""" set_query_mock(mock_client) await _setup(hass, config_ext, queries, []) assert hass.states.get("sensor.test") is ...
[ "async", "def", "test_data_repository_not_found", "(", "hass", ",", "caplog", ",", "mock_client", ",", "config_ext", ",", "queries", ",", "set_query_mock", ",", ")", ":", "set_query_mock", "(", "mock_client", ")", "await", "_setup", "(", "hass", ",", "config_ext...
[ 583, 0 ]
[ 597, 5 ]
python
en
['en', 'en', 'en']
True
get_service
(hass, config, discovery_info=None)
Get the Unify Circuit notification service.
Get the Unify Circuit notification service.
def get_service(hass, config, discovery_info=None): """Get the Unify Circuit notification service.""" if discovery_info is None: return None return CircuitNotificationService(discovery_info)
[ "def", "get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "None", "return", "CircuitNotificationService", "(", "discovery_info", ")" ]
[ 11, 0 ]
[ 16, 53 ]
python
en
['en', 'en', 'en']
True
CircuitNotificationService.__init__
(self, config)
Initialize the service.
Initialize the service.
def __init__(self, config): """Initialize the service.""" self.webhook_url = config[CONF_URL]
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "self", ".", "webhook_url", "=", "config", "[", "CONF_URL", "]" ]
[ 22, 4 ]
[ 24, 43 ]
python
en
['en', 'en', 'en']
True
CircuitNotificationService.send_message
(self, message=None, **kwargs)
Send a message to the webhook.
Send a message to the webhook.
def send_message(self, message=None, **kwargs): """Send a message to the webhook.""" webhook_url = self.webhook_url if webhook_url and message: try: circuit_message = Circuit(url=webhook_url) circuit_message.post(text=message) except Runt...
[ "def", "send_message", "(", "self", ",", "message", "=", "None", ",", "*", "*", "kwargs", ")", ":", "webhook_url", "=", "self", ".", "webhook_url", "if", "webhook_url", "and", "message", ":", "try", ":", "circuit_message", "=", "Circuit", "(", "url", "="...
[ 26, 4 ]
[ 36, 76 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[list], None], )
Set up the ISY994 binary sensor platform.
Set up the ISY994 binary sensor platform.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[list], None], ) -> bool: """Set up the ISY994 binary sensor platform.""" devices = [] devices_by_address = {} child_nodes = [] hass_isy_data = hass.data[ISY994_DOMAIN][entry.entry_id]...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", "[", "[", "list", "]", ",", "None", "]", ",", ")", "->", "bool", ":", "devices", "=", "[", "]", "dev...
[ 59, 0 ]
[ 172, 31 ]
python
en
['en', 'mg', 'en']
True
ISYBinarySensorEntity.__init__
(self, node, force_device_class=None, unknown_state=None)
Initialize the ISY994 binary sensor device.
Initialize the ISY994 binary sensor device.
def __init__(self, node, force_device_class=None, unknown_state=None) -> None: """Initialize the ISY994 binary sensor device.""" super().__init__(node) self._device_class = force_device_class
[ "def", "__init__", "(", "self", ",", "node", ",", "force_device_class", "=", "None", ",", "unknown_state", "=", "None", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "node", ")", "self", ".", "_device_class", "=", "force_device_class" ]
[ 208, 4 ]
[ 211, 47 ]
python
en
['en', 'mg', 'en']
True
ISYBinarySensorEntity.is_on
(self)
Get whether the ISY994 binary sensor device is on.
Get whether the ISY994 binary sensor device is on.
def is_on(self) -> bool: """Get whether the ISY994 binary sensor device is on.""" if self._node.status == ISY_VALUE_UNKNOWN: return None return bool(self._node.status)
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "_node", ".", "status", "==", "ISY_VALUE_UNKNOWN", ":", "return", "None", "return", "bool", "(", "self", ".", "_node", ".", "status", ")" ]
[ 214, 4 ]
[ 218, 38 ]
python
en
['en', 'en', 'en']
True
ISYBinarySensorEntity.device_class
(self)
Return the class of this device. This was discovered by parsing the device type code during init
Return the class of this device.
def device_class(self) -> str: """Return the class of this device. This was discovered by parsing the device type code during init """ return self._device_class
[ "def", "device_class", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_device_class" ]
[ 221, 4 ]
[ 226, 33 ]
python
en
['en', 'en', 'en']
True
ISYInsteonBinarySensorEntity.__init__
(self, node, force_device_class=None, unknown_state=None)
Initialize the ISY994 binary sensor device.
Initialize the ISY994 binary sensor device.
def __init__(self, node, force_device_class=None, unknown_state=None) -> None: """Initialize the ISY994 binary sensor device.""" super().__init__(node, force_device_class) self._negative_node = None self._heartbeat_device = None if self._node.status == ISY_VALUE_UNKNOWN: ...
[ "def", "__init__", "(", "self", ",", "node", ",", "force_device_class", "=", "None", ",", "unknown_state", "=", "None", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "node", ",", "force_device_class", ")", "self", ".", "_negative_node", ...
[ 238, 4 ]
[ 248, 44 ]
python
en
['en', 'mg', 'en']
True
ISYInsteonBinarySensorEntity.async_added_to_hass
(self)
Subscribe to the node and subnode event emitters.
Subscribe to the node and subnode event emitters.
async def async_added_to_hass(self) -> None: """Subscribe to the node and subnode event emitters.""" await super().async_added_to_hass() self._node.control_events.subscribe(self._positive_node_control_handler) if self._negative_node is not None: self._negative_node.control_...
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "self", ".", "_node", ".", "control_events", ".", "subscribe", "(", "self", ".", "_positive_node_control_handler", ")"...
[ 250, 4 ]
[ 259, 13 ]
python
en
['en', 'en', 'en']
True
ISYInsteonBinarySensorEntity.add_heartbeat_device
(self, device)
Register a heartbeat device for this sensor. The heartbeat node beats on its own, but we can gain a little reliability by considering any node activity for this sensor to be a heartbeat as well.
Register a heartbeat device for this sensor.
def add_heartbeat_device(self, device) -> None: """Register a heartbeat device for this sensor. The heartbeat node beats on its own, but we can gain a little reliability by considering any node activity for this sensor to be a heartbeat as well. """ self._heartbeat_devic...
[ "def", "add_heartbeat_device", "(", "self", ",", "device", ")", "->", "None", ":", "self", ".", "_heartbeat_device", "=", "device" ]
[ 261, 4 ]
[ 268, 39 ]
python
en
['en', 'en', 'en']
True
ISYInsteonBinarySensorEntity._heartbeat
(self)
Send a heartbeat to our heartbeat device, if we have one.
Send a heartbeat to our heartbeat device, if we have one.
def _heartbeat(self) -> None: """Send a heartbeat to our heartbeat device, if we have one.""" if self._heartbeat_device is not None: self._heartbeat_device.heartbeat()
[ "def", "_heartbeat", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_heartbeat_device", "is", "not", "None", ":", "self", ".", "_heartbeat_device", ".", "heartbeat", "(", ")" ]
[ 270, 4 ]
[ 273, 46 ]
python
en
['en', 'en', 'en']
True
ISYInsteonBinarySensorEntity.add_negative_node
(self, child)
Add a negative node to this binary sensor device. The negative node is a node that can receive the 'off' events for the sensor, depending on device configuration and type.
Add a negative node to this binary sensor device.
def add_negative_node(self, child) -> None: """Add a negative node to this binary sensor device. The negative node is a node that can receive the 'off' events for the sensor, depending on device configuration and type. """ self._negative_node = child if self._negative_n...
[ "def", "add_negative_node", "(", "self", ",", "child", ")", "->", "None", ":", "self", ".", "_negative_node", "=", "child", "if", "self", ".", "_negative_node", ".", "status", "!=", "ISY_VALUE_UNKNOWN", ":", "# If the negative node has a value, it means the negative n...
[ 275, 4 ]
[ 291, 43 ]
python
en
['en', 'en', 'en']
True
ISYInsteonBinarySensorEntity._negative_node_control_handler
(self, event: object)
Handle an "On" control event from the "negative" node.
Handle an "On" control event from the "negative" node.
def _negative_node_control_handler(self, event: object) -> None: """Handle an "On" control event from the "negative" node.""" if event.control == CMD_ON: _LOGGER.debug( "Sensor %s turning Off via the Negative node sending a DON command", self.name, ...
[ "def", "_negative_node_control_handler", "(", "self", ",", "event", ":", "object", ")", "->", "None", ":", "if", "event", ".", "control", "==", "CMD_ON", ":", "_LOGGER", ".", "debug", "(", "\"Sensor %s turning Off via the Negative node sending a DON command\"", ",", ...
[ 293, 4 ]
[ 302, 29 ]
python
en
['en', 'en', 'en']
True
ISYInsteonBinarySensorEntity._positive_node_control_handler
(self, event: object)
Handle On and Off control event coming from the primary node. Depending on device configuration, sometimes only On events will come to this node, with the negative node representing Off events
Handle On and Off control event coming from the primary node.
def _positive_node_control_handler(self, event: object) -> None: """Handle On and Off control event coming from the primary node. Depending on device configuration, sometimes only On events will come to this node, with the negative node representing Off events """ if eve...
[ "def", "_positive_node_control_handler", "(", "self", ",", "event", ":", "object", ")", "->", "None", ":", "if", "event", ".", "control", "==", "CMD_ON", ":", "_LOGGER", ".", "debug", "(", "\"Sensor %s turning On via the Primary node sending a DON command\"", ",", "...
[ 304, 4 ]
[ 326, 29 ]
python
en
['en', 'en', 'en']
True
ISYInsteonBinarySensorEntity.on_update
(self, event: object)
Primary node status updates. We MOSTLY ignore these updates, as we listen directly to the Control events on all nodes for this device. However, there is one edge case: If a leak sensor is unknown, due to a recent reboot of the ISY, the status will get updated to dry upon the first heart...
Primary node status updates.
def on_update(self, event: object) -> None: """Primary node status updates. We MOSTLY ignore these updates, as we listen directly to the Control events on all nodes for this device. However, there is one edge case: If a leak sensor is unknown, due to a recent reboot of the ISY, the ...
[ "def", "on_update", "(", "self", ",", "event", ":", "object", ")", "->", "None", ":", "if", "self", ".", "_status_was_unknown", "and", "self", ".", "_computed_state", "is", "None", ":", "self", ".", "_computed_state", "=", "bool", "(", "self", ".", "_nod...
[ 328, 4 ]
[ 342, 29 ]
python
en
['en', 'la', 'en']
True
ISYInsteonBinarySensorEntity.is_on
(self)
Get whether the ISY994 binary sensor device is on. Insteon leak sensors set their primary node to On when the state is DRY, not WET, so we invert the binary state if the user indicates that it is a moisture sensor.
Get whether the ISY994 binary sensor device is on.
def is_on(self) -> bool: """Get whether the ISY994 binary sensor device is on. Insteon leak sensors set their primary node to On when the state is DRY, not WET, so we invert the binary state if the user indicates that it is a moisture sensor. """ if self._computed_state ...
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "_computed_state", "is", "None", ":", "# Do this first so we don't invert None on moisture sensors", "return", "None", "if", "self", ".", "device_class", "==", "DEVICE_CLASS_MOISTURE", ":", "ret...
[ 345, 4 ]
[ 359, 35 ]
python
en
['en', 'en', 'en']
True
ISYBinarySensorHeartbeat.__init__
(self, node, parent_device)
Initialize the ISY994 binary sensor device. Computed state is set to UNKNOWN unless the ISY provided a valid state. See notes above regarding ISY Sensor status on ISY restart. If a valid state is provided (either on or off), the computed state in HA is set to OFF (Normal). If the heartb...
Initialize the ISY994 binary sensor device.
def __init__(self, node, parent_device) -> None: """Initialize the ISY994 binary sensor device. Computed state is set to UNKNOWN unless the ISY provided a valid state. See notes above regarding ISY Sensor status on ISY restart. If a valid state is provided (either on or off), the comput...
[ "def", "__init__", "(", "self", ",", "node", ",", "parent_device", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "node", ")", "self", ".", "_parent_device", "=", "parent_device", "self", ".", "_heartbeat_timer", "=", "None", "self", "....
[ 365, 4 ]
[ 379, 40 ]
python
en
['en', 'mg', 'en']
True
ISYBinarySensorHeartbeat.async_added_to_hass
(self)
Subscribe to the node and subnode event emitters.
Subscribe to the node and subnode event emitters.
async def async_added_to_hass(self) -> None: """Subscribe to the node and subnode event emitters.""" await super().async_added_to_hass() self._node.control_events.subscribe(self._heartbeat_node_control_handler) # Start the timer on bootup, so we can change from UNKNOWN to OFF s...
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "self", ".", "_node", ".", "control_events", ".", "subscribe", "(", "self", ".", "_heartbeat_node_control_handler", ")...
[ 381, 4 ]
[ 388, 29 ]
python
en
['en', 'en', 'en']
True
ISYBinarySensorHeartbeat._heartbeat_node_control_handler
(self, event: object)
Update the heartbeat timestamp when any ON/OFF event is sent. The ISY uses both DON and DOF commands (alternating) for a heartbeat.
Update the heartbeat timestamp when any ON/OFF event is sent.
def _heartbeat_node_control_handler(self, event: object) -> None: """Update the heartbeat timestamp when any ON/OFF event is sent. The ISY uses both DON and DOF commands (alternating) for a heartbeat. """ if event.control in [CMD_ON, CMD_OFF]: self.heartbeat()
[ "def", "_heartbeat_node_control_handler", "(", "self", ",", "event", ":", "object", ")", "->", "None", ":", "if", "event", ".", "control", "in", "[", "CMD_ON", ",", "CMD_OFF", "]", ":", "self", ".", "heartbeat", "(", ")" ]
[ 390, 4 ]
[ 396, 28 ]
python
en
['en', 'en', 'en']
True
ISYBinarySensorHeartbeat.heartbeat
(self)
Mark the device as online, and restart the 25 hour timer. This gets called when the heartbeat node beats, but also when the parent sensor sends any events, as we can trust that to mean the device is online. This mitigates the risk of false positives due to a single missed heartbeat even...
Mark the device as online, and restart the 25 hour timer.
def heartbeat(self): """Mark the device as online, and restart the 25 hour timer. This gets called when the heartbeat node beats, but also when the parent sensor sends any events, as we can trust that to mean the device is online. This mitigates the risk of false positives due to a sing...
[ "def", "heartbeat", "(", "self", ")", ":", "self", ".", "_computed_state", "=", "False", "self", ".", "_restart_timer", "(", ")", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 398, 4 ]
[ 408, 39 ]
python
en
['en', 'en', 'en']
True
ISYBinarySensorHeartbeat._restart_timer
(self)
Restart the 25 hour timer.
Restart the 25 hour timer.
def _restart_timer(self): """Restart the 25 hour timer.""" try: self._heartbeat_timer() self._heartbeat_timer = None except TypeError: # No heartbeat timer is active pass @callback def timer_elapsed(now) -> None: """Hea...
[ "def", "_restart_timer", "(", "self", ")", ":", "try", ":", "self", ".", "_heartbeat_timer", "(", ")", "self", ".", "_heartbeat_timer", "=", "None", "except", "TypeError", ":", "# No heartbeat timer is active", "pass", "@", "callback", "def", "timer_elapsed", "(...
[ 410, 4 ]
[ 435, 9 ]
python
en
['en', 'no', 'en']
True
ISYBinarySensorHeartbeat.on_update
(self, event: object)
Ignore node status updates. We listen directly to the Control events for this device.
Ignore node status updates.
def on_update(self, event: object) -> None: """Ignore node status updates. We listen directly to the Control events for this device. """
[ "def", "on_update", "(", "self", ",", "event", ":", "object", ")", "->", "None", ":" ]
[ 437, 4 ]
[ 441, 11 ]
python
en
['en', 'la', 'en']
True
ISYBinarySensorHeartbeat.is_on
(self)
Get whether the ISY994 binary sensor device is on. Note: This method will return false if the current state is UNKNOWN which occurs after a restart until the first heartbeat or control parent control event is received.
Get whether the ISY994 binary sensor device is on.
def is_on(self) -> bool: """Get whether the ISY994 binary sensor device is on. Note: This method will return false if the current state is UNKNOWN which occurs after a restart until the first heartbeat or control parent control event is received. """ return bool(self._co...
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "_computed_state", ")" ]
[ 444, 4 ]
[ 451, 41 ]
python
en
['en', 'en', 'en']
True
ISYBinarySensorHeartbeat.device_class
(self)
Get the class of this device.
Get the class of this device.
def device_class(self) -> str: """Get the class of this device.""" return DEVICE_CLASS_BATTERY
[ "def", "device_class", "(", "self", ")", "->", "str", ":", "return", "DEVICE_CLASS_BATTERY" ]
[ 454, 4 ]
[ 456, 35 ]
python
en
['en', 'en', 'en']
True
ISYBinarySensorHeartbeat.device_state_attributes
(self)
Get the state attributes for the device.
Get the state attributes for the device.
def device_state_attributes(self): """Get the state attributes for the device.""" attr = super().device_state_attributes attr["parent_entity_id"] = self._parent_device.entity_id return attr
[ "def", "device_state_attributes", "(", "self", ")", ":", "attr", "=", "super", "(", ")", ".", "device_state_attributes", "attr", "[", "\"parent_entity_id\"", "]", "=", "self", ".", "_parent_device", ".", "entity_id", "return", "attr" ]
[ 459, 4 ]
[ 463, 19 ]
python
en
['en', 'en', 'en']
True
ISYBinarySensorProgramEntity.is_on
(self)
Get whether the ISY994 binary sensor device is on.
Get whether the ISY994 binary sensor device is on.
def is_on(self) -> bool: """Get whether the ISY994 binary sensor device is on.""" return bool(self._node.status)
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "_node", ".", "status", ")" ]
[ 474, 4 ]
[ 476, 38 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the NX584 platform.
Set up the NX584 platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the NX584 platform.""" name = config.get(CONF_NAME) host = config.get(CONF_HOST) port = config.get(CONF_PORT) url = f"http://{host}:{port}" try: alarm_client = client.Client(url) aw...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "host", "=", "config", ".", "get", "(", "CONF_HOST", ")",...
[ 46, 0 ]
[ 79, 5 ]
python
en
['en', 'lv', 'en']
True
NX584Alarm.__init__
(self, name, alarm_client, url)
Init the nx584 alarm panel.
Init the nx584 alarm panel.
def __init__(self, name, alarm_client, url): """Init the nx584 alarm panel.""" self._name = name self._state = None self._alarm = alarm_client self._url = url
[ "def", "__init__", "(", "self", ",", "name", ",", "alarm_client", ",", "url", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_state", "=", "None", "self", ".", "_alarm", "=", "alarm_client", "self", ".", "_url", "=", "url" ]
[ 85, 4 ]
[ 90, 23 ]
python
en
['en', 'ja', 'en']
True
NX584Alarm.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" ]
[ 93, 4 ]
[ 95, 25 ]
python
en
['en', 'en', 'en']
True
NX584Alarm.code_format
(self)
Return one or more digits/characters.
Return one or more digits/characters.
def code_format(self): """Return one or more digits/characters.""" return alarm.FORMAT_NUMBER
[ "def", "code_format", "(", "self", ")", ":", "return", "alarm", ".", "FORMAT_NUMBER" ]
[ 98, 4 ]
[ 100, 34 ]
python
en
['en', 'en', 'en']
True
NX584Alarm.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 103, 4 ]
[ 105, 26 ]
python
en
['en', 'en', 'en']
True
NX584Alarm.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self) -> int: """Return the list of supported features.""" return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_ALARM_ARM_HOME", "|", "SUPPORT_ALARM_ARM_AWAY" ]
[ 108, 4 ]
[ 110, 62 ]
python
en
['en', 'en', 'en']
True
NX584Alarm.update
(self)
Process new events from panel.
Process new events from panel.
def update(self): """Process new events from panel.""" try: part = self._alarm.list_partitions()[0] zones = self._alarm.list_zones() except requests.exceptions.ConnectionError as ex: _LOGGER.error( "Unable to connect to %(host)s: %(reason)s", ...
[ "def", "update", "(", "self", ")", ":", "try", ":", "part", "=", "self", ".", "_alarm", ".", "list_partitions", "(", ")", "[", "0", "]", "zones", "=", "self", ".", "_alarm", ".", "list_zones", "(", ")", "except", "requests", ".", "exceptions", ".", ...
[ 112, 4 ]
[ 148, 51 ]
python
en
['en', 'en', 'en']
True
NX584Alarm.alarm_disarm
(self, code=None)
Send disarm command.
Send disarm command.
def alarm_disarm(self, code=None): """Send disarm command.""" self._alarm.disarm(code)
[ "def", "alarm_disarm", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_alarm", ".", "disarm", "(", "code", ")" ]
[ 150, 4 ]
[ 152, 32 ]
python
en
['en', 'pt', 'en']
True
NX584Alarm.alarm_arm_home
(self, code=None)
Send arm home command.
Send arm home command.
def alarm_arm_home(self, code=None): """Send arm home command.""" self._alarm.arm("stay")
[ "def", "alarm_arm_home", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_alarm", ".", "arm", "(", "\"stay\"", ")" ]
[ 154, 4 ]
[ 156, 31 ]
python
en
['en', 'pt', 'en']
True
NX584Alarm.alarm_arm_away
(self, code=None)
Send arm away command.
Send arm away command.
def alarm_arm_away(self, code=None): """Send arm away command.""" self._alarm.arm("exit")
[ "def", "alarm_arm_away", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_alarm", ".", "arm", "(", "\"exit\"", ")" ]
[ 158, 4 ]
[ 160, 31 ]
python
en
['en', 'en', 'en']
True
NX584Alarm.alarm_bypass
(self, zone)
Send bypass command.
Send bypass command.
def alarm_bypass(self, zone): """Send bypass command.""" self._alarm.set_bypass(zone, True)
[ "def", "alarm_bypass", "(", "self", ",", "zone", ")", ":", "self", ".", "_alarm", ".", "set_bypass", "(", "zone", ",", "True", ")" ]
[ 162, 4 ]
[ 164, 42 ]
python
en
['en', 'lb', 'en']
True