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_error_observation
(hass, mock_simple_nws)
Test error during update observation.
Test error during update observation.
async def test_error_observation(hass, mock_simple_nws): """Test error during update observation.""" utc_time = dt_util.utcnow() with patch("homeassistant.components.nws.utcnow") as mock_utc, patch( "homeassistant.components.nws.weather.utcnow" ) as mock_utc_weather: def increment_time(...
[ "async", "def", "test_error_observation", "(", "hass", ",", "mock_simple_nws", ")", ":", "utc_time", "=", "dt_util", ".", "utcnow", "(", ")", "with", "patch", "(", "\"homeassistant.components.nws.utcnow\"", ")", "as", "mock_utc", ",", "patch", "(", "\"homeassistan...
[ 185, 0 ]
[ 246, 47 ]
python
da
['nb', 'da', 'en']
False
test_error_forecast
(hass, mock_simple_nws)
Test error during update forecast.
Test error during update forecast.
async def test_error_forecast(hass, mock_simple_nws): """Test error during update forecast.""" instance = mock_simple_nws.return_value instance.update_forecast.side_effect = aiohttp.ClientError entry = MockConfigEntry( domain=nws.DOMAIN, data=NWS_CONFIG, ) entry.add_to_hass(hass...
[ "async", "def", "test_error_forecast", "(", "hass", ",", "mock_simple_nws", ")", ":", "instance", "=", "mock_simple_nws", ".", "return_value", "instance", ".", "update_forecast", ".", "side_effect", "=", "aiohttp", ".", "ClientError", "entry", "=", "MockConfigEntry"...
[ 249, 0 ]
[ 277, 46 ]
python
de
['nb', 'de', 'en']
False
test_error_forecast_hourly
(hass, mock_simple_nws)
Test error during update forecast hourly.
Test error during update forecast hourly.
async def test_error_forecast_hourly(hass, mock_simple_nws): """Test error during update forecast hourly.""" instance = mock_simple_nws.return_value instance.update_forecast_hourly.side_effect = aiohttp.ClientError # enable the hourly entity registry = await hass.helpers.entity_registry.async_get_r...
[ "async", "def", "test_error_forecast_hourly", "(", "hass", ",", "mock_simple_nws", ")", ":", "instance", "=", "mock_simple_nws", ".", "return_value", "instance", ".", "update_forecast_hourly", ".", "side_effect", "=", "aiohttp", ".", "ClientError", "# enable the hourly ...
[ 280, 0 ]
[ 318, 46 ]
python
en
['nl', 'en', 'en']
True
test_forecast_hourly_disable_enable
(hass, mock_simple_nws)
Test error during update forecast hourly.
Test error during update forecast hourly.
async def test_forecast_hourly_disable_enable(hass, mock_simple_nws): """Test error during update forecast hourly.""" entry = MockConfigEntry( domain=nws.DOMAIN, data=NWS_CONFIG, ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_blo...
[ "async", "def", "test_forecast_hourly_disable_enable", "(", "hass", ",", "mock_simple_nws", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "nws", ".", "DOMAIN", ",", "data", "=", "NWS_CONFIG", ",", ")", "entry", ".", "add_to_hass", "(", "hass",...
[ 321, 0 ]
[ 345, 42 ]
python
en
['nl', 'en', 'en']
True
interpolate_met
(in_dat, var, in_lons, in_lats, in_elev, out_lons, out_lats, out_elev, lapse=-0.005, single_dt=False)
interpolate met data for one timestep from coarse (vcsn) grid onto higher-resolution grid using bilinear interpolation. Air temperatures are first lapsed to sea level using default lapse rate of 0.005 K per m, interpolated, then lapsed to elevation of new grid :param in_dat: 3D array with data to be inte...
interpolate met data for one timestep from coarse (vcsn) grid onto higher-resolution grid using bilinear interpolation.
def interpolate_met(in_dat, var, in_lons, in_lats, in_elev, out_lons, out_lats, out_elev, lapse=-0.005, single_dt=False): """ interpolate met data for one timestep from coarse (vcsn) grid onto higher-resolution grid using bilinear interpolation. Air temperatures are first lapsed to sea level using default ...
[ "def", "interpolate_met", "(", "in_dat", ",", "var", ",", "in_lons", ",", "in_lats", ",", "in_elev", ",", "out_lons", ",", "out_lats", ",", "out_elev", ",", "lapse", "=", "-", "0.005", ",", "single_dt", "=", "False", ")", ":", "# X, Y = np.meshgrid(vcsn_lons...
[ 81, 0 ]
[ 162, 37 ]
python
en
['en', 'error', 'th']
False
daily_to_hourly_temp_grids
(max_temp_grid, min_temp_grid, single_dt=False)
run through and process daily data into hourly, one slice at a time. :param max_temp_grid: input data with dimension [time,y,x] :param min_temp_grid: input data with dimension [time,y,x] :return: hourly data with dimension [time*24,y,x]
run through and process daily data into hourly, one slice at a time. :param max_temp_grid: input data with dimension [time,y,x] :param min_temp_grid: input data with dimension [time,y,x] :return: hourly data with dimension [time*24,y,x]
def daily_to_hourly_temp_grids(max_temp_grid, min_temp_grid, single_dt=False): """ run through and process daily data into hourly, one slice at a time. :param max_temp_grid: input data with dimension [time,y,x] :param min_temp_grid: input data with dimension [time,y,x] :return: hourly data with dime...
[ "def", "daily_to_hourly_temp_grids", "(", "max_temp_grid", ",", "min_temp_grid", ",", "single_dt", "=", "False", ")", ":", "if", "single_dt", "==", "True", ":", "# assume is 2d and add a time dimension on the start", "max_temp_grid", "=", "max_temp_grid", ".", "reshape", ...
[ 165, 0 ]
[ 178, 22 ]
python
en
['en', 'error', 'th']
False
daily_to_hourly_swin_grids
(swin_grid, lats, lons, hourly_dt, single_dt=False)
converts daily mean SW into hourly using TOA rad, applying :param hi_res_sw_rad: daily sw in data with dimension [time,y,x] :return:
converts daily mean SW into hourly using TOA rad, applying
def daily_to_hourly_swin_grids(swin_grid, lats, lons, hourly_dt, single_dt=False): """ converts daily mean SW into hourly using TOA rad, applying :param hi_res_sw_rad: daily sw in data with dimension [time,y,x] :return: """ if single_dt == True: # assume is 2d and add a time dimension on the s...
[ "def", "daily_to_hourly_swin_grids", "(", "swin_grid", ",", "lats", ",", "lons", ",", "hourly_dt", ",", "single_dt", "=", "False", ")", ":", "if", "single_dt", "==", "True", ":", "# assume is 2d and add a time dimension on the start", "swin_grid", "=", "swin_grid", ...
[ 181, 0 ]
[ 207, 22 ]
python
en
['en', 'error', 'th']
False
load_new_vscn
(variable, dt_out, nc_file_in, point=None, nc_opt=False, single_dt=False, nc_datetimes=None)
load vcsn data from file for specified datetimes. transforms spatial dimensions so that latitude and longitude are increasing :param variable: string describing the field to take. options for newVCSN data are 'rain', 'tmax', 'tmin', 'srad' :param dt_out: array of datetimes requested :param nc_file_in: ...
load vcsn data from file for specified datetimes. transforms spatial dimensions so that latitude and longitude are increasing :param variable: string describing the field to take. options for newVCSN data are 'rain', 'tmax', 'tmin', 'srad' :param dt_out: array of datetimes requested :param nc_file_in: ...
def load_new_vscn(variable, dt_out, nc_file_in, point=None, nc_opt=False, single_dt=False, nc_datetimes=None): """ load vcsn data from file for specified datetimes. transforms spatial dimensions so that latitude and longitude are increasing :param variable: string describing the field to take. options for n...
[ "def", "load_new_vscn", "(", "variable", ",", "dt_out", ",", "nc_file_in", ",", "point", "=", "None", ",", "nc_opt", "=", "False", ",", "single_dt", "=", "False", ",", "nc_datetimes", "=", "None", ")", ":", "if", "nc_opt", ":", "nc_file", "=", "nc_file_i...
[ 210, 0 ]
[ 248, 15 ]
python
en
['en', 'error', 'th']
False
setup
(hass, config)
Activate Prometheus component.
Activate Prometheus component.
def setup(hass, config): """Activate Prometheus component.""" hass.http.register_view(PrometheusView(prometheus_client)) conf = config[DOMAIN] entity_filter = conf[CONF_FILTER] namespace = conf.get(CONF_PROM_NAMESPACE) climate_units = hass.config.units.temperature_unit override_metric = con...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "http", ".", "register_view", "(", "PrometheusView", "(", "prometheus_client", ")", ")", "conf", "=", "config", "[", "DOMAIN", "]", "entity_filter", "=", "conf", "[", "CONF_FILTER", "]", ...
[ 79, 0 ]
[ 106, 15 ]
python
de
['de', 'fr', 'en']
False
PrometheusMetrics.__init__
( self, prometheus_cli, entity_filter, namespace, climate_units, component_config, override_metric, default_metric, )
Initialize Prometheus Metrics.
Initialize Prometheus Metrics.
def __init__( self, prometheus_cli, entity_filter, namespace, climate_units, component_config, override_metric, default_metric, ): """Initialize Prometheus Metrics.""" self.prometheus_cli = prometheus_cli self._component_config ...
[ "def", "__init__", "(", "self", ",", "prometheus_cli", ",", "entity_filter", ",", "namespace", ",", "climate_units", ",", "component_config", ",", "override_metric", ",", "default_metric", ",", ")", ":", "self", ".", "prometheus_cli", "=", "prometheus_cli", "self"...
[ 112, 4 ]
[ 141, 43 ]
python
fr
['fr', 'sr', 'nl']
False
PrometheusMetrics.handle_event
(self, event)
Listen for new messages on the bus, and add them to Prometheus.
Listen for new messages on the bus, and add them to Prometheus.
def handle_event(self, event): """Listen for new messages on the bus, and add them to Prometheus.""" state = event.data.get("new_state") if state is None: return entity_id = state.entity_id _LOGGER.debug("Handling state update for %s", entity_id) domain, _ = ...
[ "def", "handle_event", "(", "self", ",", "event", ")", ":", "state", "=", "event", ".", "data", ".", "get", "(", "\"new_state\"", ")", "if", "state", "is", "None", ":", "return", "entity_id", "=", "state", ".", "entity_id", "_LOGGER", ".", "debug", "("...
[ 143, 4 ]
[ 179, 86 ]
python
en
['en', 'en', 'en']
True
PrometheusMetrics.state_as_number
(state)
Return a state casted to a float.
Return a state casted to a float.
def state_as_number(state): """Return a state casted to a float.""" try: value = state_helper.state_as_number(state) except ValueError: _LOGGER.debug("Could not convert %s to float", state) value = 0 return value
[ "def", "state_as_number", "(", "state", ")", ":", "try", ":", "value", "=", "state_helper", ".", "state_as_number", "(", "state", ")", "except", "ValueError", ":", "_LOGGER", ".", "debug", "(", "\"Could not convert %s to float\"", ",", "state", ")", "value", "...
[ 224, 4 ]
[ 231, 20 ]
python
en
['en', 'en', 'en']
True
PrometheusMetrics._sensor_default_metric
(self, state, unit)
Get default metric.
Get default metric.
def _sensor_default_metric(self, state, unit): """Get default metric.""" return self._default_metric
[ "def", "_sensor_default_metric", "(", "self", ",", "state", ",", "unit", ")", ":", "return", "self", ".", "_default_metric" ]
[ 404, 4 ]
[ 406, 35 ]
python
en
['fr', 'nl', 'en']
False
PrometheusMetrics._sensor_attribute_metric
(state, unit)
Get metric based on device class attribute.
Get metric based on device class attribute.
def _sensor_attribute_metric(state, unit): """Get metric based on device class attribute.""" metric = state.attributes.get(ATTR_DEVICE_CLASS) if metric is not None: return f"{metric}_{unit}" return None
[ "def", "_sensor_attribute_metric", "(", "state", ",", "unit", ")", ":", "metric", "=", "state", ".", "attributes", ".", "get", "(", "ATTR_DEVICE_CLASS", ")", "if", "metric", "is", "not", "None", ":", "return", "f\"{metric}_{unit}\"", "return", "None" ]
[ 409, 4 ]
[ 414, 19 ]
python
en
['en', 'en', 'en']
True
PrometheusMetrics._sensor_override_metric
(self, state, unit)
Get metric from override in configuration.
Get metric from override in configuration.
def _sensor_override_metric(self, state, unit): """Get metric from override in configuration.""" if self._override_metric: return self._override_metric return None
[ "def", "_sensor_override_metric", "(", "self", ",", "state", ",", "unit", ")", ":", "if", "self", ".", "_override_metric", ":", "return", "self", ".", "_override_metric", "return", "None" ]
[ 416, 4 ]
[ 420, 19 ]
python
en
['en', 'en', 'en']
True
PrometheusMetrics._sensor_override_component_metric
(self, state, unit)
Get metric from override in component confioguration.
Get metric from override in component confioguration.
def _sensor_override_component_metric(self, state, unit): """Get metric from override in component confioguration.""" return self._component_config.get(state.entity_id).get(CONF_OVERRIDE_METRIC)
[ "def", "_sensor_override_component_metric", "(", "self", ",", "state", ",", "unit", ")", ":", "return", "self", ".", "_component_config", ".", "get", "(", "state", ".", "entity_id", ")", ".", "get", "(", "CONF_OVERRIDE_METRIC", ")" ]
[ 422, 4 ]
[ 424, 84 ]
python
en
['en', 'en', 'en']
True
PrometheusMetrics._sensor_fallback_metric
(state, unit)
Get metric from fallback logic for compatibility.
Get metric from fallback logic for compatibility.
def _sensor_fallback_metric(state, unit): """Get metric from fallback logic for compatibility.""" if unit in (None, ""): _LOGGER.debug("Unsupported sensor: %s", state.entity_id) return None return f"sensor_unit_{unit}"
[ "def", "_sensor_fallback_metric", "(", "state", ",", "unit", ")", ":", "if", "unit", "in", "(", "None", ",", "\"\"", ")", ":", "_LOGGER", ".", "debug", "(", "\"Unsupported sensor: %s\"", ",", "state", ".", "entity_id", ")", "return", "None", "return", "f\"...
[ 427, 4 ]
[ 432, 36 ]
python
en
['en', 'en', 'en']
True
PrometheusMetrics._unit_string
(unit)
Get a formatted string of the unit.
Get a formatted string of the unit.
def _unit_string(unit): """Get a formatted string of the unit.""" if unit is None: return units = { TEMP_CELSIUS: "c", TEMP_FAHRENHEIT: "c", # F should go into C metric PERCENTAGE: "percent", } default = unit.replace("/", "_per_")...
[ "def", "_unit_string", "(", "unit", ")", ":", "if", "unit", "is", "None", ":", "return", "units", "=", "{", "TEMP_CELSIUS", ":", "\"c\"", ",", "TEMP_FAHRENHEIT", ":", "\"c\"", ",", "# F should go into C metric", "PERCENTAGE", ":", "\"percent\"", ",", "}", "d...
[ 435, 4 ]
[ 447, 39 ]
python
en
['en', 'en', 'en']
True
PrometheusView.__init__
(self, prometheus_cli)
Initialize Prometheus view.
Initialize Prometheus view.
def __init__(self, prometheus_cli): """Initialize Prometheus view.""" self.prometheus_cli = prometheus_cli
[ "def", "__init__", "(", "self", ",", "prometheus_cli", ")", ":", "self", ".", "prometheus_cli", "=", "prometheus_cli" ]
[ 481, 4 ]
[ 483, 44 ]
python
fr
['fr', 'fr', 'en']
True
PrometheusView.get
(self, request)
Handle request for Prometheus metrics.
Handle request for Prometheus metrics.
async def get(self, request): """Handle request for Prometheus metrics.""" _LOGGER.debug("Received Prometheus metrics request") return web.Response( body=self.prometheus_cli.generate_latest(), content_type=CONTENT_TYPE_TEXT_PLAIN, )
[ "async", "def", "get", "(", "self", ",", "request", ")", ":", "_LOGGER", ".", "debug", "(", "\"Received Prometheus metrics request\"", ")", "return", "web", ".", "Response", "(", "body", "=", "self", ".", "prometheus_cli", ".", "generate_latest", "(", ")", "...
[ 485, 4 ]
[ 492, 9 ]
python
en
['en', 'sr', 'en']
True
build_item_response
(media_library, payload)
Create response payload for the provided media query.
Create response payload for the provided media query.
async def build_item_response(media_library, payload): """Create response payload for the provided media query.""" search_id = payload["search_id"] search_type = payload["search_type"] thumbnail = None title = None media = None properties = ["thumbnail"] if search_type == MEDIA_TYPE_AL...
[ "async", "def", "build_item_response", "(", "media_library", ",", "payload", ")", ":", "search_id", "=", "payload", "[", "\"search_id\"", "]", "search_type", "=", "payload", "[", "\"search_type\"", "]", "thumbnail", "=", "None", "title", "=", "None", "media", ...
[ 60, 0 ]
[ 199, 19 ]
python
en
['en', 'en', 'en']
True
item_payload
(item, media_library)
Create response payload for a single media item. Used by async_browse_media.
Create response payload for a single media item.
def item_payload(item, media_library): """ Create response payload for a single media item. Used by async_browse_media. """ title = item["label"] thumbnail = item.get("thumbnail") if thumbnail: thumbnail = media_library.thumbnail_url(thumbnail) media_class = None if "songi...
[ "def", "item_payload", "(", "item", ",", "media_library", ")", ":", "title", "=", "item", "[", "\"label\"", "]", "thumbnail", "=", "item", ".", "get", "(", "\"thumbnail\"", ")", "if", "thumbnail", ":", "thumbnail", "=", "media_library", ".", "thumbnail_url",...
[ 202, 0 ]
[ 283, 5 ]
python
en
['en', 'error', 'th']
False
library_payload
(media_library)
Create response payload to describe contents of a specific library. Used by async_browse_media.
Create response payload to describe contents of a specific library.
def library_payload(media_library): """ Create response payload to describe contents of a specific library. Used by async_browse_media. """ library_info = BrowseMedia( media_class=MEDIA_CLASS_DIRECTORY, media_content_id="library", media_content_type="library", title=...
[ "def", "library_payload", "(", "media_library", ")", ":", "library_info", "=", "BrowseMedia", "(", "media_class", "=", "MEDIA_CLASS_DIRECTORY", ",", "media_content_id", "=", "\"library\"", ",", "media_content_type", "=", "\"library\"", ",", "title", "=", "\"Media Libr...
[ 286, 0 ]
[ 316, 23 ]
python
en
['en', 'error', 'th']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the IP Webcam switch platform.
Set up the IP Webcam switch platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the IP Webcam switch platform.""" if discovery_info is None: return host = discovery_info[CONF_HOST] name = discovery_info[CONF_NAME] switches = discovery_info[CONF_SWITCHES] ipcam = hass.da...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "host", "=", "discovery_info", "[", "CONF_HOST", "]", "name", "=",...
[ 14, 0 ]
[ 29, 42 ]
python
en
['en', 'da', 'en']
True
IPWebcamSettingsSwitch.__init__
(self, name, host, ipcam, setting)
Initialize the settings switch.
Initialize the settings switch.
def __init__(self, name, host, ipcam, setting): """Initialize the settings switch.""" super().__init__(host, ipcam) self._setting = setting self._mapped_name = KEY_MAP.get(self._setting, self._setting) self._name = f"{name} {self._mapped_name}" self._state = False
[ "def", "__init__", "(", "self", ",", "name", ",", "host", ",", "ipcam", ",", "setting", ")", ":", "super", "(", ")", ".", "__init__", "(", "host", ",", "ipcam", ")", "self", ".", "_setting", "=", "setting", "self", ".", "_mapped_name", "=", "KEY_MAP"...
[ 35, 4 ]
[ 42, 27 ]
python
en
['en', 'en', 'en']
True
IPWebcamSettingsSwitch.name
(self)
Return the name of the node.
Return the name of the node.
def name(self): """Return the name of the node.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 45, 4 ]
[ 47, 25 ]
python
en
['en', 'en', 'en']
True
IPWebcamSettingsSwitch.async_update
(self)
Get the updated status of the switch.
Get the updated status of the switch.
async def async_update(self): """Get the updated status of the switch.""" self._state = bool(self._ipcam.current_settings.get(self._setting))
[ "async", "def", "async_update", "(", "self", ")", ":", "self", ".", "_state", "=", "bool", "(", "self", ".", "_ipcam", ".", "current_settings", ".", "get", "(", "self", ".", "_setting", ")", ")" ]
[ 49, 4 ]
[ 51, 75 ]
python
en
['en', 'en', 'en']
True
IPWebcamSettingsSwitch.is_on
(self)
Return the boolean response if the node is on.
Return the boolean response if the node is on.
def is_on(self): """Return the boolean response if the node is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 54, 4 ]
[ 56, 26 ]
python
en
['en', 'en', 'en']
True
IPWebcamSettingsSwitch.async_turn_on
(self, **kwargs)
Turn device on.
Turn device on.
async def async_turn_on(self, **kwargs): """Turn device on.""" if self._setting == "torch": await self._ipcam.torch(activate=True) elif self._setting == "focus": await self._ipcam.focus(activate=True) elif self._setting == "video_recording": await self...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_setting", "==", "\"torch\"", ":", "await", "self", ".", "_ipcam", ".", "torch", "(", "activate", "=", "True", ")", "elif", "self", ".", "_setting", ...
[ 58, 4 ]
[ 69, 35 ]
python
en
['es', 'en', 'en']
True
IPWebcamSettingsSwitch.async_turn_off
(self, **kwargs)
Turn device off.
Turn device off.
async def async_turn_off(self, **kwargs): """Turn device off.""" if self._setting == "torch": await self._ipcam.torch(activate=False) elif self._setting == "focus": await self._ipcam.focus(activate=False) elif self._setting == "video_recording": await ...
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_setting", "==", "\"torch\"", ":", "await", "self", ".", "_ipcam", ".", "torch", "(", "activate", "=", "False", ")", "elif", "self", ".", "_setting", ...
[ 71, 4 ]
[ 82, 35 ]
python
en
['en', 'en', 'en']
True
IPWebcamSettingsSwitch.icon
(self)
Return the icon for the switch.
Return the icon for the switch.
def icon(self): """Return the icon for the switch.""" return ICON_MAP.get(self._setting, "mdi:flash")
[ "def", "icon", "(", "self", ")", ":", "return", "ICON_MAP", ".", "get", "(", "self", ".", "_setting", ",", "\"mdi:flash\"", ")" ]
[ 85, 4 ]
[ 87, 55 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[list], None], )
Set up the ISY994 cover platform.
Set up the ISY994 cover platform.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[list], None], ) -> bool: """Set up the ISY994 cover platform.""" hass_isy_data = hass.data[ISY994_DOMAIN][entry.entry_id] devices = [] for node in hass_isy_data[ISY994_NODES][COVER]: ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", "[", "[", "list", "]", ",", "None", "]", ",", ")", "->", "bool", ":", "hass_isy_data", "=", "hass", "....
[ 28, 0 ]
[ 43, 31 ]
python
en
['en', 'en', 'en']
True
ISYCoverEntity.current_cover_position
(self)
Return the current cover position.
Return the current cover position.
def current_cover_position(self) -> int: """Return the current cover position.""" if self._node.status == ISY_VALUE_UNKNOWN: return None if self._node.uom == UOM_8_BIT_RANGE: return round(self._node.status * 100.0 / 255.0) return sorted((0, self._node.status, 100)...
[ "def", "current_cover_position", "(", "self", ")", "->", "int", ":", "if", "self", ".", "_node", ".", "status", "==", "ISY_VALUE_UNKNOWN", ":", "return", "None", "if", "self", ".", "_node", ".", "uom", "==", "UOM_8_BIT_RANGE", ":", "return", "round", "(", ...
[ 50, 4 ]
[ 56, 53 ]
python
en
['en', 'en', 'en']
True
ISYCoverEntity.is_closed
(self)
Get whether the ISY994 cover device is closed.
Get whether the ISY994 cover device is closed.
def is_closed(self) -> bool: """Get whether the ISY994 cover device is closed.""" if self._node.status == ISY_VALUE_UNKNOWN: return None return self._node.status == 0
[ "def", "is_closed", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "_node", ".", "status", "==", "ISY_VALUE_UNKNOWN", ":", "return", "None", "return", "self", ".", "_node", ".", "status", "==", "0" ]
[ 59, 4 ]
[ 63, 37 ]
python
en
['en', 'en', 'en']
True
ISYCoverEntity.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_OPEN", "|", "SUPPORT_CLOSE", "|", "SUPPORT_SET_POSITION" ]
[ 66, 4 ]
[ 68, 66 ]
python
en
['da', 'en', 'en']
True
ISYCoverEntity.open_cover
(self, **kwargs)
Send the open cover command to the ISY994 cover device.
Send the open cover command to the ISY994 cover device.
def open_cover(self, **kwargs) -> None: """Send the open cover command to the ISY994 cover device.""" val = 100 if self._node.uom == UOM_BARRIER else None if not self._node.turn_on(val=val): _LOGGER.error("Unable to open the cover")
[ "def", "open_cover", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "val", "=", "100", "if", "self", ".", "_node", ".", "uom", "==", "UOM_BARRIER", "else", "None", "if", "not", "self", ".", "_node", ".", "turn_on", "(", "val", "=", ...
[ 70, 4 ]
[ 74, 53 ]
python
en
['en', 'en', 'en']
True
ISYCoverEntity.close_cover
(self, **kwargs)
Send the close cover command to the ISY994 cover device.
Send the close cover command to the ISY994 cover device.
def close_cover(self, **kwargs) -> None: """Send the close cover command to the ISY994 cover device.""" if not self._node.turn_off(): _LOGGER.error("Unable to close the cover")
[ "def", "close_cover", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "not", "self", ".", "_node", ".", "turn_off", "(", ")", ":", "_LOGGER", ".", "error", "(", "\"Unable to close the cover\"", ")" ]
[ 76, 4 ]
[ 79, 54 ]
python
en
['en', 'en', 'en']
True
ISYCoverEntity.set_cover_position
(self, **kwargs)
Move the cover to a specific position.
Move the cover to a specific position.
def set_cover_position(self, **kwargs): """Move the cover to a specific position.""" position = kwargs[ATTR_POSITION] if self._node.uom == UOM_8_BIT_RANGE: position = round(position * 255.0 / 100.0) if not self._node.turn_on(val=position): _LOGGER.error("Unable to...
[ "def", "set_cover_position", "(", "self", ",", "*", "*", "kwargs", ")", ":", "position", "=", "kwargs", "[", "ATTR_POSITION", "]", "if", "self", ".", "_node", ".", "uom", "==", "UOM_8_BIT_RANGE", ":", "position", "=", "round", "(", "position", "*", "255....
[ 81, 4 ]
[ 87, 57 ]
python
en
['en', 'en', 'en']
True
ISYCoverProgramEntity.is_closed
(self)
Get whether the ISY994 cover program is closed.
Get whether the ISY994 cover program is closed.
def is_closed(self) -> bool: """Get whether the ISY994 cover program is closed.""" return bool(self._node.status)
[ "def", "is_closed", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "_node", ".", "status", ")" ]
[ 94, 4 ]
[ 96, 38 ]
python
en
['en', 'en', 'en']
True
ISYCoverProgramEntity.open_cover
(self, **kwargs)
Send the open cover command to the ISY994 cover program.
Send the open cover command to the ISY994 cover program.
def open_cover(self, **kwargs) -> None: """Send the open cover command to the ISY994 cover program.""" if not self._actions.run_then(): _LOGGER.error("Unable to open the cover")
[ "def", "open_cover", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "not", "self", ".", "_actions", ".", "run_then", "(", ")", ":", "_LOGGER", ".", "error", "(", "\"Unable to open the cover\"", ")" ]
[ 98, 4 ]
[ 101, 53 ]
python
en
['en', 'en', 'en']
True
ISYCoverProgramEntity.close_cover
(self, **kwargs)
Send the close cover command to the ISY994 cover program.
Send the close cover command to the ISY994 cover program.
def close_cover(self, **kwargs) -> None: """Send the close cover command to the ISY994 cover program.""" if not self._actions.run_else(): _LOGGER.error("Unable to close the cover")
[ "def", "close_cover", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "not", "self", ".", "_actions", ".", "run_else", "(", ")", ":", "_LOGGER", ".", "error", "(", "\"Unable to close the cover\"", ")" ]
[ 103, 4 ]
[ 106, 54 ]
python
en
['en', 'en', 'en']
True
test_with_hvac_mode
(hass, state)
Test that state different hvac states.
Test that state different hvac states.
async def test_with_hvac_mode(hass, state): """Test that state different hvac states.""" calls = async_mock_service(hass, DOMAIN, SERVICE_SET_HVAC_MODE) await async_reproduce_states(hass, [State(ENTITY_1, state)]) await hass.async_block_till_done() assert len(calls) == 1 assert calls[0].data ...
[ "async", "def", "test_with_hvac_mode", "(", "hass", ",", "state", ")", ":", "calls", "=", "async_mock_service", "(", "hass", ",", "DOMAIN", ",", "SERVICE_SET_HVAC_MODE", ")", "await", "async_reproduce_states", "(", "hass", ",", "[", "State", "(", "ENTITY_1", "...
[ 33, 0 ]
[ 42, 71 ]
python
en
['en', 'en', 'en']
True
test_multiple_state
(hass)
Test that multiple states gets calls.
Test that multiple states gets calls.
async def test_multiple_state(hass): """Test that multiple states gets calls.""" calls_1 = async_mock_service(hass, DOMAIN, SERVICE_SET_HVAC_MODE) await async_reproduce_states( hass, [State(ENTITY_1, HVAC_MODE_HEAT), State(ENTITY_2, HVAC_MODE_AUTO)] ) await hass.async_block_till_done() ...
[ "async", "def", "test_multiple_state", "(", "hass", ")", ":", "calls_1", "=", "async_mock_service", "(", "hass", ",", "DOMAIN", ",", "SERVICE_SET_HVAC_MODE", ")", "await", "async_reproduce_states", "(", "hass", ",", "[", "State", "(", "ENTITY_1", ",", "HVAC_MODE...
[ 45, 0 ]
[ 64, 5 ]
python
en
['en', 'en', 'en']
True
test_state_with_none
(hass)
Test that none is not a hvac state.
Test that none is not a hvac state.
async def test_state_with_none(hass): """Test that none is not a hvac state.""" calls = async_mock_service(hass, DOMAIN, SERVICE_SET_HVAC_MODE) await async_reproduce_states(hass, [State(ENTITY_1, None)]) await hass.async_block_till_done() assert len(calls) == 0
[ "async", "def", "test_state_with_none", "(", "hass", ")", ":", "calls", "=", "async_mock_service", "(", "hass", ",", "DOMAIN", ",", "SERVICE_SET_HVAC_MODE", ")", "await", "async_reproduce_states", "(", "hass", ",", "[", "State", "(", "ENTITY_1", ",", "None", "...
[ 67, 0 ]
[ 75, 26 ]
python
en
['en', 'en', 'en']
True
test_state_with_context
(hass)
Test that context is forwarded.
Test that context is forwarded.
async def test_state_with_context(hass): """Test that context is forwarded.""" calls = async_mock_service(hass, DOMAIN, SERVICE_SET_HVAC_MODE) context = Context() await async_reproduce_states( hass, [State(ENTITY_1, HVAC_MODE_HEAT)], context=context ) await hass.async_block_till_done(...
[ "async", "def", "test_state_with_context", "(", "hass", ")", ":", "calls", "=", "async_mock_service", "(", "hass", ",", "DOMAIN", ",", "SERVICE_SET_HVAC_MODE", ")", "context", "=", "Context", "(", ")", "await", "async_reproduce_states", "(", "hass", ",", "[", ...
[ 78, 0 ]
[ 92, 38 ]
python
en
['en', 'en', 'en']
True
test_attribute
(hass, service, attribute)
Test that service call is made for each attribute.
Test that service call is made for each attribute.
async def test_attribute(hass, service, attribute): """Test that service call is made for each attribute.""" calls_1 = async_mock_service(hass, DOMAIN, service) value = "dummy" await async_reproduce_states(hass, [State(ENTITY_1, None, {attribute: value})]) await hass.async_block_till_done() ...
[ "async", "def", "test_attribute", "(", "hass", ",", "service", ",", "attribute", ")", ":", "calls_1", "=", "async_mock_service", "(", "hass", ",", "DOMAIN", ",", "service", ")", "value", "=", "\"dummy\"", "await", "async_reproduce_states", "(", "hass", ",", ...
[ 107, 0 ]
[ 118, 71 ]
python
en
['en', 'en', 'en']
True
get_time_until
(departure_time=None)
Calculate the time between now and a train's departure time.
Calculate the time between now and a train's departure time.
def get_time_until(departure_time=None): """Calculate the time between now and a train's departure time.""" if departure_time is None: return 0 delta = dt_util.utc_from_timestamp(int(departure_time)) - dt_util.now() return round(delta.total_seconds() / 60)
[ "def", "get_time_until", "(", "departure_time", "=", "None", ")", ":", "if", "departure_time", "is", "None", ":", "return", "0", "delta", "=", "dt_util", ".", "utc_from_timestamp", "(", "int", "(", "departure_time", ")", ")", "-", "dt_util", ".", "now", "(...
[ 43, 0 ]
[ 49, 44 ]
python
en
['en', 'en', 'en']
True
get_delay_in_minutes
(delay=0)
Get the delay in minutes from a delay in seconds.
Get the delay in minutes from a delay in seconds.
def get_delay_in_minutes(delay=0): """Get the delay in minutes from a delay in seconds.""" return round(int(delay) / 60)
[ "def", "get_delay_in_minutes", "(", "delay", "=", "0", ")", ":", "return", "round", "(", "int", "(", "delay", ")", "/", "60", ")" ]
[ 52, 0 ]
[ 54, 33 ]
python
en
['en', 'en', 'en']
True
get_ride_duration
(departure_time, arrival_time, delay=0)
Calculate the total travel time in minutes.
Calculate the total travel time in minutes.
def get_ride_duration(departure_time, arrival_time, delay=0): """Calculate the total travel time in minutes.""" duration = dt_util.utc_from_timestamp( int(arrival_time) ) - dt_util.utc_from_timestamp(int(departure_time)) duration_time = int(round(duration.total_seconds() / 60)) return durati...
[ "def", "get_ride_duration", "(", "departure_time", ",", "arrival_time", ",", "delay", "=", "0", ")", ":", "duration", "=", "dt_util", ".", "utc_from_timestamp", "(", "int", "(", "arrival_time", ")", ")", "-", "dt_util", ".", "utc_from_timestamp", "(", "int", ...
[ 57, 0 ]
[ 63, 54 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the NMBS sensor with iRail API.
Set up the NMBS sensor with iRail API.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the NMBS sensor with iRail API.""" api_client = iRail() name = config[CONF_NAME] show_on_map = config[CONF_SHOW_ON_MAP] station_from = config[CONF_STATION_FROM] station_to = config[CONF_STATION_TO] station_live ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "api_client", "=", "iRail", "(", ")", "name", "=", "config", "[", "CONF_NAME", "]", "show_on_map", "=", "config", "[", "CONF_SHOW_ON_MAP",...
[ 66, 0 ]
[ 87, 31 ]
python
en
['en', 'haw', 'en']
True
NMBSLiveBoard.__init__
(self, api_client, live_station, station_from, station_to)
Initialize the sensor for getting liveboard data.
Initialize the sensor for getting liveboard data.
def __init__(self, api_client, live_station, station_from, station_to): """Initialize the sensor for getting liveboard data.""" self._station = live_station self._api_client = api_client self._station_from = station_from self._station_to = station_to self._attrs = {} ...
[ "def", "__init__", "(", "self", ",", "api_client", ",", "live_station", ",", "station_from", ",", "station_to", ")", ":", "self", ".", "_station", "=", "live_station", "self", ".", "_api_client", "=", "api_client", "self", ".", "_station_from", "=", "station_f...
[ 93, 4 ]
[ 100, 26 ]
python
en
['en', 'en', 'en']
True
NMBSLiveBoard.name
(self)
Return the sensor default name.
Return the sensor default name.
def name(self): """Return the sensor default name.""" return f"NMBS Live ({self._station})"
[ "def", "name", "(", "self", ")", ":", "return", "f\"NMBS Live ({self._station})\"" ]
[ 103, 4 ]
[ 105, 45 ]
python
en
['en', 'da', 'en']
True
NMBSLiveBoard.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" unique_id = f"{self._station}_{self._station_from}_{self._station_to}" return f"nmbs_live_{unique_id}"
[ "def", "unique_id", "(", "self", ")", ":", "unique_id", "=", "f\"{self._station}_{self._station_from}_{self._station_to}\"", "return", "f\"nmbs_live_{unique_id}\"" ]
[ 108, 4 ]
[ 112, 39 ]
python
ca
['fr', 'ca', 'en']
False
NMBSLiveBoard.icon
(self)
Return the default icon or an alert icon if delays.
Return the default icon or an alert icon if delays.
def icon(self): """Return the default icon or an alert icon if delays.""" if self._attrs and int(self._attrs["delay"]) > 0: return DEFAULT_ICON_ALERT return DEFAULT_ICON
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "_attrs", "and", "int", "(", "self", ".", "_attrs", "[", "\"delay\"", "]", ")", ">", "0", ":", "return", "DEFAULT_ICON_ALERT", "return", "DEFAULT_ICON" ]
[ 115, 4 ]
[ 120, 27 ]
python
en
['en', 'en', 'en']
True
NMBSLiveBoard.state
(self)
Return sensor state.
Return sensor state.
def state(self): """Return sensor state.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 123, 4 ]
[ 125, 26 ]
python
en
['en', 'bs', 'en']
True
NMBSLiveBoard.device_state_attributes
(self)
Return the sensor attributes if data is available.
Return the sensor attributes if data is available.
def device_state_attributes(self): """Return the sensor attributes if data is available.""" if self._state is None or not self._attrs: return None delay = get_delay_in_minutes(self._attrs["delay"]) departure = get_time_until(self._attrs["time"]) attrs = { ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "_state", "is", "None", "or", "not", "self", ".", "_attrs", ":", "return", "None", "delay", "=", "get_delay_in_minutes", "(", "self", ".", "_attrs", "[", "\"delay\"", "]", ")", "...
[ 128, 4 ]
[ 149, 20 ]
python
en
['en', 'en', 'en']
True
NMBSLiveBoard.update
(self)
Set the state equal to the next departure.
Set the state equal to the next departure.
def update(self): """Set the state equal to the next departure.""" liveboard = self._api_client.get_liveboard(self._station) if liveboard is None or not liveboard["departures"]: return next_departure = liveboard["departures"]["departure"][0] self._attrs = next_depa...
[ "def", "update", "(", "self", ")", ":", "liveboard", "=", "self", ".", "_api_client", ".", "get_liveboard", "(", "self", ".", "_station", ")", "if", "liveboard", "is", "None", "or", "not", "liveboard", "[", "\"departures\"", "]", ":", "return", "next_depar...
[ 151, 4 ]
[ 163, 9 ]
python
en
['en', 'en', 'en']
True
NMBSSensor.__init__
( self, api_client, name, show_on_map, station_from, station_to, excl_vias )
Initialize the NMBS connection sensor.
Initialize the NMBS connection sensor.
def __init__( self, api_client, name, show_on_map, station_from, station_to, excl_vias ): """Initialize the NMBS connection sensor.""" self._name = name self._show_on_map = show_on_map self._api_client = api_client self._station_from = station_from self._stati...
[ "def", "__init__", "(", "self", ",", "api_client", ",", "name", ",", "show_on_map", ",", "station_from", ",", "station_to", ",", "excl_vias", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_show_on_map", "=", "show_on_map", "self", ".", "_api_c...
[ 169, 4 ]
[ 181, 26 ]
python
en
['en', 'en', 'en']
True
NMBSSensor.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" ]
[ 184, 4 ]
[ 186, 25 ]
python
en
['en', 'mi', 'en']
True
NMBSSensor.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 TIME_MINUTES
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "TIME_MINUTES" ]
[ 189, 4 ]
[ 191, 27 ]
python
en
['en', 'la', 'en']
True
NMBSSensor.icon
(self)
Return the sensor default icon or an alert icon if any delay.
Return the sensor default icon or an alert icon if any delay.
def icon(self): """Return the sensor default icon or an alert icon if any delay.""" if self._attrs: delay = get_delay_in_minutes(self._attrs["departure"]["delay"]) if delay > 0: return "mdi:alert-octagon" return "mdi:train"
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "_attrs", ":", "delay", "=", "get_delay_in_minutes", "(", "self", ".", "_attrs", "[", "\"departure\"", "]", "[", "\"delay\"", "]", ")", "if", "delay", ">", "0", ":", "return", "\"mdi:alert-octagon\...
[ 194, 4 ]
[ 201, 26 ]
python
en
['en', 'en', 'en']
True
NMBSSensor.device_state_attributes
(self)
Return sensor attributes if data is available.
Return sensor attributes if data is available.
def device_state_attributes(self): """Return sensor attributes if data is available.""" if self._state is None or not self._attrs: return None delay = get_delay_in_minutes(self._attrs["departure"]["delay"]) departure = get_time_until(self._attrs["departure"]["time"]) ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "_state", "is", "None", "or", "not", "self", ".", "_attrs", ":", "return", "None", "delay", "=", "get_delay_in_minutes", "(", "self", ".", "_attrs", "[", "\"departure\"", "]", "[",...
[ 204, 4 ]
[ 241, 20 ]
python
en
['en', 'en', 'en']
True
NMBSSensor.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" ]
[ 244, 4 ]
[ 246, 26 ]
python
en
['en', 'en', 'en']
True
NMBSSensor.station_coordinates
(self)
Get the lat, long coordinates for station.
Get the lat, long coordinates for station.
def station_coordinates(self): """Get the lat, long coordinates for station.""" if self._state is None or not self._attrs: return [] latitude = float(self._attrs["departure"]["stationinfo"]["locationY"]) longitude = float(self._attrs["departure"]["stationinfo"]["locationX"])...
[ "def", "station_coordinates", "(", "self", ")", ":", "if", "self", ".", "_state", "is", "None", "or", "not", "self", ".", "_attrs", ":", "return", "[", "]", "latitude", "=", "float", "(", "self", ".", "_attrs", "[", "\"departure\"", "]", "[", "\"statio...
[ 249, 4 ]
[ 256, 36 ]
python
en
['en', 'en', 'en']
True
NMBSSensor.is_via_connection
(self)
Return whether the connection goes through another station.
Return whether the connection goes through another station.
def is_via_connection(self): """Return whether the connection goes through another station.""" if not self._attrs: return False return "vias" in self._attrs and int(self._attrs["vias"]["number"]) > 0
[ "def", "is_via_connection", "(", "self", ")", ":", "if", "not", "self", ".", "_attrs", ":", "return", "False", "return", "\"vias\"", "in", "self", ".", "_attrs", "and", "int", "(", "self", ".", "_attrs", "[", "\"vias\"", "]", "[", "\"number\"", "]", ")...
[ 259, 4 ]
[ 264, 79 ]
python
en
['en', 'en', 'en']
True
NMBSSensor.update
(self)
Set the state to the duration of a connection.
Set the state to the duration of a connection.
def update(self): """Set the state to the duration of a connection.""" connections = self._api_client.get_connections( self._station_from, self._station_to ) if connections is None or not connections["connection"]: return if int(connections["connection"]...
[ "def", "update", "(", "self", ")", ":", "connections", "=", "self", ".", "_api_client", ".", "get_connections", "(", "self", ".", "_station_from", ",", "self", ".", "_station_to", ")", "if", "connections", "is", "None", "or", "not", "connections", "[", "\"...
[ 266, 4 ]
[ 295, 30 ]
python
en
['en', 'en', 'en']
True
async_capture_log_levels
()
Capture current logger levels for ZHA.
Capture current logger levels for ZHA.
def async_capture_log_levels(): """Capture current logger levels for ZHA.""" return { DEBUG_COMP_BELLOWS: logging.getLogger(DEBUG_COMP_BELLOWS).getEffectiveLevel(), DEBUG_COMP_ZHA: logging.getLogger(DEBUG_COMP_ZHA).getEffectiveLevel(), DEBUG_COMP_ZIGPY: logging.getLogger(DEBUG_COMP_ZIGPY...
[ "def", "async_capture_log_levels", "(", ")", ":", "return", "{", "DEBUG_COMP_BELLOWS", ":", "logging", ".", "getLogger", "(", "DEBUG_COMP_BELLOWS", ")", ".", "getEffectiveLevel", "(", ")", ",", "DEBUG_COMP_ZHA", ":", "logging", ".", "getLogger", "(", "DEBUG_COMP_Z...
[ 643, 0 ]
[ 659, 5 ]
python
en
['fr', 'en', 'en']
True
async_set_logger_levels
(levels)
Set logger levels for ZHA.
Set logger levels for ZHA.
def async_set_logger_levels(levels): """Set logger levels for ZHA.""" logging.getLogger(DEBUG_COMP_BELLOWS).setLevel(levels[DEBUG_COMP_BELLOWS]) logging.getLogger(DEBUG_COMP_ZHA).setLevel(levels[DEBUG_COMP_ZHA]) logging.getLogger(DEBUG_COMP_ZIGPY).setLevel(levels[DEBUG_COMP_ZIGPY]) logging.getLogger...
[ "def", "async_set_logger_levels", "(", "levels", ")", ":", "logging", ".", "getLogger", "(", "DEBUG_COMP_BELLOWS", ")", ".", "setLevel", "(", "levels", "[", "DEBUG_COMP_BELLOWS", "]", ")", "logging", ".", "getLogger", "(", "DEBUG_COMP_ZHA", ")", ".", "setLevel",...
[ 663, 0 ]
[ 671, 88 ]
python
en
['fr', 'no', 'en']
False
ZHAGateway.__init__
(self, hass, config, config_entry)
Initialize the gateway.
Initialize the gateway.
def __init__(self, hass, config, config_entry): """Initialize the gateway.""" self._hass = hass self._config = config self._devices = {} self._groups = {} self.coordinator_zha_device = None self._device_registry = collections.defaultdict(list) self.zha_sto...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ",", "config_entry", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_config", "=", "config", "self", ".", "_devices", "=", "{", "}", "self", ".", "_groups", "=", "{", "}", "sel...
[ 100, 4 ]
[ 120, 25 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.async_initialize
(self)
Initialize controller and connect radio.
Initialize controller and connect radio.
async def async_initialize(self): """Initialize controller and connect radio.""" discovery.PROBE.initialize(self._hass) discovery.GROUP_PROBE.initialize(self._hass) self.zha_storage = await async_get_registry(self._hass) self.ha_device_registry = await get_dev_reg(self._hass) ...
[ "async", "def", "async_initialize", "(", "self", ")", ":", "discovery", ".", "PROBE", ".", "initialize", "(", "self", ".", "_hass", ")", "discovery", ".", "GROUP_PROBE", ".", "initialize", "(", "self", ".", "_hass", ")", "self", ".", "zha_storage", "=", ...
[ 122, 4 ]
[ 165, 32 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.async_load_devices
(self)
Restore ZHA devices from zigpy application state.
Restore ZHA devices from zigpy application state.
def async_load_devices(self) -> None: """Restore ZHA devices from zigpy application state.""" for zigpy_device in self.application_controller.devices.values(): zha_device = self._async_get_or_create_device(zigpy_device, restored=True) if zha_device.nwk == 0x0000: ...
[ "def", "async_load_devices", "(", "self", ")", "->", "None", ":", "for", "zigpy_device", "in", "self", ".", "application_controller", ".", "devices", ".", "values", "(", ")", ":", "zha_device", "=", "self", ".", "_async_get_or_create_device", "(", "zigpy_device"...
[ 168, 4 ]
[ 196, 9 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.async_load_groups
(self)
Initialize ZHA groups.
Initialize ZHA groups.
def async_load_groups(self) -> None: """Initialize ZHA groups.""" for group_id in self.application_controller.groups: group = self.application_controller.groups[group_id] zha_group = self._async_get_or_create_group(group) # we can do this here because the entities are...
[ "def", "async_load_groups", "(", "self", ")", "->", "None", ":", "for", "group_id", "in", "self", ".", "application_controller", ".", "groups", ":", "group", "=", "self", ".", "application_controller", ".", "groups", "[", "group_id", "]", "zha_group", "=", "...
[ 199, 4 ]
[ 205, 68 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.async_initialize_devices_and_entities
(self)
Initialize devices and load entities.
Initialize devices and load entities.
async def async_initialize_devices_and_entities(self) -> None: """Initialize devices and load entities.""" semaphore = asyncio.Semaphore(2) async def _throttle(zha_device: zha_typing.ZhaDeviceType, cached: bool): async with semaphore: await zha_device.async_initializ...
[ "async", "def", "async_initialize_devices_and_entities", "(", "self", ")", "->", "None", ":", "semaphore", "=", "asyncio", ".", "Semaphore", "(", "2", ")", "async", "def", "_throttle", "(", "zha_device", ":", "zha_typing", ".", "ZhaDeviceType", ",", "cached", ...
[ 207, 4 ]
[ 231, 9 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.device_joined
(self, device)
Handle device joined. At this point, no information about the device is known other than its address
Handle device joined.
def device_joined(self, device): """Handle device joined. At this point, no information about the device is known other than its address """ async_dispatcher_send( self._hass, ZHA_GW_MSG, { ATTR_TYPE: ZHA_GW_MSG_DEVICE_JOINED, ...
[ "def", "device_joined", "(", "self", ",", "device", ")", ":", "async_dispatcher_send", "(", "self", ".", "_hass", ",", "ZHA_GW_MSG", ",", "{", "ATTR_TYPE", ":", "ZHA_GW_MSG_DEVICE_JOINED", ",", "ATTR_NWK", ":", "device", ".", "nwk", ",", "ATTR_IEEE", ":", "s...
[ 233, 4 ]
[ 247, 9 ]
python
en
['fr', 'en', 'en']
True
ZHAGateway.raw_device_initialized
(self, device)
Handle a device initialization without quirks loaded.
Handle a device initialization without quirks loaded.
def raw_device_initialized(self, device): """Handle a device initialization without quirks loaded.""" manuf = device.manufacturer async_dispatcher_send( self._hass, ZHA_GW_MSG, { ATTR_TYPE: ZHA_GW_MSG_RAW_INIT, ATTR_NWK: device....
[ "def", "raw_device_initialized", "(", "self", ",", "device", ")", ":", "manuf", "=", "device", ".", "manufacturer", "async_dispatcher_send", "(", "self", ".", "_hass", ",", "ZHA_GW_MSG", ",", "{", "ATTR_TYPE", ":", "ZHA_GW_MSG_RAW_INIT", ",", "ATTR_NWK", ":", ...
[ 249, 4 ]
[ 263, 9 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.device_initialized
(self, device)
Handle device joined and basic information discovered.
Handle device joined and basic information discovered.
def device_initialized(self, device): """Handle device joined and basic information discovered.""" self._hass.async_create_task(self.async_device_initialized(device))
[ "def", "device_initialized", "(", "self", ",", "device", ")", ":", "self", ".", "_hass", ".", "async_create_task", "(", "self", ".", "async_device_initialized", "(", "device", ")", ")" ]
[ 265, 4 ]
[ 267, 75 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.device_left
(self, device: zigpy_dev.Device)
Handle device leaving the network.
Handle device leaving the network.
def device_left(self, device: zigpy_dev.Device): """Handle device leaving the network.""" self.async_update_device(device, False)
[ "def", "device_left", "(", "self", ",", "device", ":", "zigpy_dev", ".", "Device", ")", ":", "self", ".", "async_update_device", "(", "device", ",", "False", ")" ]
[ 269, 4 ]
[ 271, 47 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.group_member_removed
( self, zigpy_group: ZigpyGroupType, endpoint: ZigpyEndpointType )
Handle zigpy group member removed event.
Handle zigpy group member removed event.
def group_member_removed( self, zigpy_group: ZigpyGroupType, endpoint: ZigpyEndpointType ) -> None: """Handle zigpy group member removed event.""" # need to handle endpoint correctly on groups zha_group = self._async_get_or_create_group(zigpy_group) zha_group.info("group_memb...
[ "def", "group_member_removed", "(", "self", ",", "zigpy_group", ":", "ZigpyGroupType", ",", "endpoint", ":", "ZigpyEndpointType", ")", "->", "None", ":", "# need to handle endpoint correctly on groups", "zha_group", "=", "self", ".", "_async_get_or_create_group", "(", "...
[ 273, 4 ]
[ 283, 9 ]
python
en
['nl', 'en', 'en']
True
ZHAGateway.group_member_added
( self, zigpy_group: ZigpyGroupType, endpoint: ZigpyEndpointType )
Handle zigpy group member added event.
Handle zigpy group member added event.
def group_member_added( self, zigpy_group: ZigpyGroupType, endpoint: ZigpyEndpointType ) -> None: """Handle zigpy group member added event.""" # need to handle endpoint correctly on groups zha_group = self._async_get_or_create_group(zigpy_group) zha_group.info("group_member_a...
[ "def", "group_member_added", "(", "self", ",", "zigpy_group", ":", "ZigpyGroupType", ",", "endpoint", ":", "ZigpyEndpointType", ")", "->", "None", ":", "# need to handle endpoint correctly on groups", "zha_group", "=", "self", ".", "_async_get_or_create_group", "(", "zi...
[ 285, 4 ]
[ 298, 68 ]
python
en
['nl', 'en', 'en']
True
ZHAGateway.group_added
(self, zigpy_group: ZigpyGroupType)
Handle zigpy group added event.
Handle zigpy group added event.
def group_added(self, zigpy_group: ZigpyGroupType) -> None: """Handle zigpy group added event.""" zha_group = self._async_get_or_create_group(zigpy_group) zha_group.info("group_added") # need to dispatch for entity creation here self._send_group_gateway_message(zigpy_group, ZHA_G...
[ "def", "group_added", "(", "self", ",", "zigpy_group", ":", "ZigpyGroupType", ")", "->", "None", ":", "zha_group", "=", "self", ".", "_async_get_or_create_group", "(", "zigpy_group", ")", "zha_group", ".", "info", "(", "\"group_added\"", ")", "# need to dispatch f...
[ 300, 4 ]
[ 305, 77 ]
python
en
['nl', 'en', 'en']
True
ZHAGateway.group_removed
(self, zigpy_group: ZigpyGroupType)
Handle zigpy group removed event.
Handle zigpy group removed event.
def group_removed(self, zigpy_group: ZigpyGroupType) -> None: """Handle zigpy group removed event.""" self._send_group_gateway_message(zigpy_group, ZHA_GW_MSG_GROUP_REMOVED) zha_group = self._groups.pop(zigpy_group.group_id, None) zha_group.info("group_removed") self._cleanup_gro...
[ "def", "group_removed", "(", "self", ",", "zigpy_group", ":", "ZigpyGroupType", ")", "->", "None", ":", "self", ".", "_send_group_gateway_message", "(", "zigpy_group", ",", "ZHA_GW_MSG_GROUP_REMOVED", ")", "zha_group", "=", "self", ".", "_groups", ".", "pop", "(...
[ 307, 4 ]
[ 312, 64 ]
python
en
['nl', 'en', 'en']
True
ZHAGateway._send_group_gateway_message
( self, zigpy_group: ZigpyGroupType, gateway_message_type: str )
Send the gateway event for a zigpy group event.
Send the gateway event for a zigpy group event.
def _send_group_gateway_message( self, zigpy_group: ZigpyGroupType, gateway_message_type: str ) -> None: """Send the gateway event for a zigpy group event.""" zha_group = self._groups.get(zigpy_group.group_id) if zha_group is not None: async_dispatcher_send( ...
[ "def", "_send_group_gateway_message", "(", "self", ",", "zigpy_group", ":", "ZigpyGroupType", ",", "gateway_message_type", ":", "str", ")", "->", "None", ":", "zha_group", "=", "self", ".", "_groups", ".", "get", "(", "zigpy_group", ".", "group_id", ")", "if",...
[ 314, 4 ]
[ 327, 13 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.device_removed
(self, device)
Handle device being removed from the network.
Handle device being removed from the network.
def device_removed(self, device): """Handle device being removed from the network.""" zha_device = self._devices.pop(device.ieee, None) entity_refs = self._device_registry.pop(device.ieee, None) if zha_device is not None: device_info = zha_device.zha_device_info z...
[ "def", "device_removed", "(", "self", ",", "device", ")", ":", "zha_device", "=", "self", ".", "_devices", ".", "pop", "(", "device", ".", "ieee", ",", "None", ")", "entity_refs", "=", "self", ".", "_device_registry", ".", "pop", "(", "device", ".", "i...
[ 339, 4 ]
[ 358, 17 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.get_device
(self, ieee)
Return ZHADevice for given ieee.
Return ZHADevice for given ieee.
def get_device(self, ieee): """Return ZHADevice for given ieee.""" return self._devices.get(ieee)
[ "def", "get_device", "(", "self", ",", "ieee", ")", ":", "return", "self", ".", "_devices", ".", "get", "(", "ieee", ")" ]
[ 360, 4 ]
[ 362, 38 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.get_group
(self, group_id: str)
Return Group for given group id.
Return Group for given group id.
def get_group(self, group_id: str) -> Optional[ZhaGroupType]: """Return Group for given group id.""" return self.groups.get(group_id)
[ "def", "get_group", "(", "self", ",", "group_id", ":", "str", ")", "->", "Optional", "[", "ZhaGroupType", "]", ":", "return", "self", ".", "groups", ".", "get", "(", "group_id", ")" ]
[ 364, 4 ]
[ 366, 40 ]
python
en
['da', 'en', 'en']
True
ZHAGateway.async_get_group_by_name
(self, group_name: str)
Get ZHA group by name.
Get ZHA group by name.
def async_get_group_by_name(self, group_name: str) -> Optional[ZhaGroupType]: """Get ZHA group by name.""" for group in self.groups.values(): if group.name == group_name: return group return None
[ "def", "async_get_group_by_name", "(", "self", ",", "group_name", ":", "str", ")", "->", "Optional", "[", "ZhaGroupType", "]", ":", "for", "group", "in", "self", ".", "groups", ".", "values", "(", ")", ":", "if", "group", ".", "name", "==", "group_name",...
[ 369, 4 ]
[ 374, 19 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.get_entity_reference
(self, entity_id)
Return entity reference for given entity_id if found.
Return entity reference for given entity_id if found.
def get_entity_reference(self, entity_id): """Return entity reference for given entity_id if found.""" for entity_reference in itertools.chain.from_iterable( self.device_registry.values() ): if entity_id == entity_reference.reference_id: return entity_refe...
[ "def", "get_entity_reference", "(", "self", ",", "entity_id", ")", ":", "for", "entity_reference", "in", "itertools", ".", "chain", ".", "from_iterable", "(", "self", ".", "device_registry", ".", "values", "(", ")", ")", ":", "if", "entity_id", "==", "entity...
[ 376, 4 ]
[ 382, 39 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.remove_entity_reference
(self, entity)
Remove entity reference for given entity_id if found.
Remove entity reference for given entity_id if found.
def remove_entity_reference(self, entity): """Remove entity reference for given entity_id if found.""" if entity.zha_device.ieee in self.device_registry: entity_refs = self.device_registry.get(entity.zha_device.ieee) self.device_registry[entity.zha_device.ieee] = [ ...
[ "def", "remove_entity_reference", "(", "self", ",", "entity", ")", ":", "if", "entity", ".", "zha_device", ".", "ieee", "in", "self", ".", "device_registry", ":", "entity_refs", "=", "self", ".", "device_registry", ".", "get", "(", "entity", ".", "zha_device...
[ 384, 4 ]
[ 390, 13 ]
python
en
['en', 'en', 'en']
True
ZHAGateway._cleanup_group_entity_registry_entries
( self, zigpy_group: ZigpyGroupType )
Remove entity registry entries for group entities when the groups are removed from HA.
Remove entity registry entries for group entities when the groups are removed from HA.
def _cleanup_group_entity_registry_entries( self, zigpy_group: ZigpyGroupType ) -> None: """Remove entity registry entries for group entities when the groups are removed from HA.""" # first we collect the potential unique ids for entities that could be created from this group possibl...
[ "def", "_cleanup_group_entity_registry_entries", "(", "self", ",", "zigpy_group", ":", "ZigpyGroupType", ")", "->", "None", ":", "# first we collect the potential unique ids for entities that could be created from this group", "possible_entity_unique_ids", "=", "[", "f\"{domain}_zha_...
[ 392, 4 ]
[ 419, 65 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.devices
(self)
Return devices.
Return devices.
def devices(self): """Return devices.""" return self._devices
[ "def", "devices", "(", "self", ")", ":", "return", "self", ".", "_devices" ]
[ 422, 4 ]
[ 424, 28 ]
python
en
['es', 'en', 'en']
False
ZHAGateway.groups
(self)
Return groups.
Return groups.
def groups(self): """Return groups.""" return self._groups
[ "def", "groups", "(", "self", ")", ":", "return", "self", ".", "_groups" ]
[ 427, 4 ]
[ 429, 27 ]
python
de
['de', 'no', 'en']
False
ZHAGateway.device_registry
(self)
Return entities by ieee.
Return entities by ieee.
def device_registry(self): """Return entities by ieee.""" return self._device_registry
[ "def", "device_registry", "(", "self", ")", ":", "return", "self", ".", "_device_registry" ]
[ 432, 4 ]
[ 434, 36 ]
python
en
['en', 'af', 'en']
True
ZHAGateway.register_entity_reference
( self, ieee, reference_id, zha_device, cluster_channels, device_info, remove_future, )
Record the creation of a hass entity associated with ieee.
Record the creation of a hass entity associated with ieee.
def register_entity_reference( self, ieee, reference_id, zha_device, cluster_channels, device_info, remove_future, ): """Record the creation of a hass entity associated with ieee.""" self._device_registry[ieee].append( EntityReferen...
[ "def", "register_entity_reference", "(", "self", ",", "ieee", ",", "reference_id", ",", "zha_device", ",", "cluster_channels", ",", "device_info", ",", "remove_future", ",", ")", ":", "self", ".", "_device_registry", "[", "ieee", "]", ".", "append", "(", "Enti...
[ 436, 4 ]
[ 454, 9 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.async_enable_debug_mode
(self)
Enable debug mode for ZHA.
Enable debug mode for ZHA.
def async_enable_debug_mode(self): """Enable debug mode for ZHA.""" self._log_levels[DEBUG_LEVEL_ORIGINAL] = async_capture_log_levels() async_set_logger_levels(DEBUG_LEVELS) self._log_levels[DEBUG_LEVEL_CURRENT] = async_capture_log_levels() for logger_name in DEBUG_RELAY_LOGGERS...
[ "def", "async_enable_debug_mode", "(", "self", ")", ":", "self", ".", "_log_levels", "[", "DEBUG_LEVEL_ORIGINAL", "]", "=", "async_capture_log_levels", "(", ")", "async_set_logger_levels", "(", "DEBUG_LEVELS", ")", "self", ".", "_log_levels", "[", "DEBUG_LEVEL_CURRENT...
[ 457, 4 ]
[ 466, 33 ]
python
ceb
['da', 'ceb', 'en']
False
ZHAGateway.async_disable_debug_mode
(self)
Disable debug mode for ZHA.
Disable debug mode for ZHA.
def async_disable_debug_mode(self): """Disable debug mode for ZHA.""" async_set_logger_levels(self._log_levels[DEBUG_LEVEL_ORIGINAL]) self._log_levels[DEBUG_LEVEL_CURRENT] = async_capture_log_levels() for logger_name in DEBUG_RELAY_LOGGERS: logging.getLogger(logger_name).remo...
[ "def", "async_disable_debug_mode", "(", "self", ")", ":", "async_set_logger_levels", "(", "self", ".", "_log_levels", "[", "DEBUG_LEVEL_ORIGINAL", "]", ")", "self", ".", "_log_levels", "[", "DEBUG_LEVEL_CURRENT", "]", "=", "async_capture_log_levels", "(", ")", "for"...
[ 469, 4 ]
[ 475, 34 ]
python
ceb
['da', 'ceb', 'en']
False
ZHAGateway._async_get_or_create_device
( self, zigpy_device: zha_typing.ZigpyDeviceType, restored: bool = False )
Get or create a ZHA device.
Get or create a ZHA device.
def _async_get_or_create_device( self, zigpy_device: zha_typing.ZigpyDeviceType, restored: bool = False ): """Get or create a ZHA device.""" zha_device = self._devices.get(zigpy_device.ieee) if zha_device is None: zha_device = ZHADevice.new(self._hass, zigpy_device, self,...
[ "def", "_async_get_or_create_device", "(", "self", ",", "zigpy_device", ":", "zha_typing", ".", "ZigpyDeviceType", ",", "restored", ":", "bool", "=", "False", ")", ":", "zha_device", "=", "self", ".", "_devices", ".", "get", "(", "zigpy_device", ".", "ieee", ...
[ 478, 4 ]
[ 497, 25 ]
python
en
['en', 'en', 'en']
True
ZHAGateway._async_get_or_create_group
(self, zigpy_group: ZigpyGroupType)
Get or create a ZHA group.
Get or create a ZHA group.
def _async_get_or_create_group(self, zigpy_group: ZigpyGroupType) -> ZhaGroupType: """Get or create a ZHA group.""" zha_group = self._groups.get(zigpy_group.group_id) if zha_group is None: zha_group = ZHAGroup(self._hass, self, zigpy_group) self._groups[zigpy_group.group_...
[ "def", "_async_get_or_create_group", "(", "self", ",", "zigpy_group", ":", "ZigpyGroupType", ")", "->", "ZhaGroupType", ":", "zha_group", "=", "self", ".", "_groups", ".", "get", "(", "zigpy_group", ".", "group_id", ")", "if", "zha_group", "is", "None", ":", ...
[ 500, 4 ]
[ 506, 24 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.async_device_became_available
( self, sender, profile, cluster, src_ep, dst_ep, message )
Handle tasks when a device becomes available.
Handle tasks when a device becomes available.
def async_device_became_available( self, sender, profile, cluster, src_ep, dst_ep, message ): """Handle tasks when a device becomes available.""" self.async_update_device(sender, available=True)
[ "def", "async_device_became_available", "(", "self", ",", "sender", ",", "profile", ",", "cluster", ",", "src_ep", ",", "dst_ep", ",", "message", ")", ":", "self", ".", "async_update_device", "(", "sender", ",", "available", "=", "True", ")" ]
[ 509, 4 ]
[ 513, 56 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.async_update_device
( self, sender: zigpy_dev.Device, available: bool = True )
Update device that has just become available.
Update device that has just become available.
def async_update_device( self, sender: zigpy_dev.Device, available: bool = True ) -> None: """Update device that has just become available.""" if sender.ieee in self.devices: device = self.devices[sender.ieee] # avoid a race condition during new joins if d...
[ "def", "async_update_device", "(", "self", ",", "sender", ":", "zigpy_dev", ".", "Device", ",", "available", ":", "bool", "=", "True", ")", "->", "None", ":", "if", "sender", ".", "ieee", "in", "self", ".", "devices", ":", "device", "=", "self", ".", ...
[ 516, 4 ]
[ 524, 50 ]
python
en
['en', 'en', 'en']
True
ZHAGateway.async_update_device_storage
(self, *_)
Update the devices in the store.
Update the devices in the store.
async def async_update_device_storage(self, *_): """Update the devices in the store.""" for device in self.devices.values(): self.zha_storage.async_update_device(device)
[ "async", "def", "async_update_device_storage", "(", "self", ",", "*", "_", ")", ":", "for", "device", "in", "self", ".", "devices", ".", "values", "(", ")", ":", "self", ".", "zha_storage", ".", "async_update_device", "(", "device", ")" ]
[ 526, 4 ]
[ 529, 56 ]
python
en
['en', 'en', 'en']
True