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
AbodeSensor.__init__
(self, data, device, sensor_type)
Initialize a sensor for an Abode device.
Initialize a sensor for an Abode device.
def __init__(self, data, device, sensor_type): """Initialize a sensor for an Abode device.""" super().__init__(data, device) self._sensor_type = sensor_type self._name = f"{self._device.name} {SENSOR_TYPES[self._sensor_type][0]}" self._device_class = SENSOR_TYPES[self._sensor_typ...
[ "def", "__init__", "(", "self", ",", "data", ",", "device", ",", "sensor_type", ")", ":", "super", "(", ")", ".", "__init__", "(", "data", ",", "device", ")", "self", ".", "_sensor_type", "=", "sensor_type", "self", ".", "_name", "=", "f\"{self._device.n...
[ 38, 4 ]
[ 43, 63 ]
python
en
['en', 'en', 'en']
True
AbodeSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 46, 4 ]
[ 48, 25 ]
python
en
['en', 'mi', 'en']
True
AbodeSensor.device_class
(self)
Return the device class.
Return the device class.
def device_class(self): """Return the device class.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 51, 4 ]
[ 53, 33 ]
python
en
['en', 'en', 'en']
True
AbodeSensor.unique_id
(self)
Return a unique ID to use for this device.
Return a unique ID to use for this device.
def unique_id(self): """Return a unique ID to use for this device.""" return f"{self._device.device_uuid}-{self._sensor_type}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self._device.device_uuid}-{self._sensor_type}\"" ]
[ 56, 4 ]
[ 58, 64 ]
python
en
['en', 'en', 'en']
True
AbodeSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" if self._sensor_type == CONST.TEMP_STATUS_KEY: return self._device.temp if self._sensor_type == CONST.HUMI_STATUS_KEY: return self._device.humidity if self._sensor_type == CONST.LUX_STATUS_KEY: ret...
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_sensor_type", "==", "CONST", ".", "TEMP_STATUS_KEY", ":", "return", "self", ".", "_device", ".", "temp", "if", "self", ".", "_sensor_type", "==", "CONST", ".", "HUMI_STATUS_KEY", ":", "return", ...
[ 61, 4 ]
[ 68, 35 ]
python
en
['en', 'en', 'en']
True
AbodeSensor.unit_of_measurement
(self)
Return the units of measurement.
Return the units of measurement.
def unit_of_measurement(self): """Return the units of measurement.""" if self._sensor_type == CONST.TEMP_STATUS_KEY: return self._device.temp_unit if self._sensor_type == CONST.HUMI_STATUS_KEY: return self._device.humidity_unit if self._sensor_type == CONST.LUX_ST...
[ "def", "unit_of_measurement", "(", "self", ")", ":", "if", "self", ".", "_sensor_type", "==", "CONST", ".", "TEMP_STATUS_KEY", ":", "return", "self", ".", "_device", ".", "temp_unit", "if", "self", ".", "_sensor_type", "==", "CONST", ".", "HUMI_STATUS_KEY", ...
[ 71, 4 ]
[ 78, 40 ]
python
en
['en', 'bg', 'en']
True
async_describe_on_off_states
( hass: HomeAssistantType, registry: GroupIntegrationRegistry )
Describe group on off states.
Describe group on off states.
def async_describe_on_off_states( hass: HomeAssistantType, registry: GroupIntegrationRegistry ) -> None: """Describe group on off states.""" registry.on_off_states( {STATE_ON, STATE_PAUSED, STATE_PLAYING, STATE_IDLE}, STATE_OFF )
[ "def", "async_describe_on_off_states", "(", "hass", ":", "HomeAssistantType", ",", "registry", ":", "GroupIntegrationRegistry", ")", "->", "None", ":", "registry", ".", "on_off_states", "(", "{", "STATE_ON", ",", "STATE_PAUSED", ",", "STATE_PLAYING", ",", "STATE_IDL...
[ 16, 0 ]
[ 22, 5 ]
python
en
['en', 'en', 'en']
True
_request_user_ids
()
Get dataframe of user emails, gids, names.
Get dataframe of user emails, gids, names.
def _request_user_ids(): """Get dataframe of user emails, gids, names.""" params = { 'workspace': WORKSPACE_ID, 'opt_fields': 'email,name' } endpoint = 'teams/{}/users/'.format(TEAM_ID) url = 'https://app.asana.com/api/1.0/{}'.format(endpoint) r = requests.get(url, params=par...
[ "def", "_request_user_ids", "(", ")", ":", "params", "=", "{", "'workspace'", ":", "WORKSPACE_ID", ",", "'opt_fields'", ":", "'email,name'", "}", "endpoint", "=", "'teams/{}/users/'", ".", "format", "(", "TEAM_ID", ")", "url", "=", "'https://app.asana.com/api/1.0/...
[ 50, 0 ]
[ 70, 19 ]
python
en
['en', 'da', 'en']
True
update_asana_ids
()
Update info on all asana users: email, asana_id, asana_name.
Update info on all asana users: email, asana_id, asana_name.
def update_asana_ids(): """Update info on all asana users: email, asana_id, asana_name.""" global asana_ids asana_ids = _request_user_ids() # warns if email not recognized # CHECK FOR UNRECOGNIZED ASANA EMAILS _asana_emails = set(asana_ids.email) _extra_emails = _asana_emails.difference(set(ME...
[ "def", "update_asana_ids", "(", ")", ":", "global", "asana_ids", "asana_ids", "=", "_request_user_ids", "(", ")", "# warns if email not recognized", "# CHECK FOR UNRECOGNIZED ASANA EMAILS", "_asana_emails", "=", "set", "(", "asana_ids", ".", "email", ")", "_extra_emails",...
[ 78, 0 ]
[ 95, 35 ]
python
en
['en', 'ig', 'en']
True
get_asana_id_for_user
(user)
Get personal asana user id for user database object. Update user object. Returns: asana_id (str): user's asana ID.
Get personal asana user id for user database object. Update user object.
def get_asana_id_for_user(user): """Get personal asana user id for user database object. Update user object. Returns: asana_id (str): user's asana ID. """ if user.asana_id: return user.asana_id asana_matches = asana_ids[asana_ids.email.isin(user.known_emails)] if not len(asana_m...
[ "def", "get_asana_id_for_user", "(", "user", ")", ":", "if", "user", ".", "asana_id", ":", "return", "user", ".", "asana_id", "asana_matches", "=", "asana_ids", "[", "asana_ids", ".", "email", ".", "isin", "(", "user", ".", "known_emails", ")", "]", "if", ...
[ 98, 0 ]
[ 120, 19 ]
python
en
['da', 'en', 'en']
True
_request_projects
()
Get project metadata for all unarchived projects.
Get project metadata for all unarchived projects.
def _request_projects(): """Get project metadata for all unarchived projects.""" opt_fields = ['name', 'color', 'modified_at', 'followers', 'members', 'notes', 'owner', 'public', 'team', 'workspace'] params = { 'opt_fields': ','.join(opt_fields), 'limit': ...
[ "def", "_request_projects", "(", ")", ":", "opt_fields", "=", "[", "'name'", ",", "'color'", ",", "'modified_at'", ",", "'followers'", ",", "'members'", ",", "'notes'", ",", "'owner'", ",", "'public'", ",", "'team'", ",", "'workspace'", "]", "params", "=", ...
[ 133, 0 ]
[ 159, 15 ]
python
en
['en', 'en', 'en']
True
_request_project_tasks
(project_id)
Get incomplete tasks for project.
Get incomplete tasks for project.
def _request_project_tasks(project_id): """Get incomplete tasks for project.""" keep_cols = ['name', 'due_on', 'modified_at', 'html_notes', 'assignee'] extra_cols = ['projects', 'memberships.(section|project).name'] opt_fields = keep_cols + extra_cols params = { 'opt_fields': ','.join(opt_...
[ "def", "_request_project_tasks", "(", "project_id", ")", ":", "keep_cols", "=", "[", "'name'", ",", "'due_on'", ",", "'modified_at'", ",", "'html_notes'", ",", "'assignee'", "]", "extra_cols", "=", "[", "'projects'", ",", "'memberships.(section|project).name'", "]",...
[ 178, 0 ]
[ 235, 30 ]
python
en
['en', 'da', 'en']
True
update_tasks_links
()
Gather tasks for all projects, and linkage between task, section, project.
Gather tasks for all projects, and linkage between task, section, project.
def update_tasks_links(): """Gather tasks for all projects, and linkage between task, section, project.""" global tasks, links all_tasks, all_parents = [], [] project_ids = set(projects.index) for project_id in project_ids: tasks, parents = _request_project_tasks(project_id) all_tas...
[ "def", "update_tasks_links", "(", ")", ":", "global", "tasks", ",", "links", "all_tasks", ",", "all_parents", "=", "[", "]", ",", "[", "]", "project_ids", "=", "set", "(", "projects", ".", "index", ")", "for", "project_id", "in", "project_ids", ":", "tas...
[ 244, 0 ]
[ 287, 33 ]
python
en
['en', 'en', 'en']
True
load_user_assigned_tasks
(user)
Get table of upcoming tasks assigned to db user. Returns: pd.DataFrame of tasks (including 'location' column) if asana match and if any tasks assigned to user, else None.
Get table of upcoming tasks assigned to db user.
def load_user_assigned_tasks(user): """Get table of upcoming tasks assigned to db user. Returns: pd.DataFrame of tasks (including 'location' column) if asana match and if any tasks assigned to user, else None. """ asana_id = get_asana_id_for_user(user) if asana_id is None: ...
[ "def", "load_user_assigned_tasks", "(", "user", ")", ":", "asana_id", "=", "get_asana_id_for_user", "(", "user", ")", "if", "asana_id", "is", "None", ":", "return", "my_tasks", "=", "tasks", "[", "tasks", ".", "assignee", "==", "asana_id", "]", ".", "copy", ...
[ 324, 0 ]
[ 344, 19 ]
python
en
['en', 'en', 'en']
True
Unused.custom_request
(endpoint, param_dict)
Test custom endpoint. Args: endpoint (str): e.g. 'teams/{}/users/'.format(TEAM_ID) param_dict (dict): e.g. params = {'workspace': WORKSPACE_ID, 'opt_fields': 'email,name'} Returns: r: http response object.
Test custom endpoint.
def custom_request(endpoint, param_dict): """Test custom endpoint. Args: endpoint (str): e.g. 'teams/{}/users/'.format(TEAM_ID) param_dict (dict): e.g. params = {'workspace': WORKSPACE_ID, 'opt_fields': 'email,name'} Returns: r: http response ...
[ "def", "custom_request", "(", "endpoint", ",", "param_dict", ")", ":", "# params = {", "# 'workspace': WORKSPACE_ID,", "# 'opt_fields': 'email,name'", "# }", "# endpoint = 'teams/{}/users/'.format(TEAM_ID)", "url", "=", "'https://app.asana.com/api/1.0/{}'", ".", "format...
[ 357, 4 ]
[ 374, 16 ]
python
en
['en', 'en', 'en']
True
Unused.unpack_records
(df, col)
Convert column with list of dicts values to new dataframe, preserving index.
Convert column with list of dicts values to new dataframe, preserving index.
def unpack_records(df, col): """Convert column with list of dicts values to new dataframe, preserving index.""" out = [] ind_name = df.index.name for ind, r in df.iterrows(): try: temp = pd.DataFrame.from_records(r[col]) except ValueError: ...
[ "def", "unpack_records", "(", "df", ",", "col", ")", ":", "out", "=", "[", "]", "ind_name", "=", "df", ".", "index", ".", "name", "for", "ind", ",", "r", "in", "df", ".", "iterrows", "(", ")", ":", "try", ":", "temp", "=", "pd", ".", "DataFrame...
[ 377, 4 ]
[ 392, 18 ]
python
en
['en', 'en', 'en']
True
Unused.add_first_last
(names_df)
Add first and last name to dataframe, based on full_name column.
Add first and last name to dataframe, based on full_name column.
def add_first_last(names_df): """Add first and last name to dataframe, based on full_name column.""" names_df['firstname'], names_df['lastname'] = \ zip(*names_df['full_name'].apply(lambda v: v.split(' ')).values) return names_df.sort_values('lastname')
[ "def", "add_first_last", "(", "names_df", ")", ":", "names_df", "[", "'firstname'", "]", ",", "names_df", "[", "'lastname'", "]", "=", "zip", "(", "*", "names_df", "[", "'full_name'", "]", ".", "apply", "(", "lambda", "v", ":", "v", ".", "split", "(", ...
[ 395, 4 ]
[ 399, 47 ]
python
en
['en', 'en', 'en']
True
Unused.get_asana_user_task_lists
()
Get dictionary of user_id: task_list_id for all users.
Get dictionary of user_id: task_list_id for all users.
def get_asana_user_task_lists(): """Get dictionary of user_id: task_list_id for all users.""" params = { 'workspace': WORKSPACE_ID, } # name_ids = [tuple(i) for i in asana_ids[['asana_name', 'asana_id']].values] user_list_dict = {} user_ids = asana_ids['asana_...
[ "def", "get_asana_user_task_lists", "(", ")", ":", "params", "=", "{", "'workspace'", ":", "WORKSPACE_ID", ",", "}", "# name_ids = [tuple(i) for i in asana_ids[['asana_name', 'asana_id']].values]", "user_list_dict", "=", "{", "}", "user_ids", "=", "asana_ids", "[", "'asan...
[ 410, 4 ]
[ 439, 29 ]
python
en
['en', 'en', 'en']
True
Unused.get_user_tasks
(user)
NOT USED. Get task details and associated projects for user. Args: user: user object. Returns: tasks (pd.DataFrame): table of tasks. task_projects (pd.DataFrame): task_id, project_id table.
NOT USED. Get task details and associated projects for user.
def get_user_tasks(user): """NOT USED. Get task details and associated projects for user. Args: user: user object. Returns: tasks (pd.DataFrame): table of tasks. task_projects (pd.DataFrame): task_id, project_id table. """ # NOTES: can use ei...
[ "def", "get_user_tasks", "(", "user", ")", ":", "# NOTES: can use either notes or html_notes", "# not in response if requested: ('owner', 'current_status', 'team')", "# don't need: ('workspace', 'due_at')", "opt_fields", "=", "[", "'name'", ",", "'due_on'", ",", "'modified_at...
[ 442, 4 ]
[ 497, 34 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Jewish Calendar binary sensor devices.
Set up the Jewish Calendar binary sensor devices.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Jewish Calendar binary sensor devices.""" if discovery_info is None: return async_add_entities( [ JewishCalendarBinarySensor(hass.data[DOMAIN], sensor, sensor_info) f...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "async_add_entities", "(", "[", "JewishCalendarBinarySensor", "(", "ha...
[ 9, 0 ]
[ 19, 5 ]
python
en
['en', 'bs', 'en']
True
JewishCalendarBinarySensor.__init__
(self, data, sensor, sensor_info)
Initialize the binary sensor.
Initialize the binary sensor.
def __init__(self, data, sensor, sensor_info): """Initialize the binary sensor.""" self._location = data["location"] self._type = sensor self._name = f"{data['name']} {sensor_info[0]}" self._icon = sensor_info[1] self._hebrew = data["language"] == "hebrew" self._c...
[ "def", "__init__", "(", "self", ",", "data", ",", "sensor", ",", "sensor_info", ")", ":", "self", ".", "_location", "=", "data", "[", "\"location\"", "]", "self", ".", "_type", "=", "sensor", "self", ".", "_name", "=", "f\"{data['name']} {sensor_info[0]}\"",...
[ 25, 4 ]
[ 35, 37 ]
python
en
['en', 'haw', 'en']
True
JewishCalendarBinarySensor.icon
(self)
Return the icon of the entity.
Return the icon of the entity.
def icon(self): """Return the icon of the entity.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 38, 4 ]
[ 40, 25 ]
python
en
['en', 'en', 'en']
True
JewishCalendarBinarySensor.unique_id
(self)
Generate a unique id.
Generate a unique id.
def unique_id(self) -> str: """Generate a unique id.""" return f"{self._prefix}_{self._type}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._prefix}_{self._type}\"" ]
[ 43, 4 ]
[ 45, 45 ]
python
co
['fr', 'co', 'it']
False
JewishCalendarBinarySensor.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 48, 4 ]
[ 50, 25 ]
python
en
['en', 'en', 'en']
True
JewishCalendarBinarySensor.is_on
(self)
Return true if sensor is on.
Return true if sensor is on.
def is_on(self): """Return true if sensor is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 53, 4 ]
[ 55, 26 ]
python
en
['en', 'et', 'en']
True
JewishCalendarBinarySensor.async_update
(self)
Update the state of the sensor.
Update the state of the sensor.
async def async_update(self): """Update the state of the sensor.""" zmanim = hdate.Zmanim( date=dt_util.now(), location=self._location, candle_lighting_offset=self._candle_lighting_offset, havdalah_offset=self._havdalah_offset, hebrew=self._heb...
[ "async", "def", "async_update", "(", "self", ")", ":", "zmanim", "=", "hdate", ".", "Zmanim", "(", "date", "=", "dt_util", ".", "now", "(", ")", ",", "location", "=", "self", ".", "_location", ",", "candle_lighting_offset", "=", "self", ".", "_candle_lig...
[ 57, 4 ]
[ 67, 52 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistant, config: Config)
Set up configured SMHI.
Set up configured SMHI.
async def async_setup(hass: HomeAssistant, config: Config) -> bool: """Set up configured SMHI.""" # We allow setup only through config flow type of config return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "Config", ")", "->", "bool", ":", "# We allow setup only through config flow type of config", "return", "True" ]
[ 11, 0 ]
[ 14, 15 ]
python
en
['en', 'zu', 'en']
True
async_setup_entry
(hass: HomeAssistant, config_entry: ConfigEntry)
Set up SMHI forecast as config entry.
Set up SMHI forecast as config entry.
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up SMHI forecast as config entry.""" hass.async_create_task( hass.config_entries.async_forward_entry_setup(config_entry, "weather") ) return True
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ")", "->", "bool", ":", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "async_forward_entry_setup", "(", "config_entry", ",...
[ 17, 0 ]
[ 22, 15 ]
python
en
['en', 'pt', 'en']
True
async_unload_entry
(hass: HomeAssistant, config_entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Unload a config entry.""" await hass.config_entries.async_forward_entry_unload(config_entry, "weather") return True
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ")", "->", "bool", ":", "await", "hass", ".", "config_entries", ".", "async_forward_entry_unload", "(", "config_entry", ",", "\"weather\"", ")", "retu...
[ 25, 0 ]
[ 28, 15 ]
python
en
['en', 'es', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Arduino platform.
Set up the Arduino platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Arduino platform.""" board = hass.data[DOMAIN] pins = config[CONF_PINS] switches = [] for pinnum, pin in pins.items(): switches.append(ArduinoSwitch(pinnum, pin, board)) add_entities(switches)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "board", "=", "hass", ".", "data", "[", "DOMAIN", "]", "pins", "=", "config", "[", "CONF_PINS", "]", "switches", "=", "[", "]", "for...
[ 27, 0 ]
[ 36, 26 ]
python
en
['en', 'lv', 'en']
True
ArduinoSwitch.__init__
(self, pin, options, board)
Initialize the Pin.
Initialize the Pin.
def __init__(self, pin, options, board): """Initialize the Pin.""" self._pin = pin self._name = options[CONF_NAME] self.pin_type = CONF_TYPE self.direction = "out" self._state = options[CONF_INITIAL] if options[CONF_NEGATE]: self.turn_on_handler = bo...
[ "def", "__init__", "(", "self", ",", "pin", ",", "options", ",", "board", ")", ":", "self", ".", "_pin", "=", "pin", "self", ".", "_name", "=", "options", "[", "CONF_NAME", "]", "self", ".", "pin_type", "=", "CONF_TYPE", "self", ".", "direction", "="...
[ 42, 4 ]
[ 59, 77 ]
python
en
['en', 'en', 'en']
True
ArduinoSwitch.name
(self)
Get the name of the pin.
Get the name of the pin.
def name(self): """Get the name of the pin.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 62, 4 ]
[ 64, 25 ]
python
en
['en', 'en', 'en']
True
ArduinoSwitch.is_on
(self)
Return true if pin is high/on.
Return true if pin is high/on.
def is_on(self): """Return true if pin is high/on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 67, 4 ]
[ 69, 26 ]
python
en
['en', 'en', 'en']
True
ArduinoSwitch.turn_on
(self, **kwargs)
Turn the pin to high/on.
Turn the pin to high/on.
def turn_on(self, **kwargs): """Turn the pin to high/on.""" self._state = True self.turn_on_handler(self._pin)
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_state", "=", "True", "self", ".", "turn_on_handler", "(", "self", ".", "_pin", ")" ]
[ 71, 4 ]
[ 74, 39 ]
python
en
['en', 'en', 'en']
True
ArduinoSwitch.turn_off
(self, **kwargs)
Turn the pin to low/off.
Turn the pin to low/off.
def turn_off(self, **kwargs): """Turn the pin to low/off.""" self._state = False self.turn_off_handler(self._pin)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_state", "=", "False", "self", ".", "turn_off_handler", "(", "self", ".", "_pin", ")" ]
[ 76, 4 ]
[ 79, 40 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Set up Velbus binary sensor based on config_entry.
Set up Velbus binary sensor based on config_entry.
async def async_setup_entry(hass, entry, async_add_entities): """Set up Velbus binary sensor based on config_entry.""" cntrl = hass.data[DOMAIN][entry.entry_id]["cntrl"] modules_data = hass.data[DOMAIN][entry.entry_id]["climate"] entities = [] for address, channel in modules_data: module = c...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "cntrl", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "[", "\"cntrl\"", "]", "modules_data", "=", "hass", ".", "data...
[ 18, 0 ]
[ 26, 32 ]
python
en
['en', 'zu', 'en']
True
VelbusClimate.supported_features
(self)
Return the list off supported features.
Return the list off supported features.
def supported_features(self): """Return the list off supported features.""" return SUPPORT_TARGET_TEMPERATURE
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_TARGET_TEMPERATURE" ]
[ 33, 4 ]
[ 35, 41 ]
python
en
['en', 'en', 'en']
True
VelbusClimate.temperature_unit
(self)
Return the unit this state is expressed in.
Return the unit this state is expressed in.
def temperature_unit(self): """Return the unit this state is expressed in.""" if self._module.get_unit(self._channel) == TEMP_CELSIUS: return TEMP_CELSIUS return TEMP_FAHRENHEIT
[ "def", "temperature_unit", "(", "self", ")", ":", "if", "self", ".", "_module", ".", "get_unit", "(", "self", ".", "_channel", ")", "==", "TEMP_CELSIUS", ":", "return", "TEMP_CELSIUS", "return", "TEMP_FAHRENHEIT" ]
[ 38, 4 ]
[ 42, 30 ]
python
en
['en', 'en', 'en']
True
VelbusClimate.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" return self._module.get_state(self._channel)
[ "def", "current_temperature", "(", "self", ")", ":", "return", "self", ".", "_module", ".", "get_state", "(", "self", ".", "_channel", ")" ]
[ 45, 4 ]
[ 47, 52 ]
python
en
['en', 'la', 'en']
True
VelbusClimate.hvac_mode
(self)
Return hvac operation ie. heat, cool mode. Need to be one of HVAC_MODE_*.
Return hvac operation ie. heat, cool mode.
def hvac_mode(self): """Return hvac operation ie. heat, cool mode. Need to be one of HVAC_MODE_*. """ return HVAC_MODE_HEAT
[ "def", "hvac_mode", "(", "self", ")", ":", "return", "HVAC_MODE_HEAT" ]
[ 50, 4 ]
[ 55, 29 ]
python
bg
['en', 'bg', 'bg']
True
VelbusClimate.hvac_modes
(self)
Return the list of available hvac operation modes. Need to be a subset of HVAC_MODES.
Return the list of available hvac operation modes.
def hvac_modes(self): """Return the list of available hvac operation modes. Need to be a subset of HVAC_MODES. """ return [HVAC_MODE_HEAT]
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "[", "HVAC_MODE_HEAT", "]" ]
[ 58, 4 ]
[ 63, 31 ]
python
en
['en', 'en', 'en']
True
VelbusClimate.target_temperature
(self)
Return the temperature we try to reach.
Return the temperature we try to reach.
def target_temperature(self): """Return the temperature we try to reach.""" return self._module.get_climate_target()
[ "def", "target_temperature", "(", "self", ")", ":", "return", "self", ".", "_module", ".", "get_climate_target", "(", ")" ]
[ 66, 4 ]
[ 68, 48 ]
python
en
['en', 'en', 'en']
True
VelbusClimate.set_temperature
(self, **kwargs)
Set new target temperatures.
Set new target temperatures.
def set_temperature(self, **kwargs): """Set new target temperatures.""" temp = kwargs.get(ATTR_TEMPERATURE) if temp is None: return try: self._module.set_temp(temp) except VelbusException as err: _LOGGER.error("A Velbus error occurred: %s", err...
[ "def", "set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "temp", "=", "kwargs", ".", "get", "(", "ATTR_TEMPERATURE", ")", "if", "temp", "is", "None", ":", "return", "try", ":", "self", ".", "_module", ".", "set_temp", "(", "temp", ")...
[ 70, 4 ]
[ 80, 39 ]
python
en
['en', 'ca', 'en']
True
VelbusClimate.set_hvac_mode
(self, hvac_mode)
Set new target hvac mode.
Set new target hvac mode.
def set_hvac_mode(self, hvac_mode): """Set new target hvac mode."""
[ "def", "set_hvac_mode", "(", "self", ",", "hvac_mode", ")", ":" ]
[ 82, 4 ]
[ 83, 39 ]
python
da
['da', 'su', 'en']
False
test_process_integration_platforms
(hass)
Test processing integrations.
Test processing integrations.
async def test_process_integration_platforms(hass): """Test processing integrations.""" loaded_platform = Mock() mock_platform(hass, "loaded.platform_to_check", loaded_platform) hass.config.components.add("loaded") event_platform = Mock() mock_platform(hass, "event.platform_to_check", event_pla...
[ "async", "def", "test_process_integration_platforms", "(", "hass", ")", ":", "loaded_platform", "=", "Mock", "(", ")", "mock_platform", "(", "hass", ",", "\"loaded.platform_to_check\"", ",", "loaded_platform", ")", "hass", ".", "config", ".", "components", ".", "a...
[ 7, 0 ]
[ 35, 44 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up for Satel Integra alarm panels.
Set up for Satel Integra alarm panels.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up for Satel Integra alarm panels.""" if not discovery_info: return configured_partitions = discovery_info[CONF_DEVICE_PARTITIONS] controller = hass.data[DATA_SATEL] devices = [] for partitio...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "not", "discovery_info", ":", "return", "configured_partitions", "=", "discovery_info", "[", "CONF_DEVICE_PARTITIONS", ...
[ 33, 0 ]
[ 51, 31 ]
python
en
['en', 'da', 'en']
True
SatelIntegraAlarmPanel.__init__
(self, controller, name, arm_home_mode, partition_id)
Initialize the alarm panel.
Initialize the alarm panel.
def __init__(self, controller, name, arm_home_mode, partition_id): """Initialize the alarm panel.""" self._name = name self._state = None self._arm_home_mode = arm_home_mode self._partition_id = partition_id self._satel = controller
[ "def", "__init__", "(", "self", ",", "controller", ",", "name", ",", "arm_home_mode", ",", "partition_id", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_state", "=", "None", "self", ".", "_arm_home_mode", "=", "arm_home_mode", "self", ".", ...
[ 57, 4 ]
[ 63, 32 ]
python
en
['en', 'en', 'en']
True
SatelIntegraAlarmPanel.async_added_to_hass
(self)
Update alarm status and register callbacks for future updates.
Update alarm status and register callbacks for future updates.
async def async_added_to_hass(self): """Update alarm status and register callbacks for future updates.""" _LOGGER.debug("Starts listening for panel messages") self._update_alarm_status() self.async_on_remove( async_dispatcher_connect( self.hass, SIGNAL_PANEL_M...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Starts listening for panel messages\"", ")", "self", ".", "_update_alarm_status", "(", ")", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", "...
[ 65, 4 ]
[ 73, 9 ]
python
en
['en', 'la', 'en']
True
SatelIntegraAlarmPanel._update_alarm_status
(self)
Handle alarm status update.
Handle alarm status update.
def _update_alarm_status(self): """Handle alarm status update.""" state = self._read_alarm_state() _LOGGER.debug("Got status update, current status: %s", state) if state != self._state: self._state = state self.async_write_ha_state() else: _LOG...
[ "def", "_update_alarm_status", "(", "self", ")", ":", "state", "=", "self", ".", "_read_alarm_state", "(", ")", "_LOGGER", ".", "debug", "(", "\"Got status update, current status: %s\"", ",", "state", ")", "if", "state", "!=", "self", ".", "_state", ":", "self...
[ 76, 4 ]
[ 84, 70 ]
python
en
['tr', 'la', 'en']
False
SatelIntegraAlarmPanel._read_alarm_state
(self)
Read current status of the alarm and translate it into HA status.
Read current status of the alarm and translate it into HA status.
def _read_alarm_state(self): """Read current status of the alarm and translate it into HA status.""" # Default - disarmed: hass_alarm_status = STATE_ALARM_DISARMED if not self._satel.connected: return None state_map = OrderedDict( [ (Ala...
[ "def", "_read_alarm_state", "(", "self", ")", ":", "# Default - disarmed:", "hass_alarm_status", "=", "STATE_ALARM_DISARMED", "if", "not", "self", ".", "_satel", ".", "connected", ":", "return", "None", "state_map", "=", "OrderedDict", "(", "[", "(", "AlarmState",...
[ 86, 4 ]
[ 118, 32 ]
python
en
['en', 'en', 'en']
True
SatelIntegraAlarmPanel.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" ]
[ 121, 4 ]
[ 123, 25 ]
python
en
['en', 'en', 'en']
True
SatelIntegraAlarmPanel.should_poll
(self)
Return the polling state.
Return the polling state.
def should_poll(self): """Return the polling state.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 126, 4 ]
[ 128, 20 ]
python
en
['en', 'en', 'en']
True
SatelIntegraAlarmPanel.code_format
(self)
Return the regex for code format or None if no code is required.
Return the regex for code format or None if no code is required.
def code_format(self): """Return the regex for code format or None if no code is required.""" return alarm.FORMAT_NUMBER
[ "def", "code_format", "(", "self", ")", ":", "return", "alarm", ".", "FORMAT_NUMBER" ]
[ 131, 4 ]
[ 133, 34 ]
python
en
['en', 'en', 'en']
True
SatelIntegraAlarmPanel.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" ]
[ 136, 4 ]
[ 138, 26 ]
python
en
['en', 'en', 'en']
True
SatelIntegraAlarmPanel.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" ]
[ 141, 4 ]
[ 143, 62 ]
python
en
['en', 'en', 'en']
True
SatelIntegraAlarmPanel.async_alarm_disarm
(self, code=None)
Send disarm command.
Send disarm command.
async def async_alarm_disarm(self, code=None): """Send disarm command.""" if not code: _LOGGER.debug("Code was empty or None") return clear_alarm_necessary = self._state == STATE_ALARM_TRIGGERED _LOGGER.debug("Disarming, self._state: %s", self._state) a...
[ "async", "def", "async_alarm_disarm", "(", "self", ",", "code", "=", "None", ")", ":", "if", "not", "code", ":", "_LOGGER", ".", "debug", "(", "\"Code was empty or None\"", ")", "return", "clear_alarm_necessary", "=", "self", ".", "_state", "==", "STATE_ALARM_...
[ 145, 4 ]
[ 160, 69 ]
python
en
['en', 'pt', 'en']
True
SatelIntegraAlarmPanel.async_alarm_arm_away
(self, code=None)
Send arm away command.
Send arm away command.
async def async_alarm_arm_away(self, code=None): """Send arm away command.""" _LOGGER.debug("Arming away") if code: await self._satel.arm(code, [self._partition_id])
[ "async", "def", "async_alarm_arm_away", "(", "self", ",", "code", "=", "None", ")", ":", "_LOGGER", ".", "debug", "(", "\"Arming away\"", ")", "if", "code", ":", "await", "self", ".", "_satel", ".", "arm", "(", "code", ",", "[", "self", ".", "_partitio...
[ 162, 4 ]
[ 167, 61 ]
python
en
['en', 'en', 'en']
True
SatelIntegraAlarmPanel.async_alarm_arm_home
(self, code=None)
Send arm home command.
Send arm home command.
async def async_alarm_arm_home(self, code=None): """Send arm home command.""" _LOGGER.debug("Arming home") if code: await self._satel.arm(code, [self._partition_id], self._arm_home_mode)
[ "async", "def", "async_alarm_arm_home", "(", "self", ",", "code", "=", "None", ")", ":", "_LOGGER", ".", "debug", "(", "\"Arming home\"", ")", "if", "code", ":", "await", "self", ".", "_satel", ".", "arm", "(", "code", ",", "[", "self", ".", "_partitio...
[ 169, 4 ]
[ 174, 82 ]
python
en
['en', 'pt', 'en']
True
has_all_unique_names
(value)
Validate that printers have an unique name.
Validate that printers have an unique name.
def has_all_unique_names(value): """Validate that printers have an unique name.""" names = [util_slugify(printer["name"]) for printer in value] vol.Schema(vol.Unique())(names) return value
[ "def", "has_all_unique_names", "(", "value", ")", ":", "names", "=", "[", "util_slugify", "(", "printer", "[", "\"name\"", "]", ")", "for", "printer", "in", "value", "]", "vol", ".", "Schema", "(", "vol", ".", "Unique", "(", ")", ")", "(", "names", "...
[ 38, 0 ]
[ 42, 16 ]
python
en
['en', 'en', 'en']
True
ensure_valid_path
(value)
Validate the path, ensuring it starts and ends with a /.
Validate the path, ensuring it starts and ends with a /.
def ensure_valid_path(value): """Validate the path, ensuring it starts and ends with a /.""" vol.Schema(cv.string)(value) if value[0] != "/": value = f"/{value}" if value[-1] != "/": value += "/" return value
[ "def", "ensure_valid_path", "(", "value", ")", ":", "vol", ".", "Schema", "(", "cv", ".", "string", ")", "(", "value", ")", "if", "value", "[", "0", "]", "!=", "\"/\"", ":", "value", "=", "f\"/{value}\"", "if", "value", "[", "-", "1", "]", "!=", ...
[ 45, 0 ]
[ 52, 16 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Set up the OctoPrint component.
Set up the OctoPrint component.
def setup(hass, config): """Set up the OctoPrint component.""" printers = hass.data[DOMAIN] = {} success = False def device_discovered(service, info): """Get called when an Octoprint server has been discovered.""" _LOGGER.debug("Found an Octoprint server: %s", info) discovery.liste...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "printers", "=", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "success", "=", "False", "def", "device_discovered", "(", "service", ",", "info", ")", ":", "\"\"\"Get called when an Octoprint s...
[ 129, 0 ]
[ 181, 18 ]
python
en
['en', 'en', 'en']
True
get_value_from_json
(json_dict, sensor_type, group, tool)
Return the value for sensor_type from the JSON.
Return the value for sensor_type from the JSON.
def get_value_from_json(json_dict, sensor_type, group, tool): """Return the value for sensor_type from the JSON.""" if group not in json_dict: return None if sensor_type in json_dict[group]: if sensor_type == "target" and json_dict[sensor_type] is None: return 0 return ...
[ "def", "get_value_from_json", "(", "json_dict", ",", "sensor_type", ",", "group", ",", "tool", ")", ":", "if", "group", "not", "in", "json_dict", ":", "return", "None", "if", "sensor_type", "in", "json_dict", "[", "group", "]", ":", "if", "sensor_type", "=...
[ 299, 0 ]
[ 314, 15 ]
python
en
['en', 'en', 'en']
True
OctoPrintAPI.__init__
(self, api_url, key, bed, number_of_tools)
Initialize OctoPrint API and set headers needed later.
Initialize OctoPrint API and set headers needed later.
def __init__(self, api_url, key, bed, number_of_tools): """Initialize OctoPrint API and set headers needed later.""" self.api_url = api_url self.headers = {CONTENT_TYPE: CONTENT_TYPE_JSON, "X-Api-Key": key} self.printer_last_reading = [{}, None] self.job_last_reading = [{}, None]...
[ "def", "__init__", "(", "self", ",", "api_url", ",", "key", ",", "bed", ",", "number_of_tools", ")", ":", "self", ".", "api_url", "=", "api_url", "self", ".", "headers", "=", "{", "CONTENT_TYPE", ":", "CONTENT_TYPE_JSON", ",", "\"X-Api-Key\"", ":", "key", ...
[ 187, 4 ]
[ 200, 46 ]
python
en
['en', 'en', 'en']
True
OctoPrintAPI.get_tools
(self)
Get the list of tools that temperature is monitored on.
Get the list of tools that temperature is monitored on.
def get_tools(self): """Get the list of tools that temperature is monitored on.""" tools = [] if self.number_of_tools > 0: for tool_number in range(0, self.number_of_tools): tools.append(f"tool{tool_number!s}") if self.bed: tools.append("bed") ...
[ "def", "get_tools", "(", "self", ")", ":", "tools", "=", "[", "]", "if", "self", ".", "number_of_tools", ">", "0", ":", "for", "tool_number", "in", "range", "(", "0", ",", "self", ".", "number_of_tools", ")", ":", "tools", ".", "append", "(", "f\"too...
[ 202, 4 ]
[ 214, 20 ]
python
en
['en', 'en', 'en']
True
OctoPrintAPI.get
(self, endpoint)
Send a get request, and return the response as a dict.
Send a get request, and return the response as a dict.
def get(self, endpoint): """Send a get request, and return the response as a dict.""" # Only query the API at most every 30 seconds now = time.time() if endpoint == "job": last_time = self.job_last_reading[1] if last_time is not None: if now - last...
[ "def", "get", "(", "self", ",", "endpoint", ")", ":", "# Only query the API at most every 30 seconds", "now", "=", "time", ".", "time", "(", ")", "if", "endpoint", "==", "\"job\"", ":", "last_time", "=", "self", ".", "job_last_reading", "[", "1", "]", "if", ...
[ 216, 4 ]
[ 288, 23 ]
python
en
['en', 'en', 'en']
True
OctoPrintAPI.update
(self, sensor_type, end_point, group, tool=None)
Return the value for sensor_type from the provided endpoint.
Return the value for sensor_type from the provided endpoint.
def update(self, sensor_type, end_point, group, tool=None): """Return the value for sensor_type from the provided endpoint.""" response = self.get(end_point) if response is not None: return get_value_from_json(response, sensor_type, group, tool) return response
[ "def", "update", "(", "self", ",", "sensor_type", ",", "end_point", ",", "group", ",", "tool", "=", "None", ")", ":", "response", "=", "self", ".", "get", "(", "end_point", ")", "if", "response", "is", "not", "None", ":", "return", "get_value_from_json",...
[ 290, 4 ]
[ 296, 23 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Set up StarLine entry.
Set up StarLine entry.
async def async_setup_entry(hass, entry, async_add_entities): """Set up StarLine entry.""" account: StarlineAccount = hass.data[DOMAIN][entry.entry_id] entities = [] for device in account.api.devices.values(): if device.support_position: entities.append(StarlineDeviceTracker(account,...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "account", ":", "StarlineAccount", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "entities", "=", "[", "]", "for", "d...
[ 10, 0 ]
[ 17, 32 ]
python
en
['en', 'da', 'en']
True
StarlineDeviceTracker.__init__
(self, account: StarlineAccount, device: StarlineDevice)
Set up StarLine entity.
Set up StarLine entity.
def __init__(self, account: StarlineAccount, device: StarlineDevice): """Set up StarLine entity.""" super().__init__(account, device, "location", "Location")
[ "def", "__init__", "(", "self", ",", "account", ":", "StarlineAccount", ",", "device", ":", "StarlineDevice", ")", ":", "super", "(", ")", ".", "__init__", "(", "account", ",", "device", ",", "\"location\"", ",", "\"Location\"", ")" ]
[ 23, 4 ]
[ 25, 65 ]
python
en
['en', 'cs', 'en']
True
StarlineDeviceTracker.device_state_attributes
(self)
Return device specific attributes.
Return device specific attributes.
def device_state_attributes(self): """Return device specific attributes.""" return self._account.gps_attrs(self._device)
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_account", ".", "gps_attrs", "(", "self", ".", "_device", ")" ]
[ 28, 4 ]
[ 30, 52 ]
python
en
['fr', 'it', 'en']
False
StarlineDeviceTracker.battery_level
(self)
Return the battery level of the device.
Return the battery level of the device.
def battery_level(self): """Return the battery level of the device.""" return self._device.battery_level
[ "def", "battery_level", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "battery_level" ]
[ 33, 4 ]
[ 35, 41 ]
python
en
['en', 'en', 'en']
True
StarlineDeviceTracker.location_accuracy
(self)
Return the gps accuracy of the device.
Return the gps accuracy of the device.
def location_accuracy(self): """Return the gps accuracy of the device.""" return self._device.position["r"] if "r" in self._device.position else 0
[ "def", "location_accuracy", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "position", "[", "\"r\"", "]", "if", "\"r\"", "in", "self", ".", "_device", ".", "position", "else", "0" ]
[ 38, 4 ]
[ 40, 80 ]
python
en
['en', 'en', 'en']
True
StarlineDeviceTracker.latitude
(self)
Return latitude value of the device.
Return latitude value of the device.
def latitude(self): """Return latitude value of the device.""" return self._device.position["x"]
[ "def", "latitude", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "position", "[", "\"x\"", "]" ]
[ 43, 4 ]
[ 45, 41 ]
python
en
['en', 'en', 'en']
True
StarlineDeviceTracker.longitude
(self)
Return longitude value of the device.
Return longitude value of the device.
def longitude(self): """Return longitude value of the device.""" return self._device.position["y"]
[ "def", "longitude", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "position", "[", "\"y\"", "]" ]
[ 48, 4 ]
[ 50, 41 ]
python
en
['en', 'zu', 'en']
True
StarlineDeviceTracker.source_type
(self)
Return the source type, eg gps or router, of the device.
Return the source type, eg gps or router, of the device.
def source_type(self): """Return the source type, eg gps or router, of the device.""" return SOURCE_TYPE_GPS
[ "def", "source_type", "(", "self", ")", ":", "return", "SOURCE_TYPE_GPS" ]
[ 53, 4 ]
[ 55, 30 ]
python
en
['en', 'en', 'en']
True
StarlineDeviceTracker.icon
(self)
Return the icon to use in the frontend, if any.
Return the icon to use in the frontend, if any.
def icon(self): """Return the icon to use in the frontend, if any.""" return "mdi:map-marker-outline"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:map-marker-outline\"" ]
[ 58, 4 ]
[ 60, 39 ]
python
en
['en', 'en', 'en']
True
config_per_platform
(config: "ConfigType", domain: str)
Break a component config into different platforms. For example, will find 'switch', 'switch 2', 'switch 3', .. etc Async friendly.
Break a component config into different platforms.
def config_per_platform(config: "ConfigType", domain: str) -> Iterable[Tuple[Any, Any]]: """Break a component config into different platforms. For example, will find 'switch', 'switch 2', 'switch 3', .. etc Async friendly. """ for config_key in extract_domain_configs(config, domain): platfo...
[ "def", "config_per_platform", "(", "config", ":", "\"ConfigType\"", ",", "domain", ":", "str", ")", "->", "Iterable", "[", "Tuple", "[", "Any", ",", "Any", "]", "]", ":", "for", "config_key", "in", "extract_domain_configs", "(", "config", ",", "domain", ")...
[ 10, 0 ]
[ 31, 32 ]
python
en
['it', 'en', 'en']
True
extract_domain_configs
(config: "ConfigType", domain: str)
Extract keys from config for given domain name. Async friendly.
Extract keys from config for given domain name.
def extract_domain_configs(config: "ConfigType", domain: str) -> Sequence[str]: """Extract keys from config for given domain name. Async friendly. """ pattern = re.compile(fr"^{domain}(| .+)$") return [key for key in config.keys() if pattern.match(key)]
[ "def", "extract_domain_configs", "(", "config", ":", "\"ConfigType\"", ",", "domain", ":", "str", ")", "->", "Sequence", "[", "str", "]", ":", "pattern", "=", "re", ".", "compile", "(", "fr\"^{domain}(| .+)$\"", ")", "return", "[", "key", "for", "key", "in...
[ 34, 0 ]
[ 40, 63 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities )
Set up Azure DevOps sensor based on a config entry.
Set up Azure DevOps sensor based on a config entry.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities ) -> None: """Set up Azure DevOps sensor based on a config entry.""" instance_key = f"{DOMAIN}_{entry.data[CONF_ORG]}_{entry.data[CONF_PROJECT]}" client = hass.data[instance_key][DATA_AZURE_DEVOPS_CLIENT] or...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "instance_key", "=", "f\"{DOMAIN}_{entry.data[CONF_ORG]}_{entry.data[CONF_PROJECT]}\"", "client", "=", "hass", ...
[ 30, 0 ]
[ 53, 37 ]
python
en
['en', 'da', 'en']
True
AzureDevOpsSensor.__init__
( self, client: DevOpsClient, organization: str, project: str, key: str, name: str, icon: str, measurement: str = "", unit_of_measurement: str = "", )
Initialize Azure DevOps sensor.
Initialize Azure DevOps sensor.
def __init__( self, client: DevOpsClient, organization: str, project: str, key: str, name: str, icon: str, measurement: str = "", unit_of_measurement: str = "", ) -> None: """Initialize Azure DevOps sensor.""" self._state = None...
[ "def", "__init__", "(", "self", ",", "client", ":", "DevOpsClient", ",", "organization", ":", "str", ",", "project", ":", "str", ",", "key", ":", "str", ",", "name", ":", "str", ",", "icon", ":", "str", ",", "measurement", ":", "str", "=", "\"\"", ...
[ 59, 4 ]
[ 81, 59 ]
python
de
['de', 'fy', 'en']
False
AzureDevOpsSensor.unique_id
(self)
Return the unique ID for this sensor.
Return the unique ID for this sensor.
def unique_id(self) -> str: """Return the unique ID for this sensor.""" return "_".join([self.organization, self.key])
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "\"_\"", ".", "join", "(", "[", "self", ".", "organization", ",", "self", ".", "key", "]", ")" ]
[ 84, 4 ]
[ 86, 54 ]
python
en
['en', 'la', 'en']
True
AzureDevOpsSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self) -> str: """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_state" ]
[ 89, 4 ]
[ 91, 26 ]
python
en
['en', 'en', 'en']
True
AzureDevOpsSensor.device_state_attributes
(self)
Return the attributes of the sensor.
Return the attributes of the sensor.
def device_state_attributes(self) -> object: """Return the attributes of the sensor.""" return self._attributes
[ "def", "device_state_attributes", "(", "self", ")", "->", "object", ":", "return", "self", ".", "_attributes" ]
[ 94, 4 ]
[ 96, 31 ]
python
en
['en', 'en', 'en']
True
AzureDevOpsSensor.unit_of_measurement
(self)
Return the unit this state is expressed in.
Return the unit this state is expressed in.
def unit_of_measurement(self) -> str: """Return the unit this state is expressed in.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 99, 4 ]
[ 101, 40 ]
python
en
['en', 'en', 'en']
True
AzureDevOpsLatestBuildSensor.__init__
( self, client: DevOpsClient, organization: str, project: str, build: DevOpsBuild )
Initialize Azure DevOps sensor.
Initialize Azure DevOps sensor.
def __init__( self, client: DevOpsClient, organization: str, project: str, build: DevOpsBuild ): """Initialize Azure DevOps sensor.""" self.build: DevOpsBuild = build super().__init__( client, organization, project, f"{build.project.id}...
[ "def", "__init__", "(", "self", ",", "client", ":", "DevOpsClient", ",", "organization", ":", "str", ",", "project", ":", "str", ",", "build", ":", "DevOpsBuild", ")", ":", "self", ".", "build", ":", "DevOpsBuild", "=", "build", "super", "(", ")", ".",...
[ 107, 4 ]
[ 119, 9 ]
python
de
['de', 'fy', 'en']
False
AzureDevOpsLatestBuildSensor._azure_devops_update
(self)
Update Azure DevOps entity.
Update Azure DevOps entity.
async def _azure_devops_update(self) -> bool: """Update Azure DevOps entity.""" try: build: DevOpsBuild = await self.client.get_build( self.organization, self.project, self.build.id ) except aiohttp.ClientError as exception: _LOGGER.warning(exc...
[ "async", "def", "_azure_devops_update", "(", "self", ")", "->", "bool", ":", "try", ":", "build", ":", "DevOpsBuild", "=", "await", "self", ".", "client", ".", "get_build", "(", "self", ".", "organization", ",", "self", ".", "project", ",", "self", ".", ...
[ 121, 4 ]
[ 147, 19 ]
python
en
['eo', 'fy', 'en']
False
mock_handle_entity_call
()
Mock service platform call.
Mock service platform call.
def mock_handle_entity_call(): """Mock service platform call.""" with patch( "homeassistant.helpers.service._handle_entity_call", return_value=None, ) as mock_call: yield mock_call
[ "def", "mock_handle_entity_call", "(", ")", ":", "with", "patch", "(", "\"homeassistant.helpers.service._handle_entity_call\"", ",", "return_value", "=", "None", ",", ")", "as", "mock_call", ":", "yield", "mock_call" ]
[ 43, 0 ]
[ 49, 23 ]
python
en
['en', 'da', 'en']
True
mock_entities
(hass)
Return mock entities in an ordered dict.
Return mock entities in an ordered dict.
def mock_entities(hass): """Return mock entities in an ordered dict.""" kitchen = MockEntity( entity_id="light.kitchen", available=True, should_poll=False, supported_features=SUPPORT_A, ) living_room = MockEntity( entity_id="light.living_room", available=T...
[ "def", "mock_entities", "(", "hass", ")", ":", "kitchen", "=", "MockEntity", "(", "entity_id", "=", "\"light.kitchen\"", ",", "available", "=", "True", ",", "should_poll", "=", "False", ",", "supported_features", "=", "SUPPORT_A", ",", ")", "living_room", "=",...
[ 53, 0 ]
[ 84, 19 ]
python
en
['en', 'en', 'en']
True
area_mock
(hass)
Mock including area info.
Mock including area info.
def area_mock(hass): """Mock including area info.""" hass.states.async_set("light.Bowl", STATE_ON) hass.states.async_set("light.Ceiling", STATE_OFF) hass.states.async_set("light.Kitchen", STATE_OFF) device_in_area = dev_reg.DeviceEntry(area_id="test-area") device_no_area = dev_reg.DeviceEntry()...
[ "def", "area_mock", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"light.Bowl\"", ",", "STATE_ON", ")", "hass", ".", "states", ".", "async_set", "(", "\"light.Ceiling\"", ",", "STATE_OFF", ")", "hass", ".", "states", ".", "async_se...
[ 88, 0 ]
[ 155, 5 ]
python
en
['en', 'ro', 'en']
True
test_extract_entity_ids
(hass)
Test extract_entity_ids method.
Test extract_entity_ids method.
async def test_extract_entity_ids(hass): """Test extract_entity_ids method.""" hass.states.async_set("light.Bowl", STATE_ON) hass.states.async_set("light.Ceiling", STATE_OFF) hass.states.async_set("light.Kitchen", STATE_OFF) assert await async_setup_component(hass, "group", {}) await hass.async...
[ "async", "def", "test_extract_entity_ids", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"light.Bowl\"", ",", "STATE_ON", ")", "hass", ".", "states", ".", "async_set", "(", "\"light.Ceiling\"", ",", "STATE_OFF", ")", "hass", ".", "st...
[ 286, 0 ]
[ 318, 5 ]
python
en
['de', 'en', 'en']
True
test_extract_entity_ids_from_area
(hass, area_mock)
Test extract_entity_ids method with areas.
Test extract_entity_ids method with areas.
async def test_extract_entity_ids_from_area(hass, area_mock): """Test extract_entity_ids method with areas.""" call = ha.ServiceCall("light", "turn_on", {"area_id": "own-area"}) assert { "light.in_own_area", } == await service.async_extract_entity_ids(hass, call) call = ha.ServiceCall("lig...
[ "async", "def", "test_extract_entity_ids_from_area", "(", "hass", ",", "area_mock", ")", ":", "call", "=", "ha", ".", "ServiceCall", "(", "\"light\"", ",", "\"turn_on\"", ",", "{", "\"area_id\"", ":", "\"own-area\"", "}", ")", "assert", "{", "\"light.in_own_area...
[ 321, 0 ]
[ 349, 5 ]
python
en
['en', 'en', 'en']
True
test_async_get_all_descriptions
(hass)
Test async_get_all_descriptions.
Test async_get_all_descriptions.
async def test_async_get_all_descriptions(hass): """Test async_get_all_descriptions.""" group = hass.components.group group_config = {group.DOMAIN: {}} await async_setup_component(hass, group.DOMAIN, group_config) descriptions = await service.async_get_all_descriptions(hass) assert len(descript...
[ "async", "def", "test_async_get_all_descriptions", "(", "hass", ")", ":", "group", "=", "hass", ".", "components", ".", "group", "group_config", "=", "{", "group", ".", "DOMAIN", ":", "{", "}", "}", "await", "async_setup_component", "(", "hass", ",", "group"...
[ 352, 0 ]
[ 372, 63 ]
python
en
['en', 'fr', 'en']
False
test_call_with_required_features
(hass, mock_entities)
Test service calls invoked only if entity has required features.
Test service calls invoked only if entity has required features.
async def test_call_with_required_features(hass, mock_entities): """Test service calls invoked only if entity has required features.""" test_service_mock = AsyncMock(return_value=None) await service.entity_service_call( hass, [Mock(entities=mock_entities)], test_service_mock, ...
[ "async", "def", "test_call_with_required_features", "(", "hass", ",", "mock_entities", ")", ":", "test_service_mock", "=", "AsyncMock", "(", "return_value", "=", "None", ")", "await", "service", ".", "entity_service_call", "(", "hass", ",", "[", "Mock", "(", "en...
[ 375, 0 ]
[ 392, 55 ]
python
en
['en', 'en', 'en']
True
test_call_with_both_required_features
(hass, mock_entities)
Test service calls invoked only if entity has both features.
Test service calls invoked only if entity has both features.
async def test_call_with_both_required_features(hass, mock_entities): """Test service calls invoked only if entity has both features.""" test_service_mock = AsyncMock(return_value=None) await service.entity_service_call( hass, [Mock(entities=mock_entities)], test_service_mock, ...
[ "async", "def", "test_call_with_both_required_features", "(", "hass", ",", "mock_entities", ")", ":", "test_service_mock", "=", "AsyncMock", "(", "return_value", "=", "None", ")", "await", "service", ".", "entity_service_call", "(", "hass", ",", "[", "Mock", "(", ...
[ 395, 0 ]
[ 409, 5 ]
python
en
['en', 'en', 'en']
True
test_call_with_one_of_required_features
(hass, mock_entities)
Test service calls invoked with one entity having the required features.
Test service calls invoked with one entity having the required features.
async def test_call_with_one_of_required_features(hass, mock_entities): """Test service calls invoked with one entity having the required features.""" test_service_mock = AsyncMock(return_value=None) await service.entity_service_call( hass, [Mock(entities=mock_entities)], test_servic...
[ "async", "def", "test_call_with_one_of_required_features", "(", "hass", ",", "mock_entities", ")", ":", "test_service_mock", "=", "AsyncMock", "(", "return_value", "=", "None", ")", "await", "service", ".", "entity_service_call", "(", "hass", ",", "[", "Mock", "("...
[ 412, 0 ]
[ 430, 55 ]
python
en
['en', 'en', 'en']
True
test_call_with_sync_func
(hass, mock_entities)
Test invoking sync service calls.
Test invoking sync service calls.
async def test_call_with_sync_func(hass, mock_entities): """Test invoking sync service calls.""" test_service_mock = Mock(return_value=None) await service.entity_service_call( hass, [Mock(entities=mock_entities)], test_service_mock, ha.ServiceCall("test_domain", "test_service...
[ "async", "def", "test_call_with_sync_func", "(", "hass", ",", "mock_entities", ")", ":", "test_service_mock", "=", "Mock", "(", "return_value", "=", "None", ")", "await", "service", ".", "entity_service_call", "(", "hass", ",", "[", "Mock", "(", "entities", "=...
[ 433, 0 ]
[ 442, 44 ]
python
en
['fr', 'en', 'en']
True
test_call_with_sync_attr
(hass, mock_entities)
Test invoking sync service calls.
Test invoking sync service calls.
async def test_call_with_sync_attr(hass, mock_entities): """Test invoking sync service calls.""" mock_method = mock_entities["light.kitchen"].sync_method = Mock(return_value=None) await service.entity_service_call( hass, [Mock(entities=mock_entities)], "sync_method", ha.Servi...
[ "async", "def", "test_call_with_sync_attr", "(", "hass", ",", "mock_entities", ")", ":", "mock_method", "=", "mock_entities", "[", "\"light.kitchen\"", "]", ".", "sync_method", "=", "Mock", "(", "return_value", "=", "None", ")", "await", "service", ".", "entity_...
[ 445, 0 ]
[ 460, 45 ]
python
en
['fr', 'en', 'en']
True
test_call_context_user_not_exist
(hass)
Check we don't allow deleted users to do things.
Check we don't allow deleted users to do things.
async def test_call_context_user_not_exist(hass): """Check we don't allow deleted users to do things.""" with pytest.raises(exceptions.UnknownUser) as err: await service.entity_service_call( hass, [], Mock(), ha.ServiceCall( "test_domain", ...
[ "async", "def", "test_call_context_user_not_exist", "(", "hass", ")", ":", "with", "pytest", ".", "raises", "(", "exceptions", ".", "UnknownUser", ")", "as", "err", ":", "await", "service", ".", "entity_service_call", "(", "hass", ",", "[", "]", ",", "Mock",...
[ 463, 0 ]
[ 477, 54 ]
python
en
['en', 'en', 'en']
True
test_call_context_target_all
(hass, mock_handle_entity_call, mock_entities)
Check we only target allowed entities if targeting all.
Check we only target allowed entities if targeting all.
async def test_call_context_target_all(hass, mock_handle_entity_call, mock_entities): """Check we only target allowed entities if targeting all.""" with patch( "homeassistant.auth.AuthManager.async_get_user", return_value=Mock( permissions=PolicyPermissions( {"entitie...
[ "async", "def", "test_call_context_target_all", "(", "hass", ",", "mock_handle_entity_call", ",", "mock_entities", ")", ":", "with", "patch", "(", "\"homeassistant.auth.AuthManager.async_get_user\"", ",", "return_value", "=", "Mock", "(", "permissions", "=", "PolicyPermis...
[ 480, 0 ]
[ 503, 83 ]
python
en
['en', 'en', 'en']
True
test_call_context_target_specific
( hass, mock_handle_entity_call, mock_entities )
Check targeting specific entities.
Check targeting specific entities.
async def test_call_context_target_specific( hass, mock_handle_entity_call, mock_entities ): """Check targeting specific entities.""" with patch( "homeassistant.auth.AuthManager.async_get_user", return_value=Mock( permissions=PolicyPermissions( {"entities": {"enti...
[ "async", "def", "test_call_context_target_specific", "(", "hass", ",", "mock_handle_entity_call", ",", "mock_entities", ")", ":", "with", "patch", "(", "\"homeassistant.auth.AuthManager.async_get_user\"", ",", "return_value", "=", "Mock", "(", "permissions", "=", "PolicyP...
[ 506, 0 ]
[ 531, 83 ]
python
en
['en', 'en', 'en']
True
test_call_context_target_specific_no_auth
( hass, mock_handle_entity_call, mock_entities )
Check targeting specific entities without auth.
Check targeting specific entities without auth.
async def test_call_context_target_specific_no_auth( hass, mock_handle_entity_call, mock_entities ): """Check targeting specific entities without auth.""" with pytest.raises(exceptions.Unauthorized) as err: with patch( "homeassistant.auth.AuthManager.async_get_user", return_v...
[ "async", "def", "test_call_context_target_specific_no_auth", "(", "hass", ",", "mock_handle_entity_call", ",", "mock_entities", ")", ":", "with", "pytest", ".", "raises", "(", "exceptions", ".", "Unauthorized", ")", "as", "err", ":", "with", "patch", "(", "\"homea...
[ 534, 0 ]
[ 556, 49 ]
python
en
['en', 'en', 'en']
True