Skip to content

Commit

Permalink
dedicated files per gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
chomupashchuk committed Aug 2, 2021
1 parent 1bbac7f commit ac9d0bd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
47 changes: 26 additions & 21 deletions custom_components/aquaariston/aristonaqua.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class AquaAristonHandler:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""

_VERSION = "1.0.40"
_VERSION = "1.0.41"

_LOGGER = logging.getLogger(__name__)
_LEVEL_CRITICAL = "CRITICAL"
Expand Down Expand Up @@ -376,6 +376,10 @@ def __init__(self,
self._changing_data = False

self._default_gw = gw
if self._default_gw:
self._gw_name = self._default_gw + '_'
else:
self._gw_name = ""

self._ariston_sensors = dict()
self._subscribed_sensors_old = dict()
Expand Down Expand Up @@ -577,7 +581,7 @@ def __init__(self,
if self._store_file:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = 'data_ariston_valid_requests.json'
store_file = self._gw_name + 'data_ariston_valid_requests.json'
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, 'w') as ariston_fetched:
json.dump(self._valid_requests, ariston_fetched)
Expand Down Expand Up @@ -834,21 +838,21 @@ def supported_sensors_set_values(self) -> dict:
return sensors_dictionary

def _write_showers_temp(self):
if self._boiler_type == self._TYPE_VELIS:
if self._boiler_type == self._TYPE_VELIS and self._gw_name:
with self._temp_lock:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = 'required_shower_temperature.json'
store_file = self._gw_name + 'required_shower_temperature.json'
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, 'w') as req_temp:
json.dump({self._PARAM_REQUIRED_TEMPERATURE: self._showers_required_temp,
self._SHOWERS_MODE: self._showers_mode
}, req_temp)

def _read_showers_temp(self):
if self._boiler_type == self._TYPE_VELIS:
if self._boiler_type == self._TYPE_VELIS and self._gw_name:
with self._temp_lock:
store_file = 'required_shower_temperature.json'
store_file = self._gw_name + 'required_shower_temperature.json'
store_file_path = os.path.join(self._store_folder, store_file)
try:
with open(store_file_path) as req_temp:
Expand Down Expand Up @@ -965,7 +969,7 @@ def _login_session(self):
if self._store_file:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = "data_ariston_login_" + str(resp.status_code) + "_error.txt"
store_file = self._gw_name + "data_ariston_login_" + str(resp.status_code) + "_error.txt"
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, "w") as f:
f.write(resp.text)
Expand All @@ -977,6 +981,7 @@ def _login_session(self):
if plant_id:
with self._plant_id_lock:
self._plant_id = plant_id
self._gw_name = plant_id + '_'
# self._model_fetch()
if self._boiler_type == self._TYPE_LYDOS_HYBRID:
self._fetch_max_temp()
Expand All @@ -1001,7 +1006,7 @@ def _model_fetch(self):
if self._store_file:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = "data_ariston_model_" + str(resp.status_code) + "_error.txt"
store_file = self._gw_name + "data_ariston_model_" + str(resp.status_code) + "_error.txt"
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, "w") as f:
f.write(resp.text)
Expand All @@ -1012,7 +1017,7 @@ def _model_fetch(self):
if self._store_file:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = 'data_ariston_model_data.json'
store_file = self._gw_name + 'data_ariston_model_data.json'
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, 'w') as ariston_fetched:
json.dump(resp.json(), ariston_fetched)
Expand Down Expand Up @@ -1045,7 +1050,7 @@ def _fetch_max_temp(self):
if self._store_file:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = 'lydos_max_temperatures.json'
store_file = self._gw_name + 'lydos_max_temperatures.json'
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, 'w') as ariston_fetched:
json.dump(resp.json(), ariston_fetched)
Expand Down Expand Up @@ -1346,7 +1351,7 @@ def _store_data(self, resp, request_type=""):
if self._store_file:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = "data_ariston" + request_type + "_" + str(resp.status_code) + "_error.txt"
store_file = self._gw_name + "data_ariston" + request_type + "_" + str(resp.status_code) + "_error.txt"
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, "w") as f:
f.write(resp.text)
Expand All @@ -1356,7 +1361,7 @@ def _store_data(self, resp, request_type=""):
if self._store_file:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = "data_ariston" + request_type + "_non_json_error.txt"
store_file = self._gw_name + "data_ariston" + request_type + "_non_json_error.txt"
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, "w") as f:
f.write(resp.text)
Expand Down Expand Up @@ -1454,7 +1459,7 @@ def _store_data(self, resp, request_type=""):
if self._store_file:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = 'data_ariston' + request_type + '.json'
store_file = self._gw_name + 'data_ariston' + request_type + '.json'
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, 'w') as ariston_fetched:
if request_type == self._REQUEST_GET_MAIN:
Expand All @@ -1471,7 +1476,7 @@ def _store_data(self, resp, request_type=""):
json.dump(self._ariston_shower_data, ariston_fetched)
elif request_type == self._REQUEST_GET_VERSION:
ariston_fetched.write(self._version)
store_file = 'data_ariston_timers.json'
store_file = self._gw_name + 'data_ariston_timers.json'
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, 'w') as ariston_fetched:
json.dump([self._set_time_start, self._set_time_end, self._get_time_start, self._get_time_end],
Expand Down Expand Up @@ -1628,7 +1633,7 @@ def _queue_get_data(self):
if self._store_file:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = 'data_ariston_all_set_get.json'
store_file = self._gw_name + 'data_ariston_all_set_get.json'
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, 'w') as ariston_fetched:
json.dump(self._set_param_group, ariston_fetched)
Expand Down Expand Up @@ -1682,15 +1687,15 @@ def _setting_http_data(self, set_data, request_type=""):
if self._store_file:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = 'data_ariston' + request_type + '.json'
store_file = self._gw_name + 'data_ariston' + request_type + '.json'
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, 'w') as ariston_fetched:
json.dump(set_data, ariston_fetched)
store_file = 'data_ariston_all_set.json'
store_file = self._gw_name + 'data_ariston_all_set.json'
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, 'w') as ariston_fetched:
json.dump(self._set_param, ariston_fetched)
store_file = 'data_ariston_timers.json'
store_file = self._gw_name + 'data_ariston_timers.json'
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, 'w') as ariston_fetched:
json.dump([self._set_time_start, self._set_time_end, self._get_time_start, self._get_time_end],
Expand Down Expand Up @@ -1737,7 +1742,7 @@ def _setting_http_data(self, set_data, request_type=""):
if self._store_file:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = "data_ariston" + request_type + "_" + str(resp.status_code) + "_error.txt"
store_file = self._gw_name + "data_ariston" + request_type + "_" + str(resp.status_code) + "_error.txt"
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, "w") as f:
f.write(resp.text)
Expand Down Expand Up @@ -2047,11 +2052,11 @@ def _preparing_setting_http_data(self):
if self._store_file:
if not os.path.isdir(self._store_folder):
os.makedirs(self._store_folder)
store_file = 'data_ariston_all_set_get.json'
store_file = self._gw_name + 'data_ariston_all_set_get.json'
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, 'w') as ariston_fetched:
json.dump(self._set_param_group, ariston_fetched)
store_file = 'data_ariston_all_set.json'
store_file = self._gw_name + 'data_ariston_all_set.json'
store_file_path = os.path.join(self._store_folder, store_file)
with open(store_file_path, 'w') as ariston_fetched:
json.dump(self._set_param, ariston_fetched)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aquaariston/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"requirements": [],
"dependencies": [],
"codeowners": ["@chomupashchuk"],
"version": "1.0.40"
"version": "1.0.41"
}

0 comments on commit ac9d0bd

Please sign in to comment.