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
Thermostat.target_humidity
(self)
Return the desired humidity set point.
Return the desired humidity set point.
def target_humidity(self) -> int | None: """Return the desired humidity set point.""" if self.has_humidifier_control: return self.thermostat["runtime"]["desiredHumidity"] return None
[ "def", "target_humidity", "(", "self", ")", "->", "int", "|", "None", ":", "if", "self", ".", "has_humidifier_control", ":", "return", "self", ".", "thermostat", "[", "\"runtime\"", "]", "[", "\"desiredHumidity\"", "]", "return", "None" ]
[ 421, 4 ]
[ 425, 19 ]
python
en
['en', 'en', 'en']
True
Thermostat.min_humidity
(self)
Return the minimum humidity.
Return the minimum humidity.
def min_humidity(self) -> int: """Return the minimum humidity.""" return DEFAULT_MIN_HUMIDITY
[ "def", "min_humidity", "(", "self", ")", "->", "int", ":", "return", "DEFAULT_MIN_HUMIDITY" ]
[ 428, 4 ]
[ 430, 35 ]
python
en
['en', 'et', 'en']
True
Thermostat.max_humidity
(self)
Return the maximum humidity.
Return the maximum humidity.
def max_humidity(self) -> int: """Return the maximum humidity.""" return DEFAULT_MAX_HUMIDITY
[ "def", "max_humidity", "(", "self", ")", "->", "int", ":", "return", "DEFAULT_MAX_HUMIDITY" ]
[ 433, 4 ]
[ 435, 35 ]
python
en
['en', 'la', 'en']
True
Thermostat.target_temperature
(self)
Return the temperature we try to reach.
Return the temperature we try to reach.
def target_temperature(self): """Return the temperature we try to reach.""" if self.hvac_mode == HVAC_MODE_HEAT_COOL: return None if self.hvac_mode == HVAC_MODE_HEAT: return round(self.thermostat["runtime"]["desiredHeat"] / 10.0) if self.hvac_mode == HVAC_MODE_COO...
[ "def", "target_temperature", "(", "self", ")", ":", "if", "self", ".", "hvac_mode", "==", "HVAC_MODE_HEAT_COOL", ":", "return", "None", "if", "self", ".", "hvac_mode", "==", "HVAC_MODE_HEAT", ":", "return", "round", "(", "self", ".", "thermostat", "[", "\"ru...
[ 438, 4 ]
[ 446, 19 ]
python
en
['en', 'en', 'en']
True
Thermostat.fan
(self)
Return the current fan status.
Return the current fan status.
def fan(self): """Return the current fan status.""" if "fan" in self.thermostat["equipmentStatus"]: return STATE_ON return HVAC_MODE_OFF
[ "def", "fan", "(", "self", ")", ":", "if", "\"fan\"", "in", "self", ".", "thermostat", "[", "\"equipmentStatus\"", "]", ":", "return", "STATE_ON", "return", "HVAC_MODE_OFF" ]
[ 449, 4 ]
[ 453, 28 ]
python
en
['en', 'bg', 'en']
True
Thermostat.fan_mode
(self)
Return the fan setting.
Return the fan setting.
def fan_mode(self): """Return the fan setting.""" return self.thermostat["runtime"]["desiredFanMode"]
[ "def", "fan_mode", "(", "self", ")", ":", "return", "self", ".", "thermostat", "[", "\"runtime\"", "]", "[", "\"desiredFanMode\"", "]" ]
[ 456, 4 ]
[ 458, 59 ]
python
en
['en', 'fy', 'en']
True
Thermostat.fan_modes
(self)
Return the available fan modes.
Return the available fan modes.
def fan_modes(self): """Return the available fan modes.""" return self._fan_modes
[ "def", "fan_modes", "(", "self", ")", ":", "return", "self", ".", "_fan_modes" ]
[ 461, 4 ]
[ 463, 30 ]
python
en
['en', 'en', 'en']
True
Thermostat.preset_mode
(self)
Return current preset mode.
Return current preset mode.
def preset_mode(self): """Return current preset mode.""" events = self.thermostat["events"] for event in events: if not event["running"]: continue if event["type"] == "hold": if event["holdClimateRef"] in self._preset_modes: ...
[ "def", "preset_mode", "(", "self", ")", ":", "events", "=", "self", ".", "thermostat", "[", "\"events\"", "]", "for", "event", "in", "events", ":", "if", "not", "event", "[", "\"running\"", "]", ":", "continue", "if", "event", "[", "\"type\"", "]", "==...
[ 466, 4 ]
[ 486, 82 ]
python
en
['en', 'ca', 'en']
True
Thermostat.hvac_mode
(self)
Return current operation.
Return current operation.
def hvac_mode(self): """Return current operation.""" return ECOBEE_HVAC_TO_HASS[self.thermostat["settings"]["hvacMode"]]
[ "def", "hvac_mode", "(", "self", ")", ":", "return", "ECOBEE_HVAC_TO_HASS", "[", "self", ".", "thermostat", "[", "\"settings\"", "]", "[", "\"hvacMode\"", "]", "]" ]
[ 489, 4 ]
[ 491, 75 ]
python
bg
['nl', 'bg', 'en']
False
Thermostat.hvac_modes
(self)
Return the operation modes list.
Return the operation modes list.
def hvac_modes(self): """Return the operation modes list.""" return self._operation_list
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "self", ".", "_operation_list" ]
[ 494, 4 ]
[ 496, 35 ]
python
en
['en', 'en', 'en']
True
Thermostat.current_humidity
(self)
Return the current humidity.
Return the current humidity.
def current_humidity(self) -> int | None: """Return the current humidity.""" return self.thermostat["runtime"]["actualHumidity"]
[ "def", "current_humidity", "(", "self", ")", "->", "int", "|", "None", ":", "return", "self", ".", "thermostat", "[", "\"runtime\"", "]", "[", "\"actualHumidity\"", "]" ]
[ 499, 4 ]
[ 501, 59 ]
python
en
['en', 'en', 'en']
True
Thermostat.hvac_action
(self)
Return current HVAC action. Ecobee returns a CSV string with different equipment that is active. We are prioritizing any heating/cooling equipment, otherwase look at drying/fanning. Idle if nothing going on. We are unable to map all actions to HA equivalents.
Return current HVAC action.
def hvac_action(self): """Return current HVAC action. Ecobee returns a CSV string with different equipment that is active. We are prioritizing any heating/cooling equipment, otherwase look at drying/fanning. Idle if nothing going on. We are unable to map all actions to HA equiv...
[ "def", "hvac_action", "(", "self", ")", ":", "if", "self", ".", "thermostat", "[", "\"equipmentStatus\"", "]", "==", "\"\"", ":", "return", "CURRENT_HVAC_IDLE", "actions", "=", "[", "ECOBEE_HVAC_ACTION_TO_HASS", "[", "status", "]", "for", "status", "in", "self...
[ 504, 4 ]
[ 531, 32 ]
python
en
['en', 'da', 'en']
True
Thermostat.extra_state_attributes
(self)
Return device specific state attributes.
Return device specific state attributes.
def extra_state_attributes(self): """Return device specific state attributes.""" status = self.thermostat["equipmentStatus"] return { "fan": self.fan, "climate_mode": self._preset_modes[ self.thermostat["program"]["currentClimateRef"] ], ...
[ "def", "extra_state_attributes", "(", "self", ")", ":", "status", "=", "self", ".", "thermostat", "[", "\"equipmentStatus\"", "]", "return", "{", "\"fan\"", ":", "self", ".", "fan", ",", "\"climate_mode\"", ":", "self", ".", "_preset_modes", "[", "self", "."...
[ 534, 4 ]
[ 544, 9 ]
python
en
['fr', 'en', 'en']
True
Thermostat.is_aux_heat
(self)
Return true if aux heater.
Return true if aux heater.
def is_aux_heat(self): """Return true if aux heater.""" return "auxHeat" in self.thermostat["equipmentStatus"]
[ "def", "is_aux_heat", "(", "self", ")", ":", "return", "\"auxHeat\"", "in", "self", ".", "thermostat", "[", "\"equipmentStatus\"", "]" ]
[ 547, 4 ]
[ 549, 62 ]
python
fr
['fr', 'co', 'fr']
True
Thermostat.async_turn_aux_heat_on
(self)
Turn auxiliary heater on.
Turn auxiliary heater on.
async def async_turn_aux_heat_on(self) -> None: """Turn auxiliary heater on.""" if not self.is_aux_heat: _LOGGER.warning("# Changing aux heat is not supported")
[ "async", "def", "async_turn_aux_heat_on", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "is_aux_heat", ":", "_LOGGER", ".", "warning", "(", "\"# Changing aux heat is not supported\"", ")" ]
[ 551, 4 ]
[ 554, 67 ]
python
en
['fr', 'fi', 'en']
False
Thermostat.async_turn_aux_heat_off
(self)
Turn auxiliary heater off.
Turn auxiliary heater off.
async def async_turn_aux_heat_off(self) -> None: """Turn auxiliary heater off.""" if self.is_aux_heat: _LOGGER.warning("# Changing aux heat is not supported")
[ "async", "def", "async_turn_aux_heat_off", "(", "self", ")", "->", "None", ":", "if", "self", ".", "is_aux_heat", ":", "_LOGGER", ".", "warning", "(", "\"# Changing aux heat is not supported\"", ")" ]
[ 556, 4 ]
[ 559, 67 ]
python
en
['en', 'en', 'en']
True
Thermostat.set_preset_mode
(self, preset_mode)
Activate a preset.
Activate a preset.
def set_preset_mode(self, preset_mode): """Activate a preset.""" if preset_mode == self.preset_mode: return self.update_without_throttle = True # If we are currently in vacation mode, cancel it. if self.preset_mode == PRESET_VACATION: self.data.ecobee.de...
[ "def", "set_preset_mode", "(", "self", ",", "preset_mode", ")", ":", "if", "preset_mode", "==", "self", ".", "preset_mode", ":", "return", "self", ".", "update_without_throttle", "=", "True", "# If we are currently in vacation mode, cancel it.", "if", "self", ".", "...
[ 561, 4 ]
[ 615, 13 ]
python
ca
['en', 'ca', 'it']
False
Thermostat.preset_modes
(self)
Return available preset modes.
Return available preset modes.
def preset_modes(self): """Return available preset modes.""" return list(self._preset_modes.values())
[ "def", "preset_modes", "(", "self", ")", ":", "return", "list", "(", "self", ".", "_preset_modes", ".", "values", "(", ")", ")" ]
[ 618, 4 ]
[ 620, 48 ]
python
en
['fr', 'en', 'en']
True
Thermostat.set_auto_temp_hold
(self, heat_temp, cool_temp)
Set temperature hold in auto mode.
Set temperature hold in auto mode.
def set_auto_temp_hold(self, heat_temp, cool_temp): """Set temperature hold in auto mode.""" if cool_temp is not None: cool_temp_setpoint = cool_temp else: cool_temp_setpoint = self.thermostat["runtime"]["desiredCool"] / 10.0 if heat_temp is not None: ...
[ "def", "set_auto_temp_hold", "(", "self", ",", "heat_temp", ",", "cool_temp", ")", ":", "if", "cool_temp", "is", "not", "None", ":", "cool_temp_setpoint", "=", "cool_temp", "else", ":", "cool_temp_setpoint", "=", "self", ".", "thermostat", "[", "\"runtime\"", ...
[ 622, 4 ]
[ 649, 43 ]
python
it
['en', 'it', 'it']
True
Thermostat.set_fan_mode
(self, fan_mode)
Set the fan mode. Valid values are "on" or "auto".
Set the fan mode. Valid values are "on" or "auto".
def set_fan_mode(self, fan_mode): """Set the fan mode. Valid values are "on" or "auto".""" if fan_mode.lower() not in (FAN_ON, FAN_AUTO): error = "Invalid fan_mode value: Valid values are 'on' or 'auto'" _LOGGER.error(error) return self.data.ecobee.set_fan_...
[ "def", "set_fan_mode", "(", "self", ",", "fan_mode", ")", ":", "if", "fan_mode", ".", "lower", "(", ")", "not", "in", "(", "FAN_ON", ",", "FAN_AUTO", ")", ":", "error", "=", "\"Invalid fan_mode value: Valid values are 'on' or 'auto'\"", "_LOGGER", ".", "error",...
[ 651, 4 ]
[ 665, 57 ]
python
en
['en', 'en', 'en']
True
Thermostat.set_temp_hold
(self, temp)
Set temperature hold in modes other than auto. Ecobee API: It is good practice to set the heat and cool hold temperatures to be the same, if the thermostat is in either heat, cool, auxHeatOnly, or off mode. If the thermostat is in auto mode, an additional rule is required. The cool hold...
Set temperature hold in modes other than auto.
def set_temp_hold(self, temp): """Set temperature hold in modes other than auto. Ecobee API: It is good practice to set the heat and cool hold temperatures to be the same, if the thermostat is in either heat, cool, auxHeatOnly, or off mode. If the thermostat is in auto mode, an ...
[ "def", "set_temp_hold", "(", "self", ",", "temp", ")", ":", "if", "self", ".", "hvac_mode", "==", "HVAC_MODE_HEAT", "or", "self", ".", "hvac_mode", "==", "HVAC_MODE_COOL", ":", "heat_temp", "=", "temp", "cool_temp", "=", "temp", "else", ":", "delta", "=", ...
[ 667, 4 ]
[ 685, 53 ]
python
en
['en', 'en', 'en']
True
Thermostat.set_temperature
(self, **kwargs)
Set new target temperature.
Set new target temperature.
def set_temperature(self, **kwargs): """Set new target temperature.""" low_temp = kwargs.get(ATTR_TARGET_TEMP_LOW) high_temp = kwargs.get(ATTR_TARGET_TEMP_HIGH) temp = kwargs.get(ATTR_TEMPERATURE) if self.hvac_mode == HVAC_MODE_HEAT_COOL and ( low_temp is not None or...
[ "def", "set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "low_temp", "=", "kwargs", ".", "get", "(", "ATTR_TARGET_TEMP_LOW", ")", "high_temp", "=", "kwargs", ".", "get", "(", "ATTR_TARGET_TEMP_HIGH", ")", "temp", "=", "kwargs", ".", "get",...
[ 687, 4 ]
[ 700, 86 ]
python
en
['en', 'ca', 'en']
True
Thermostat.set_humidity
(self, humidity)
Set the humidity level.
Set the humidity level.
def set_humidity(self, humidity): """Set the humidity level.""" if humidity not in range(0, 101): raise ValueError( f"Invalid set_humidity value (must be in range 0-100): {humidity}" ) self.data.ecobee.set_humidity(self.thermostat_index, int(humidity)) ...
[ "def", "set_humidity", "(", "self", ",", "humidity", ")", ":", "if", "humidity", "not", "in", "range", "(", "0", ",", "101", ")", ":", "raise", "ValueError", "(", "f\"Invalid set_humidity value (must be in range 0-100): {humidity}\"", ")", "self", ".", "data", "...
[ 702, 4 ]
[ 710, 43 ]
python
en
['en', 'zu', 'en']
True
Thermostat.set_hvac_mode
(self, hvac_mode)
Set HVAC mode (auto, auxHeatOnly, cool, heat, off).
Set HVAC mode (auto, auxHeatOnly, cool, heat, off).
def set_hvac_mode(self, hvac_mode): """Set HVAC mode (auto, auxHeatOnly, cool, heat, off).""" ecobee_value = next( (k for k, v in ECOBEE_HVAC_TO_HASS.items() if v == hvac_mode), None ) if ecobee_value is None: _LOGGER.error("Invalid mode for set_hvac_mode: %s", hv...
[ "def", "set_hvac_mode", "(", "self", ",", "hvac_mode", ")", ":", "ecobee_value", "=", "next", "(", "(", "k", "for", "k", ",", "v", "in", "ECOBEE_HVAC_TO_HASS", ".", "items", "(", ")", "if", "v", "==", "hvac_mode", ")", ",", "None", ")", "if", "ecobee...
[ 712, 4 ]
[ 721, 43 ]
python
fr
['fr', 'ny', 'fr']
True
Thermostat.set_fan_min_on_time
(self, fan_min_on_time)
Set the minimum fan on time.
Set the minimum fan on time.
def set_fan_min_on_time(self, fan_min_on_time): """Set the minimum fan on time.""" self.data.ecobee.set_fan_min_on_time(self.thermostat_index, fan_min_on_time) self.update_without_throttle = True
[ "def", "set_fan_min_on_time", "(", "self", ",", "fan_min_on_time", ")", ":", "self", ".", "data", ".", "ecobee", ".", "set_fan_min_on_time", "(", "self", ".", "thermostat_index", ",", "fan_min_on_time", ")", "self", ".", "update_without_throttle", "=", "True" ]
[ 723, 4 ]
[ 726, 43 ]
python
en
['en', 'sq', 'en']
True
Thermostat.resume_program
(self, resume_all)
Resume the thermostat schedule program.
Resume the thermostat schedule program.
def resume_program(self, resume_all): """Resume the thermostat schedule program.""" self.data.ecobee.resume_program( self.thermostat_index, "true" if resume_all else "false" ) self.update_without_throttle = True
[ "def", "resume_program", "(", "self", ",", "resume_all", ")", ":", "self", ".", "data", ".", "ecobee", ".", "resume_program", "(", "self", ".", "thermostat_index", ",", "\"true\"", "if", "resume_all", "else", "\"false\"", ")", "self", ".", "update_without_thro...
[ 728, 4 ]
[ 733, 43 ]
python
en
['en', 'en', 'en']
True
Thermostat.hold_preference
(self)
Return user preference setting for hold time.
Return user preference setting for hold time.
def hold_preference(self): """Return user preference setting for hold time.""" # Values returned from thermostat are: # "useEndTime2hour", "useEndTime4hour" # "nextPeriod", "askMe" # "indefinite" device_preference = self.thermostat["settings"]["holdAction"] ...
[ "def", "hold_preference", "(", "self", ")", ":", "# Values returned from thermostat are:", "# \"useEndTime2hour\", \"useEndTime4hour\"", "# \"nextPeriod\", \"askMe\"", "# \"indefinite\"", "device_preference", "=", "self", ".", "thermostat", "[", "\"settings\"", "]", "[", ...
[ 735, 4 ]
[ 749, 69 ]
python
en
['da', 'en', 'en']
True
Thermostat.hold_hours
(self)
Return user preference setting for hold duration in hours.
Return user preference setting for hold duration in hours.
def hold_hours(self): """Return user preference setting for hold duration in hours.""" # Values returned from thermostat are: # "useEndTime2hour", "useEndTime4hour" # "nextPeriod", "askMe" # "indefinite" device_preference = self.thermostat["settings"]["holdAction"] ...
[ "def", "hold_hours", "(", "self", ")", ":", "# Values returned from thermostat are:", "# \"useEndTime2hour\", \"useEndTime4hour\"", "# \"nextPeriod\", \"askMe\"", "# \"indefinite\"", "device_preference", "=", "self", ".", "thermostat", "[", "\"settings\"", "]", "[", "\"ho...
[ 751, 4 ]
[ 762, 52 ]
python
en
['en', 'en', 'en']
True
Thermostat.create_vacation
(self, service_data)
Create a vacation with user-specified parameters.
Create a vacation with user-specified parameters.
def create_vacation(self, service_data): """Create a vacation with user-specified parameters.""" vacation_name = service_data[ATTR_VACATION_NAME] cool_temp = convert( service_data[ATTR_COOL_TEMP], self.hass.config.units.temperature_unit, TEMP_FAHRENHEIT, ...
[ "def", "create_vacation", "(", "self", ",", "service_data", ")", ":", "vacation_name", "=", "service_data", "[", "ATTR_VACATION_NAME", "]", "cool_temp", "=", "convert", "(", "service_data", "[", "ATTR_COOL_TEMP", "]", ",", "self", ".", "hass", ".", "config", "...
[ 764, 4 ]
[ 808, 9 ]
python
en
['en', 'en', 'en']
True
Thermostat.delete_vacation
(self, vacation_name)
Delete a vacation with the specified name.
Delete a vacation with the specified name.
def delete_vacation(self, vacation_name): """Delete a vacation with the specified name.""" _LOGGER.debug( "Deleting a vacation on thermostat %s with name %s", self.name, vacation_name, ) self.data.ecobee.delete_vacation(self.thermostat_index, vacation_...
[ "def", "delete_vacation", "(", "self", ",", "vacation_name", ")", ":", "_LOGGER", ".", "debug", "(", "\"Deleting a vacation on thermostat %s with name %s\"", ",", "self", ".", "name", ",", "vacation_name", ",", ")", "self", ".", "data", ".", "ecobee", ".", "dele...
[ 810, 4 ]
[ 817, 78 ]
python
en
['en', 'en', 'en']
True
Thermostat.turn_on
(self)
Set the thermostat to the last active HVAC mode.
Set the thermostat to the last active HVAC mode.
def turn_on(self): """Set the thermostat to the last active HVAC mode.""" _LOGGER.debug( "Turning on ecobee thermostat %s in %s mode", self.name, self._last_active_hvac_mode, ) self.set_hvac_mode(self._last_active_hvac_mode)
[ "def", "turn_on", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Turning on ecobee thermostat %s in %s mode\"", ",", "self", ".", "name", ",", "self", ".", "_last_active_hvac_mode", ",", ")", "self", ".", "set_hvac_mode", "(", "self", ".", "_last_active...
[ 819, 4 ]
[ 826, 55 ]
python
en
['en', 'en', 'en']
True
Thermostat.set_dst_mode
(self, dst_enabled)
Enable/disable automatic daylight savings time.
Enable/disable automatic daylight savings time.
def set_dst_mode(self, dst_enabled): """Enable/disable automatic daylight savings time.""" self.data.ecobee.set_dst_mode(self.thermostat_index, dst_enabled)
[ "def", "set_dst_mode", "(", "self", ",", "dst_enabled", ")", ":", "self", ".", "data", ".", "ecobee", ".", "set_dst_mode", "(", "self", ".", "thermostat_index", ",", "dst_enabled", ")" ]
[ 828, 4 ]
[ 830, 73 ]
python
en
['en', 'en', 'en']
True
Thermostat.set_mic_mode
(self, mic_enabled)
Enable/disable Alexa mic (only for Ecobee 4).
Enable/disable Alexa mic (only for Ecobee 4).
def set_mic_mode(self, mic_enabled): """Enable/disable Alexa mic (only for Ecobee 4).""" self.data.ecobee.set_mic_mode(self.thermostat_index, mic_enabled)
[ "def", "set_mic_mode", "(", "self", ",", "mic_enabled", ")", ":", "self", ".", "data", ".", "ecobee", ".", "set_mic_mode", "(", "self", ".", "thermostat_index", ",", "mic_enabled", ")" ]
[ 832, 4 ]
[ 834, 73 ]
python
en
['en', 'en', 'en']
True
Thermostat.set_occupancy_modes
(self, auto_away=None, follow_me=None)
Enable/disable Smart Home/Away and Follow Me modes.
Enable/disable Smart Home/Away and Follow Me modes.
def set_occupancy_modes(self, auto_away=None, follow_me=None): """Enable/disable Smart Home/Away and Follow Me modes.""" self.data.ecobee.set_occupancy_modes( self.thermostat_index, auto_away, follow_me )
[ "def", "set_occupancy_modes", "(", "self", ",", "auto_away", "=", "None", ",", "follow_me", "=", "None", ")", ":", "self", ".", "data", ".", "ecobee", ".", "set_occupancy_modes", "(", "self", ".", "thermostat_index", ",", "auto_away", ",", "follow_me", ")" ]
[ 836, 4 ]
[ 840, 9 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Raspberry Pi Power Supply Checker from a config entry.
Set up Raspberry Pi Power Supply Checker from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Raspberry Pi Power Supply Checker from a config entry.""" hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "hass", ".", "config_entries", ".", "async_setup_platforms", "(", "entry", ",", "PLATFORMS", ")", "return", "True" ]
[ 7, 0 ]
[ 10, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "return", "await", "hass", ".", "config_entries", ".", "async_unload_platforms", "(", "entry", ",", "PLATFORMS", ")" ]
[ 13, 0 ]
[ 15, 77 ]
python
en
['en', 'es', 'en']
True
test_migration
(hass: HomeAssistant)
Test that we can migrate coronavirus to stable unique ID.
Test that we can migrate coronavirus to stable unique ID.
async def test_migration(hass: HomeAssistant) -> None: """Test that we can migrate coronavirus to stable unique ID.""" nl_entry = MockConfigEntry(domain=DOMAIN, title="Netherlands", data={"country": 34}) nl_entry.add_to_hass(hass) worldwide_entry = MockConfigEntry( domain=DOMAIN, title="Worldwid...
[ "async", "def", "test_migration", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "nl_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "title", "=", "\"Netherlands\"", ",", "data", "=", "{", "\"country\"", ":", "34", "}", ")", ...
[ 14, 0 ]
[ 54, 56 ]
python
en
['en', 'en', 'en']
True
test_config_entry_not_ready
( mock_get_cases: MagicMock, hass: HomeAssistant )
Test the configuration entry not ready.
Test the configuration entry not ready.
async def test_config_entry_not_ready( mock_get_cases: MagicMock, hass: HomeAssistant ) -> None: """Test the configuration entry not ready.""" entry = MockConfigEntry(domain=DOMAIN, title="Netherlands", data={"country": 34}) entry.add_to_hass(hass) assert await async_setup_component(hass, DOMAIN, {...
[ "async", "def", "test_config_entry_not_ready", "(", "mock_get_cases", ":", "MagicMock", ",", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "title", "=", "\"Netherlands\"", ",", "data", ...
[ 61, 0 ]
[ 71, 54 ]
python
en
['en', 'en', 'en']
True
EcoNetFlowHandler.__init__
(self)
Initialize the config flow.
Initialize the config flow.
def __init__(self): """Initialize the config flow.""" self.data_schema = vol.Schema( { vol.Required(CONF_EMAIL): str, vol.Required(CONF_PASSWORD): str, } )
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "data_schema", "=", "vol", ".", "Schema", "(", "{", "vol", ".", "Required", "(", "CONF_EMAIL", ")", ":", "str", ",", "vol", ".", "Required", "(", "CONF_PASSWORD", ")", ":", "str", ",", "}", ")"...
[ 16, 4 ]
[ 23, 9 ]
python
en
['en', 'en', 'en']
True
EcoNetFlowHandler.async_step_user
(self, user_input=None)
Handle the start of the config flow.
Handle the start of the config flow.
async def async_step_user(self, user_input=None): """Handle the start of the config flow.""" if not user_input: return self.async_show_form( step_id="user", data_schema=self.data_schema, ) await self.async_set_unique_id(user_input[CONF_EMA...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "not", "user_input", ":", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"user\"", ",", "data_schema", "=", "self", ".", "data_schema", ",", "...
[ 25, 4 ]
[ 59, 9 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the SleepIQ sensors.
Set up the SleepIQ sensors.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the SleepIQ sensors.""" if discovery_info is None: return data = hass.data[DOMAIN] data.update() dev = [] for bed_id, bed in data.beds.items(): for side in SIDES: if getattr(bed, side) is...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "data", ".", "update", "(",...
[ 9, 0 ]
[ 22, 21 ]
python
en
['en', 'bg', 'en']
True
SleepNumberSensor.__init__
(self, sleepiq_data, bed_id, side)
Initialize the sensor.
Initialize the sensor.
def __init__(self, sleepiq_data, bed_id, side): """Initialize the sensor.""" SleepIQSensor.__init__(self, sleepiq_data, bed_id, side) self._state = None self.type = SLEEP_NUMBER self._name = SENSOR_TYPES[self.type] self.update()
[ "def", "__init__", "(", "self", ",", "sleepiq_data", ",", "bed_id", ",", "side", ")", ":", "SleepIQSensor", ".", "__init__", "(", "self", ",", "sleepiq_data", ",", "bed_id", ",", "side", ")", "self", ".", "_state", "=", "None", "self", ".", "type", "="...
[ 28, 4 ]
[ 36, 21 ]
python
en
['en', 'en', 'en']
True
SleepNumberSensor.native_value
(self)
Return the state of the sensor.
Return the state of the sensor.
def native_value(self): """Return the state of the sensor.""" return self._state
[ "def", "native_value", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 39, 4 ]
[ 41, 26 ]
python
en
['en', 'en', 'en']
True
SleepNumberSensor.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 ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 44, 4 ]
[ 46, 19 ]
python
en
['en', 'en', 'en']
True
SleepNumberSensor.update
(self)
Get the latest data from SleepIQ and updates the states.
Get the latest data from SleepIQ and updates the states.
def update(self): """Get the latest data from SleepIQ and updates the states.""" SleepIQSensor.update(self) self._state = self.side.sleep_number
[ "def", "update", "(", "self", ")", ":", "SleepIQSensor", ".", "update", "(", "self", ")", "self", ".", "_state", "=", "self", ".", "side", ".", "sleep_number" ]
[ 48, 4 ]
[ 51, 44 ]
python
en
['en', 'en', 'en']
True
generate_binary_sensors
(entry)
Generate binary sensors. For each Account there is one power sensor with zone == 0. For each Zone in each Account there is one smoke and one moisture sensor.
Generate binary sensors.
def generate_binary_sensors(entry) -> Iterable[SIABinarySensorBase]: """Generate binary sensors. For each Account there is one power sensor with zone == 0. For each Zone in each Account there is one smoke and one moisture sensor. """ for account in entry.data[CONF_ACCOUNTS]: yield SIABinary...
[ "def", "generate_binary_sensors", "(", "entry", ")", "->", "Iterable", "[", "SIABinarySensorBase", "]", ":", "for", "account", "in", "entry", ".", "data", "[", "CONF_ACCOUNTS", "]", ":", "yield", "SIABinarySensorPower", "(", "entry", ",", "account", ")", "zone...
[ 52, 0 ]
[ 63, 63 ]
python
en
['en', 'ms', 'en']
True
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback, )
Set up SIA binary sensors from a config entry.
Set up SIA binary sensors from a config entry.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: """Set up SIA binary sensors from a config entry.""" async_add_entities(generate_binary_sensors(entry))
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "AddEntitiesCallback", ",", ")", "->", "None", ":", "async_add_entities", "(", "generate_binary_sensors", "(", "entry", ")", "...
[ 66, 0 ]
[ 72, 54 ]
python
en
['en', 'en', 'en']
True
SIABinarySensorBase.__init__
( self, entry: ConfigEntry, account_data: dict[str, Any], zone: int, device_class: str, )
Initialize a base binary sensor.
Initialize a base binary sensor.
def __init__( self, entry: ConfigEntry, account_data: dict[str, Any], zone: int, device_class: str, ) -> None: """Initialize a base binary sensor.""" super().__init__(entry, account_data, zone, device_class) self._attr_unique_id = SIA_UNIQUE_ID_FORMAT...
[ "def", "__init__", "(", "self", ",", "entry", ":", "ConfigEntry", ",", "account_data", ":", "dict", "[", "str", ",", "Any", "]", ",", "zone", ":", "int", ",", "device_class", ":", "str", ",", ")", "->", "None", ":", "super", "(", ")", ".", "__init_...
[ 78, 4 ]
[ 90, 9 ]
python
en
['en', 'haw', 'en']
True
SIABinarySensorBase.handle_last_state
(self, last_state: State | None)
Handle the last state.
Handle the last state.
def handle_last_state(self, last_state: State | None) -> None: """Handle the last state.""" if last_state is not None and last_state.state is not None: if last_state.state == STATE_ON: self._attr_is_on = True elif last_state.state == STATE_OFF: sel...
[ "def", "handle_last_state", "(", "self", ",", "last_state", ":", "State", "|", "None", ")", "->", "None", ":", "if", "last_state", "is", "not", "None", "and", "last_state", ".", "state", "is", "not", "None", ":", "if", "last_state", ".", "state", "==", ...
[ 92, 4 ]
[ 100, 44 ]
python
en
['en', 'en', 'en']
True
SIABinarySensorMoisture.__init__
( self, entry: ConfigEntry, account_data: dict[str, Any], zone: int, )
Initialize a Moisture binary sensor.
Initialize a Moisture binary sensor.
def __init__( self, entry: ConfigEntry, account_data: dict[str, Any], zone: int, ) -> None: """Initialize a Moisture binary sensor.""" super().__init__(entry, account_data, zone, DEVICE_CLASS_MOISTURE) self._attr_entity_registry_enabled_default = False
[ "def", "__init__", "(", "self", ",", "entry", ":", "ConfigEntry", ",", "account_data", ":", "dict", "[", "str", ",", "Any", "]", ",", "zone", ":", "int", ",", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "entry", ",", "account_d...
[ 106, 4 ]
[ 114, 58 ]
python
en
['en', 'haw', 'en']
True
SIABinarySensorMoisture.update_state
(self, sia_event: SIAEvent)
Update the state of the binary sensor.
Update the state of the binary sensor.
def update_state(self, sia_event: SIAEvent) -> None: """Update the state of the binary sensor.""" new_state = MOISTURE_CODE_CONSEQUENCES.get(sia_event.code, None) if new_state is not None: _LOGGER.debug("New state will be %s", new_state) self._attr_is_on = new_state
[ "def", "update_state", "(", "self", ",", "sia_event", ":", "SIAEvent", ")", "->", "None", ":", "new_state", "=", "MOISTURE_CODE_CONSEQUENCES", ".", "get", "(", "sia_event", ".", "code", ",", "None", ")", "if", "new_state", "is", "not", "None", ":", "_LOGGE...
[ 116, 4 ]
[ 121, 40 ]
python
en
['en', 'en', 'en']
True
SIABinarySensorSmoke.__init__
( self, entry: ConfigEntry, account_data: dict[str, Any], zone: int, )
Initialize a Smoke binary sensor.
Initialize a Smoke binary sensor.
def __init__( self, entry: ConfigEntry, account_data: dict[str, Any], zone: int, ) -> None: """Initialize a Smoke binary sensor.""" super().__init__(entry, account_data, zone, DEVICE_CLASS_SMOKE) self._attr_entity_registry_enabled_default = False
[ "def", "__init__", "(", "self", ",", "entry", ":", "ConfigEntry", ",", "account_data", ":", "dict", "[", "str", ",", "Any", "]", ",", "zone", ":", "int", ",", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "entry", ",", "account_d...
[ 127, 4 ]
[ 135, 58 ]
python
en
['en', 'haw', 'en']
True
SIABinarySensorSmoke.update_state
(self, sia_event: SIAEvent)
Update the state of the binary sensor.
Update the state of the binary sensor.
def update_state(self, sia_event: SIAEvent) -> None: """Update the state of the binary sensor.""" new_state = SMOKE_CODE_CONSEQUENCES.get(sia_event.code, None) if new_state is not None: _LOGGER.debug("New state will be %s", new_state) self._attr_is_on = new_state
[ "def", "update_state", "(", "self", ",", "sia_event", ":", "SIAEvent", ")", "->", "None", ":", "new_state", "=", "SMOKE_CODE_CONSEQUENCES", ".", "get", "(", "sia_event", ".", "code", ",", "None", ")", "if", "new_state", "is", "not", "None", ":", "_LOGGER",...
[ 137, 4 ]
[ 142, 40 ]
python
en
['en', 'en', 'en']
True
SIABinarySensorPower.__init__
( self, entry: ConfigEntry, account_data: dict[str, Any], )
Initialize a Power binary sensor.
Initialize a Power binary sensor.
def __init__( self, entry: ConfigEntry, account_data: dict[str, Any], ) -> None: """Initialize a Power binary sensor.""" super().__init__(entry, account_data, SIA_HUB_ZONE, DEVICE_CLASS_POWER) self._attr_entity_registry_enabled_default = True
[ "def", "__init__", "(", "self", ",", "entry", ":", "ConfigEntry", ",", "account_data", ":", "dict", "[", "str", ",", "Any", "]", ",", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "entry", ",", "account_data", ",", "SIA_HUB_ZONE", ...
[ 148, 4 ]
[ 155, 57 ]
python
en
['en', 'pl', 'en']
True
SIABinarySensorPower.update_state
(self, sia_event: SIAEvent)
Update the state of the binary sensor.
Update the state of the binary sensor.
def update_state(self, sia_event: SIAEvent) -> None: """Update the state of the binary sensor.""" new_state = POWER_CODE_CONSEQUENCES.get(sia_event.code, None) if new_state is not None: _LOGGER.debug("New state will be %s", new_state) self._attr_is_on = new_state
[ "def", "update_state", "(", "self", ",", "sia_event", ":", "SIAEvent", ")", "->", "None", ":", "new_state", "=", "POWER_CODE_CONSEQUENCES", ".", "get", "(", "sia_event", ".", "code", ",", "None", ")", "if", "new_state", "is", "not", "None", ":", "_LOGGER",...
[ 157, 4 ]
[ 162, 40 ]
python
en
['en', 'en', 'en']
True
correct_format
(parsed_data, expected_keys, filename)
Ensure the parsed file matches the needed format Returns True, <message> on error Returns False, None on success
Ensure the parsed file matches the needed format Returns True, <message> on error Returns False, None on success
def correct_format(parsed_data, expected_keys, filename): ''' Ensure the parsed file matches the needed format Returns True, <message> on error Returns False, None on success ''' # validate keys are what we expect def is_list_of_strings(data): ''' Helper function for correct_...
[ "def", "correct_format", "(", "parsed_data", ",", "expected_keys", ",", "filename", ")", ":", "# validate keys are what we expect", "def", "is_list_of_strings", "(", "data", ")", ":", "'''\n Helper function for correct_format()\n '''", "if", "data", "is", "Non...
[ 25, 0 ]
[ 65, 22 ]
python
en
['en', 'error', 'th']
False
verify_permissions
(f)
Verify 600 permissions on a file
Verify 600 permissions on a file
def verify_permissions(f): ''' Verify 600 permissions on a file ''' mode = stat.S_IMODE(os.stat(f).st_mode) if not mode == 0o600: raise RuntimeError("Invalid permissions on %s. " "Expected 0600 got %s" % (f, oct(mode))) logger.debug("Correct file permissions on...
[ "def", "verify_permissions", "(", "f", ")", ":", "mode", "=", "stat", ".", "S_IMODE", "(", "os", ".", "stat", "(", "f", ")", ".", "st_mode", ")", "if", "not", "mode", "==", "0o600", ":", "raise", "RuntimeError", "(", "\"Invalid permissions on %s. \"", "\...
[ 86, 0 ]
[ 94, 53 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.__init__
(self, config, conn=None)
Load config from parent
Load config from parent
def __init__(self, config, conn=None): """ Load config from parent """ self.config = config self.fallback_file = constants.collection_fallback_file self.remove_file = config.remove_file self.redaction_file = config.redaction_file self.content_redaction_fil...
[ "def", "__init__", "(", "self", ",", "config", ",", "conn", "=", "None", ")", ":", "self", ".", "config", "=", "config", "self", ".", "fallback_file", "=", "constants", ".", "collection_fallback_file", "self", ".", "remove_file", "=", "config", ".", "remov...
[ 102, 4 ]
[ 132, 28 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.validate_gpg_sig
(self, path, sig=None)
Validate the collection rules
Validate the collection rules
def validate_gpg_sig(self, path, sig=None): """ Validate the collection rules """ logger.debug("Verifying GPG signature of Insights configuration") if sig is None: sig = path + ".asc" command = ("/usr/bin/gpg --no-default-keyring " "--keyrin...
[ "def", "validate_gpg_sig", "(", "self", ",", "path", ",", "sig", "=", "None", ")", ":", "logger", ".", "debug", "(", "\"Verifying GPG signature of Insights configuration\"", ")", "if", "sig", "is", "None", ":", "sig", "=", "path", "+", "\".asc\"", "command", ...
[ 134, 4 ]
[ 159, 23 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.try_disk
(self, path, gpg=True)
Try to load json off disk
Try to load json off disk
def try_disk(self, path, gpg=True): """ Try to load json off disk """ if not os.path.isfile(path): return if not gpg or self.validate_gpg_sig(path): stream = open(path, 'r') json_stream = stream.read() if len(json_stream): ...
[ "def", "try_disk", "(", "self", ",", "path", ",", "gpg", "=", "True", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "return", "if", "not", "gpg", "or", "self", ".", "validate_gpg_sig", "(", "path", ")", ":", "str...
[ 161, 4 ]
[ 180, 22 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.get_collection_rules
(self, raw=False)
Download the collection rules
Download the collection rules
def get_collection_rules(self, raw=False): """ Download the collection rules """ logger.debug("Attemping to download collection rules from %s", self.collection_rules_url) logger.log(NETWORK, "GET %s", self.collection_rules_url) try: req =...
[ "def", "get_collection_rules", "(", "self", ",", "raw", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"Attemping to download collection rules from %s\"", ",", "self", ".", "collection_rules_url", ")", "logger", ".", "log", "(", "NETWORK", ",", "\"GET %s\"...
[ 182, 4 ]
[ 218, 39 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.get_collection_rules_gpg
(self, collection_rules)
Download the collection rules gpg signature
Download the collection rules gpg signature
def get_collection_rules_gpg(self, collection_rules): """ Download the collection rules gpg signature """ sig_text = self.fetch_gpg() sig_response = NamedTemporaryFile(suffix=".asc") sig_response.write(sig_text.encode('utf-8')) sig_response.file.flush() se...
[ "def", "get_collection_rules_gpg", "(", "self", ",", "collection_rules", ")", ":", "sig_text", "=", "self", ".", "fetch_gpg", "(", ")", "sig_response", "=", "NamedTemporaryFile", "(", "suffix", "=", "\".asc\"", ")", "sig_response", ".", "write", "(", "sig_text",...
[ 237, 4 ]
[ 246, 81 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.write_collection_data
(self, path, data)
Write collections rules to disk
Write collections rules to disk
def write_collection_data(self, path, data): """ Write collections rules to disk """ flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC fd = os.open(path, flags, 0o600) with os.fdopen(fd, 'w') as dyn_conf_file: dyn_conf_file.write(data)
[ "def", "write_collection_data", "(", "self", ",", "path", ",", "data", ")", ":", "flags", "=", "os", ".", "O_WRONLY", "|", "os", ".", "O_CREAT", "|", "os", ".", "O_TRUNC", "fd", "=", "os", ".", "open", "(", "path", ",", "flags", ",", "0o600", ")", ...
[ 248, 4 ]
[ 255, 37 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.get_conf_file
(self)
Get config from local config file, first try cache, then fallback.
Get config from local config file, first try cache, then fallback.
def get_conf_file(self): """ Get config from local config file, first try cache, then fallback. """ for conf_file in [self.collection_rules_file, self.fallback_file]: logger.debug("trying to read conf from: " + conf_file) conf = self.try_disk(conf_file, self.gpg) ...
[ "def", "get_conf_file", "(", "self", ")", ":", "for", "conf_file", "in", "[", "self", ".", "collection_rules_file", ",", "self", ".", "fallback_file", "]", ":", "logger", ".", "debug", "(", "\"trying to read conf from: \"", "+", "conf_file", ")", "conf", "=", ...
[ 257, 4 ]
[ 277, 82 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.get_conf_update
(self)
Get updated config from URL, fallback to local file if download fails.
Get updated config from URL, fallback to local file if download fails.
def get_conf_update(self): """ Get updated config from URL, fallback to local file if download fails. """ dyn_conf = self.get_collection_rules() if not dyn_conf: return self.get_conf_file() version = dyn_conf.get('version', None) if version is None: ...
[ "def", "get_conf_update", "(", "self", ")", ":", "dyn_conf", "=", "self", ".", "get_collection_rules", "(", ")", "if", "not", "dyn_conf", ":", "return", "self", ".", "get_conf_file", "(", ")", "version", "=", "dyn_conf", ".", "get", "(", "'version'", ",", ...
[ 279, 4 ]
[ 296, 23 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.get_rm_conf_old
(self)
Get excluded files config from remove_file.
Get excluded files config from remove_file.
def get_rm_conf_old(self): """ Get excluded files config from remove_file. """ # Convert config object into dict self.using_new_format = False parsedconfig = ConfigParser.RawConfigParser() if not self.remove_file: # no filename defined, return nothing ...
[ "def", "get_rm_conf_old", "(", "self", ")", ":", "# Convert config object into dict", "self", ".", "using_new_format", "=", "False", "parsedconfig", "=", "ConfigParser", ".", "RawConfigParser", "(", ")", "if", "not", "self", ".", "remove_file", ":", "# no filename d...
[ 298, 4 ]
[ 350, 27 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.load_redaction_file
(self, fname)
Load the YAML-style file-redaction.yaml or file-content-redaction.yaml files
Load the YAML-style file-redaction.yaml or file-content-redaction.yaml files
def load_redaction_file(self, fname): ''' Load the YAML-style file-redaction.yaml or file-content-redaction.yaml files ''' if fname not in (self.redaction_file, self.content_redaction_file): # invalid function use, should never get here in a production situation ...
[ "def", "load_redaction_file", "(", "self", ",", "fname", ")", ":", "if", "fname", "not", "in", "(", "self", ".", "redaction_file", ",", "self", ".", "content_redaction_file", ")", ":", "# invalid function use, should never get here in a production situation", "return", ...
[ 352, 4 ]
[ 386, 21 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.get_rm_conf
(self)
Try to load the the "new" version of remove.conf (file-redaction.yaml and file-redaction.yaml)
Try to load the the "new" version of remove.conf (file-redaction.yaml and file-redaction.yaml)
def get_rm_conf(self): ''' Try to load the the "new" version of remove.conf (file-redaction.yaml and file-redaction.yaml) ''' rm_conf = {} redact_conf = self.load_redaction_file(self.redaction_file) content_redact_conf = self.load_redaction_file(self.content_redac...
[ "def", "get_rm_conf", "(", "self", ")", ":", "rm_conf", "=", "{", "}", "redact_conf", "=", "self", ".", "load_redaction_file", "(", "self", ".", "redaction_file", ")", "content_redact_conf", "=", "self", ".", "load_redaction_file", "(", "self", ".", "content_r...
[ 388, 4 ]
[ 415, 27 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.get_tags_conf
(self)
Try to load the tags.conf file
Try to load the tags.conf file
def get_tags_conf(self): ''' Try to load the tags.conf file ''' if not os.path.isfile(self.tags_file): logger.info("%s does not exist", self.tags_file) return None else: try: load_yaml(self.tags_file) logger.info...
[ "def", "get_tags_conf", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "self", ".", "tags_file", ")", ":", "logger", ".", "info", "(", "\"%s does not exist\"", ",", "self", ".", "tags_file", ")", "return", "None", "else", ":...
[ 417, 4 ]
[ 430, 27 ]
python
en
['en', 'error', 'th']
False
InsightsUploadConf.validate
(self)
Validate remove.conf and tags.conf
Validate remove.conf and tags.conf
def validate(self): ''' Validate remove.conf and tags.conf ''' self.get_tags_conf() success = self.get_rm_conf() if not success: logger.info('No contents in the blacklist configuration to validate.') return None # Using print here as this c...
[ "def", "validate", "(", "self", ")", ":", "self", ".", "get_tags_conf", "(", ")", "success", "=", "self", ".", "get_rm_conf", "(", ")", "if", "not", "success", ":", "logger", ".", "info", "(", "'No contents in the blacklist configuration to validate.'", ")", "...
[ 432, 4 ]
[ 445, 19 ]
python
en
['en', 'error', 'th']
False
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up AdGuard Home from a config entry.
Set up AdGuard Home from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up AdGuard Home from a config entry.""" session = async_get_clientsession(hass, entry.data[CONF_VERIFY_SSL]) adguard = AdGuardHome( entry.data[CONF_HOST], port=entry.data[CONF_PORT], username=entry.d...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "session", "=", "async_get_clientsession", "(", "hass", ",", "entry", ".", "data", "[", "CONF_VERIFY_SSL", "]", ")", "adguard", ...
[ 50, 0 ]
[ 114, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload AdGuard Home config entry.
Unload AdGuard Home config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload AdGuard Home config entry.""" hass.services.async_remove(DOMAIN, SERVICE_ADD_URL) hass.services.async_remove(DOMAIN, SERVICE_REMOVE_URL) hass.services.async_remove(DOMAIN, SERVICE_ENABLE_URL) hass.services.async...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "hass", ".", "services", ".", "async_remove", "(", "DOMAIN", ",", "SERVICE_ADD_URL", ")", "hass", ".", "services", ".", "async_...
[ 117, 0 ]
[ 129, 20 ]
python
en
['da', 'en', 'en']
True
AdGuardHomeEntity.__init__
( self, adguard: AdGuardHome, entry: ConfigEntry, name: str, icon: str, enabled_default: bool = True, )
Initialize the AdGuard Home entity.
Initialize the AdGuard Home entity.
def __init__( self, adguard: AdGuardHome, entry: ConfigEntry, name: str, icon: str, enabled_default: bool = True, ) -> None: """Initialize the AdGuard Home entity.""" self._available = True self._enabled_default = enabled_default self._...
[ "def", "__init__", "(", "self", ",", "adguard", ":", "AdGuardHome", ",", "entry", ":", "ConfigEntry", ",", "name", ":", "str", ",", "icon", ":", "str", ",", "enabled_default", ":", "bool", "=", "True", ",", ")", "->", "None", ":", "self", ".", "_avai...
[ 135, 4 ]
[ 149, 30 ]
python
en
['en', 'en', 'en']
True
AdGuardHomeEntity.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self) -> str: """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_name" ]
[ 152, 4 ]
[ 154, 25 ]
python
en
['en', 'en', 'en']
True
AdGuardHomeEntity.icon
(self)
Return the mdi icon of the entity.
Return the mdi icon of the entity.
def icon(self) -> str: """Return the mdi icon of the entity.""" return self._icon
[ "def", "icon", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_icon" ]
[ 157, 4 ]
[ 159, 25 ]
python
en
['en', 'en', 'en']
True
AdGuardHomeEntity.entity_registry_enabled_default
(self)
Return if the entity should be enabled when first added to the entity registry.
Return if the entity should be enabled when first added to the entity registry.
def entity_registry_enabled_default(self) -> bool: """Return if the entity should be enabled when first added to the entity registry.""" return self._enabled_default
[ "def", "entity_registry_enabled_default", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_enabled_default" ]
[ 162, 4 ]
[ 164, 36 ]
python
en
['en', 'en', 'en']
True
AdGuardHomeEntity.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" ]
[ 167, 4 ]
[ 169, 30 ]
python
en
['en', 'en', 'en']
True
AdGuardHomeEntity.async_update
(self)
Update AdGuard Home entity.
Update AdGuard Home entity.
async def async_update(self) -> None: """Update AdGuard Home entity.""" if not self.enabled: return try: await self._adguard_update() self._available = True except AdGuardHomeError: if self._available: _LOGGER.debug( ...
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "enabled", ":", "return", "try", ":", "await", "self", ".", "_adguard_update", "(", ")", "self", ".", "_available", "=", "True", "except", "AdGuardHomeError", ...
[ 171, 4 ]
[ 185, 35 ]
python
en
['es', 'en', 'en']
True
AdGuardHomeEntity._adguard_update
(self)
Update AdGuard Home entity.
Update AdGuard Home entity.
async def _adguard_update(self) -> None: """Update AdGuard Home entity.""" raise NotImplementedError()
[ "async", "def", "_adguard_update", "(", "self", ")", "->", "None", ":", "raise", "NotImplementedError", "(", ")" ]
[ 187, 4 ]
[ 189, 35 ]
python
en
['es', 'en', 'en']
True
AdGuardHomeDeviceEntity.device_info
(self)
Return device information about this AdGuard Home instance.
Return device information about this AdGuard Home instance.
def device_info(self) -> DeviceInfo: """Return device information about this AdGuard Home instance.""" return { "identifiers": { (DOMAIN, self.adguard.host, self.adguard.port, self.adguard.base_path) # type: ignore }, "name": "AdGuard Home", ...
[ "def", "device_info", "(", "self", ")", "->", "DeviceInfo", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "adguard", ".", "host", ",", "self", ".", "adguard", ".", "port", ",", "self", ".", "adguard", ".", "base_path...
[ 196, 4 ]
[ 208, 9 ]
python
en
['en', 'en', 'en']
True
test_async_setup_entry
(hass, entry)
Test a successful setup entry and unload of entry.
Test a successful setup entry and unload of entry.
async def test_async_setup_entry(hass, entry): """Test a successful setup entry and unload of entry.""" await init_integration(hass, entry) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert entry.state == ConfigEntryState.LOADED assert await hass.config_entries.async_unload(entry.en...
[ "async", "def", "test_async_setup_entry", "(", "hass", ",", "entry", ")", ":", "await", "init_integration", "(", "hass", ",", "entry", ")", "assert", "len", "(", "hass", ".", "config_entries", ".", "async_entries", "(", "DOMAIN", ")", ")", "==", "1", "asse...
[ 19, 0 ]
[ 29, 36 ]
python
en
['en', 'en', 'en']
True
test_async_setup_multiple_entries
(hass, entry, entry2)
Test a successful setup and unload of multiple entries.
Test a successful setup and unload of multiple entries.
async def test_async_setup_multiple_entries(hass, entry, entry2): """Test a successful setup and unload of multiple entries.""" for config_entry in (entry, entry2): await init_integration(hass, config_entry) assert config_entry.state == ConfigEntryState.LOADED await hass.async_block_till...
[ "async", "def", "test_async_setup_multiple_entries", "(", "hass", ",", "entry", ",", "entry2", ")", ":", "for", "config_entry", "in", "(", "entry", ",", "entry2", ")", ":", "await", "init_integration", "(", "hass", ",", "config_entry", ")", "assert", "config_e...
[ 33, 0 ]
[ 48, 36 ]
python
en
['en', 'en', 'en']
True
test_async_setup_entry_update
(hass, entry)
Test a successful setup entry if entry with same id already exists.
Test a successful setup entry if entry with same id already exists.
async def test_async_setup_entry_update(hass, entry): """Test a successful setup entry if entry with same id already exists.""" # setup first entry entry.source = config_entries.SOURCE_IMPORT # create dummy entity for LCN platform as an orphan entity_registry = await er.async_get_registry(hass) ...
[ "async", "def", "test_async_setup_entry_update", "(", "hass", ",", "entry", ")", ":", "# setup first entry", "entry", ".", "source", "=", "config_entries", ".", "SOURCE_IMPORT", "# create dummy entity for LCN platform as an orphan", "entity_registry", "=", "await", "er", ...
[ 52, 0 ]
[ 69, 64 ]
python
en
['en', 'en', 'en']
True
test_async_setup_entry_raises_authentication_error
(hass, entry)
Test that an authentication error is handled properly.
Test that an authentication error is handled properly.
async def test_async_setup_entry_raises_authentication_error(hass, entry): """Test that an authentication error is handled properly.""" with patch.object( PchkConnectionManager, "async_connect", side_effect=PchkAuthenticationError ): await init_integration(hass, entry) assert entry.state...
[ "async", "def", "test_async_setup_entry_raises_authentication_error", "(", "hass", ",", "entry", ")", ":", "with", "patch", ".", "object", "(", "PchkConnectionManager", ",", "\"async_connect\"", ",", "side_effect", "=", "PchkAuthenticationError", ")", ":", "await", "i...
[ 72, 0 ]
[ 78, 54 ]
python
en
['en', 'en', 'en']
True
test_async_setup_entry_raises_license_error
(hass, entry)
Test that an authentication error is handled properly.
Test that an authentication error is handled properly.
async def test_async_setup_entry_raises_license_error(hass, entry): """Test that an authentication error is handled properly.""" with patch.object( PchkConnectionManager, "async_connect", side_effect=PchkLicenseError ): await init_integration(hass, entry) assert entry.state == ConfigEntr...
[ "async", "def", "test_async_setup_entry_raises_license_error", "(", "hass", ",", "entry", ")", ":", "with", "patch", ".", "object", "(", "PchkConnectionManager", ",", "\"async_connect\"", ",", "side_effect", "=", "PchkLicenseError", ")", ":", "await", "init_integratio...
[ 81, 0 ]
[ 87, 54 ]
python
en
['en', 'en', 'en']
True
test_async_setup_entry_raises_timeout_error
(hass, entry)
Test that an authentication error is handled properly.
Test that an authentication error is handled properly.
async def test_async_setup_entry_raises_timeout_error(hass, entry): """Test that an authentication error is handled properly.""" with patch.object(PchkConnectionManager, "async_connect", side_effect=TimeoutError): await init_integration(hass, entry) assert entry.state == ConfigEntryState.SETUP_ERROR
[ "async", "def", "test_async_setup_entry_raises_timeout_error", "(", "hass", ",", "entry", ")", ":", "with", "patch", ".", "object", "(", "PchkConnectionManager", ",", "\"async_connect\"", ",", "side_effect", "=", "TimeoutError", ")", ":", "await", "init_integration", ...
[ 90, 0 ]
[ 94, 54 ]
python
en
['en', 'en', 'en']
True
test_async_setup_from_configuration_yaml
(hass)
Test a successful setup using data from configuration.yaml.
Test a successful setup using data from configuration.yaml.
async def test_async_setup_from_configuration_yaml(hass): """Test a successful setup using data from configuration.yaml.""" await async_setup_component(hass, "persistent_notification", {}) with patch("homeassistant.components.lcn.async_setup_entry") as async_setup_entry: await setup_component(hass)...
[ "async", "def", "test_async_setup_from_configuration_yaml", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "with", "patch", "(", "\"homeassistant.components.lcn.async_setup_entry\"", ")", "as",...
[ 98, 0 ]
[ 105, 49 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the USGS Earthquake Hazards Program Feed platform.
Set up the USGS Earthquake Hazards Program Feed platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the USGS Earthquake Hazards Program Feed platform.""" scan_interval = config.get(CONF_SCAN_INTERVAL, SCAN_INTERVAL) feed_type = config[CONF_FEED_TYPE] coordinates = ( config.get(CONF_LATITUDE, hass.config.latitude), ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "scan_interval", "=", "config", ".", "get", "(", "CONF_SCAN_INTERVAL", ",", "SCAN_INTERVAL", ")", "feed_type", "=", "config", "[", "CONF_FEE...
[ 87, 0 ]
[ 112, 71 ]
python
en
['en', 'da', 'en']
True
UsgsEarthquakesFeedEntityManager.__init__
( self, hass, add_entities, scan_interval, coordinates, feed_type, radius_in_km, minimum_magnitude, )
Initialize the Feed Entity Manager.
Initialize the Feed Entity Manager.
def __init__( self, hass, add_entities, scan_interval, coordinates, feed_type, radius_in_km, minimum_magnitude, ): """Initialize the Feed Entity Manager.""" self._hass = hass self._feed_manager = UsgsEarthquakeHazardsProgramFee...
[ "def", "__init__", "(", "self", ",", "hass", ",", "add_entities", ",", "scan_interval", ",", "coordinates", ",", "feed_type", ",", "radius_in_km", ",", "minimum_magnitude", ",", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_feed_manager", "=", ...
[ 118, 4 ]
[ 141, 43 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesFeedEntityManager.startup
(self)
Start up this manager.
Start up this manager.
def startup(self): """Start up this manager.""" self._feed_manager.update() self._init_regular_updates()
[ "def", "startup", "(", "self", ")", ":", "self", ".", "_feed_manager", ".", "update", "(", ")", "self", ".", "_init_regular_updates", "(", ")" ]
[ 143, 4 ]
[ 146, 36 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesFeedEntityManager._init_regular_updates
(self)
Schedule regular updates at the specified interval.
Schedule regular updates at the specified interval.
def _init_regular_updates(self): """Schedule regular updates at the specified interval.""" track_time_interval( self._hass, lambda now: self._feed_manager.update(), self._scan_interval )
[ "def", "_init_regular_updates", "(", "self", ")", ":", "track_time_interval", "(", "self", ".", "_hass", ",", "lambda", "now", ":", "self", ".", "_feed_manager", ".", "update", "(", ")", ",", "self", ".", "_scan_interval", ")" ]
[ 148, 4 ]
[ 152, 9 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesFeedEntityManager.get_entry
(self, external_id)
Get feed entry by external id.
Get feed entry by external id.
def get_entry(self, external_id): """Get feed entry by external id.""" return self._feed_manager.feed_entries.get(external_id)
[ "def", "get_entry", "(", "self", ",", "external_id", ")", ":", "return", "self", ".", "_feed_manager", ".", "feed_entries", ".", "get", "(", "external_id", ")" ]
[ 154, 4 ]
[ 156, 63 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesFeedEntityManager._generate_entity
(self, external_id)
Generate new entity.
Generate new entity.
def _generate_entity(self, external_id): """Generate new entity.""" new_entity = UsgsEarthquakesEvent(self, external_id) # Add new entities to HA. self._add_entities([new_entity], True)
[ "def", "_generate_entity", "(", "self", ",", "external_id", ")", ":", "new_entity", "=", "UsgsEarthquakesEvent", "(", "self", ",", "external_id", ")", "# Add new entities to HA.", "self", ".", "_add_entities", "(", "[", "new_entity", "]", ",", "True", ")" ]
[ 158, 4 ]
[ 162, 46 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesFeedEntityManager._update_entity
(self, external_id)
Update entity.
Update entity.
def _update_entity(self, external_id): """Update entity.""" dispatcher_send(self._hass, SIGNAL_UPDATE_ENTITY.format(external_id))
[ "def", "_update_entity", "(", "self", ",", "external_id", ")", ":", "dispatcher_send", "(", "self", ".", "_hass", ",", "SIGNAL_UPDATE_ENTITY", ".", "format", "(", "external_id", ")", ")" ]
[ 164, 4 ]
[ 166, 77 ]
python
en
['es', 'en', 'en']
False
UsgsEarthquakesFeedEntityManager._remove_entity
(self, external_id)
Remove entity.
Remove entity.
def _remove_entity(self, external_id): """Remove entity.""" dispatcher_send(self._hass, SIGNAL_DELETE_ENTITY.format(external_id))
[ "def", "_remove_entity", "(", "self", ",", "external_id", ")", ":", "dispatcher_send", "(", "self", ".", "_hass", ",", "SIGNAL_DELETE_ENTITY", ".", "format", "(", "external_id", ")", ")" ]
[ 168, 4 ]
[ 170, 77 ]
python
en
['es', 'it', 'en']
False
UsgsEarthquakesEvent.__init__
(self, feed_manager, external_id)
Initialize entity with data from feed entry.
Initialize entity with data from feed entry.
def __init__(self, feed_manager, external_id): """Initialize entity with data from feed entry.""" self._feed_manager = feed_manager self._external_id = external_id self._name = None self._distance = None self._latitude = None self._longitude = None self._a...
[ "def", "__init__", "(", "self", ",", "feed_manager", ",", "external_id", ")", ":", "self", ".", "_feed_manager", "=", "feed_manager", "self", ".", "_external_id", "=", "external_id", "self", ".", "_name", "=", "None", "self", ".", "_distance", "=", "None", ...
[ 176, 4 ]
[ 193, 41 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesEvent.async_added_to_hass
(self)
Call when entity is added to hass.
Call when entity is added to hass.
async def async_added_to_hass(self): """Call when entity is added to hass.""" self._remove_signal_delete = async_dispatcher_connect( self.hass, SIGNAL_DELETE_ENTITY.format(self._external_id), self._delete_callback, ) self._remove_signal_update = async_...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_remove_signal_delete", "=", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "SIGNAL_DELETE_ENTITY", ".", "format", "(", "self", ".", "_external_id", ")", ",", "self", ".", ...
[ 195, 4 ]
[ 206, 9 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesEvent._delete_callback
(self)
Remove this entity.
Remove this entity.
def _delete_callback(self): """Remove this entity.""" self._remove_signal_delete() self._remove_signal_update() self.hass.async_create_task(self.async_remove(force_remove=True))
[ "def", "_delete_callback", "(", "self", ")", ":", "self", ".", "_remove_signal_delete", "(", ")", "self", ".", "_remove_signal_update", "(", ")", "self", ".", "hass", ".", "async_create_task", "(", "self", ".", "async_remove", "(", "force_remove", "=", "True",...
[ 209, 4 ]
[ 213, 73 ]
python
en
['en', 'en', 'en']
True
UsgsEarthquakesEvent._update_callback
(self)
Call update method.
Call update method.
def _update_callback(self): """Call update method.""" self.async_schedule_update_ha_state(True)
[ "def", "_update_callback", "(", "self", ")", ":", "self", ".", "async_schedule_update_ha_state", "(", "True", ")" ]
[ 216, 4 ]
[ 218, 49 ]
python
en
['en', 'sn', 'en']
True
UsgsEarthquakesEvent.should_poll
(self)
No polling needed for USGS Earthquake events.
No polling needed for USGS Earthquake events.
def should_poll(self): """No polling needed for USGS Earthquake events.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 221, 4 ]
[ 223, 20 ]
python
en
['en', 'en', 'en']
True