Skip to content

Commit

Permalink
new sensors added for energy consumption
Browse files Browse the repository at this point in the history
  • Loading branch information
chomupashchuk committed Oct 2, 2021
1 parent e2ddaa8 commit fda5208
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 48 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ Order of Installation:
- `ch_set_temperature` - set CH temperature.
- `ch_program` - CH Time Program.
- `ch_water_temperature` - CH Water Temperature. **WORKS ONLY ON SPECIFIC MODELS WHILE ON OTHERS CAUSES CRASHES**
- `cooling_last_24h` - energy use for pump cooling in a day.
- `cooling_last_7d` - energy use for pump cooling in a week.
- `cooling_last_30d` - energy use for pump cooling in a month.
- `cooling_last_365d` - energy use for pump cooling in a year.
- `cooling_last_24h` - energy use for pump cooling in a day. Not supported on all models.
- `cooling_last_7d` - energy use for pump cooling in a week. Not supported on all models.
- `cooling_last_30d` - energy use for pump cooling in a month. Not supported on all models.
- `cooling_last_365d` - energy use for pump cooling in a year. Not supported on all models.
- `cooling_today` - energy use for pump cooling today. Not supported on all models.
- `dhw_program` - DHW Time Program.
- `dhw_comfort_function` - DHW comfort function.
- `dhw_mode` - mode of DHW. Not supported on all models.
Expand All @@ -99,6 +100,7 @@ Order of Installation:
- `heating_last_30d` - energy use for heating in last 7 days. Not supported on all models.
- `heating_last_365d` - energy use for heating in last 30 days. Not supported on all models.
- `heating_last_7d` - energy use for heating in last 365 days. Not supported on all models.
- `heating_today` - energy use for heating today. Not supported on all models.
- `mode` - mode of boiler (`off` or `summer` or `winter` and others).
- `outside_temperature` - outside temperature. Not supported on all models.
- `signal_strength` - Wifi signal strength.
Expand All @@ -107,6 +109,7 @@ Order of Installation:
- `water_last_30d` - energy use for water in last 7 days. Not supported on all models.
- `water_last_365d` - energy use for water in last 30 days. Not supported on all models.
- `water_last_7d` - energy use for water in last 365 days. Not supported on all models.
- `water_today` - energy use for water today. Not supported on all models.

#### Binary sensors
**Some parameters are not supported on all models**
Expand Down
61 changes: 59 additions & 2 deletions custom_components/ariston/ariston.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class AristonHandler:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""

_VERSION = "1.0.41"
_VERSION = "1.0.43"

_LOGGER = logging.getLogger(__name__)
_LEVEL_CRITICAL = "CRITICAL"
Expand Down Expand Up @@ -151,6 +151,7 @@ class AristonHandler:
_PARAM_COOLING_LAST_7D_LIST = "cooling_last_7d_list"
_PARAM_COOLING_LAST_30D_LIST = "cooling_last_30d_list"
_PARAM_COOLING_LAST_365D_LIST = "cooling_last_365d_list"
_PARAM_COOLING_TODAY = "cooling_today"
_PARAM_ERRORS = "errors"
_PARAM_ERRORS_COUNT = "errors_count"
_PARAM_DHW_COMFORT_FUNCTION = "dhw_comfort_function"
Expand All @@ -168,6 +169,7 @@ class AristonHandler:
_PARAM_HEATING_LAST_7D_LIST = "heating_last_7d_list"
_PARAM_HEATING_LAST_30D_LIST = "heating_last_30d_list"
_PARAM_HEATING_LAST_365D_LIST = "heating_last_365d_list"
_PARAM_HEATING_TODAY = "heating_today"
_PARAM_MODE = "mode"
_PARAM_OUTSIDE_TEMPERATURE = "outside_temperature"
_PARAM_SIGNAL_STRENGTH = "signal_strength"
Expand All @@ -179,6 +181,7 @@ class AristonHandler:
_PARAM_WATER_LAST_7D_LIST = "water_last_7d_list"
_PARAM_WATER_LAST_30D_LIST = "water_last_30d_list"
_PARAM_WATER_LAST_365D_LIST = "water_last_365d_list"
_PARAM_WATER_TODAY = "water_today"
_PARAM_UNITS = "units"
_PARAM_THERMAL_CLEANSE_CYCLE = "dhw_thermal_cleanse_cycle"
_PARAM_GAS_TYPE = "gas_type"
Expand Down Expand Up @@ -343,6 +346,7 @@ class AristonHandler:
_PARAM_HEATING_LAST_7D_LIST,
_PARAM_HEATING_LAST_30D_LIST,
_PARAM_HEATING_LAST_365D_LIST,
_PARAM_HEATING_TODAY,
_PARAM_WATER_LAST_24H,
_PARAM_WATER_LAST_7D,
_PARAM_WATER_LAST_30D,
Expand All @@ -351,14 +355,16 @@ class AristonHandler:
_PARAM_WATER_LAST_7D_LIST,
_PARAM_WATER_LAST_30D_LIST,
_PARAM_WATER_LAST_365D_LIST,
_PARAM_WATER_TODAY,
_PARAM_COOLING_LAST_24H,
_PARAM_COOLING_LAST_7D,
_PARAM_COOLING_LAST_30D,
_PARAM_COOLING_LAST_365D,
_PARAM_COOLING_LAST_24H_LIST,
_PARAM_COOLING_LAST_7D_LIST,
_PARAM_COOLING_LAST_30D_LIST,
_PARAM_COOLING_LAST_365D_LIST
_PARAM_COOLING_LAST_365D_LIST,
_PARAM_COOLING_TODAY
}
_GET_REQUEST_MAIN = {
_PARAM_CH_DETECTED_TEMPERATURE,
Expand Down Expand Up @@ -526,16 +532,19 @@ def _update_units(self):
self._ariston_sensors[self._PARAM_HEATING_LAST_7D][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_HEATING_LAST_30D][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_HEATING_LAST_365D][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_HEATING_TODAY][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_WATER_LAST_24H][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_WATER_LAST_7D][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_WATER_LAST_30D][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_WATER_LAST_365D][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_WATER_TODAY][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_SIGNAL_STRENGTH][self._UNITS] = '%'
self._ariston_sensors[self._PARAM_THERMAL_CLEANSE_CYCLE][self._UNITS] = 'h'
self._ariston_sensors[self._PARAM_COOLING_LAST_24H][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_COOLING_LAST_7D][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_COOLING_LAST_30D][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_COOLING_LAST_365D][self._UNITS] = 'kBtuh'
self._ariston_sensors[self._PARAM_COOLING_TODAY][self._UNITS] = 'kBtuh'
elif self._ariston_sensors[self._PARAM_UNITS][self._VALUE] == self._VAL_METRIC:
self._ariston_sensors[self._PARAM_CH_ANTIFREEZE_TEMPERATURE][self._UNITS] = "°C"
self._ariston_sensors[self._PARAM_CH_DETECTED_TEMPERATURE][self._UNITS] = "°C"
Expand All @@ -556,16 +565,19 @@ def _update_units(self):
self._ariston_sensors[self._PARAM_HEATING_LAST_7D][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_HEATING_LAST_30D][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_HEATING_LAST_365D][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_HEATING_TODAY][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_WATER_LAST_24H][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_WATER_LAST_7D][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_WATER_LAST_30D][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_WATER_LAST_365D][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_WATER_TODAY][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_SIGNAL_STRENGTH][self._UNITS] = '%'
self._ariston_sensors[self._PARAM_THERMAL_CLEANSE_CYCLE][self._UNITS] = 'h'
self._ariston_sensors[self._PARAM_COOLING_LAST_24H][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_COOLING_LAST_7D][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_COOLING_LAST_30D][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_COOLING_LAST_365D][self._UNITS] = 'kWh'
self._ariston_sensors[self._PARAM_COOLING_TODAY][self._UNITS] = 'kWh'

def __init__(self,
username: str,
Expand Down Expand Up @@ -1683,6 +1695,48 @@ def _set_sensors(self, request_type=""):
self._ariston_sensors[self._PARAM_WATER_LAST_365D][self._VALUE] = None
self._ariston_sensors[self._PARAM_WATER_LAST_365D_LIST][self._VALUE] = None

try:
sum_obj = 0
start_hour = int(self._ariston_gas_data["daily"]["leftColumnLabel"])
use_iterated = False
for item in self._ariston_gas_data["daily"]["data"]:
if start_hour == 0 or start_hour == 24:
use_iterated = True
start_hour += 2
if use_iterated:
sum_obj = sum_obj + item["y3"]
self._ariston_sensors[self._PARAM_COOLING_TODAY][self._VALUE] = round(sum_obj, 3)
except KeyError:
self._ariston_sensors[self._PARAM_COOLING_TODAY][self._VALUE] = None

try:
sum_obj = 0
start_hour = int(self._ariston_gas_data["daily"]["leftColumnLabel"])
use_iterated = False
for item in self._ariston_gas_data["daily"]["data"]:
if start_hour == 0 or start_hour == 24:
use_iterated = True
start_hour += 2
if use_iterated:
sum_obj = sum_obj + item["y2"]
self._ariston_sensors[self._PARAM_HEATING_TODAY][self._VALUE] = round(sum_obj, 3)
except KeyError:
self._ariston_sensors[self._PARAM_HEATING_TODAY][self._VALUE] = None

try:
sum_obj = 0
start_hour = int(self._ariston_gas_data["daily"]["leftColumnLabel"])
use_iterated = False
for item in self._ariston_gas_data["daily"]["data"]:
if start_hour == 0 or start_hour == 24:
use_iterated = True
start_hour += 2
if use_iterated:
sum_obj = sum_obj + item["y"]
self._ariston_sensors[self._PARAM_WATER_TODAY][self._VALUE] = round(sum_obj, 3)
except KeyError:
self._ariston_sensors[self._PARAM_WATER_TODAY][self._VALUE] = None

else:
self._ariston_sensors[self._PARAM_ACCOUNT_CH_GAS][self._VALUE] = None
self._ariston_sensors[self._PARAM_ACCOUNT_DHW_GAS][self._VALUE] = None
Expand Down Expand Up @@ -1712,6 +1766,9 @@ def _set_sensors(self, request_type=""):
self._ariston_sensors[self._PARAM_HEATING_LAST_365D_LIST][self._VALUE] = None
self._ariston_sensors[self._PARAM_WATER_LAST_365D_LIST][self._VALUE] = None
self._ariston_sensors[self._PARAM_COOLING_LAST_365D_LIST][self._VALUE] = None
self._ariston_sensors[self._PARAM_COOLING_TODAY][self._VALUE] = None
self._ariston_sensors[self._PARAM_HEATING_TODAY][self._VALUE] = None
self._ariston_sensors[self._PARAM_WATER_TODAY][self._VALUE] = None

if request_type == self._REQUEST_GET_OTHER:

Expand Down
3 changes: 3 additions & 0 deletions custom_components/ariston/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
PARAM_COOLING_LAST_7D_LIST = "cooling_last_7d_list"
PARAM_COOLING_LAST_30D_LIST = "cooling_last_30d_list"
PARAM_COOLING_LAST_365D_LIST = "cooling_last_365d_list"
PARAM_COOLING_TODAY = "cooling_today"
PARAM_ERRORS = "errors"
PARAM_ERRORS_COUNT = "errors_count"
PARAM_DHW_COMFORT_FUNCTION = "dhw_comfort_function"
Expand All @@ -40,6 +41,7 @@
PARAM_HEATING_LAST_7D_LIST = "heating_last_7d_list"
PARAM_HEATING_LAST_30D_LIST = "heating_last_30d_list"
PARAM_HEATING_LAST_365D_LIST = "heating_last_365d_list"
PARAM_HEATING_TODAY = "heating_today"
PARAM_MODE = "mode"
PARAM_OUTSIDE_TEMPERATURE = "outside_temperature"
PARAM_SIGNAL_STRENGTH = "signal_strength"
Expand All @@ -51,6 +53,7 @@
PARAM_WATER_LAST_7D_LIST = "water_last_7d_list"
PARAM_WATER_LAST_30D_LIST = "water_last_30d_list"
PARAM_WATER_LAST_365D_LIST = "water_last_365d_list"
PARAM_WATER_TODAY = "water_today"
PARAM_UNITS = "units"
PARAM_THERMAL_CLEANSE_CYCLE = "dhw_thermal_cleanse_cycle"
PARAM_GAS_TYPE = "gas_type"
Expand Down
Loading

0 comments on commit fda5208

Please sign in to comment.