Skip to content

Commit

Permalink
Исправление для дробной температуры
Browse files Browse the repository at this point in the history
  • Loading branch information
and7ey committed Jun 5, 2024
1 parent c865c46 commit 5fd0044
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions custom_components/haier_evo/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def login(self, refresh=False):
resp = requests.post(refresh_path, data={'refreshToken': self._refreshtoken})
_LOGGER.debug(f"Refresh ({self._email}) status code: {resp.status_code}")

_LOGGER.debug(f"{resp.json()}")
if resp: _LOGGER.debug(f"{resp.json()}")

if (
resp.status_code == 200
Expand Down Expand Up @@ -120,7 +120,9 @@ def pull_data(self):
_LOGGER.debug(resp.text)
containers = resp.json().get("data", {}).get("presentation", {}).get("layout", {}).get('scrollContainer', [])
for item in containers:
if item.get("contractName", "") == "deviceList":
component_id = item.get("trackingData", {}).get("component", {}).get("componentId", "")
_LOGGER.debug(component_id)
if item.get("contractName", "") == "deviceList" and component_id == "72a6d224-cb66-4e6d-b427-2e4609252684": # check for smart devices only
state_data = item.get("state", {})
state_json = json.loads(state_data)
devices = state_json.get('items', [{}])
Expand Down Expand Up @@ -224,17 +226,17 @@ def __init__(self, device_mac: str, device_serial: str, device_title: str, haier
attributes = resp.json().get("attributes", {})
for attr in attributes:
if attr.get('name', '') == self._config_current_temperature: # Температура в комнате
self._current_temperature = int(attr.get('currentValue'))
self._current_temperature = float(attr.get('currentValue'))
elif attr.get('name', '') == self._config_mode: # Режимы
self._mode = int(attr.get('currentValue'))
elif attr.get('name', '') == self._config_fan_mode: # Скорость вентилятора
self._fan_mode = int(attr.get('currentValue'))
elif attr.get('name', '') == self._config_status: # Включение/выключение
self._status = int(attr.get('currentValue'))
elif attr.get('name', '') == self._config_target_temperature: # Целевая температура
self._target_temperature = int(attr.get('currentValue'))
self._min_temperature = int(attr.get('range', {}).get('data', {}).get('minValue', 0))
self._max_temperature = int(attr.get('range', {}).get('data', {}).get('maxValue', 0))
self._target_temperature = float(attr.get('currentValue'))
self._min_temperature = float(attr.get('range', {}).get('data', {}).get('minValue', 0))
self._max_temperature = float(attr.get('range', {}).get('data', {}).get('maxValue', 0))

settings = resp.json().get("settings", {})
firmware = settings.get('firmware', {}).get('value', None)
Expand Down Expand Up @@ -311,15 +313,15 @@ def _handle_status_update(self, received_message: dict) -> None:

for key, value in message_statuses[0]['properties'].items():
if key == self._config_current_temperature: # Температура в комнате
self._current_temperature = int(value)
self._current_temperature = float(value)
if key == self._config_mode: # Режимы
self._mode = self._config.get_value_from_mappings(self._config_mode, int(value))
if key == self._config_fan_mode: # Скорость вентилятора
self._fan_mode = self._config.get_value_from_mappings(self._config_fan_mode, int(value))
if key == self._config_status: # Включение/выключение
self._status = int(value)
if key == self._config_target_temperature: # Целевая температура
self._target_temperature = int(value)
self._target_temperature = float(value)


def _on_open(self, ws: websocket.WebSocket) -> None:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/haier_evo/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/and7ey/haier_evo/issues",
"requirements": ["requests"],
"version": "0.2.1",
"version": "0.2.2",
"zeroconf": []
}

0 comments on commit 5fd0044

Please sign in to comment.