Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
test_form_cannot_connect
(hass)
Test we handle cannot connect error.
Test we handle cannot connect error.
async def test_form_cannot_connect(hass): """Test we handle cannot connect error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.components.volumio.config_flow.Volumio.get_system_info", s...
[ "async", "def", "test_form_cannot_connect", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", "...
[ 135, 0 ]
[ 151, 58 ]
python
en
['en', 'en', 'en']
True
test_form_exception
(hass)
Test we handle generic error.
Test we handle generic error.
async def test_form_exception(hass): """Test we handle generic error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.components.volumio.config_flow.Volumio.get_system_info", side_effect=E...
[ "async", "def", "test_form_exception", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ")", ...
[ 154, 0 ]
[ 170, 51 ]
python
nl
['nl', 'nl', 'en']
True
test_discovery
(hass)
Test discovery flow works.
Test discovery flow works.
async def test_discovery(hass): """Test discovery flow works.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY ) with patch( "homeassistant.components.volumio.config_flow.Volumio.get_system_info", return_value=TE...
[ "async", "def", "test_discovery", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"zeroconf\"", "}", ",", "data", "=", "TEST_DISCOVE...
[ 173, 0 ]
[ 203, 48 ]
python
en
['en', 'en', 'en']
True
test_discovery_cannot_connect
(hass)
Test discovery aborts if cannot connect.
Test discovery aborts if cannot connect.
async def test_discovery_cannot_connect(hass): """Test discovery aborts if cannot connect.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY ) with patch( "homeassistant.components.volumio.config_flow.Volumio.get_system_i...
[ "async", "def", "test_discovery_cannot_connect", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"zeroconf\"", "}", ",", "data", "=", ...
[ 206, 0 ]
[ 223, 48 ]
python
en
['en', 'en', 'en']
True
test_discovery_duplicate_data
(hass)
Test discovery aborts if same mDNS packet arrives.
Test discovery aborts if same mDNS packet arrives.
async def test_discovery_duplicate_data(hass): """Test discovery aborts if same mDNS packet arrives.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY ) assert result["type"] == "form" assert result["step_id"] == "discovery_con...
[ "async", "def", "test_discovery_duplicate_data", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"zeroconf\"", "}", ",", "data", "=", ...
[ 226, 0 ]
[ 238, 52 ]
python
en
['en', 'en', 'en']
True
test_discovery_updates_unique_id
(hass)
Test a duplicate discovery id aborts and updates existing entry.
Test a duplicate discovery id aborts and updates existing entry.
async def test_discovery_updates_unique_id(hass): """Test a duplicate discovery id aborts and updates existing entry.""" entry = MockConfigEntry( domain=DOMAIN, unique_id=TEST_DISCOVERY_RESULT["id"], data={ "host": "dummy", "port": 11, "name": "dummy",...
[ "async", "def", "test_discovery_updates_unique_id", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "unique_id", "=", "TEST_DISCOVERY_RESULT", "[", "\"id\"", "]", ",", "data", "=", "{", "\"host\"", ":", "\"dummy\"", "...
[ 241, 0 ]
[ 273, 48 ]
python
en
['en', 'en', 'en']
True
GridSearchTuner._json2parameter
(self, ss_spec)
Generate all possible configs for hyperparameters from hyperparameter space. Parameters ---------- ss_spec : dict or list Hyperparameter space or the ``_value`` of a hyperparameter Returns ------- list or dict All the candidate choices o...
Generate all possible configs for hyperparameters from hyperparameter space.
def _json2parameter(self, ss_spec): """ Generate all possible configs for hyperparameters from hyperparameter space. Parameters ---------- ss_spec : dict or list Hyperparameter space or the ``_value`` of a hyperparameter Returns ------- list ...
[ "def", "_json2parameter", "(", "self", ",", "ss_spec", ")", ":", "if", "isinstance", "(", "ss_spec", ",", "dict", ")", ":", "if", "'_type'", "in", "ss_spec", ".", "keys", "(", ")", ":", "_type", "=", "ss_spec", "[", "'_type'", "]", "_value", "=", "ss...
[ 42, 4 ]
[ 91, 28 ]
python
en
['en', 'error', 'th']
False
GridSearchTuner._parse_quniform
(self, param_value)
Parse type of quniform parameter and return a list
Parse type of quniform parameter and return a list
def _parse_quniform(self, param_value): """ Parse type of quniform parameter and return a list """ low, high, q = param_value[0], param_value[1], param_value[2] return np.clip(np.arange(np.round(low/q), np.round(high/q)+1) * q, low, high)
[ "def", "_parse_quniform", "(", "self", ",", "param_value", ")", ":", "low", ",", "high", ",", "q", "=", "param_value", "[", "0", "]", ",", "param_value", "[", "1", "]", ",", "param_value", "[", "2", "]", "return", "np", ".", "clip", "(", "np", ".",...
[ 93, 4 ]
[ 98, 85 ]
python
en
['en', 'error', 'th']
False
GridSearchTuner._parse_randint
(self, param_value)
Parse type of randint parameter and return a list
Parse type of randint parameter and return a list
def _parse_randint(self, param_value): """ Parse type of randint parameter and return a list """ if param_value[0] >= param_value[1]: raise ValueError("Randint should contain at least 1 candidate, but [%s, %s) contains none.", param_value[0], para...
[ "def", "_parse_randint", "(", "self", ",", "param_value", ")", ":", "if", "param_value", "[", "0", "]", ">=", "param_value", "[", "1", "]", ":", "raise", "ValueError", "(", "\"Randint should contain at least 1 candidate, but [%s, %s) contains none.\"", ",", "param_val...
[ 100, 4 ]
[ 107, 65 ]
python
en
['en', 'error', 'th']
False
GridSearchTuner._expand_parameters
(self, para)
Enumerate all possible combinations of all parameters Parameters ---------- para : dict {key1: [v11, v12, ...], key2: [v21, v22, ...], ...} Returns ------- dict {{key1: v11, key2: v21, ...}, {key1: v11, key2: v22, ...}, ...}
Enumerate all possible combinations of all parameters
def _expand_parameters(self, para): """ Enumerate all possible combinations of all parameters Parameters ---------- para : dict {key1: [v11, v12, ...], key2: [v21, v22, ...], ...} Returns ------- dict {{key1: v11, key2: v21, ...},...
[ "def", "_expand_parameters", "(", "self", ",", "para", ")", ":", "if", "len", "(", "para", ")", "==", "1", ":", "for", "key", ",", "values", "in", "para", ".", "items", "(", ")", ":", "return", "list", "(", "map", "(", "lambda", "v", ":", "{", ...
[ 109, 4 ]
[ 135, 23 ]
python
en
['en', 'error', 'th']
False
GridSearchTuner.update_search_space
(self, search_space)
Check if the search space is valid and expand it: support only ``choice``, ``quniform``, ``randint``. Parameters ---------- search_space : dict The format could be referred to search space spec (https://nni.readthedocs.io/en/latest/Tutorial/SearchSpaceSpec.html).
Check if the search space is valid and expand it: support only ``choice``, ``quniform``, ``randint``.
def update_search_space(self, search_space): """ Check if the search space is valid and expand it: support only ``choice``, ``quniform``, ``randint``. Parameters ---------- search_space : dict The format could be referred to search space spec (https://nni.readthedocs...
[ "def", "update_search_space", "(", "self", ",", "search_space", ")", ":", "self", ".", "expanded_search_space", "=", "self", ".", "_json2parameter", "(", "search_space", ")" ]
[ 137, 4 ]
[ 146, 71 ]
python
en
['en', 'error', 'th']
False
GridSearchTuner.generate_parameters
(self, parameter_id, **kwargs)
Generate parameters for one trial. Parameters ---------- parameter_id : int The id for the generated hyperparameter **kwargs Not used Returns ------- dict One configuration from the expanded search space. Rai...
Generate parameters for one trial.
def generate_parameters(self, parameter_id, **kwargs): """ Generate parameters for one trial. Parameters ---------- parameter_id : int The id for the generated hyperparameter **kwargs Not used Returns ------- dict ...
[ "def", "generate_parameters", "(", "self", ",", "parameter_id", ",", "*", "*", "kwargs", ")", ":", "self", ".", "count", "+=", "1", "while", "self", ".", "count", "<=", "len", "(", "self", ".", "expanded_search_space", ")", "-", "1", ":", "_params_tuple"...
[ 148, 4 ]
[ 176, 61 ]
python
en
['en', 'error', 'th']
False
GridSearchTuner.receive_trial_result
(self, parameter_id, parameters, value, **kwargs)
Receive a trial's final performance result reported through :func:`~nni.report_final_result` by the trial. GridSearchTuner does not need trial's results.
Receive a trial's final performance result reported through :func:`~nni.report_final_result` by the trial. GridSearchTuner does not need trial's results.
def receive_trial_result(self, parameter_id, parameters, value, **kwargs): """ Receive a trial's final performance result reported through :func:`~nni.report_final_result` by the trial. GridSearchTuner does not need trial's results. """ pass
[ "def", "receive_trial_result", "(", "self", ",", "parameter_id", ",", "parameters", ",", "value", ",", "*", "*", "kwargs", ")", ":", "pass" ]
[ 178, 4 ]
[ 183, 12 ]
python
en
['en', 'error', 'th']
False
GridSearchTuner.import_data
(self, data)
Import additional data for tuning Parameters ---------- list A list of dictionarys, each of which has at least two keys, ``parameter`` and ``value``
Import additional data for tuning
def import_data(self, data): """ Import additional data for tuning Parameters ---------- list A list of dictionarys, each of which has at least two keys, ``parameter`` and ``value`` """ _completed_num = 0 for trial_info in data: lo...
[ "def", "import_data", "(", "self", ",", "data", ")", ":", "_completed_num", "=", "0", "for", "trial_info", "in", "data", ":", "logger", ".", "info", "(", "\"Importing data, current processing progress %s / %s\"", ",", "_completed_num", ",", "len", "(", "data", "...
[ 185, 4 ]
[ 207, 69 ]
python
en
['en', 'error', 'th']
False
async_get_service
(hass, config, discovery_info=None)
Get the notification service.
Get the notification service.
async def async_get_service(hass, config, discovery_info=None): """Get the notification service.""" if discovery_info is None: return return TplinkNotifyService(hass, discovery_info)
[ "async", "def", "async_get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "return", "TplinkNotifyService", "(", "hass", ",", "discovery_info", ")" ]
[ 14, 0 ]
[ 18, 52 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Track states and offer events for calendars.
Track states and offer events for calendars.
async def async_setup(hass, config): """Track states and offer events for calendars.""" component = hass.data[DOMAIN] = EntityComponent( _LOGGER, DOMAIN, hass, SCAN_INTERVAL ) hass.http.register_view(CalendarListView(component)) hass.http.register_view(CalendarEventView(component)) has...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "component", "=", "hass", ".", "data", "[", "DOMAIN", "]", "=", "EntityComponent", "(", "_LOGGER", ",", "DOMAIN", ",", "hass", ",", "SCAN_INTERVAL", ")", "hass", ".", "http", ".", "re...
[ 29, 0 ]
[ 43, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry)
Set up a config entry.
Set up a config entry.
async def async_setup_entry(hass, entry): """Set up a config entry.""" return await hass.data[DOMAIN].async_setup_entry(entry)
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "return", "await", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_setup_entry", "(", "entry", ")" ]
[ 46, 0 ]
[ 48, 59 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, entry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass, entry): """Unload a config entry.""" return await hass.data[DOMAIN].async_unload_entry(entry)
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "return", "await", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_unload_entry", "(", "entry", ")" ]
[ 51, 0 ]
[ 53, 60 ]
python
en
['en', 'es', 'en']
True
get_date
(date)
Get the dateTime from date or dateTime as a local.
Get the dateTime from date or dateTime as a local.
def get_date(date): """Get the dateTime from date or dateTime as a local.""" if "date" in date: return dt.start_of_local_day( dt.dt.datetime.combine(dt.parse_date(date["date"]), dt.dt.time.min) ) return dt.as_local(dt.parse_datetime(date["dateTime"]))
[ "def", "get_date", "(", "date", ")", ":", "if", "\"date\"", "in", "date", ":", "return", "dt", ".", "start_of_local_day", "(", "dt", ".", "dt", ".", "datetime", ".", "combine", "(", "dt", ".", "parse_date", "(", "date", "[", "\"date\"", "]", ")", ","...
[ 56, 0 ]
[ 62, 59 ]
python
en
['en', 'en', 'en']
True
normalize_event
(event)
Normalize a calendar event.
Normalize a calendar event.
def normalize_event(event): """Normalize a calendar event.""" normalized_event = {} start = event.get("start") end = event.get("end") start = get_date(start) if start is not None else None end = get_date(end) if end is not None else None normalized_event["dt_start"] = start normalized_e...
[ "def", "normalize_event", "(", "event", ")", ":", "normalized_event", "=", "{", "}", "start", "=", "event", ".", "get", "(", "\"start\"", ")", "end", "=", "event", ".", "get", "(", "\"end\"", ")", "start", "=", "get_date", "(", "start", ")", "if", "s...
[ 65, 0 ]
[ 88, 27 ]
python
en
['es', 'pt', 'en']
False
calculate_offset
(event, offset)
Calculate event offset. Return the updated event with the offset_time included.
Calculate event offset.
def calculate_offset(event, offset): """Calculate event offset. Return the updated event with the offset_time included. """ summary = event.get("summary", "") # check if we have an offset tag in the message # time is HH:MM or MM reg = f"{offset}([+-]?[0-9]{{0,2}}(:[0-9]{{0,2}})?)" searc...
[ "def", "calculate_offset", "(", "event", ",", "offset", ")", ":", "summary", "=", "event", ".", "get", "(", "\"summary\"", ",", "\"\"", ")", "# check if we have an offset tag in the message", "# time is HH:MM or MM", "reg", "=", "f\"{offset}([+-]?[0-9]{{0,2}}(:[0-9]{{0,2}...
[ 91, 0 ]
[ 116, 16 ]
python
en
['en', 'en', 'en']
True
is_offset_reached
(event)
Have we reached the offset time specified in the event title.
Have we reached the offset time specified in the event title.
def is_offset_reached(event): """Have we reached the offset time specified in the event title.""" start = get_date(event["start"]) if start is None or event["offset_time"] == dt.dt.timedelta(): return False return start + event["offset_time"] <= dt.now(start.tzinfo)
[ "def", "is_offset_reached", "(", "event", ")", ":", "start", "=", "get_date", "(", "event", "[", "\"start\"", "]", ")", "if", "start", "is", "None", "or", "event", "[", "\"offset_time\"", "]", "==", "dt", ".", "dt", ".", "timedelta", "(", ")", ":", "...
[ 119, 0 ]
[ 125, 63 ]
python
en
['en', 'en', 'en']
True
CalendarEventDevice.event
(self)
Return the next upcoming event.
Return the next upcoming event.
def event(self): """Return the next upcoming event.""" raise NotImplementedError()
[ "def", "event", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 132, 4 ]
[ 134, 35 ]
python
en
['en', 'en', 'en']
True
CalendarEventDevice.state_attributes
(self)
Return the entity state attributes.
Return the entity state attributes.
def state_attributes(self): """Return the entity state attributes.""" event = self.event if event is None: return None event = normalize_event(event) return { "message": event["message"], "all_day": event["all_day"], "start_time": ...
[ "def", "state_attributes", "(", "self", ")", ":", "event", "=", "self", ".", "event", "if", "event", "is", "None", ":", "return", "None", "event", "=", "normalize_event", "(", "event", ")", "return", "{", "\"message\"", ":", "event", "[", "\"message\"", ...
[ 137, 4 ]
[ 151, 9 ]
python
en
['en', 'en', 'en']
True
CalendarEventDevice.state
(self)
Return the state of the calendar event.
Return the state of the calendar event.
def state(self): """Return the state of the calendar event.""" event = self.event if event is None: return STATE_OFF event = normalize_event(event) start = event["dt_start"] end = event["dt_end"] if start is None or end is None: return ST...
[ "def", "state", "(", "self", ")", ":", "event", "=", "self", ".", "event", "if", "event", "is", "None", ":", "return", "STATE_OFF", "event", "=", "normalize_event", "(", "event", ")", "start", "=", "event", "[", "\"dt_start\"", "]", "end", "=", "event"...
[ 154, 4 ]
[ 172, 24 ]
python
en
['en', 'en', 'en']
True
CalendarEventDevice.async_get_events
(self, hass, start_date, end_date)
Return calendar events within a datetime range.
Return calendar events within a datetime range.
async def async_get_events(self, hass, start_date, end_date): """Return calendar events within a datetime range.""" raise NotImplementedError()
[ "async", "def", "async_get_events", "(", "self", ",", "hass", ",", "start_date", ",", "end_date", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 174, 4 ]
[ 176, 35 ]
python
en
['en', 'en', 'en']
True
CalendarEventView.__init__
(self, component: EntityComponent)
Initialize calendar view.
Initialize calendar view.
def __init__(self, component: EntityComponent) -> None: """Initialize calendar view.""" self.component = component
[ "def", "__init__", "(", "self", ",", "component", ":", "EntityComponent", ")", "->", "None", ":", "self", ".", "component", "=", "component" ]
[ 185, 4 ]
[ 187, 34 ]
python
en
['en', 'co', 'en']
True
CalendarEventView.get
(self, request, entity_id)
Return calendar events.
Return calendar events.
async def get(self, request, entity_id): """Return calendar events.""" entity = self.component.get_entity(entity_id) start = request.query.get("start") end = request.query.get("end") if None in (start, end, entity): return web.Response(status=HTTP_BAD_REQUEST) ...
[ "async", "def", "get", "(", "self", ",", "request", ",", "entity_id", ")", ":", "entity", "=", "self", ".", "component", ".", "get_entity", "(", "entity_id", ")", "start", "=", "request", ".", "query", ".", "get", "(", "\"start\"", ")", "end", "=", "...
[ 189, 4 ]
[ 204, 36 ]
python
en
['ro', 'is', 'en']
False
CalendarListView.__init__
(self, component: EntityComponent)
Initialize calendar view.
Initialize calendar view.
def __init__(self, component: EntityComponent) -> None: """Initialize calendar view.""" self.component = component
[ "def", "__init__", "(", "self", ",", "component", ":", "EntityComponent", ")", "->", "None", ":", "self", ".", "component", "=", "component" ]
[ 213, 4 ]
[ 215, 34 ]
python
en
['en', 'co', 'en']
True
CalendarListView.get
(self, request: web.Request)
Retrieve calendar list.
Retrieve calendar list.
async def get(self, request: web.Request) -> web.Response: """Retrieve calendar list.""" hass = request.app["hass"] calendar_list: List[Dict[str, str]] = [] for entity in self.component.entities: state = hass.states.get(entity.entity_id) calendar_list.append({"na...
[ "async", "def", "get", "(", "self", ",", "request", ":", "web", ".", "Request", ")", "->", "web", ".", "Response", ":", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "calendar_list", ":", "List", "[", "Dict", "[", "str", ",", "str", "]"...
[ 217, 4 ]
[ 226, 83 ]
python
en
['fr', 'ga', 'en']
False
safe_read
( cluster, attributes, allow_cache=True, only_cache=False, manufacturer=None )
Swallow all exceptions from network read. If we throw during initialization, setup fails. Rather have an entity that exists, but is in a maybe wrong state, than no entity. This method should probably only be used during initialization.
Swallow all exceptions from network read.
async def safe_read( cluster, attributes, allow_cache=True, only_cache=False, manufacturer=None ): """Swallow all exceptions from network read. If we throw during initialization, setup fails. Rather have an entity that exists, but is in a maybe wrong state, than no entity. This method should probab...
[ "async", "def", "safe_read", "(", "cluster", ",", "attributes", ",", "allow_cache", "=", "True", ",", "only_cache", "=", "False", ",", "manufacturer", "=", "None", ")", ":", "try", ":", "result", ",", "_", "=", "await", "cluster", ".", "read_attributes", ...
[ 46, 0 ]
[ 64, 17 ]
python
en
['en', 'en', 'en']
True
get_matched_clusters
( source_zha_device: ZhaDeviceType, target_zha_device: ZhaDeviceType )
Get matched input/output cluster pairs for 2 devices.
Get matched input/output cluster pairs for 2 devices.
async def get_matched_clusters( source_zha_device: ZhaDeviceType, target_zha_device: ZhaDeviceType ) -> List[BindingPair]: """Get matched input/output cluster pairs for 2 devices.""" source_clusters = source_zha_device.async_get_std_clusters() target_clusters = target_zha_device.async_get_std_clusters()...
[ "async", "def", "get_matched_clusters", "(", "source_zha_device", ":", "ZhaDeviceType", ",", "target_zha_device", ":", "ZhaDeviceType", ")", "->", "List", "[", "BindingPair", "]", ":", "source_clusters", "=", "source_zha_device", ".", "async_get_std_clusters", "(", ")...
[ 67, 0 ]
[ 101, 27 ]
python
en
['en', 'en', 'en']
True
async_is_bindable_target
(source_zha_device, target_zha_device)
Determine if target is bindable to source.
Determine if target is bindable to source.
def async_is_bindable_target(source_zha_device, target_zha_device): """Determine if target is bindable to source.""" if target_zha_device.nwk == 0x0000: return True source_clusters = source_zha_device.async_get_std_clusters() target_clusters = target_zha_device.async_get_std_clusters() for...
[ "def", "async_is_bindable_target", "(", "source_zha_device", ",", "target_zha_device", ")", ":", "if", "target_zha_device", ".", "nwk", "==", "0x0000", ":", "return", "True", "source_clusters", "=", "source_zha_device", ".", "async_get_std_clusters", "(", ")", "target...
[ 105, 0 ]
[ 120, 16 ]
python
en
['en', 'en', 'en']
True
async_get_zha_device
(hass, device_id)
Get a ZHA device for the given device registry id.
Get a ZHA device for the given device registry id.
async def async_get_zha_device(hass, device_id): """Get a ZHA device for the given device registry id.""" device_registry = await hass.helpers.device_registry.async_get_registry() registry_device = device_registry.async_get(device_id) zha_gateway = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY] ieee_address ...
[ "async", "def", "async_get_zha_device", "(", "hass", ",", "device_id", ")", ":", "device_registry", "=", "await", "hass", ".", "helpers", ".", "device_registry", ".", "async_get_registry", "(", ")", "registry_device", "=", "device_registry", ".", "async_get", "(",...
[ 123, 0 ]
[ 130, 36 ]
python
en
['en', 'en', 'en']
True
find_state_attributes
(states: List[State], key: str)
Find attributes with matching key from states.
Find attributes with matching key from states.
def find_state_attributes(states: List[State], key: str) -> Iterator[Any]: """Find attributes with matching key from states.""" for state in states: value = state.attributes.get(key) if value is not None: yield value
[ "def", "find_state_attributes", "(", "states", ":", "List", "[", "State", "]", ",", "key", ":", "str", ")", "->", "Iterator", "[", "Any", "]", ":", "for", "state", "in", "states", ":", "value", "=", "state", ".", "attributes", ".", "get", "(", "key",...
[ 133, 0 ]
[ 138, 23 ]
python
en
['en', 'en', 'en']
True
mean_int
(*args)
Return the mean of the supplied values.
Return the mean of the supplied values.
def mean_int(*args): """Return the mean of the supplied values.""" return int(sum(args) / len(args))
[ "def", "mean_int", "(", "*", "args", ")", ":", "return", "int", "(", "sum", "(", "args", ")", "/", "len", "(", "args", ")", ")" ]
[ 141, 0 ]
[ 143, 37 ]
python
en
['en', 'en', 'en']
True
mean_tuple
(*args)
Return the mean values along the columns of the supplied values.
Return the mean values along the columns of the supplied values.
def mean_tuple(*args): """Return the mean values along the columns of the supplied values.""" return tuple(sum(x) / len(x) for x in zip(*args))
[ "def", "mean_tuple", "(", "*", "args", ")", ":", "return", "tuple", "(", "sum", "(", "x", ")", "/", "len", "(", "x", ")", "for", "x", "in", "zip", "(", "*", "args", ")", ")" ]
[ 146, 0 ]
[ 148, 53 ]
python
en
['en', 'en', 'en']
True
reduce_attribute
( states: List[State], key: str, default: Optional[Any] = None, reduce: Callable[..., Any] = mean_int, )
Find the first attribute matching key from states. If none are found, return default.
Find the first attribute matching key from states.
def reduce_attribute( states: List[State], key: str, default: Optional[Any] = None, reduce: Callable[..., Any] = mean_int, ) -> Any: """Find the first attribute matching key from states. If none are found, return default. """ attrs = list(find_state_attributes(states, key)) if not ...
[ "def", "reduce_attribute", "(", "states", ":", "List", "[", "State", "]", ",", "key", ":", "str", ",", "default", ":", "Optional", "[", "Any", "]", "=", "None", ",", "reduce", ":", "Callable", "[", "...", ",", "Any", "]", "=", "mean_int", ",", ")",...
[ 151, 0 ]
[ 169, 25 ]
python
en
['en', 'en', 'en']
True
retryable_req
( delays=(1, 5, 10, 15, 30, 60, 120, 180, 360, 600, 900, 1800), raise_=False )
Make a method with ZCL requests retryable. This adds delays keyword argument to function. len(delays) is number of tries. raise_ if the final attempt should raise the exception.
Make a method with ZCL requests retryable.
def retryable_req( delays=(1, 5, 10, 15, 30, 60, 120, 180, 360, 600, 900, 1800), raise_=False ): """Make a method with ZCL requests retryable. This adds delays keyword argument to function. len(delays) is number of tries. raise_ if the final attempt should raise the exception. """ def deco...
[ "def", "retryable_req", "(", "delays", "=", "(", "1", ",", "5", ",", "10", ",", "15", ",", "30", ",", "60", ",", "120", ",", "180", ",", "360", ",", "600", ",", "900", ",", "1800", ")", ",", "raise_", "=", "False", ")", ":", "def", "decorator...
[ 196, 0 ]
[ 240, 20 ]
python
en
['en', 'en', 'en']
True
convert_install_code
(value: str)
Convert string to install code bytes and validate length.
Convert string to install code bytes and validate length.
def convert_install_code(value: str) -> bytes: """Convert string to install code bytes and validate length.""" try: code = binascii.unhexlify(value.replace("-", "").lower()) except binascii.Error as exc: raise vol.Invalid(f"invalid hex string: {value}") from exc if len(code) != 18: # ...
[ "def", "convert_install_code", "(", "value", ":", "str", ")", "->", "bytes", ":", "try", ":", "code", "=", "binascii", ".", "unhexlify", "(", "value", ".", "replace", "(", "\"-\"", ",", "\"\"", ")", ".", "lower", "(", ")", ")", "except", "binascii", ...
[ 243, 0 ]
[ 257, 15 ]
python
en
['en', 'en', 'en']
True
qr_to_install_code
(qr_code: str)
Try to parse the QR code. if successful, return a tuple of a EUI64 address and install code.
Try to parse the QR code.
def qr_to_install_code(qr_code: str) -> Tuple[zigpy.types.EUI64, bytes]: """Try to parse the QR code. if successful, return a tuple of a EUI64 address and install code. """ for code_pattern in QR_CODES: match = re.search(code_pattern, qr_code, re.VERBOSE) if match is None: ...
[ "def", "qr_to_install_code", "(", "qr_code", ":", "str", ")", "->", "Tuple", "[", "zigpy", ".", "types", ".", "EUI64", ",", "bytes", "]", ":", "for", "code_pattern", "in", "QR_CODES", ":", "match", "=", "re", ".", "search", "(", "code_pattern", ",", "q...
[ 282, 0 ]
[ 300, 61 ]
python
en
['en', 'en', 'en']
True
LogMixin.log
(self, level, msg, *args)
Log with level.
Log with level.
def log(self, level, msg, *args): """Log with level.""" raise NotImplementedError
[ "def", "log", "(", "self", ",", "level", ",", "msg", ",", "*", "args", ")", ":", "raise", "NotImplementedError" ]
[ 175, 4 ]
[ 177, 33 ]
python
en
['en', 'en', 'en']
True
LogMixin.debug
(self, msg, *args)
Debug level log.
Debug level log.
def debug(self, msg, *args): """Debug level log.""" return self.log(logging.DEBUG, msg, *args)
[ "def", "debug", "(", "self", ",", "msg", ",", "*", "args", ")", ":", "return", "self", ".", "log", "(", "logging", ".", "DEBUG", ",", "msg", ",", "*", "args", ")" ]
[ 179, 4 ]
[ 181, 50 ]
python
ceb
['es', 'ceb', 'en']
False
LogMixin.info
(self, msg, *args)
Info level log.
Info level log.
def info(self, msg, *args): """Info level log.""" return self.log(logging.INFO, msg, *args)
[ "def", "info", "(", "self", ",", "msg", ",", "*", "args", ")", ":", "return", "self", ".", "log", "(", "logging", ".", "INFO", ",", "msg", ",", "*", "args", ")" ]
[ 183, 4 ]
[ 185, 49 ]
python
bg
['es', 'bg', 'en']
False
LogMixin.warning
(self, msg, *args)
Warning method log.
Warning method log.
def warning(self, msg, *args): """Warning method log.""" return self.log(logging.WARNING, msg, *args)
[ "def", "warning", "(", "self", ",", "msg", ",", "*", "args", ")", ":", "return", "self", ".", "log", "(", "logging", ".", "WARNING", ",", "msg", ",", "*", "args", ")" ]
[ 187, 4 ]
[ 189, 52 ]
python
en
['en', 'jv', 'en']
True
LogMixin.error
(self, msg, *args)
Error level log.
Error level log.
def error(self, msg, *args): """Error level log.""" return self.log(logging.ERROR, msg, *args)
[ "def", "error", "(", "self", ",", "msg", ",", "*", "args", ")", ":", "return", "self", ".", "log", "(", "logging", ".", "ERROR", ",", "msg", ",", "*", "args", ")" ]
[ 191, 4 ]
[ 193, 50 ]
python
en
['es', 'la', 'en']
False
async_setup_entity_basic
( hass, config, async_add_entities, config_entry, discovery_data=None )
Set up a MQTT Light.
Set up a MQTT Light.
async def async_setup_entity_basic( hass, config, async_add_entities, config_entry, discovery_data=None ): """Set up a MQTT Light.""" if CONF_STATE_VALUE_TEMPLATE not in config and CONF_VALUE_TEMPLATE in config: config[CONF_STATE_VALUE_TEMPLATE] = config[CONF_VALUE_TEMPLATE] async_add_entities(...
[ "async", "def", "async_setup_entity_basic", "(", "hass", ",", "config", ",", "async_add_entities", ",", "config_entry", ",", "discovery_data", "=", "None", ")", ":", "if", "CONF_STATE_VALUE_TEMPLATE", "not", "in", "config", "and", "CONF_VALUE_TEMPLATE", "in", "confi...
[ 156, 0 ]
[ 163, 79 ]
python
en
['en', 'lb', 'en']
True
MqttLight.__init__
(self, hass, config, config_entry, discovery_data)
Initialize MQTT light.
Initialize MQTT light.
def __init__(self, hass, config, config_entry, discovery_data): """Initialize MQTT light.""" self.hass = hass self._state = False self._sub_state = None self._brightness = None self._hs = None self._color_temp = None self._effect = None self._white...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ",", "config_entry", ",", "discovery_data", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "_state", "=", "False", "self", ".", "_sub_state", "=", "None", "self", ".", "_brightness", ...
[ 176, 4 ]
[ 209, 72 ]
python
en
['en', 'lb', 'it']
False
MqttLight.async_added_to_hass
(self)
Subscribe to MQTT events.
Subscribe to MQTT events.
async def async_added_to_hass(self): """Subscribe to MQTT events.""" await super().async_added_to_hass() await self._subscribe_topics()
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "await", "self", ".", "_subscribe_topics", "(", ")" ]
[ 211, 4 ]
[ 214, 38 ]
python
en
['en', 'en', 'en']
True
MqttLight.discovery_update
(self, discovery_payload)
Handle updated discovery message.
Handle updated discovery message.
async def discovery_update(self, discovery_payload): """Handle updated discovery message.""" config = PLATFORM_SCHEMA_BASIC(discovery_payload) self._setup_from_config(config) await self.attributes_discovery_update(config) await self.availability_discovery_update(config) a...
[ "async", "def", "discovery_update", "(", "self", ",", "discovery_payload", ")", ":", "config", "=", "PLATFORM_SCHEMA_BASIC", "(", "discovery_payload", ")", "self", ".", "_setup_from_config", "(", "config", ")", "await", "self", ".", "attributes_discovery_update", "(...
[ 216, 4 ]
[ 224, 35 ]
python
en
['en', 'en', 'en']
True
MqttLight._setup_from_config
(self, config)
(Re)Setup the entity.
(Re)Setup the entity.
def _setup_from_config(self, config): """(Re)Setup the entity.""" self._config = config topic = { key: config.get(key) for key in ( CONF_BRIGHTNESS_COMMAND_TOPIC, CONF_BRIGHTNESS_STATE_TOPIC, CONF_COLOR_TEMP_COMMAND_TOPIC, ...
[ "def", "_setup_from_config", "(", "self", ",", "config", ")", ":", "self", ".", "_config", "=", "config", "topic", "=", "{", "key", ":", "config", ".", "get", "(", "key", ")", "for", "key", "in", "(", "CONF_BRIGHTNESS_COMMAND_TOPIC", ",", "CONF_BRIGHTNESS_...
[ 226, 4 ]
[ 294, 78 ]
python
en
['en', 'haw', 'en']
True
MqttLight._subscribe_topics
(self)
(Re)Subscribe to topics.
(Re)Subscribe to topics.
async def _subscribe_topics(self): """(Re)Subscribe to topics.""" topics = {} last_state = await self.async_get_last_state() @callback @log_messages(self.hass, self.entity_id) def state_received(msg): """Handle new MQTT messages.""" payload = sel...
[ "async", "def", "_subscribe_topics", "(", "self", ")", ":", "topics", "=", "{", "}", "last_state", "=", "await", "self", ".", "async_get_last_state", "(", ")", "@", "callback", "@", "log_messages", "(", "self", ".", "hass", ",", "self", ".", "entity_id", ...
[ 296, 4 ]
[ 526, 9 ]
python
en
['en', 'en', 'en']
True
MqttLight.async_will_remove_from_hass
(self)
Unsubscribe when removed.
Unsubscribe when removed.
async def async_will_remove_from_hass(self): """Unsubscribe when removed.""" self._sub_state = await subscription.async_unsubscribe_topics( self.hass, self._sub_state ) await MqttAttributes.async_will_remove_from_hass(self) await MqttAvailability.async_will_remove_fro...
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", ":", "self", ".", "_sub_state", "=", "await", "subscription", ".", "async_unsubscribe_topics", "(", "self", ".", "hass", ",", "self", ".", "_sub_state", ")", "await", "MqttAttributes", ".", "async_...
[ 528, 4 ]
[ 535, 67 ]
python
en
['en', 'en', 'en']
True
MqttLight.brightness
(self)
Return the brightness of this light between 0..255.
Return the brightness of this light between 0..255.
def brightness(self): """Return the brightness of this light between 0..255.""" brightness = self._brightness if brightness: brightness = min(round(brightness), 255) return brightness
[ "def", "brightness", "(", "self", ")", ":", "brightness", "=", "self", ".", "_brightness", "if", "brightness", ":", "brightness", "=", "min", "(", "round", "(", "brightness", ")", ",", "255", ")", "return", "brightness" ]
[ 538, 4 ]
[ 543, 25 ]
python
en
['en', 'en', 'en']
True
MqttLight.hs_color
(self)
Return the hs color value.
Return the hs color value.
def hs_color(self): """Return the hs color value.""" if self._white_value: return None return self._hs
[ "def", "hs_color", "(", "self", ")", ":", "if", "self", ".", "_white_value", ":", "return", "None", "return", "self", ".", "_hs" ]
[ 546, 4 ]
[ 550, 23 ]
python
en
['en', 'en', 'en']
True
MqttLight.color_temp
(self)
Return the color temperature in mired.
Return the color temperature in mired.
def color_temp(self): """Return the color temperature in mired.""" supports_color = ( self._topic[CONF_RGB_COMMAND_TOPIC] or self._topic[CONF_HS_COMMAND_TOPIC] or self._topic[CONF_XY_COMMAND_TOPIC] ) if self._white_value or not supports_color: ...
[ "def", "color_temp", "(", "self", ")", ":", "supports_color", "=", "(", "self", ".", "_topic", "[", "CONF_RGB_COMMAND_TOPIC", "]", "or", "self", ".", "_topic", "[", "CONF_HS_COMMAND_TOPIC", "]", "or", "self", ".", "_topic", "[", "CONF_XY_COMMAND_TOPIC", "]", ...
[ 553, 4 ]
[ 562, 19 ]
python
en
['en', 'en', 'en']
True
MqttLight.min_mireds
(self)
Return the coldest color_temp that this light supports.
Return the coldest color_temp that this light supports.
def min_mireds(self): """Return the coldest color_temp that this light supports.""" return self._config.get(CONF_MIN_MIREDS, super().min_mireds)
[ "def", "min_mireds", "(", "self", ")", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_MIN_MIREDS", ",", "super", "(", ")", ".", "min_mireds", ")" ]
[ 565, 4 ]
[ 567, 68 ]
python
en
['en', 'en', 'en']
True
MqttLight.max_mireds
(self)
Return the warmest color_temp that this light supports.
Return the warmest color_temp that this light supports.
def max_mireds(self): """Return the warmest color_temp that this light supports.""" return self._config.get(CONF_MAX_MIREDS, super().max_mireds)
[ "def", "max_mireds", "(", "self", ")", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_MAX_MIREDS", ",", "super", "(", ")", ".", "max_mireds", ")" ]
[ 570, 4 ]
[ 572, 68 ]
python
en
['en', 'en', 'en']
True
MqttLight.white_value
(self)
Return the white property.
Return the white property.
def white_value(self): """Return the white property.""" white_value = self._white_value if white_value: white_value = min(round(white_value), 255) return white_value return None
[ "def", "white_value", "(", "self", ")", ":", "white_value", "=", "self", ".", "_white_value", "if", "white_value", ":", "white_value", "=", "min", "(", "round", "(", "white_value", ")", ",", "255", ")", "return", "white_value", "return", "None" ]
[ 575, 4 ]
[ 581, 19 ]
python
en
['en', 'en', 'en']
True
MqttLight.should_poll
(self)
No polling needed for a MQTT light.
No polling needed for a MQTT light.
def should_poll(self): """No polling needed for a MQTT light.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 584, 4 ]
[ 586, 20 ]
python
en
['en', 'en', 'en']
True
MqttLight.name
(self)
Return the name of the device if any.
Return the name of the device if any.
def name(self): """Return the name of the device if any.""" return self._config[CONF_NAME]
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_config", "[", "CONF_NAME", "]" ]
[ 589, 4 ]
[ 591, 38 ]
python
en
['en', 'en', 'en']
True
MqttLight.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 594, 4 ]
[ 596, 30 ]
python
ca
['fr', 'ca', 'en']
False
MqttLight.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 599, 4 ]
[ 601, 26 ]
python
en
['en', 'fy', 'en']
True
MqttLight.assumed_state
(self)
Return true if we do optimistic updates.
Return true if we do optimistic updates.
def assumed_state(self): """Return true if we do optimistic updates.""" return self._optimistic
[ "def", "assumed_state", "(", "self", ")", ":", "return", "self", ".", "_optimistic" ]
[ 604, 4 ]
[ 606, 31 ]
python
en
['pt', 'la', 'en']
False
MqttLight.effect_list
(self)
Return the list of supported effects.
Return the list of supported effects.
def effect_list(self): """Return the list of supported effects.""" return self._config.get(CONF_EFFECT_LIST)
[ "def", "effect_list", "(", "self", ")", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_EFFECT_LIST", ")" ]
[ 609, 4 ]
[ 611, 49 ]
python
en
['en', 'en', 'en']
True
MqttLight.effect
(self)
Return the current effect.
Return the current effect.
def effect(self): """Return the current effect.""" return self._effect
[ "def", "effect", "(", "self", ")", ":", "return", "self", ".", "_effect" ]
[ 614, 4 ]
[ 616, 27 ]
python
en
['en', 'en', 'en']
True
MqttLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" supported_features = 0 supported_features |= self._topic[CONF_RGB_COMMAND_TOPIC] is not None and ( SUPPORT_COLOR | SUPPORT_BRIGHTNESS ) supported_features |= ( self._topic[CONF_BRIGHTNESS_COMMAND...
[ "def", "supported_features", "(", "self", ")", ":", "supported_features", "=", "0", "supported_features", "|=", "self", ".", "_topic", "[", "CONF_RGB_COMMAND_TOPIC", "]", "is", "not", "None", "and", "(", "SUPPORT_COLOR", "|", "SUPPORT_BRIGHTNESS", ")", "supported_...
[ 619, 4 ]
[ 647, 33 ]
python
en
['da', 'en', 'en']
True
MqttLight.async_turn_on
(self, **kwargs)
Turn the device on. This method is a coroutine.
Turn the device on.
async def async_turn_on(self, **kwargs): """Turn the device on. This method is a coroutine. """ should_update = False on_command_type = self._config[CONF_ON_COMMAND_TYPE] if on_command_type == "first": mqtt.async_publish( self.hass, ...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "should_update", "=", "False", "on_command_type", "=", "self", ".", "_config", "[", "CONF_ON_COMMAND_TYPE", "]", "if", "on_command_type", "==", "\"first\"", ":", "mqtt", ".", "a...
[ 649, 4 ]
[ 858, 39 ]
python
en
['en', 'en', 'en']
True
MqttLight.async_turn_off
(self, **kwargs)
Turn the device off. This method is a coroutine.
Turn the device off.
async def async_turn_off(self, **kwargs): """Turn the device off. This method is a coroutine. """ mqtt.async_publish( self.hass, self._topic[CONF_COMMAND_TOPIC], self._payload["off"], self._config[CONF_QOS], self._config[CONF_R...
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "mqtt", ".", "async_publish", "(", "self", ".", "hass", ",", "self", ".", "_topic", "[", "CONF_COMMAND_TOPIC", "]", ",", "self", ".", "_payload", "[", "\"off\"", "]", ","...
[ 860, 4 ]
[ 876, 39 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the XBee Zigbee binary sensor platform.
Set up the XBee Zigbee binary sensor platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the XBee Zigbee binary sensor platform.""" zigbee_device = hass.data[DOMAIN] add_entities([XBeeBinarySensor(XBeeDigitalInConfig(config), zigbee_device)], True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "zigbee_device", "=", "hass", ".", "data", "[", "DOMAIN", "]", "add_entities", "(", "[", "XBeeBinarySensor", "(", "XBeeDigitalInConfig", "("...
[ 15, 0 ]
[ 18, 86 ]
python
en
['en', 'xh', 'en']
True
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 19, 0 ]
[ 21, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 25, 0 ]
[ 27, 30 ]
python
en
['en', 'fy', 'en']
True
test_get_actions
(hass, device_reg, entity_reg)
Test we get the expected actions from a vacuum.
Test we get the expected actions from a vacuum.
async def test_get_actions(hass, device_reg, entity_reg): """Test we get the expected actions from a vacuum.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, conn...
[ "async", "def", "test_get_actions", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ")", ...
[ 30, 0 ]
[ 54, 48 ]
python
en
['en', 'en', 'en']
True
test_action
(hass)
Test for turn_on and turn_off actions.
Test for turn_on and turn_off actions.
async def test_action(hass): """Test for turn_on and turn_off actions.""" assert await async_setup_component( hass, automation.DOMAIN, { automation.DOMAIN: [ { "trigger": {"platform": "event", "event_type": "test_event_dock"}, ...
[ "async", "def", "test_action", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "automation", ".", "DOMAIN", ",", "{", "automation", ".", "DOMAIN", ":", "[", "{", "\"trigger\"", ":", "{", "\"platform\"", ":", "\"event\"", ...
[ 57, 0 ]
[ 97, 32 ]
python
en
['en', 'en', 'en']
True
kill_raspistill
(*args)
Kill any previously running raspistill process..
Kill any previously running raspistill process..
def kill_raspistill(*args): """Kill any previously running raspistill process..""" subprocess.Popen( ["killall", "raspistill"], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT )
[ "def", "kill_raspistill", "(", "*", "args", ")", ":", "subprocess", ".", "Popen", "(", "[", "\"killall\"", ",", "\"raspistill\"", "]", ",", "stdout", "=", "subprocess", ".", "DEVNULL", ",", "stderr", "=", "subprocess", ".", "STDOUT", ")" ]
[ 26, 0 ]
[ 30, 5 ]
python
en
['en', 'sv', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Raspberry Camera.
Set up the Raspberry Camera.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Raspberry Camera.""" # We only want this platform to be set up via discovery. # prevent initializing by erroneous platform config section in yaml conf if discovery_info is None: return if shutil.which("raspis...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "# We only want this platform to be set up via discovery.", "# prevent initializing by erroneous platform config section in yaml conf", "if", "discovery_info", ...
[ 33, 0 ]
[ 69, 49 ]
python
en
['en', 'zh', 'en']
True
RaspberryCamera.__init__
(self, device_info)
Initialize Raspberry Pi camera component.
Initialize Raspberry Pi camera component.
def __init__(self, device_info): """Initialize Raspberry Pi camera component.""" super().__init__() self._name = device_info[CONF_NAME] self._config = device_info # Kill if there's raspistill instance kill_raspistill() cmd_args = [ "raspistill", ...
[ "def", "__init__", "(", "self", ",", "device_info", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_name", "=", "device_info", "[", "CONF_NAME", "]", "self", ".", "_config", "=", "device_info", "# Kill if there's raspistill instance", ...
[ 75, 4 ]
[ 119, 87 ]
python
co
['it', 'co', 'en']
False
RaspberryCamera.camera_image
(self)
Return raspistill image response.
Return raspistill image response.
def camera_image(self): """Return raspistill image response.""" with open(self._config[CONF_FILE_PATH], "rb") as file: return file.read()
[ "def", "camera_image", "(", "self", ")", ":", "with", "open", "(", "self", ".", "_config", "[", "CONF_FILE_PATH", "]", ",", "\"rb\"", ")", "as", "file", ":", "return", "file", ".", "read", "(", ")" ]
[ 121, 4 ]
[ 124, 30 ]
python
sv
['sv', 'sv', 'en']
True
RaspberryCamera.name
(self)
Return the name of this camera.
Return the name of this camera.
def name(self): """Return the name of this camera.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 127, 4 ]
[ 129, 25 ]
python
en
['en', 'en', 'en']
True
RaspberryCamera.frame_interval
(self)
Return the interval between frames of the stream.
Return the interval between frames of the stream.
def frame_interval(self): """Return the interval between frames of the stream.""" return self._config[CONF_TIMELAPSE] / 1000
[ "def", "frame_interval", "(", "self", ")", ":", "return", "self", ".", "_config", "[", "CONF_TIMELAPSE", "]", "/", "1000" ]
[ 132, 4 ]
[ 134, 50 ]
python
en
['en', 'en', 'en']
True
int64_feature
(values)
Returns a TF-Feature of int64s. Args: values: A scalar or list of values. Returns: A TF-Feature.
Returns a TF-Feature of int64s.
def int64_feature(values): """Returns a TF-Feature of int64s. Args: values: A scalar or list of values. Returns: A TF-Feature. """ if not isinstance(values, (tuple, list)): values = [values] return tf.train.Feature(int64_list=tf.train.Int64List(value=values))
[ "def", "int64_feature", "(", "values", ")", ":", "if", "not", "isinstance", "(", "values", ",", "(", "tuple", ",", "list", ")", ")", ":", "values", "=", "[", "values", "]", "return", "tf", ".", "train", ".", "Feature", "(", "int64_list", "=", "tf", ...
[ 30, 0 ]
[ 41, 70 ]
python
en
['en', 'en', 'en']
True
bytes_list_feature
(values)
Returns a TF-Feature of list of bytes. Args: values: A string or list of strings. Returns: A TF-Feature.
Returns a TF-Feature of list of bytes.
def bytes_list_feature(values): """Returns a TF-Feature of list of bytes. Args: values: A string or list of strings. Returns: A TF-Feature. """ return tf.train.Feature(bytes_list=tf.train.BytesList(value=values))
[ "def", "bytes_list_feature", "(", "values", ")", ":", "return", "tf", ".", "train", ".", "Feature", "(", "bytes_list", "=", "tf", ".", "train", ".", "BytesList", "(", "value", "=", "values", ")", ")" ]
[ 44, 0 ]
[ 53, 70 ]
python
en
['en', 'en', 'en']
True
float_list_feature
(values)
Returns a TF-Feature of list of floats. Args: values: A float or list of floats. Returns: A TF-Feature.
Returns a TF-Feature of list of floats.
def float_list_feature(values): """Returns a TF-Feature of list of floats. Args: values: A float or list of floats. Returns: A TF-Feature. """ return tf.train.Feature(float_list=tf.train.FloatList(value=values))
[ "def", "float_list_feature", "(", "values", ")", ":", "return", "tf", ".", "train", ".", "Feature", "(", "float_list", "=", "tf", ".", "train", ".", "FloatList", "(", "value", "=", "values", ")", ")" ]
[ 56, 0 ]
[ 65, 70 ]
python
en
['en', 'en', 'en']
True
bytes_feature
(values)
Returns a TF-Feature of bytes. Args: values: A string. Returns: A TF-Feature.
Returns a TF-Feature of bytes.
def bytes_feature(values): """Returns a TF-Feature of bytes. Args: values: A string. Returns: A TF-Feature. """ return tf.train.Feature(bytes_list=tf.train.BytesList(value=[values]))
[ "def", "bytes_feature", "(", "values", ")", ":", "return", "tf", ".", "train", ".", "Feature", "(", "bytes_list", "=", "tf", ".", "train", ".", "BytesList", "(", "value", "=", "[", "values", "]", ")", ")" ]
[ 68, 0 ]
[ 77, 72 ]
python
en
['en', 'en', 'en']
True
float_feature
(values)
Returns a TF-Feature of floats. Args: values: A scalar of list of values. Returns: A TF-Feature.
Returns a TF-Feature of floats.
def float_feature(values): """Returns a TF-Feature of floats. Args: values: A scalar of list of values. Returns: A TF-Feature. """ if not isinstance(values, (tuple, list)): values = [values] return tf.train.Feature(float_list=tf.train.FloatList(value=values))
[ "def", "float_feature", "(", "values", ")", ":", "if", "not", "isinstance", "(", "values", ",", "(", "tuple", ",", "list", ")", ")", ":", "values", "=", "[", "values", "]", "return", "tf", ".", "train", ".", "Feature", "(", "float_list", "=", "tf", ...
[ 80, 0 ]
[ 91, 70 ]
python
en
['en', 'en', 'en']
True
download_url
(url, dataset_dir)
Downloads the tarball or zip file from url into filepath. Args: url: The URL of a tarball or zip file. dataset_dir: The directory where the temporary files are stored. Returns: filepath: path where the file is downloaded.
Downloads the tarball or zip file from url into filepath.
def download_url(url, dataset_dir): """Downloads the tarball or zip file from url into filepath. Args: url: The URL of a tarball or zip file. dataset_dir: The directory where the temporary files are stored. Returns: filepath: path where the file is downloaded. """ filename = url.split('/')[-1] ...
[ "def", "download_url", "(", "url", ",", "dataset_dir", ")", ":", "filename", "=", "url", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "filepath", "=", "os", ".", "path", ".", "join", "(", "dataset_dir", ",", "filename", ")", "def", "_progress",...
[ 104, 0 ]
[ 126, 17 ]
python
en
['en', 'en', 'en']
True
download_and_uncompress_tarball
(tarball_url, dataset_dir)
Downloads the `tarball_url` and uncompresses it locally. Args: tarball_url: The URL of a tarball file. dataset_dir: The directory where the temporary files are stored.
Downloads the `tarball_url` and uncompresses it locally.
def download_and_uncompress_tarball(tarball_url, dataset_dir): """Downloads the `tarball_url` and uncompresses it locally. Args: tarball_url: The URL of a tarball file. dataset_dir: The directory where the temporary files are stored. """ filepath = download_url(tarball_url, dataset_dir) tarfile.open(...
[ "def", "download_and_uncompress_tarball", "(", "tarball_url", ",", "dataset_dir", ")", ":", "filepath", "=", "download_url", "(", "tarball_url", ",", "dataset_dir", ")", "tarfile", ".", "open", "(", "filepath", ",", "'r:gz'", ")", ".", "extractall", "(", "datase...
[ 129, 0 ]
[ 137, 56 ]
python
en
['en', 'en', 'en']
True
download_and_uncompress_zipfile
(zip_url, dataset_dir)
Downloads the `zip_url` and uncompresses it locally. Args: zip_url: The URL of a zip file. dataset_dir: The directory where the temporary files are stored.
Downloads the `zip_url` and uncompresses it locally.
def download_and_uncompress_zipfile(zip_url, dataset_dir): """Downloads the `zip_url` and uncompresses it locally. Args: zip_url: The URL of a zip file. dataset_dir: The directory where the temporary files are stored. """ filename = zip_url.split('/')[-1] filepath = os.path.join(dataset_dir, filename...
[ "def", "download_and_uncompress_zipfile", "(", "zip_url", ",", "dataset_dir", ")", ":", "filename", "=", "zip_url", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "filepath", "=", "os", ".", "path", ".", "join", "(", "dataset_dir", ",", "filename", "...
[ 140, 0 ]
[ 161, 45 ]
python
en
['en', 'en', 'en']
True
write_label_file
(labels_to_class_names, dataset_dir, filename=LABELS_FILENAME)
Writes a file with the list of class names. Args: labels_to_class_names: A map of (integer) labels to class names. dataset_dir: The directory in which the labels file should be written. filename: The filename where the class names are written.
Writes a file with the list of class names.
def write_label_file(labels_to_class_names, dataset_dir, filename=LABELS_FILENAME): """Writes a file with the list of class names. Args: labels_to_class_names: A map of (integer) labels to class names. dataset_dir: The directory in which the labels file should be w...
[ "def", "write_label_file", "(", "labels_to_class_names", ",", "dataset_dir", ",", "filename", "=", "LABELS_FILENAME", ")", ":", "labels_filename", "=", "os", ".", "path", ".", "join", "(", "dataset_dir", ",", "filename", ")", "with", "tf", ".", "gfile", ".", ...
[ 164, 0 ]
[ 178, 46 ]
python
en
['en', 'en', 'en']
True
has_labels
(dataset_dir, filename=LABELS_FILENAME)
Specifies whether or not the dataset directory contains a label map file. Args: dataset_dir: The directory in which the labels file is found. filename: The filename where the class names are written. Returns: `True` if the labels file exists and `False` otherwise.
Specifies whether or not the dataset directory contains a label map file.
def has_labels(dataset_dir, filename=LABELS_FILENAME): """Specifies whether or not the dataset directory contains a label map file. Args: dataset_dir: The directory in which the labels file is found. filename: The filename where the class names are written. Returns: `True` if the labels file exists ...
[ "def", "has_labels", "(", "dataset_dir", ",", "filename", "=", "LABELS_FILENAME", ")", ":", "return", "tf", ".", "gfile", ".", "Exists", "(", "os", ".", "path", ".", "join", "(", "dataset_dir", ",", "filename", ")", ")" ]
[ 181, 0 ]
[ 191, 61 ]
python
en
['en', 'en', 'en']
True
read_label_file
(dataset_dir, filename=LABELS_FILENAME)
Reads the labels file and returns a mapping from ID to class name. Args: dataset_dir: The directory in which the labels file is found. filename: The filename where the class names are written. Returns: A map from a label (integer) to class name.
Reads the labels file and returns a mapping from ID to class name.
def read_label_file(dataset_dir, filename=LABELS_FILENAME): """Reads the labels file and returns a mapping from ID to class name. Args: dataset_dir: The directory in which the labels file is found. filename: The filename where the class names are written. Returns: A map from a label (integer) to cla...
[ "def", "read_label_file", "(", "dataset_dir", ",", "filename", "=", "LABELS_FILENAME", ")", ":", "labels_filename", "=", "os", ".", "path", ".", "join", "(", "dataset_dir", ",", "filename", ")", "with", "tf", ".", "gfile", ".", "Open", "(", "labels_filename"...
[ 194, 0 ]
[ 214, 30 ]
python
en
['en', 'en', 'en']
True
open_sharded_output_tfrecords
(exit_stack, base_path, num_shards)
Opens all TFRecord shards for writing and adds them to an exit stack. Args: exit_stack: A context2.ExitStack used to automatically closed the TFRecords opened in this function. base_path: The base path for all shards num_shards: The number of shards Returns: The list of opened TFRecords. Pos...
Opens all TFRecord shards for writing and adds them to an exit stack.
def open_sharded_output_tfrecords(exit_stack, base_path, num_shards): """Opens all TFRecord shards for writing and adds them to an exit stack. Args: exit_stack: A context2.ExitStack used to automatically closed the TFRecords opened in this function. base_path: The base path for all shards num_sha...
[ "def", "open_sharded_output_tfrecords", "(", "exit_stack", ",", "base_path", ",", "num_shards", ")", ":", "tf_record_output_filenames", "=", "[", "'{}-{:05d}-of-{:05d}'", ".", "format", "(", "base_path", ",", "idx", ",", "num_shards", ")", "for", "idx", "in", "ran...
[ 217, 0 ]
[ 239, 18 ]
python
en
['en', 'en', 'en']
True
init_integration
(hass)
Set up the Dexcom integration in Home Assistant.
Set up the Dexcom integration in Home Assistant.
async def init_integration(hass) -> MockConfigEntry: """Set up the Dexcom integration in Home Assistant.""" entry = MockConfigEntry( domain=DOMAIN, title="test_username", unique_id="test_username", data=CONFIG, options=None, ) with patch( "homeassistant.co...
[ "async", "def", "init_integration", "(", "hass", ")", "->", "MockConfigEntry", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "title", "=", "\"test_username\"", ",", "unique_id", "=", "\"test_username\"", ",", "data", "=", "CONFIG", "...
[ 21, 0 ]
[ 41, 16 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the SPC binary sensor.
Set up the SPC binary sensor.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the SPC binary sensor.""" if discovery_info is None: return api = hass.data[DATA_API] async_add_entities( [ SpcBinarySensor(zone) for zone in api.zones.values() ...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "api", "=", "hass", ".", "data", "[", "DATA_API", "]", "async_ad...
[ 24, 0 ]
[ 35, 5 ]
python
en
['en', 'haw', 'en']
True
SpcBinarySensor.__init__
(self, zone)
Initialize the sensor device.
Initialize the sensor device.
def __init__(self, zone): """Initialize the sensor device.""" self._zone = zone
[ "def", "__init__", "(", "self", ",", "zone", ")", ":", "self", ".", "_zone", "=", "zone" ]
[ 41, 4 ]
[ 43, 25 ]
python
en
['en', 'en', 'en']
True
SpcBinarySensor.async_added_to_hass
(self)
Call for adding new entities.
Call for adding new entities.
async def async_added_to_hass(self): """Call for adding new entities.""" self.async_on_remove( async_dispatcher_connect( self.hass, SIGNAL_UPDATE_SENSOR.format(self._zone.id), self._update_callback, ) )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "SIGNAL_UPDATE_SENSOR", ".", "format", "(", "self", ".", "_zone", ".", "id", ")", ",", "self", ".", ...
[ 45, 4 ]
[ 53, 9 ]
python
en
['en', 'en', 'en']
True
SpcBinarySensor._update_callback
(self)
Call update method.
Call update method.
def _update_callback(self): """Call update method.""" self.async_schedule_update_ha_state(True)
[ "def", "_update_callback", "(", "self", ")", ":", "self", ".", "async_schedule_update_ha_state", "(", "True", ")" ]
[ 56, 4 ]
[ 58, 49 ]
python
en
['en', 'sn', 'en']
True
SpcBinarySensor.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._zone.name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_zone", ".", "name" ]
[ 61, 4 ]
[ 63, 30 ]
python
en
['en', 'en', 'en']
True
SpcBinarySensor.is_on
(self)
Whether the device is switched on.
Whether the device is switched on.
def is_on(self): """Whether the device is switched on.""" return self._zone.input == ZoneInput.OPEN
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_zone", ".", "input", "==", "ZoneInput", ".", "OPEN" ]
[ 66, 4 ]
[ 68, 49 ]
python
en
['en', 'en', 'en']
True
SpcBinarySensor.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 71, 4 ]
[ 73, 20 ]
python
en
['en', 'en', 'en']
True