Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Михаил Шутов committed Feb 8, 2024
2 parents 7a50084 + 7d11790 commit 40f6787
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 13 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@

После авторизации в Home Assistant (далее НА) добавляются все устройства аккаунта.

*Модели устройств на которых проверена работоспособность:*
*Модели контроллеров на которых проверена работоспособность:*
* *CLIMATIC*
* *H2000+ pro*
* *H2000+*
* *H2000*
* *H1000*
* *H1000+*

*Модели термостатов на которых проверена работоспособность:*
* *T100 (H-1)*
* *T102 (H-2)*

`* на данный момент устройства термостат не передают котловые сенсоры`

## Возможности
В НА из ZONT добавляются следующие объекты каждого устройства:
* Контуры отопления
Expand Down
4 changes: 2 additions & 2 deletions custom_components/zont_ha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator, UpdateFailed
)
from .const import DOMAIN, PLATFORMS
from .const import DOMAIN, PLATFORMS, TIME_UPDATE
from .core.zont import Zont

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(self, hass, zont):
hass,
_LOGGER,
name="ZONT",
update_interval=timedelta(seconds=60),
update_interval=timedelta(seconds=TIME_UPDATE),
)
self.zont = zont

Expand Down
21 changes: 15 additions & 6 deletions custom_components/zont_ha/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from . import ZontCoordinator, DOMAIN
from .const import MANUFACTURER, TIME_OUT_REQUEST, MAX_TEMP_AIR, MIN_TEMP_AIR
from .const import (
MANUFACTURER, TIME_OUT_REQUEST, MAX_TEMP_AIR, MIN_TEMP_AIR,
MODELS_THERMOSTAT_ZONT
)
from .core.exceptions import TemperatureOutOfRangeError, SetHvacModeError
from .core.models_zont import DeviceZONT, HeatingModeZONT
from .core.zont import Zont
Expand Down Expand Up @@ -156,11 +159,17 @@ async def async_set_preset_mode(self, preset_mode):
self._device, preset_mode
)
if heating_mode is not None:
await self._zont.set_heating_mode(
device=self._device,
heating_circuit=self._heating_circuit,
heating_mode_id=heating_mode.id
)
if self._device.model in MODELS_THERMOSTAT_ZONT:
await self._zont.set_heating_mode_all_heating_circuits(
device=self._device,
heating_mode=heating_mode
)
else:
await self._zont.set_heating_mode(
device=self._device,
heating_circuit=self._heating_circuit,
heating_mode_id=heating_mode.id
)
else:
await self._zont.set_target_temperature(
device=self._device,
Expand Down
4 changes: 4 additions & 0 deletions custom_components/zont_ha/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

URL_SEND_COMMAND_ZONT_OLD = 'https://lk.zont-online.ru/api/send_z3k_command'

URL_SEND_COMMAND_ZONT = 'https://lk.zont-online.ru/api/widget/v2/activate_heating_mode'
URL_GET_DEVICES = 'https://lk.zont-online.ru/api/widget/v2/get_devices'
URL_SET_TARGET_TEMP = 'https://lk.zont-online.ru/api/widget/v2/set_target_temp'
URL_SET_GUARD = 'https://lk.zont-online.ru/api/widget/v2/set_guard'
Expand Down Expand Up @@ -62,3 +63,6 @@
COUNTER_REPEAT = 18
TIME_OUT_REPEAT = 10
TIME_OUT_REQUEST = 2
TIME_UPDATE = 60

MODELS_THERMOSTAT_ZONT = ('T100', 'T102')
2 changes: 1 addition & 1 deletion custom_components/zont_ha/core/models_zont.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ControlEntityZONT(BaseEntityZONT):
class HeatingCircuitZONT(ControlEntityZONT):
"""Контур отопления"""

status: str
status: str | None
active: bool
actual_temp: float | None
is_off: bool
Expand Down
4 changes: 4 additions & 0 deletions custom_components/zont_ha/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def check_send_command(func):
async def check_response(*args, **kwargs):
device = kwargs.get('device')
heating_circuit = kwargs.get('heating_circuit')
heating_mode = kwargs.get('heating_mode')
target_temp = kwargs.get('target_temp')
guard_zone = kwargs.get('guard_zone')
custom_control = kwargs.get('control')
Expand All @@ -30,6 +31,9 @@ async def check_response(*args, **kwargs):
elif guard_zone is not None:
control = guard_zone
set_value = command
elif heating_mode is not None:
control = heating_mode
set_value = 'Установлен во всех контурах'
else:
return func

Expand Down
18 changes: 16 additions & 2 deletions custom_components/zont_ha/core/zont.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
URL_GET_DEVICES, URL_SET_TARGET_TEMP, URL_SEND_COMMAND_ZONT_OLD,
MIN_TEMP_AIR, MAX_TEMP_AIR, MIN_TEMP_GVS, MAX_TEMP_GVS, MIN_TEMP_FLOOR,
MAX_TEMP_FLOOR, MATCHES_GVS, MATCHES_FLOOR, URL_TRIGGER_CUSTOM_BUTTON,
URL_SET_GUARD, BINARY_SENSOR_TYPES,
URL_SET_GUARD, BINARY_SENSOR_TYPES, URL_SEND_COMMAND_ZONT,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -70,7 +70,7 @@ async def get_update(self):
_LOGGER.error(self.error.error_ui)
return status_code
self.data = AccountZont.parse_raw(text)
_LOGGER.info(f'Данные аккаунта {self.mail} обновлены')
_LOGGER.debug(f'Данные аккаунта {self.mail} обновлены')
return status_code

def get_device(self, device_id: int) -> DeviceZONT | None:
Expand Down Expand Up @@ -264,6 +264,20 @@ async def set_heating_mode(
_LOGGER.debug(await response.text())
return response

@check_send_command
async def set_heating_mode_all_heating_circuits(
self, device: DeviceZONT, heating_mode: HeatingModeZONT
) -> ClientResponse:
"""Отправка команды на установку нужного режима для всех контуров."""
return await self.session.post(
url=URL_SEND_COMMAND_ZONT,
json={
'device_id': device.id,
'mode_id': heating_mode.id
},
headers=self.headers
)

@check_send_command
async def toggle_switch(
self, device: DeviceZONT, control: CustomControlZONT,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/zont_ha/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"integration_type": "hub",
"dependencies": ["http", "zeroconf"],
"requirements": [],
"version": "0.2.3"
"version": "0.2.4"
}

0 comments on commit 40f6787

Please sign in to comment.