Skip to content

Commit

Permalink
## [2.0.3] 2021-01-26
Browse files Browse the repository at this point in the history
### Fixed
- forecast_observations bug fix
  • Loading branch information
devfrstslv committed Jan 26, 2021
1 parent 6b39737 commit a2a6bac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [2.0.3] Unreleased
## [2.0.4] Unreleased
### Fixed

### Added

### Changed

## [2.0.3] 2021-01-26
### Fixed
- forecast_observations bug fix

## [2.0.2] 2021-01-25
### Changed
Detailed README & info
Expand Down
18 changes: 12 additions & 6 deletions custom_components/climacell/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def __init__(
self.__icon = icon

self.__friendly_name = "cc " + sensor_friendly_name

if timestep == 'current':
self._observation = 0
else:
Expand All @@ -329,10 +330,15 @@ def __init__(
timestep_length = 1
if timestep_suffix == "m":
timestep_length = 2
timestep_formatted = (
str(timestep_int * self._observation).zfill(timestep_length)
+ timestep_suffix
)

if self._observation is None:
timestep_formatted = ""
else:
timestep_formatted = (
str(timestep_int * (self._observation)).zfill(timestep_length)
+ timestep_suffix
)

self.__friendly_name += " " + timestep_formatted

if isinstance(unit, dict):
Expand Down Expand Up @@ -391,15 +397,15 @@ def update(self):
self.__data_provider.retrieve_update()

if self.__data_provider.data is not None:
if self._observation >= len(self.__data_provider.data["intervals"]):
if (0 if self._observation is None else self._observation) >= len(self.__data_provider.data["intervals"]):
_LOGGER.error(
"observation %s missing: %s",
self._observation,
self.__data_provider.data,
)
return

sensor_data = self.__data_provider.data["intervals"][self._observation]
sensor_data = self.__data_provider.data["intervals"][(0 if self._observation is None else self._observation)]
self._state = sensor_data["values"][self.__field]
if self.__valuemap is not None:
self._state = self.__valuemap[str(self._state)]
Expand Down

0 comments on commit a2a6bac

Please sign in to comment.