custom_components/aquaariston/sensor.py
def update(self):
        """Get the latest data and updates the state."""
        try:
            if self._sensor_type == PARAM_TEMPERATURE_MODE:
                self._state = self._api.temperature_mode
                return
            if not self._api.available:
                return
            if not self._api.sensor_values[self._sensor_type][VALUE] is None:
                if self._sensor_type == PARAM_TIME_PROGRAM:
                    if self._api.sensor_values[self._sensor_type][VALUE] != {}:
                        self._state = STATE_AVAILABLE
                    else:
                        self._state = None
                elif self._sensor_type == PARAM_ERRORS:
                    if self._api.sensor_values[self._sensor_type][VALUE] == []:
                        self._state = STATE_GOOD
                    else:
                        self._state = STATE_ERRORS
                else:
                    self._state = self._api.sensor_values[self._sensor_type][VALUE]
            else:
                self._state = None

            self._attrs = {}
            if self._sensor_type in {
                PARAM_CLEANSE_TEMPERATURE,
                PARAM_REQUIRED_TEMPERATURE,
                PARAM_REQUIRED_SHOWERS,
            }:
                try:
                    self._attrs["Min"] = self._api.supported_sensors_set_values[
                        self._sensor_type
                    ]["min"]
                    self._attrs["Max"] = self._api.supported_sensors_set_values[
                        self._sensor_type
                    ]["max"]
                except KeyError:
                    self._attrs["Min"] = None
                    self._attrs["Max"] = None

            elif self._sensor_type == PARAM_ERRORS:
                if self._api.sensor_values[PARAM_ERRORS][VALUE]:
                    for valid_error in self._api.sensor_values[PARAM_ERRORS][VALUE]:
                        self._attrs[valid_error] = ""

            elif self._sensor_type in {
                PARAM_ENERGY_USE_DAY,
                PARAM_ENERGY_USE_WEEK,
                PARAM_ENERGY_USE_MONTH,
                PARAM_ENERGY_USE_YEAR,
            }:
                list_param = self._sensor_type + "_periods"
                self._attrs = self._api.sensor_values[list_param][VALUE]

            elif self._sensor_type == PARAM_TIME_PROGRAM:
                if not self._api.sensor_values[self._sensor_type][VALUE] is None:
                    self._attrs = self._api.sensor_values[self._sensor_type][VALUE]

        except KeyError:
            _LOGGER.warning("Problem updating sensors for Ariston Aqua")
Get the latest data and updates the state.
Get the latest data and updates the state.
Get the latest data and updates the state .
def update(self):
        try:
            if self._sensor_type == PARAM_TEMPERATURE_MODE:
                self._state = self._api.temperature_mode
                return
            if not self._api.available:
                return
            if not self._api.sensor_values[self._sensor_type][VALUE] is None:
                if self._sensor_type == PARAM_TIME_PROGRAM:
                    if self._api.sensor_values[self._sensor_type][VALUE] != {}:
                        self._state = STATE_AVAILABLE
                    else:
                        self._state = None
                elif self._sensor_type == PARAM_ERRORS:
                    if self._api.sensor_values[self._sensor_type][VALUE] == []:
                        self._state = STATE_GOOD
                    else:
                        self._state = STATE_ERRORS
                else:
                    self._state = self._api.sensor_values[self._sensor_type][VALUE]
            else:
                self._state = None
            self._attrs = {}
            if self._sensor_type in {
                PARAM_CLEANSE_TEMPERATURE,
                PARAM_REQUIRED_TEMPERATURE,
                PARAM_REQUIRED_SHOWERS,
            }:
                try:
                    self._attrs["Min"] = self._api.supported_sensors_set_values[
                        self._sensor_type
                    ]["min"]
                    self._attrs["Max"] = self._api.supported_sensors_set_values[
                        self._sensor_type
                    ]["max"]
                except KeyError:
                    self._attrs["Min"] = None
                    self._attrs["Max"] = None
            elif self._sensor_type == PARAM_ERRORS:
                if self._api.sensor_values[PARAM_ERRORS][VALUE]:
                    for valid_error in self._api.sensor_values[PARAM_ERRORS][VALUE]:
                        self._attrs[valid_error] = ""
            elif self._sensor_type in {
                PARAM_ENERGY_USE_DAY,
                PARAM_ENERGY_USE_WEEK,
                PARAM_ENERGY_USE_MONTH,
                PARAM_ENERGY_USE_YEAR,
            }:
                list_param = self._sensor_type + "_periods"
                self._attrs = self._api.sensor_values[list_param][VALUE]
            elif self._sensor_type == PARAM_TIME_PROGRAM:
                if not self._api.sensor_values[self._sensor_type][VALUE] is None:
                    self._attrs = self._api.sensor_values[self._sensor_type][VALUE]
        except KeyError:
            _LOGGER.warning("Problem updating sensors for Ariston Aqua")
def update ( self ) : try : if self . _sensor_type == PARAM_TEMPERATURE_MODE : self . _state = self . _api . temperature_mode return if not self . _api . available : return if not self . _api . sensor_values [ self . _sensor_type ] [ VALUE ] is None : if self . _sensor_type == PARAM_TIME_PROGRAM : if self . _api . sensor_values [ self . _sensor_type ] [ VALUE ] != { } : self . _state = STATE_AVAILABLE else : self . _state = None elif self . _sensor_type == PARAM_ERRORS : if self . _api . sensor_values [ self . _sensor_type ] [ VALUE ] == [ ] : self . _state = STATE_GOOD else : self . _state = STATE_ERRORS else : self . _state = self . _api . sensor_values [ self . _sensor_type ] [ VALUE ] else : self . _state = None self . _attrs = { } if self . _sensor_type in { PARAM_CLEANSE_TEMPERATURE , PARAM_REQUIRED_TEMPERATURE , PARAM_REQUIRED_SHOWERS , } : try : self . _attrs [ "Min" ] = self . _api . supported_sensors_set_values [ self . _sensor_type ] [ "min" ] self . _attrs [ "Max" ] = self . _api . supported_sensors_set_values [ self . _sensor_type ] [ "max" ] except KeyError : self . _attrs [ "Min" ] = None self . _attrs [ "Max" ] = None elif self . _sensor_type == PARAM_ERRORS : if self . _api . sensor_values [ PARAM_ERRORS ] [ VALUE ] : for valid_error in self . _api . sensor_values [ PARAM_ERRORS ] [ VALUE ] : self . _attrs [ valid_error ] = "" elif self . _sensor_type in { PARAM_ENERGY_USE_DAY , PARAM_ENERGY_USE_WEEK , PARAM_ENERGY_USE_MONTH , PARAM_ENERGY_USE_YEAR , } : list_param = self . _sensor_type + "_periods" self . _attrs = self . _api . sensor_values [ list_param ] [ VALUE ] elif self . _sensor_type == PARAM_TIME_PROGRAM : if not self . _api . sensor_values [ self . _sensor_type ] [ VALUE ] is None : self . _attrs = self . _api . sensor_values [ self . _sensor_type ] [ VALUE ] except KeyError : _LOGGER . warning ( "Problem updating sensors for Ariston Aqua" )
Get the latest data and updates the state.
Get the latest data and updates the state .
"""Get the latest data and updates the state."""
self