Skip to content

Commit

Permalink
fix support thermostat MCS300
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Lysov committed Oct 25, 2023
1 parent debbbd5 commit 799d422
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 2 deletions.
2 changes: 2 additions & 0 deletions custom_components/sst_cloud/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entitie
new_devices.append(Thermostat_equation(module,hass))
if module.get_device_type == 6:
new_devices.append(Thermostat_equation(module,hass))
if module.get_device_type == 0:
new_devices.append(Thermostat_equation(module,hass))
async_add_entities(new_devices)


Expand Down
2 changes: 1 addition & 1 deletion custom_components/sst_cloud/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/sergeylysov/sst_cloud/issues",
"requirements": ["requests","requests"],
"version": "0.1.28",
"version": "0.1.29",
"zeroconf": []
}
120 changes: 119 additions & 1 deletion custom_components/sst_cloud/sst.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,130 @@ def pull_data(self):
self.devices.append(LeakModule(json_device, self))
if json_device["type"] == 2 or json_device["type"] == 4:
self.devices.append(NeptunProwWiFi(json_device, self))
if json_device["type"] == 3 or json_device["type"] == 1 or json_device["type"] == 0:
if json_device["type"] == 3 or json_device["type"] == 1:
self.devices.append(ThermostatEquation(json_device, self))
if json_device["type"] == 6:
self.devices.append(ThermostatEcosmart25(json_device, self))
if json_device["type"] == 5:
self.devices.append(ThermostatOKE20(json_device, self))
if json_device["type"] == 0:
self.devices.append(ThermostatMCS300(json_device, self))
#Thermostat MCS300
class ThermostatMCS300:

def __init__(self,moduleDescription: json, sst: SST):
self._sst = sst
self.model_name = "MCS300"
self._hass:HomeAssistant = sst.hass
self.config = json.loads(moduleDescription["parsed_configuration"])
self._access_status = self.config["access_status"]
self._id = moduleDescription["id"]
self._device_name = moduleDescription["name"]
self._house_id = moduleDescription["house"]
self._type = moduleDescription["type"] #0
self._current_temperature = self.config["current_temperature"]
self._target_temperature = self.config["settings"]["temperature_manual"]
self._status = self.config["settings"]["status"]
self._mode = self.config["settings"]["mode"]
self._update_flag = True

def update(self) -> None:
# Обновляем парметры модуля
#Пропускаем обновление после изменения температуры, т.к. после обновления сразу прилетает старое значение
if self._update_flag == True:
response = requests.get(SST_CLOUD_API_URL +
"houses/" + str(self._house_id) + "/devices/" + str(self._id),
headers={"Authorization": "Token " + self._sst.key})
moduleDescription = json.loads(response.text)
self.config = json.loads(moduleDescription["parsed_configuration"])
self._access_status = self.config["access_status"]
self._device_name = moduleDescription["name"]
self._house_id = moduleDescription["house"]
self._type = moduleDescription["type"] # 0
self._current_temperature = self.config["current_temperature"]
self._target_temperature = self.config["settings"]["temperature_manual"]
self._status = self.config["settings"]["status"]
self._mode = self.config["settings"]["mode"]
self._update_flag = True
def setTemperature(self,temp) -> None:
self._update_flag = False
self._target_temperature = temp
requests.post(SST_CLOUD_API_URL +
"houses/" + str(self._house_id) + "/devices/" + str(self._id) + "/temperature/",
json={"temperature_manual": temp},
headers={"Authorization": "Token " + self._sst.key})
def switchOn(self) -> None:
self._update_flag = False

requests.post(SST_CLOUD_API_URL +
"houses/" + str(self._house_id) + "/devices/" + str(self._id) + "/status/",
json={"status": "on"},
headers={"Authorization": "Token " + self._sst.key})
self._status="on"
def switchOff(self) -> None:
self._update_flag = False
requests.post(SST_CLOUD_API_URL +
"houses/" + str(self._house_id) + "/devices/" + str(self._id) + "/status/",
json={"status": "off"},
headers={"Authorization": "Token " + self._sst.key})
self._status="off"

def switchToManual(self) -> None:
self._update_flag = False
requests.post(SST_CLOUD_API_URL +
"houses/" + str(self._house_id) + "/devices/" + str(self._id) + "/mode/",
json={"mode": "manual"},
headers={"Authorization": "Token " + self._sst.key})
self._mode="manual"

def switchToChart(self) -> None:
self._update_flag = False
requests.post(SST_CLOUD_API_URL +
"houses/" + str(self._house_id) + "/devices/" + str(self._id) + "/mode/",
json={"mode": "chart"},
headers={"Authorization": "Token " + self._sst.key})
self._mode="chart"



def set_target_temp(self,temp):

self._target_temperature = temp
@property
def get_status(self) -> str:
return self._status
@property
def get_avalible_status(self) -> bool:
if self._access_status == "available":
return "true"
else:
return "false"

@property
def get_device_id(self) -> str:
return self._id

@property
def get_device_name(self) -> str:
return self._device_name

@property
def get_device_type(self) -> int:
return self._type
@property
def get_current_floor_temperature(self) -> int:
return self._current_temperature

@property
def get_target_floor_temperature(self) -> int:
return self._target_temperature
@property
def get_mode(self) -> str:
return self._mode
def get_config(self):
return self.config


#Thermostat OKE-20
class ThermostatOKE20:

Expand Down

0 comments on commit 799d422

Please sign in to comment.