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_entity_device_info_remove
(hass, mqtt_mock)
Test device registry remove.
Test device registry remove.
async def test_entity_device_info_remove(hass, mqtt_mock): """Test device registry remove.""" await help_test_entity_device_info_remove( hass, mqtt_mock, binary_sensor.DOMAIN, DEFAULT_CONFIG )
[ "async", "def", "test_entity_device_info_remove", "(", "hass", ",", "mqtt_mock", ")", ":", "await", "help_test_entity_device_info_remove", "(", "hass", ",", "mqtt_mock", ",", "binary_sensor", ".", "DOMAIN", ",", "DEFAULT_CONFIG", ")" ]
[ 775, 0 ]
[ 779, 5 ]
python
en
['fr', 'en', 'en']
True
test_entity_id_update_subscriptions
(hass, mqtt_mock)
Test MQTT subscriptions are managed when entity_id is updated.
Test MQTT subscriptions are managed when entity_id is updated.
async def test_entity_id_update_subscriptions(hass, mqtt_mock): """Test MQTT subscriptions are managed when entity_id is updated.""" await help_test_entity_id_update_subscriptions( hass, mqtt_mock, binary_sensor.DOMAIN, DEFAULT_CONFIG )
[ "async", "def", "test_entity_id_update_subscriptions", "(", "hass", ",", "mqtt_mock", ")", ":", "await", "help_test_entity_id_update_subscriptions", "(", "hass", ",", "mqtt_mock", ",", "binary_sensor", ".", "DOMAIN", ",", "DEFAULT_CONFIG", ")" ]
[ 782, 0 ]
[ 786, 5 ]
python
en
['en', 'en', 'en']
True
test_entity_id_update_discovery_update
(hass, mqtt_mock)
Test MQTT discovery update when entity_id is updated.
Test MQTT discovery update when entity_id is updated.
async def test_entity_id_update_discovery_update(hass, mqtt_mock): """Test MQTT discovery update when entity_id is updated.""" await help_test_entity_id_update_discovery_update( hass, mqtt_mock, binary_sensor.DOMAIN, DEFAULT_CONFIG )
[ "async", "def", "test_entity_id_update_discovery_update", "(", "hass", ",", "mqtt_mock", ")", ":", "await", "help_test_entity_id_update_discovery_update", "(", "hass", ",", "mqtt_mock", ",", "binary_sensor", ".", "DOMAIN", ",", "DEFAULT_CONFIG", ")" ]
[ 789, 0 ]
[ 793, 5 ]
python
en
['en', 'en', 'en']
True
test_entity_debug_info_message
(hass, mqtt_mock)
Test MQTT debug info.
Test MQTT debug info.
async def test_entity_debug_info_message(hass, mqtt_mock): """Test MQTT debug info.""" await help_test_entity_debug_info_message( hass, mqtt_mock, binary_sensor.DOMAIN, DEFAULT_CONFIG )
[ "async", "def", "test_entity_debug_info_message", "(", "hass", ",", "mqtt_mock", ")", ":", "await", "help_test_entity_debug_info_message", "(", "hass", ",", "mqtt_mock", ",", "binary_sensor", ".", "DOMAIN", ",", "DEFAULT_CONFIG", ")" ]
[ 796, 0 ]
[ 800, 5 ]
python
es
['es', 'mt', 'it']
False
setup_frontend
(hass)
Fixture to setup the frontend.
Fixture to setup the frontend.
def setup_frontend(hass): """Fixture to setup the frontend.""" hass.loop.run_until_complete(async_setup_component(hass, "frontend", {}))
[ "def", "setup_frontend", "(", "hass", ")", ":", "hass", ".", "loop", ".", "run_until_complete", "(", "async_setup_component", "(", "hass", ",", "\"frontend\"", ",", "{", "}", ")", ")" ]
[ 8, 0 ]
[ 10, 77 ]
python
en
['en', 'en', 'en']
True
test_get_user_data_empty
(hass, hass_ws_client, hass_storage)
Test get_user_data command.
Test get_user_data command.
async def test_get_user_data_empty(hass, hass_ws_client, hass_storage): """Test get_user_data command.""" client = await hass_ws_client(hass) await client.send_json( {"id": 5, "type": "frontend/get_user_data", "key": "non-existing-key"} ) res = await client.receive_json() assert res["s...
[ "async", "def", "test_get_user_data_empty", "(", "hass", ",", "hass_ws_client", ",", "hass_storage", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "5", ",", "\"type\"", ":"...
[ 13, 0 ]
[ 23, 41 ]
python
en
['nl', 'en', 'en']
True
test_get_user_data
(hass, hass_ws_client, hass_admin_user, hass_storage)
Test get_user_data command.
Test get_user_data command.
async def test_get_user_data(hass, hass_ws_client, hass_admin_user, hass_storage): """Test get_user_data command.""" storage_key = f"{DOMAIN}.user_data_{hass_admin_user.id}" hass_storage[storage_key] = { "key": storage_key, "version": 1, "data": {"test-key": "test-value", "test-compl...
[ "async", "def", "test_get_user_data", "(", "hass", ",", "hass_ws_client", ",", "hass_admin_user", ",", "hass_storage", ")", ":", "storage_key", "=", "f\"{DOMAIN}.user_data_{hass_admin_user.id}\"", "hass_storage", "[", "storage_key", "]", "=", "{", "\"key\"", ":", "sto...
[ 26, 0 ]
[ 64, 68 ]
python
en
['nl', 'en', 'en']
True
test_set_user_data_empty
(hass, hass_ws_client, hass_storage)
Test set_user_data command.
Test set_user_data command.
async def test_set_user_data_empty(hass, hass_ws_client, hass_storage): """Test set_user_data command.""" client = await hass_ws_client(hass) # test creating await client.send_json( {"id": 6, "type": "frontend/get_user_data", "key": "test-key"} ) res = await client.receive_json() ...
[ "async", "def", "test_set_user_data_empty", "(", "hass", ",", "hass_ws_client", ",", "hass_storage", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "# test creating", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "6", ","...
[ 67, 0 ]
[ 99, 49 ]
python
en
['en', 'no', 'en']
True
test_set_user_data
(hass, hass_ws_client, hass_storage, hass_admin_user)
Test set_user_data command with initial data.
Test set_user_data command with initial data.
async def test_set_user_data(hass, hass_ws_client, hass_storage, hass_admin_user): """Test set_user_data command with initial data.""" storage_key = f"{DOMAIN}.user_data_{hass_admin_user.id}" hass_storage[storage_key] = { "version": 1, "data": {"test-key": "test-value", "test-complex": "stri...
[ "async", "def", "test_set_user_data", "(", "hass", ",", "hass_ws_client", ",", "hass_storage", ",", "hass_admin_user", ")", ":", "storage_key", "=", "f\"{DOMAIN}.user_data_{hass_admin_user.id}\"", "hass_storage", "[", "storage_key", "]", "=", "{", "\"version\"", ":", ...
[ 102, 0 ]
[ 164, 49 ]
python
en
['en', 'en', 'en']
True
get_args
(argv: list)
gets the args and dictionarize them
gets the args and dictionarize them
def get_args(argv: list): """gets the args and dictionarize them""" if len(argv) not in [5,7]: Errors.args_error() data = {} # getting the type of the title if "-" in argv[1]: data["type"] = "series" if argv[1] == "-s" else "movie" if argv[1] == "-m" else None else: ...
[ "def", "get_args", "(", "argv", ":", "list", ")", ":", "if", "len", "(", "argv", ")", "not", "in", "[", "5", ",", "7", "]", ":", "Errors", ".", "args_error", "(", ")", "data", "=", "{", "}", "# getting the type of the title", "if", "\"-\"", "in", "...
[ 12, 0 ]
[ 40, 15 ]
python
en
['en', 'en', 'en']
True
get_matches
(title: str, search_type: str = "all", backup_search_type: str = None)
gets the search matches of the specified title, and can specify the type of the given search so it can be ('exact', 'close', 'popular', or 'all') and 'all' is the default option
gets the search matches of the specified title, and can specify the type of the given search so it can be ('exact', 'close', 'popular', or 'all') and 'all' is the default option
def get_matches(title: str, search_type: str = "all", backup_search_type: str = None) -> dict: """gets the search matches of the specified title, and can specify the type of the given search so it can be ('exact', 'close', 'popular', or 'all') and 'all' is the default option""" page = requests.post(URL...
[ "def", "get_matches", "(", "title", ":", "str", ",", "search_type", ":", "str", "=", "\"all\"", ",", "backup_search_type", ":", "str", "=", "None", ")", "->", "dict", ":", "page", "=", "requests", ".", "post", "(", "URL_SEARCH_BY_TITLE", ",", "{", "\"que...
[ 43, 0 ]
[ 73, 68 ]
python
en
['en', 'en', 'en']
True
get_year
(text: str)
gets the year of a title depending on its text
gets the year of a title depending on its text
def get_year(text: str) -> str: """gets the year of a title depending on its text""" if "(" not in text and ")" not in text: return None return text[text.find("(") + 1: text.find(")")]
[ "def", "get_year", "(", "text", ":", "str", ")", "->", "str", ":", "if", "\"(\"", "not", "in", "text", "and", "\")\"", "not", "in", "text", ":", "return", "None", "return", "text", "[", "text", ".", "find", "(", "\"(\"", ")", "+", "1", ":", "text...
[ 76, 0 ]
[ 82, 51 ]
python
en
['en', 'en', 'en']
True
get_exact_match
(title: str, year: str = "")
gets the exact match of a search query if it does exist and its page url
gets the exact match of a search query if it does exist and its page url
def get_exact_match(title: str, year: str = "") -> str: """gets the exact match of a search query if it does exist and its page url""" matches = get_matches(title, search_type="exact", backup_search_type="close") if not matches: return None if year: matches_by_year = [matc...
[ "def", "get_exact_match", "(", "title", ":", "str", ",", "year", ":", "str", "=", "\"\"", ")", "->", "str", ":", "matches", "=", "get_matches", "(", "title", ",", "search_type", "=", "\"exact\"", ",", "backup_search_type", "=", "\"close\"", ")", "if", "n...
[ 85, 0 ]
[ 101, 21 ]
python
en
['en', 'en', 'en']
True
get_subtitles
(title_page_url: str, subtitle_type: "the type of subtitle (series, movie)" = "movie")
gets the subtitles from a specific title page
gets the subtitles from a specific title page
def get_subtitles(title_page_url: str, subtitle_type: "the type of subtitle (series, movie)" = "movie") -> list: """gets the subtitles from a specific title page""" page = requests.get(title_page_url) soup = BeautifulSoup(page.content, "html.parser") check_soup(soup, "To many requests", "Too many reque...
[ "def", "get_subtitles", "(", "title_page_url", ":", "str", ",", "subtitle_type", ":", "\"the type of subtitle (series, movie)\"", "=", "\"movie\"", ")", "->", "list", ":", "page", "=", "requests", ".", "get", "(", "title_page_url", ")", "soup", "=", "BeautifulSoup...
[ 161, 0 ]
[ 175, 20 ]
python
en
['en', 'en', 'en']
True
get_subtitle
(subtitile: Subtitle, location: str = "", keep_zip_file: bool = False)
gets the subtitle itself and saves it to a specific location, and returns True in case of succession
gets the subtitle itself and saves it to a specific location, and returns True in case of succession
def get_subtitle(subtitile: Subtitle, location: str = "", keep_zip_file: bool = False): """gets the subtitle itself and saves it to a specific location, and returns True in case of succession""" # write to the current location if there was no specified location # if there was a one write to it if l...
[ "def", "get_subtitle", "(", "subtitile", ":", "Subtitle", ",", "location", ":", "str", "=", "\"\"", ",", "keep_zip_file", ":", "bool", "=", "False", ")", ":", "# write to the current location if there was no specified location", "# if there was a one write to it", "if", ...
[ 178, 0 ]
[ 210, 15 ]
python
en
['en', 'en', 'en']
True
movie_subtitle
(title: str, language: str, format: "format of movie (bluray, hdrip...)", year: str = "", location: str = "", keep_zip_file: bool = False)
downloads a movie subtitle and saves it to the current location or to a specified location, and returns True in case of succession and False in case of problem existance
downloads a movie subtitle and saves it to the current location or to a specified location, and returns True in case of succession and False in case of problem existance
def movie_subtitle(title: str, language: str, format: "format of movie (bluray, hdrip...)", year: str = "", location: str = "", keep_zip_file: bool = False): """downloads a movie subtitle and saves it to the current location or to a specified location, and returns True in case of succession and False in case ...
[ "def", "movie_subtitle", "(", "title", ":", "str", ",", "language", ":", "str", ",", "format", ":", "\"format of movie (bluray, hdrip...)\"", ",", "year", ":", "str", "=", "\"\"", ",", "location", ":", "str", "=", "\"\"", ",", "keep_zip_file", ":", "bool", ...
[ 213, 0 ]
[ 234, 20 ]
python
en
['en', 'en', 'en']
True
get_matches_series
(title: str, specific_sub_title: str = "")
gets the links of the subtitles of all the seasons of a series or gets a specific version (specific title of the series)
gets the links of the subtitles of all the seasons of a series or gets a specific version (specific title of the series)
def get_matches_series(title: str, specific_sub_title: str = "") -> list: """gets the links of the subtitles of all the seasons of a series or gets a specific version (specific title of the series)""" all_matches = get_matches(title, "tv-series") if not all_matches: return None # the "{tit...
[ "def", "get_matches_series", "(", "title", ":", "str", ",", "specific_sub_title", ":", "str", "=", "\"\"", ")", "->", "list", ":", "all_matches", "=", "get_matches", "(", "title", ",", "\"tv-series\"", ")", "if", "not", "all_matches", ":", "return", "None", ...
[ 237, 0 ]
[ 251, 18 ]
python
en
['en', 'en', 'en']
True
get_series_season
(title: str, season: int)
gets a series subtitles page link of the specified season
gets a series subtitles page link of the specified season
def get_series_season(title: str, season: int) -> dict: """gets a series subtitles page link of the specified season""" matches = get_matches_series(title) if not matches: return None for match in matches: key = list(match.keys())[0] # getting the season ordinal number only ...
[ "def", "get_series_season", "(", "title", ":", "str", ",", "season", ":", "int", ")", "->", "dict", ":", "matches", "=", "get_matches_series", "(", "title", ")", "if", "not", "matches", ":", "return", "None", "for", "match", "in", "matches", ":", "key", ...
[ 254, 0 ]
[ 268, 15 ]
python
en
['en', 'en', 'en']
True
series_subtitle
(title: str, season: int, episode: int, language: str, format: "format of the episode (bluray, hdrip...)", location: str = "", keep_zip_file: bool = False)
downloads a series episode subtitle and saves it to the current location or to a specified location, and returns True in case of succession and False in case of problem existance
downloads a series episode subtitle and saves it to the current location or to a specified location, and returns True in case of succession and False in case of problem existance
def series_subtitle(title: str, season: int, episode: int, language: str, format: "format of the episode (bluray, hdrip...)", location: str = "", keep_zip_file: bool = False): """downloads a series episode subtitle and saves it to the current location or to a specified location, and returns True in case of succ...
[ "def", "series_subtitle", "(", "title", ":", "str", ",", "season", ":", "int", ",", "episode", ":", "int", ",", "language", ":", "str", ",", "format", ":", "\"format of the episode (bluray, hdrip...)\"", ",", "location", ":", "str", "=", "\"\"", ",", "keep_z...
[ 271, 0 ]
[ 293, 20 ]
python
en
['en', 'en', 'en']
True
Subtitle.setAttrsSeries
(self, subtitle_title)
sets the season and the episode of the series
sets the season and the episode of the series
def setAttrsSeries(self, subtitle_title): """sets the season and the episode of the series""" match = re.search("s[0]?[0-9]e[0]?[0-9]", subtitle_title, re.IGNORECASE) if match: info = match.group().lower() self.season = int(info[info.find("s") + 1 : info.find("e")]) ...
[ "def", "setAttrsSeries", "(", "self", ",", "subtitle_title", ")", ":", "match", "=", "re", ".", "search", "(", "\"s[0]?[0-9]e[0]?[0-9]\"", ",", "subtitle_title", ",", "re", ".", "IGNORECASE", ")", "if", "match", ":", "info", "=", "match", ".", "group", "("...
[ 117, 4 ]
[ 127, 31 ]
python
en
['en', 'en', 'en']
True
Subtitle.get_subtitle_format
(subtitle_title)
gets the format of the subtitle (bluray, hdrip, web-dl, trailer, ...) and returns None in case of unknown type
gets the format of the subtitle (bluray, hdrip, web-dl, trailer, ...) and returns None in case of unknown type
def get_subtitle_format(subtitle_title): """gets the format of the subtitle (bluray, hdrip, web-dl, trailer, ...) and returns None in case of unknown type""" # the following RegEx are for finding the blueray or the blue-ray if "trailer" in subtitle_title.lower(): ret...
[ "def", "get_subtitle_format", "(", "subtitle_title", ")", ":", "# the following RegEx are for finding the blueray or the blue-ray", "if", "\"trailer\"", "in", "subtitle_title", ".", "lower", "(", ")", ":", "return", "\"trailer\"", "elif", "re", ".", "compile", "(", "\"....
[ 130, 4 ]
[ 158, 23 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up Airly sensor entities based on a config entry.
Set up Airly sensor entities based on a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up Airly sensor entities based on a config entry.""" name = config_entry.data[CONF_NAME] coordinator = hass.data[DOMAIN][config_entry.entry_id] sensors = [] for sensor in SENSOR_TYPES: sensors.append(AirlySensor(co...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "name", "=", "config_entry", ".", "data", "[", "CONF_NAME", "]", "coordinator", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", "."...
[ 61, 0 ]
[ 71, 38 ]
python
en
['en', 'en', 'en']
True
AirlySensor.__init__
(self, coordinator, name, kind)
Initialize.
Initialize.
def __init__(self, coordinator, name, kind): """Initialize.""" super().__init__(coordinator) self._name = name self.kind = kind self._device_class = None self._state = None self._icon = None self._unit_of_measurement = None self._attrs = {ATTR_ATTR...
[ "def", "__init__", "(", "self", ",", "coordinator", ",", "name", ",", "kind", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "_name", "=", "name", "self", ".", "kind", "=", "kind", "self", ".", "_device_class", "=...
[ 77, 4 ]
[ 86, 53 ]
python
en
['en', 'en', 'it']
False
AirlySensor.name
(self)
Return the name.
Return the name.
def name(self): """Return the name.""" return f"{self._name} {SENSOR_TYPES[self.kind][ATTR_LABEL]}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self._name} {SENSOR_TYPES[self.kind][ATTR_LABEL]}\"" ]
[ 89, 4 ]
[ 91, 68 ]
python
en
['en', 'ig', 'en']
True
AirlySensor.state
(self)
Return the state.
Return the state.
def state(self): """Return the state.""" self._state = self.coordinator.data[self.kind] if self.kind in [ATTR_API_PM1, ATTR_API_PRESSURE]: self._state = round(self._state) if self.kind in [ATTR_API_TEMPERATURE, ATTR_API_HUMIDITY]: self._state = round(self._state, ...
[ "def", "state", "(", "self", ")", ":", "self", ".", "_state", "=", "self", ".", "coordinator", ".", "data", "[", "self", ".", "kind", "]", "if", "self", ".", "kind", "in", "[", "ATTR_API_PM1", ",", "ATTR_API_PRESSURE", "]", ":", "self", ".", "_state"...
[ 94, 4 ]
[ 101, 26 ]
python
en
['en', 'en', 'en']
True
AirlySensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return self._attrs
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_attrs" ]
[ 104, 4 ]
[ 106, 26 ]
python
en
['en', 'en', 'en']
True
AirlySensor.icon
(self)
Return the icon.
Return the icon.
def icon(self): """Return the icon.""" self._icon = SENSOR_TYPES[self.kind][ATTR_ICON] return self._icon
[ "def", "icon", "(", "self", ")", ":", "self", ".", "_icon", "=", "SENSOR_TYPES", "[", "self", ".", "kind", "]", "[", "ATTR_ICON", "]", "return", "self", ".", "_icon" ]
[ 109, 4 ]
[ 112, 25 ]
python
en
['en', 'sr', 'en']
True
AirlySensor.device_class
(self)
Return the device_class.
Return the device_class.
def device_class(self): """Return the device_class.""" return SENSOR_TYPES[self.kind][ATTR_DEVICE_CLASS]
[ "def", "device_class", "(", "self", ")", ":", "return", "SENSOR_TYPES", "[", "self", ".", "kind", "]", "[", "ATTR_DEVICE_CLASS", "]" ]
[ 115, 4 ]
[ 117, 57 ]
python
en
['en', 'en', 'en']
True
AirlySensor.unique_id
(self)
Return a unique_id for this entity.
Return a unique_id for this entity.
def unique_id(self): """Return a unique_id for this entity.""" return f"{self.coordinator.latitude}-{self.coordinator.longitude}-{self.kind.lower()}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self.coordinator.latitude}-{self.coordinator.longitude}-{self.kind.lower()}\"" ]
[ 120, 4 ]
[ 122, 94 ]
python
en
['en', 'en', 'en']
True
AirlySensor.device_info
(self)
Return the device info.
Return the device info.
def device_info(self): """Return the device info.""" return { "identifiers": { (DOMAIN, self.coordinator.latitude, self.coordinator.longitude) }, "name": DEFAULT_NAME, "manufacturer": MANUFACTURER, "entry_type": "service", ...
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "coordinator", ".", "latitude", ",", "self", ".", "coordinator", ".", "longitude", ")", "}", ",", "\"name\"", ":", "DEFAULT_NAME", "...
[ 125, 4 ]
[ 134, 9 ]
python
en
['en', 'en', 'en']
True
AirlySensor.unit_of_measurement
(self)
Return the unit the value is expressed in.
Return the unit the value is expressed in.
def unit_of_measurement(self): """Return the unit the value is expressed in.""" return SENSOR_TYPES[self.kind][ATTR_UNIT]
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "SENSOR_TYPES", "[", "self", ".", "kind", "]", "[", "ATTR_UNIT", "]" ]
[ 137, 4 ]
[ 139, 49 ]
python
en
['en', 'en', 'en']
True
get_scanner
(hass, config)
Validate the configuration and return a Luci scanner.
Validate the configuration and return a Luci scanner.
def get_scanner(hass, config): """Validate the configuration and return a Luci scanner.""" scanner = LuciDeviceScanner(config[DOMAIN]) return scanner if scanner.success_init else None
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "scanner", "=", "LuciDeviceScanner", "(", "config", "[", "DOMAIN", "]", ")", "return", "scanner", "if", "scanner", ".", "success_init", "else", "None" ]
[ 36, 0 ]
[ 40, 52 ]
python
en
['en', 'en', 'en']
True
LuciDeviceScanner.__init__
(self, config)
Initialize the scanner.
Initialize the scanner.
def __init__(self, config): """Initialize the scanner.""" self.router = OpenWrtRpc( config[CONF_HOST], config[CONF_USERNAME], config[CONF_PASSWORD], config[CONF_SSL], config[CONF_VERIFY_SSL], ) self.last_results = {} s...
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "self", ".", "router", "=", "OpenWrtRpc", "(", "config", "[", "CONF_HOST", "]", ",", "config", "[", "CONF_USERNAME", "]", ",", "config", "[", "CONF_PASSWORD", "]", ",", "config", "[", "CONF_SSL", ...
[ 46, 4 ]
[ 58, 54 ]
python
en
['en', 'en', 'en']
True
LuciDeviceScanner.scan_devices
(self)
Scan for new devices and return a list with found device IDs.
Scan for new devices and return a list with found device IDs.
def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" self._update_info() return [device.mac for device in self.last_results]
[ "def", "scan_devices", "(", "self", ")", ":", "self", ".", "_update_info", "(", ")", "return", "[", "device", ".", "mac", "for", "device", "in", "self", ".", "last_results", "]" ]
[ 60, 4 ]
[ 64, 59 ]
python
en
['en', 'en', 'en']
True
LuciDeviceScanner.get_device_name
(self, device)
Return the name of the given device or None if we don't know.
Return the name of the given device or None if we don't know.
def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" name = next( (result.hostname for result in self.last_results if result.mac == device), None, ) return name
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "name", "=", "next", "(", "(", "result", ".", "hostname", "for", "result", "in", "self", ".", "last_results", "if", "result", ".", "mac", "==", "device", ")", ",", "None", ",", ")", "ret...
[ 66, 4 ]
[ 72, 19 ]
python
en
['en', 'en', 'en']
True
LuciDeviceScanner.get_extra_attributes
(self, device)
Get extra attributes of a device. Some known extra attributes that may be returned in the device tuple include MAC address (mac), network device (dev), IP address (ip), reachable status (reachable), associated router (host), hostname if known (hostname) among others.
Get extra attributes of a device.
def get_extra_attributes(self, device): """ Get extra attributes of a device. Some known extra attributes that may be returned in the device tuple include MAC address (mac), network device (dev), IP address (ip), reachable status (reachable), associated router (host), ho...
[ "def", "get_extra_attributes", "(", "self", ",", "device", ")", ":", "device", "=", "next", "(", "(", "result", "for", "result", "in", "self", ".", "last_results", "if", "result", ".", "mac", "==", "device", ")", ",", "None", ")", "return", "device", "...
[ 74, 4 ]
[ 86, 31 ]
python
en
['en', 'error', 'th']
False
LuciDeviceScanner._update_info
(self)
Check the Luci router for devices.
Check the Luci router for devices.
def _update_info(self): """Check the Luci router for devices.""" result = self.router.get_all_connected_devices(only_reachable=True) _LOGGER.debug("Luci get_all_connected_devices returned: %s", result) last_results = [] for device in result: if ( not...
[ "def", "_update_info", "(", "self", ")", ":", "result", "=", "self", ".", "router", ".", "get_all_connected_devices", "(", "only_reachable", "=", "True", ")", "_LOGGER", ".", "debug", "(", "\"Luci get_all_connected_devices returned: %s\"", ",", "result", ")", "las...
[ 88, 4 ]
[ 104, 40 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities )
Set up a Toon switches based on a config entry.
Set up a Toon switches based on a config entry.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities ) -> None: """Set up a Toon switches based on a config entry.""" coordinator = hass.data[DOMAIN][entry.entry_id] async_add_entities( [ToonProgramSwitch(coordinator), ToonHolidayModeSwitch(coordinator)] ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "coordinator", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", ...
[ 29, 0 ]
[ 37, 5 ]
python
en
['en', 'en', 'en']
True
ToonSwitch.__init__
(self, coordinator: ToonDataUpdateCoordinator, *, key: str)
Initialize the Toon switch.
Initialize the Toon switch.
def __init__(self, coordinator: ToonDataUpdateCoordinator, *, key: str) -> None: """Initialize the Toon switch.""" self.key = key super().__init__( coordinator, enabled_default=SWITCH_ENTITIES[key][ATTR_DEFAULT_ENABLED], icon=SWITCH_ENTITIES[key][ATTR_ICON], ...
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "ToonDataUpdateCoordinator", ",", "*", ",", "key", ":", "str", ")", "->", "None", ":", "self", ".", "key", "=", "key", "super", "(", ")", ".", "__init__", "(", "coordinator", ",", "enabled_default"...
[ 43, 4 ]
[ 52, 9 ]
python
en
['en', 'en', 'en']
True
ToonSwitch.unique_id
(self)
Return the unique ID for this binary sensor.
Return the unique ID for this binary sensor.
def unique_id(self) -> str: """Return the unique ID for this binary sensor.""" agreement_id = self.coordinator.data.agreement.agreement_id return f"{agreement_id}_{self.key}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "agreement_id", "=", "self", ".", "coordinator", ".", "data", ".", "agreement", ".", "agreement_id", "return", "f\"{agreement_id}_{self.key}\"" ]
[ 55, 4 ]
[ 58, 43 ]
python
en
['en', 'en', 'en']
True
ToonSwitch.is_on
(self)
Return the status of the binary sensor.
Return the status of the binary sensor.
def is_on(self) -> bool: """Return the status of the binary sensor.""" section = getattr( self.coordinator.data, SWITCH_ENTITIES[self.key][ATTR_SECTION] ) value = getattr(section, SWITCH_ENTITIES[self.key][ATTR_MEASUREMENT]) if SWITCH_ENTITIES[self.key][ATTR_INVERTED...
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "section", "=", "getattr", "(", "self", ".", "coordinator", ".", "data", ",", "SWITCH_ENTITIES", "[", "self", ".", "key", "]", "[", "ATTR_SECTION", "]", ")", "value", "=", "getattr", "(", "section", ...
[ 61, 4 ]
[ 71, 20 ]
python
en
['en', 'mi', 'en']
True
ToonProgramSwitch.__init__
(self, coordinator: ToonDataUpdateCoordinator)
Initialize the Toon program switch.
Initialize the Toon program switch.
def __init__(self, coordinator: ToonDataUpdateCoordinator) -> None: """Initialize the Toon program switch.""" super().__init__(coordinator, key="thermostat_program")
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "ToonDataUpdateCoordinator", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ",", "key", "=", "\"thermostat_program\"", ")" ]
[ 77, 4 ]
[ 79, 63 ]
python
en
['en', 'pl', 'en']
True
ToonProgramSwitch.async_turn_off
(self, **kwargs: Any)
Turn off the Toon program switch.
Turn off the Toon program switch.
async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the Toon program switch.""" await self.coordinator.toon.set_active_state( ACTIVE_STATE_AWAY, PROGRAM_STATE_OFF )
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "await", "self", ".", "coordinator", ".", "toon", ".", "set_active_state", "(", "ACTIVE_STATE_AWAY", ",", "PROGRAM_STATE_OFF", ")" ]
[ 82, 4 ]
[ 86, 9 ]
python
en
['en', 'en', 'en']
True
ToonProgramSwitch.async_turn_on
(self, **kwargs: Any)
Turn on the Toon program switch.
Turn on the Toon program switch.
async def async_turn_on(self, **kwargs: Any) -> None: """Turn on the Toon program switch.""" await self.coordinator.toon.set_active_state( ACTIVE_STATE_AWAY, PROGRAM_STATE_ON )
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "await", "self", ".", "coordinator", ".", "toon", ".", "set_active_state", "(", "ACTIVE_STATE_AWAY", ",", "PROGRAM_STATE_ON", ")" ]
[ 89, 4 ]
[ 93, 9 ]
python
en
['en', 'en', 'en']
True
ToonHolidayModeSwitch.__init__
(self, coordinator: ToonDataUpdateCoordinator)
Initialize the Toon holiday switch.
Initialize the Toon holiday switch.
def __init__(self, coordinator: ToonDataUpdateCoordinator) -> None: """Initialize the Toon holiday switch.""" super().__init__(coordinator, key="thermostat_holiday_mode")
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "ToonDataUpdateCoordinator", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ",", "key", "=", "\"thermostat_holiday_mode\"", ")" ]
[ 99, 4 ]
[ 101, 68 ]
python
en
['en', 'en', 'en']
True
ToonHolidayModeSwitch.async_turn_off
(self, **kwargs: Any)
Turn off the Toon holiday mode switch.
Turn off the Toon holiday mode switch.
async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the Toon holiday mode switch.""" await self.coordinator.toon.set_active_state( ACTIVE_STATE_AWAY, PROGRAM_STATE_ON )
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "await", "self", ".", "coordinator", ".", "toon", ".", "set_active_state", "(", "ACTIVE_STATE_AWAY", ",", "PROGRAM_STATE_ON", ")" ]
[ 104, 4 ]
[ 108, 9 ]
python
en
['en', 'en', 'en']
True
ToonHolidayModeSwitch.async_turn_on
(self, **kwargs: Any)
Turn on the Toon holiday mode switch.
Turn on the Toon holiday mode switch.
async def async_turn_on(self, **kwargs: Any) -> None: """Turn on the Toon holiday mode switch.""" await self.coordinator.toon.set_active_state( ACTIVE_STATE_HOLIDAY, PROGRAM_STATE_OFF )
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "await", "self", ".", "coordinator", ".", "toon", ".", "set_active_state", "(", "ACTIVE_STATE_HOLIDAY", ",", "PROGRAM_STATE_OFF", ")" ]
[ 111, 4 ]
[ 115, 9 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Create the ViCare sensor devices.
Create the ViCare sensor devices.
def setup_platform(hass, config, add_entities, discovery_info=None): """Create the ViCare sensor devices.""" if discovery_info is None: return vicare_api = hass.data[VICARE_DOMAIN][VICARE_API] heating_type = hass.data[VICARE_DOMAIN][VICARE_HEATING_TYPE] sensors = SENSORS_GENERIC.copy() ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "vicare_api", "=", "hass", ".", "data", "[", "VICARE_DOMAIN", "]", "[", "VICARE_API",...
[ 214, 0 ]
[ 232, 5 ]
python
en
['en', 'en', 'en']
True
ViCareSensor.__init__
(self, name, api, sensor_type)
Initialize the sensor.
Initialize the sensor.
def __init__(self, name, api, sensor_type): """Initialize the sensor.""" self._sensor = SENSOR_TYPES[sensor_type] self._name = f"{name} {self._sensor[CONF_NAME]}" self._api = api self._sensor_type = sensor_type self._state = None
[ "def", "__init__", "(", "self", ",", "name", ",", "api", ",", "sensor_type", ")", ":", "self", ".", "_sensor", "=", "SENSOR_TYPES", "[", "sensor_type", "]", "self", ".", "_name", "=", "f\"{name} {self._sensor[CONF_NAME]}\"", "self", ".", "_api", "=", "api", ...
[ 238, 4 ]
[ 244, 26 ]
python
en
['en', 'en', 'en']
True
ViCareSensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return self._state is not None and self._state != PYVICARE_ERROR
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_state", "is", "not", "None", "and", "self", ".", "_state", "!=", "PYVICARE_ERROR" ]
[ 247, 4 ]
[ 249, 72 ]
python
en
['en', 'en', 'en']
True
ViCareSensor.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return f"{self._api.service.id}-{self._sensor_type}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self._api.service.id}-{self._sensor_type}\"" ]
[ 252, 4 ]
[ 254, 60 ]
python
ca
['fr', 'ca', 'en']
False
ViCareSensor.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" ]
[ 257, 4 ]
[ 259, 25 ]
python
en
['en', 'mi', 'en']
True
ViCareSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return self._sensor[CONF_ICON]
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_sensor", "[", "CONF_ICON", "]" ]
[ 262, 4 ]
[ 264, 38 ]
python
en
['en', 'en', 'en']
True
ViCareSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 267, 4 ]
[ 269, 26 ]
python
en
['en', 'en', 'en']
True
ViCareSensor.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return self._sensor[CONF_UNIT_OF_MEASUREMENT]
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_sensor", "[", "CONF_UNIT_OF_MEASUREMENT", "]" ]
[ 272, 4 ]
[ 274, 53 ]
python
en
['en', 'la', 'en']
True
ViCareSensor.device_class
(self)
Return the class of this device, from component DEVICE_CLASSES.
Return the class of this device, from component DEVICE_CLASSES.
def device_class(self): """Return the class of this device, from component DEVICE_CLASSES.""" return self._sensor[CONF_DEVICE_CLASS]
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_sensor", "[", "CONF_DEVICE_CLASS", "]" ]
[ 277, 4 ]
[ 279, 46 ]
python
en
['en', 'en', 'en']
True
ViCareSensor.update
(self)
Update state of sensor.
Update state of sensor.
def update(self): """Update state of sensor.""" try: self._state = self._sensor[CONF_GETTER](self._api) except requests.exceptions.ConnectionError: _LOGGER.error("Unable to retrieve data from ViCare server") except ValueError: _LOGGER.error("Unable to ...
[ "def", "update", "(", "self", ")", ":", "try", ":", "self", ".", "_state", "=", "self", ".", "_sensor", "[", "CONF_GETTER", "]", "(", "self", ".", "_api", ")", "except", "requests", ".", "exceptions", ".", "ConnectionError", ":", "_LOGGER", ".", "error...
[ 281, 4 ]
[ 288, 69 ]
python
en
['en', 'co', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Raspberry PI GPIO devices.
Set up the Raspberry PI GPIO devices.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Raspberry PI GPIO devices.""" setup_reload_service(hass, DOMAIN, PLATFORMS) invert_logic = config.get(CONF_INVERT_LOGIC) switches = [] ports = config.get(CONF_PORTS) for port, name in ports.items(): swi...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "setup_reload_service", "(", "hass", ",", "DOMAIN", ",", "PLATFORMS", ")", "invert_logic", "=", "config", ".", "get", "(", "CONF_INVERT_LOGI...
[ 28, 0 ]
[ 39, 26 ]
python
en
['en', 'sr', 'en']
True
RPiGPIOSwitch.__init__
(self, name, port, invert_logic)
Initialize the pin.
Initialize the pin.
def __init__(self, name, port, invert_logic): """Initialize the pin.""" self._name = name or DEVICE_DEFAULT_NAME self._port = port self._invert_logic = invert_logic self._state = False rpi_gpio.setup_output(self._port) rpi_gpio.write_output(self._port, 1 if self._...
[ "def", "__init__", "(", "self", ",", "name", ",", "port", ",", "invert_logic", ")", ":", "self", ".", "_name", "=", "name", "or", "DEVICE_DEFAULT_NAME", "self", ".", "_port", "=", "port", "self", ".", "_invert_logic", "=", "invert_logic", "self", ".", "_...
[ 45, 4 ]
[ 52, 73 ]
python
en
['en', 'en', 'en']
True
RPiGPIOSwitch.name
(self)
Return the name of the switch.
Return the name of the switch.
def name(self): """Return the name of the switch.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 55, 4 ]
[ 57, 25 ]
python
en
['en', 'en', 'en']
True
RPiGPIOSwitch.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 60, 4 ]
[ 62, 20 ]
python
en
['en', 'en', 'en']
True
RPiGPIOSwitch.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" ]
[ 65, 4 ]
[ 67, 26 ]
python
en
['en', 'fy', 'en']
True
RPiGPIOSwitch.turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
def turn_on(self, **kwargs): """Turn the device on.""" rpi_gpio.write_output(self._port, 0 if self._invert_logic else 1) self._state = True self.schedule_update_ha_state()
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "rpi_gpio", ".", "write_output", "(", "self", ".", "_port", ",", "0", "if", "self", ".", "_invert_logic", "else", "1", ")", "self", ".", "_state", "=", "True", "self", ".", "schedule_u...
[ 69, 4 ]
[ 73, 39 ]
python
en
['en', 'en', 'en']
True
RPiGPIOSwitch.turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
def turn_off(self, **kwargs): """Turn the device off.""" rpi_gpio.write_output(self._port, 1 if self._invert_logic else 0) self._state = False self.schedule_update_ha_state()
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "rpi_gpio", ".", "write_output", "(", "self", ".", "_port", ",", "1", "if", "self", ".", "_invert_logic", "else", "0", ")", "self", ".", "_state", "=", "False", "self", ".", "schedule...
[ 75, 4 ]
[ 79, 39 ]
python
en
['en', 'en', 'en']
True
floats_list
(shape, scale=1.0, rng=None, name=None)
Creates a random float32 tensor
Creates a random float32 tensor
def floats_list(shape, scale=1.0, rng=None, name=None): """Creates a random float32 tensor""" if rng is None: rng = global_rng values = [] for batch_idx in range(shape[0]): values.append([]) for _ in range(shape[1]): values[-1].append(rng.random() * scale) retur...
[ "def", "floats_list", "(", "shape", ",", "scale", "=", "1.0", ",", "rng", "=", "None", ",", "name", "=", "None", ")", ":", "if", "rng", "is", "None", ":", "rng", "=", "global_rng", "values", "=", "[", "]", "for", "batch_idx", "in", "range", "(", ...
[ 31, 0 ]
[ 42, 17 ]
python
en
['en', 'ca', 'en']
True
async_setup_platform
( hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info: Optional[DiscoveryInfoType] = None, )
Read configuration and create Modbus climate.
Read configuration and create Modbus climate.
async def async_setup_platform( hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info: Optional[DiscoveryInfoType] = None, ): """Read configuration and create Modbus climate.""" if discovery_info is None: return entities = [] for entity in discovery_inf...
[ "async", "def", "async_setup_platform", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "ConfigType", ",", "async_add_entities", ",", "discovery_info", ":", "Optional", "[", "DiscoveryInfoType", "]", "=", "None", ",", ")", ":", "if", "discovery_info", ...
[ 55, 0 ]
[ 101, 32 ]
python
en
['en', 'en', 'en']
True
ModbusThermostat.__init__
( self, hub: ModbusHub, config: Dict[str, Any], )
Initialize the modbus thermostat.
Initialize the modbus thermostat.
def __init__( self, hub: ModbusHub, config: Dict[str, Any], ): """Initialize the modbus thermostat.""" self._hub: ModbusHub = hub self._name = config[CONF_NAME] self._slave = config[CONF_SLAVE] self._target_temperature_register = config[CONF_TARGET_TEM...
[ "def", "__init__", "(", "self", ",", "hub", ":", "ModbusHub", ",", "config", ":", "Dict", "[", "str", ",", "Any", "]", ",", ")", ":", "self", ".", "_hub", ":", "ModbusHub", "=", "hub", "self", ".", "_name", "=", "config", "[", "CONF_NAME", "]", "...
[ 107, 4 ]
[ 134, 30 ]
python
en
['en', 'en', 'en']
True
ModbusThermostat.async_added_to_hass
(self)
Handle entity which will be added.
Handle entity which will be added.
async def async_added_to_hass(self): """Handle entity which will be added.""" async_track_time_interval( self.hass, lambda arg: self._update(), self._scan_interval )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "async_track_time_interval", "(", "self", ".", "hass", ",", "lambda", "arg", ":", "self", ".", "_update", "(", ")", ",", "self", ".", "_scan_interval", ")" ]
[ 136, 4 ]
[ 140, 9 ]
python
en
['en', 'en', 'en']
True
ModbusThermostat.should_poll
(self)
Return True if entity has to be polled for state. False if entity pushes its state to HA.
Return True if entity has to be polled for state.
def should_poll(self): """Return True if entity has to be polled for state. False if entity pushes its state to HA. """ # Handle polling directly in this entity return False
[ "def", "should_poll", "(", "self", ")", ":", "# Handle polling directly in this entity", "return", "False" ]
[ 143, 4 ]
[ 150, 20 ]
python
en
['en', 'en', 'en']
True
ModbusThermostat.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self): """Return the list of supported features.""" return SUPPORT_TARGET_TEMPERATURE
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_TARGET_TEMPERATURE" ]
[ 153, 4 ]
[ 155, 41 ]
python
en
['en', 'en', 'en']
True
ModbusThermostat.hvac_mode
(self)
Return the current HVAC mode.
Return the current HVAC mode.
def hvac_mode(self): """Return the current HVAC mode.""" return HVAC_MODE_AUTO
[ "def", "hvac_mode", "(", "self", ")", ":", "return", "HVAC_MODE_AUTO" ]
[ 158, 4 ]
[ 160, 29 ]
python
en
['en', 'co', 'en']
True
ModbusThermostat.hvac_modes
(self)
Return the possible HVAC modes.
Return the possible HVAC modes.
def hvac_modes(self): """Return the possible HVAC modes.""" return [HVAC_MODE_AUTO]
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "[", "HVAC_MODE_AUTO", "]" ]
[ 163, 4 ]
[ 165, 31 ]
python
en
['en', 'en', 'en']
True
ModbusThermostat.set_hvac_mode
(self, hvac_mode: str)
Set new target hvac mode.
Set new target hvac mode.
def set_hvac_mode(self, hvac_mode: str) -> None: """Set new target hvac mode."""
[ "def", "set_hvac_mode", "(", "self", ",", "hvac_mode", ":", "str", ")", "->", "None", ":" ]
[ 167, 4 ]
[ 168, 39 ]
python
da
['da', 'su', 'en']
False
ModbusThermostat.name
(self)
Return the name of the climate device.
Return the name of the climate device.
def name(self): """Return the name of the climate device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 173, 4 ]
[ 175, 25 ]
python
en
['en', 'en', 'en']
True
ModbusThermostat.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" return self._current_temperature
[ "def", "current_temperature", "(", "self", ")", ":", "return", "self", ".", "_current_temperature" ]
[ 178, 4 ]
[ 180, 40 ]
python
en
['en', 'la', 'en']
True
ModbusThermostat.target_temperature
(self)
Return the target temperature.
Return the target temperature.
def target_temperature(self): """Return the target temperature.""" return self._target_temperature
[ "def", "target_temperature", "(", "self", ")", ":", "return", "self", ".", "_target_temperature" ]
[ 183, 4 ]
[ 185, 39 ]
python
en
['en', 'la', 'en']
True
ModbusThermostat.temperature_unit
(self)
Return the unit of measurement.
Return the unit of measurement.
def temperature_unit(self): """Return the unit of measurement.""" return TEMP_FAHRENHEIT if self._unit == "F" else TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_FAHRENHEIT", "if", "self", ".", "_unit", "==", "\"F\"", "else", "TEMP_CELSIUS" ]
[ 188, 4 ]
[ 190, 69 ]
python
en
['en', 'la', 'en']
True
ModbusThermostat.min_temp
(self)
Return the minimum temperature.
Return the minimum temperature.
def min_temp(self): """Return the minimum temperature.""" return self._min_temp
[ "def", "min_temp", "(", "self", ")", ":", "return", "self", ".", "_min_temp" ]
[ 193, 4 ]
[ 195, 29 ]
python
en
['en', 'la', 'en']
True
ModbusThermostat.max_temp
(self)
Return the maximum temperature.
Return the maximum temperature.
def max_temp(self): """Return the maximum temperature.""" return self._max_temp
[ "def", "max_temp", "(", "self", ")", ":", "return", "self", ".", "_max_temp" ]
[ 198, 4 ]
[ 200, 29 ]
python
en
['en', 'la', 'en']
True
ModbusThermostat.target_temperature_step
(self)
Return the supported step of target temperature.
Return the supported step of target temperature.
def target_temperature_step(self): """Return the supported step of target temperature.""" return self._temp_step
[ "def", "target_temperature_step", "(", "self", ")", ":", "return", "self", ".", "_temp_step" ]
[ 203, 4 ]
[ 205, 30 ]
python
en
['en', 'en', 'en']
True
ModbusThermostat.set_temperature
(self, **kwargs)
Set new target temperature.
Set new target temperature.
def set_temperature(self, **kwargs): """Set new target temperature.""" target_temperature = int( (kwargs.get(ATTR_TEMPERATURE) - self._offset) / self._scale ) if target_temperature is None: return byte_string = struct.pack(self._structure, target_temperatu...
[ "def", "set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "target_temperature", "=", "int", "(", "(", "kwargs", ".", "get", "(", "ATTR_TEMPERATURE", ")", "-", "self", ".", "_offset", ")", "/", "self", ".", "_scale", ")", "if", "target_t...
[ 207, 4 ]
[ 217, 22 ]
python
en
['en', 'ca', 'en']
True
ModbusThermostat.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_available" ]
[ 220, 4 ]
[ 222, 30 ]
python
en
['en', 'en', 'en']
True
ModbusThermostat._update
(self)
Update Target & Current Temperature.
Update Target & Current Temperature.
def _update(self): """Update Target & Current Temperature.""" self._target_temperature = self._read_register( CALL_TYPE_REGISTER_HOLDING, self._target_temperature_register ) self._current_temperature = self._read_register( self._current_temperature_register_type, ...
[ "def", "_update", "(", "self", ")", ":", "self", ".", "_target_temperature", "=", "self", ".", "_read_register", "(", "CALL_TYPE_REGISTER_HOLDING", ",", "self", ".", "_target_temperature_register", ")", "self", ".", "_current_temperature", "=", "self", ".", "_read...
[ 224, 4 ]
[ 233, 39 ]
python
en
['en', 'la', 'en']
True
ModbusThermostat._read_register
(self, register_type, register)
Read register using the Modbus hub slave.
Read register using the Modbus hub slave.
def _read_register(self, register_type, register) -> Optional[float]: """Read register using the Modbus hub slave.""" try: if register_type == CALL_TYPE_REGISTER_INPUT: result = self._hub.read_input_registers( self._slave, register, self._count ...
[ "def", "_read_register", "(", "self", ",", "register_type", ",", "register", ")", "->", "Optional", "[", "float", "]", ":", "try", ":", "if", "register_type", "==", "CALL_TYPE_REGISTER_INPUT", ":", "result", "=", "self", ".", "_hub", ".", "read_input_registers...
[ 235, 4 ]
[ 264, 29 ]
python
en
['en', 'hmn', 'en']
True
ModbusThermostat._write_register
(self, register, value)
Write holding register using the Modbus hub slave.
Write holding register using the Modbus hub slave.
def _write_register(self, register, value): """Write holding register using the Modbus hub slave.""" try: self._hub.write_registers(self._slave, register, [value, 0]) except ConnectionException: self._available = False return self._available = True
[ "def", "_write_register", "(", "self", ",", "register", ",", "value", ")", ":", "try", ":", "self", ".", "_hub", ".", "write_registers", "(", "self", ".", "_slave", ",", "register", ",", "[", "value", ",", "0", "]", ")", "except", "ConnectionException", ...
[ 266, 4 ]
[ 274, 30 ]
python
en
['en', 'hmn', 'en']
True
async_get_conditions
( hass: HomeAssistant, device_id: str )
List device conditions.
List device conditions.
async def async_get_conditions( hass: HomeAssistant, device_id: str ) -> List[Dict[str, str]]: """List device conditions.""" conditions: List[Dict[str, str]] = [] entity_registry = await async_get_registry(hass) entries = [ entry for entry in async_entries_for_device(entity_registry,...
[ "async", "def", "async_get_conditions", "(", "hass", ":", "HomeAssistant", ",", "device_id", ":", "str", ")", "->", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ":", "conditions", ":", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ...
[ 101, 0 ]
[ 141, 21 ]
python
en
['fr', 'en', 'en']
True
async_condition_from_config
( config: ConfigType, config_validation: bool )
Evaluate state based on configuration.
Evaluate state based on configuration.
def async_condition_from_config( config: ConfigType, config_validation: bool ) -> condition.ConditionCheckerType: """Evaluate state based on configuration.""" if config_validation: config = CONDITION_SCHEMA(config) numeric_state_config = { condition.CONF_CONDITION: "numeric_state", ...
[ "def", "async_condition_from_config", "(", "config", ":", "ConfigType", ",", "config_validation", ":", "bool", ")", "->", "condition", ".", "ConditionCheckerType", ":", "if", "config_validation", ":", "config", "=", "CONDITION_SCHEMA", "(", "config", ")", "numeric_s...
[ 145, 0 ]
[ 160, 74 ]
python
en
['en', 'en', 'en']
True
async_get_condition_capabilities
(hass, config)
List condition capabilities.
List condition capabilities.
async def async_get_condition_capabilities(hass, config): """List condition capabilities.""" state = hass.states.get(config[CONF_ENTITY_ID]) unit_of_measurement = ( state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) if state else None ) if not state or not unit_of_measurement: raise Inv...
[ "async", "def", "async_get_condition_capabilities", "(", "hass", ",", "config", ")", ":", "state", "=", "hass", ".", "states", ".", "get", "(", "config", "[", "CONF_ENTITY_ID", "]", ")", "unit_of_measurement", "=", "(", "state", ".", "attributes", ".", "get"...
[ 163, 0 ]
[ 184, 5 ]
python
en
['ro', 'sr', 'en']
False
test_extract_placeholders
()
Test extracting placeholders from data.
Test extracting placeholders from data.
def test_extract_placeholders(): """Test extracting placeholders from data.""" assert placeholder.extract_placeholders(Placeholder("hello")) == {"hello"} assert placeholder.extract_placeholders( {"info": [1, Placeholder("hello"), 2, Placeholder("world")]} ) == {"hello", "world"}
[ "def", "test_extract_placeholders", "(", ")", ":", "assert", "placeholder", ".", "extract_placeholders", "(", "Placeholder", "(", "\"hello\"", ")", ")", "==", "{", "\"hello\"", "}", "assert", "placeholder", ".", "extract_placeholders", "(", "{", "\"info\"", ":", ...
[ 7, 0 ]
[ 12, 27 ]
python
en
['en', 'en', 'en']
True
test_substitute
()
Test we can substitute.
Test we can substitute.
def test_substitute(): """Test we can substitute.""" assert placeholder.substitute(Placeholder("hello"), {"hello": 5}) == 5 with pytest.raises(placeholder.UndefinedSubstitution): placeholder.substitute(Placeholder("hello"), {}) assert ( placeholder.substitute( {"info": [1, ...
[ "def", "test_substitute", "(", ")", ":", "assert", "placeholder", ".", "substitute", "(", "Placeholder", "(", "\"hello\"", ")", ",", "{", "\"hello\"", ":", "5", "}", ")", "==", "5", "with", "pytest", ".", "raises", "(", "placeholder", ".", "UndefinedSubsti...
[ 15, 0 ]
[ 28, 5 ]
python
en
['en', 'en', 'en']
True
session_id_generator
(source: str, destination: str)
The helper function to generate unique session id. Args: source (str): Message's source, destination (str): Message's destination. Returns: session_id (str): The unique session id. i.e. "uuid.source.destination"
The helper function to generate unique session id.
def session_id_generator(source: str, destination: str) -> str: """ The helper function to generate unique session id. Args: source (str): Message's source, destination (str): Message's destination. Returns: session_id (str): The unique session id. i.e. "uuid.source...
[ "def", "session_id_generator", "(", "source", ":", "str", ",", "destination", ":", "str", ")", "->", "str", ":", "unique_id", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", "session_id", "=", "'.'", ".", "join", "(", "[", "unique_id", ",", "so...
[ 6, 0 ]
[ 21, 21 ]
python
en
['en', 'error', 'th']
False
track_changes
(coll: collection.ObservableCollection)
Create helper to track changes in a collection.
Create helper to track changes in a collection.
def track_changes(coll: collection.ObservableCollection): """Create helper to track changes in a collection.""" changes = [] async def listener(*args): changes.append(args) coll.async_add_listener(listener) return changes
[ "def", "track_changes", "(", "coll", ":", "collection", ".", "ObservableCollection", ")", ":", "changes", "=", "[", "]", "async", "def", "listener", "(", "*", "args", ")", ":", "changes", ".", "append", "(", "args", ")", "coll", ".", "async_add_listener", ...
[ 13, 0 ]
[ 22, 18 ]
python
en
['en', 'en', 'en']
True
test_id_manager
()
Test the ID manager.
Test the ID manager.
def test_id_manager(): """Test the ID manager.""" id_manager = collection.IDManager() assert not id_manager.has_id("some_id") data = {} id_manager.add_collection(data) assert not id_manager.has_id("some_id") data["some_id"] = 1 assert id_manager.has_id("some_id") assert id_manager.ge...
[ "def", "test_id_manager", "(", ")", ":", "id_manager", "=", "collection", ".", "IDManager", "(", ")", "assert", "not", "id_manager", ".", "has_id", "(", "\"some_id\"", ")", "data", "=", "{", "}", "id_manager", ".", "add_collection", "(", "data", ")", "asse...
[ 72, 0 ]
[ 82, 49 ]
python
en
['en', 'en', 'en']
True
test_observable_collection
()
Test observerable collection.
Test observerable collection.
async def test_observable_collection(): """Test observerable collection.""" coll = collection.ObservableCollection(_LOGGER) assert coll.async_items() == [] coll.data["bla"] = 1 assert coll.async_items() == [1] changes = track_changes(coll) await coll.notify_changes( [collection.Coll...
[ "async", "def", "test_observable_collection", "(", ")", ":", "coll", "=", "collection", ".", "ObservableCollection", "(", "_LOGGER", ")", "assert", "coll", ".", "async_items", "(", ")", "==", "[", "]", "coll", ".", "data", "[", "\"bla\"", "]", "=", "1", ...
[ 85, 0 ]
[ 97, 67 ]
python
en
['sl', 'en', 'en']
True
test_yaml_collection
()
Test a YAML collection.
Test a YAML collection.
async def test_yaml_collection(): """Test a YAML collection.""" id_manager = collection.IDManager() coll = collection.YamlCollection(_LOGGER, id_manager) changes = track_changes(coll) await coll.async_load( [{"id": "mock-1", "name": "Mock 1"}, {"id": "mock-2", "name": "Mock 2"}] ) as...
[ "async", "def", "test_yaml_collection", "(", ")", ":", "id_manager", "=", "collection", ".", "IDManager", "(", ")", "coll", "=", "collection", ".", "YamlCollection", "(", "_LOGGER", ",", "id_manager", ")", "changes", "=", "track_changes", "(", "coll", ")", "...
[ 100, 0 ]
[ 141, 5 ]
python
en
['en', 'en', 'en']
True
test_yaml_collection_skipping_duplicate_ids
()
Test YAML collection skipping duplicate IDs.
Test YAML collection skipping duplicate IDs.
async def test_yaml_collection_skipping_duplicate_ids(): """Test YAML collection skipping duplicate IDs.""" id_manager = collection.IDManager() id_manager.add_collection({"existing": True}) coll = collection.YamlCollection(_LOGGER, id_manager) changes = track_changes(coll) await coll.async_load(...
[ "async", "def", "test_yaml_collection_skipping_duplicate_ids", "(", ")", ":", "id_manager", "=", "collection", ".", "IDManager", "(", ")", "id_manager", ".", "add_collection", "(", "{", "\"existing\"", ":", "True", "}", ")", "coll", "=", "collection", ".", "Yaml...
[ 144, 0 ]
[ 158, 5 ]
python
en
['ms', 'en', 'en']
True
test_storage_collection
(hass)
Test storage collection.
Test storage collection.
async def test_storage_collection(hass): """Test storage collection.""" store = storage.Store(hass, 1, "test-data") await store.async_save( { "items": [ {"id": "mock-1", "name": "Mock 1", "data": 1}, {"id": "mock-2", "name": "Mock 2", "data": 2}, ...
[ "async", "def", "test_storage_collection", "(", "hass", ")", ":", "store", "=", "storage", ".", "Store", "(", "hass", ",", "1", ",", "\"test-data\"", ")", "await", "store", ".", "async_save", "(", "{", "\"items\"", ":", "[", "{", "\"id\"", ":", "\"mock-1...
[ 161, 0 ]
[ 221, 5 ]
python
en
['en', 'de', 'en']
True
test_attach_entity_component_collection
(hass)
Test attaching collection to entity component.
Test attaching collection to entity component.
async def test_attach_entity_component_collection(hass): """Test attaching collection to entity component.""" ent_comp = entity_component.EntityComponent(_LOGGER, "test", hass) coll = collection.ObservableCollection(_LOGGER) collection.attach_entity_component_collection(ent_comp, coll, MockEntity) ...
[ "async", "def", "test_attach_entity_component_collection", "(", "hass", ")", ":", "ent_comp", "=", "entity_component", ".", "EntityComponent", "(", "_LOGGER", ",", "\"test\"", ",", "hass", ")", "coll", "=", "collection", ".", "ObservableCollection", "(", "_LOGGER", ...
[ 224, 0 ]
[ 260, 49 ]
python
en
['en', 'en', 'en']
True
test_storage_collection_websocket
(hass, hass_ws_client)
Test exposing a storage collection via websockets.
Test exposing a storage collection via websockets.
async def test_storage_collection_websocket(hass, hass_ws_client): """Test exposing a storage collection via websockets.""" store = storage.Store(hass, 1, "test-data") coll = MockStorageCollection(store, _LOGGER) changes = track_changes(coll) collection.StorageCollectionWebsocket( coll, ...
[ "async", "def", "test_storage_collection_websocket", "(", "hass", ",", "hass_ws_client", ")", ":", "store", "=", "storage", ".", "Store", "(", "hass", ",", "1", ",", "\"test-data\"", ")", "coll", "=", "MockStorageCollection", "(", "store", ",", "_LOGGER", ")",...
[ 263, 0 ]
[ 396, 5 ]
python
en
['en', 'en', 'en']
True
MockEntity.__init__
(self, config)
Initialize entity.
Initialize entity.
def __init__(self, config): """Initialize entity.""" self._config = config
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "self", ".", "_config", "=", "config" ]
[ 28, 4 ]
[ 30, 29 ]
python
es
['es', 'pl', 'it']
False