DEVELOPMENT ENVIRONMENT

~liljamo/ha-ouman-eh800

ref: 084a34e5eb98102d3beeff54d9c1368155cec938 ha-ouman-eh800/custom_components/ouman_eh800/eh800.py -rw-r--r-- 1.6 KiB
084a34e5Jonni Liljamo format 19 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""TODO"""

import logging
import requests

_LOGGER = logging.getLogger(__name__)


class EH800:
    """TODO"""

    def __init__(self, host: str, port: int, username: str, password: str) -> None:
        """TODO"""
        self._uri = f"http://{host}:{port}"
        self._login = f"uid={username};pwd={password};"

        self._outside_temp = 0.0
        self._l1_room_temp = 0.0
        self._l1_supply_temp = 0.0

    def _refresh_login(self) -> bool:
        """TODO"""
        r = requests.get(f"{self._uri}/login?{self._login}")

        if r.text[:-1] == "login?result=ok;":
            _LOGGER.debug("Login ok")
            return True

        _LOGGER.debug("Login error")
        return False

    def _request_value(self, register) -> str:
        """TODO"""
        if not self._refresh_login():
            return ""

        r = requests.get(f"{self._uri}/request?{register}")
        eq_index = r.text.find("=")
        sc_index = r.text.find(";")
        return r.text[eq_index + 1 : sc_index]

    def get_outside_temp(self) -> float:
        """TODO"""
        return self._outside_temp

    def update_outside_temp(self):
        """TODO"""
        self._outside_temp = self._request_value("S_227_85")

    def get_l1_room_temp(self) -> float:
        """TODO"""
        return self._l1_room_temp

    def update_l1_room_temp(self):
        """TODO"""
        self._l1_room_temp = self._request_value("S_261_85")

    def get_l1_supply_temp(self) -> float:
        """TODO"""
        return self._l1_supply_temp

    def update_l1_supply_temp(self):
        """TODO"""
        self._l1_supply_temp = self._request_value("S_259_85")