YOGYUI

광교아이파크::난방 Apple 홈킷 연동 (5) - Final 본문

홈네트워크(IoT)/광교아이파크

광교아이파크::난방 Apple 홈킷 연동 (5) - Final

요겨 2021. 1. 3. 02:39
반응형

[5] 마무리

거실, 침실, 컴퓨터방 모두 적절하게 액세서리 추가

        {
            "accessory": "Thermostat",
            "name": "Living room thermostat",
            "apiroute": "http://localhost:9999/heat/room1",
            "temperatureDisplayUnits": 0,
            "currentRelativeHumidity": false,
            "heatOnly": true,
            "maxTemp": 40,
            "minTemp": 5,
            "minStep": 0.5,
            "listener": true,
            "port": 12345,
            "manufacturer": "Bestin",
            "serial": "yogyui thermostat",
            "model": "Bestin",
            "pollInterval": 60
        },
        {
            "accessory": "Thermostat",
            "name": "Bed room thermostat",
            "apiroute": "http://localhost:9999/heat/room2",
            "temperatureDisplayUnits": 0,
            "currentRelativeHumidity": false,
            "heatOnly": true,
            "maxTemp": 40,
            "minTemp": 5,
            "minStep": 0.5,
            "listener": true,
            "port": 12346,
            "manufacturer": "Bestin",
            "serial": "yogyui thermostat",
            "model": "Bestin",
            "pollInterval": 60
        },
        {
            "accessory": "Thermostat",
            "name": "PC room thermostat",
            "apiroute": "http://localhost:9999/heat/room3",
            "temperatureDisplayUnits": 0,
            "currentRelativeHumidity": false,
            "heatOnly": true,
            "maxTemp": 40,
            "minTemp": 5,
            "minStep": 0.5,
            "listener": true,
            "port": 12347,
            "manufacturer": "Bestin",
            "serial": "yogyui thermostat",
            "model": "Bestin",
            "pollInterval": 60
        },

서버 쪽의 Notification 구문도 세 방 모두 대응할 수 있도록 수정

# app.py
""" 중략 """

def parse_control_result(chunk: bytearray):
    if len(chunk) < 10:
        return
    header = chunk[1]
    command = chunk[3]
    if header == 0x28 and command in [0x91, 0x92]:
        room_idx = chunk[5] & 0x0F
        room = rooms[room_idx]
        room.heat = bool(chunk[6] & 0x01)
        room.heat_temp_setting = (chunk[7] & 0x3F) + (chunk[7] & 0x40 > 0) * 0.5
        room.heat_temp_current = chunk[9] / 10.0
        # notification
        if room.heat_prev != room.heat or room.heat_temp_setting != room.heat_temp_setting_prev or not room.heat_init:
            try:
                url = "http://0.0.0.0:{}/".format(room.heat_listener_port)
                url += "targetHeatingCoolingState?value={}".format(int(room.heat))
                requests.get(url)
                print('Notify: {}'.format(url))
            except Exception:
                print("Connection refused by the server..")
                time.sleep(0.5)
            try:
                url = "http://0.0.0.0:{}/".format(room.heat_listener_port)
                url += "targetTemperature?value={}".format(room.heat_temp_setting)
                requests.get(url)
                print('Notify: {}'.format(url))
            except Exception:
                print("Connection refused by the server..")
                time.sleep(0.5)
            room.heat_init = True
        room.heat_prev = room.heat
        room.heat_temp_setting_prev = room.heat_temp_setting

""" 중략 """

홈브리지 재시작 후 액세서리 위치 설정

거실 - 난방 액세서리 추가
침실 - 난방 액세서리 추가
컴퓨터방 - 난방 액세서리 추가

가끔 난방 끄는걸 깜빡하고 외출할 때가 있어서 단순하게 아침에 꺼버리는 자동화를 추가했다

아침에 난방 모두 끄는 자동화 추가

currentTemperature 표기 시 0.5단위 truncation 이슈는 시간날 때 해결하도록 한다

(어차피 세 방 모두 eve-degree 온습도 센서 제품 배치해두어서 정밀도가 아쉽지는 않다)

>> 검색해보니 OS 이슈인 것 같다 (다른 온도 센서 제품도 모두 동일하게 0.5 단위로 잘린다)

community.home-assistant.io/t/homekit-temperature-conversion/139151/9

www.reddit.com/r/HomeKit/comments/d6wwfe/ios_13_homekit_siri_temperature_bug/

위 이슈들은 iOS 13일 경우 같은데 iOS 14에서도 동일하게 발생하고 있는듯...

 

조명때와 마찬가지로, 최소한의 비용으로 집안 난방 기능을 애플 디바이스로 제어할 수 있게 되었다!

 

[시리즈 링크]

광교아이파크::난방 Apple 홈킷 연동 (1)

광교아이파크::난방 Apple 홈킷 연동 (2)

광교아이파크::난방 Apple 홈킷 연동 (3)

광교아이파크::난방 Apple 홈킷 연동 (4)

광교아이파크::난방 Apple 홈킷 연동 (5)

반응형