mihai-dinculescu / tapo

Unofficial Tapo API Client. Works with TP-Link Tapo smart devices. Tested with light bulbs (L510, L520, L530, L610, L630), light strips (L900, L920, L930), plugs (P100, P105, P110, P115, P300), hubs (H100), switches (S200B) and sensors (KE100, T100, T110, T300, T310, T315).
MIT License
339 stars 35 forks source link

Support for KE100 (TRV) via H100 #118

Closed pwoerndle closed 9 months ago

pwoerndle commented 10 months ago

Hi everyone, I recently got a kit with a H100 (https://www.tp-link.com/en/home-networking/smart-hub/tapo-h100/) Hub and a KE100 (https://www.tp-link.com/en/home-networking/smart-thermostat/ke100/) thermostat.

Following some of the examples for other child devices on the hub I was able to create the code read data from the KE100 attached to the hub. I'm struggling to get write operations going for the KE100 e.g. to set the target temperature.

Did you foresee write operations to child devices on the hub? Do you have any examples I could follow to maybe translate to operations on the KE100 TRV?

mihai-dinculescu commented 10 months ago

Did you foresee write operations to child devices on the hub?

Yeah, I'm happy to add whatever is useful to people. Unfortunately, I have electric radiators, so I cannot test the KE100 TRV myself.

Can you please execute get_child_device_component_list_json on the hub and paste what's returned for the KE100 TRV here? The first step is figuring out which is the operation that you need.

pwoerndle commented 10 months ago

This is what I get from get_child_device_component_list_json on the hub:

Object {
    "child_component_list": Array [Object {
            "component_list": Array [Object {
                    "id": String("device"),
                    "ver_code": Number(2)
                }, Object {
                    "id": String("quick_setup"),
                    "ver_code": Number(3)
                }, Object {
                    "id": String("time"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("device_local_time"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("schedule"),
                    "ver_code": Number(2)
                }, Object {
                    "id": String("countdown"),
                    "ver_code": Number(2)
                }, Object {
                    "id": String("account"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("synchronize"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("sunrise_sunset"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("cloud_connect"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("iot_cloud"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("frost_protection"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("child_protection"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("temperature"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("temp_control"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("remove_scale"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("shutdown_mode"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("progress_calibration"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("early_start"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("temp_record"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("screen_setting"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("night_mode"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("smart_control_schedule"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("firmware"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("battery_detect"),
                    "ver_code": Number(1)
                }, Object {
                    "id": String("window_open_detect"),
                    "ver_code": Number(1)
                }
            ],
            "device_id": String("REDACTED")
        }
    ],
    "start_index": Number(0),
    "sum": Number(1)
}

I was actually able to get some working example for reading and writing the TRV values. Any good way to share the code with you? I though used the parameters which are exposed by the child device directly. See the following listing for the data exposed from the device.

Object {
    "at_low_battery": Bool(false),
    "avatar": String("kasa_trv"),
    "bind_count": Number(1),
    "category": String("subg.trv"),
    "child_protection": Bool(false),
    "current_temp": Number(20.7),
    "device_id": String("REDACTED"),
    "frost_protection_on": Bool(true),
    "fw_ver": String("2.1.0 Build 221209 Rel.102225"),
    "hw_id": String("REDACTED"),
    "hw_ver": String("1.0"),
    "jamming_rssi": Number(-107),
    "jamming_signal_level": Number(2),
    "lastOnboardingTimestamp": Number(1697277340),
    "location": String(""),
    "mac": String("AREDACTED"),
    "max_control_temp": Number(30),
    "min_control_temp": Number(5),
    "model": String("KE100"),
    "nickname": String("REDACTED"),
    "oem_id": String("REDACTED"),
    "parent_device_id": String("REDACTED"),
    "region": String("REDACTED"),
    "rssi": Number(-18),
    "signal_level": Number(3),
    "specs": String("EU"),
    "status": String("online"),
    "target_temp": Number(17.0),
    "temp_offset": Number(0),
    "temp_unit": String("celsius"),
    "trv_states": Array [],
    "type": String("SMART.KASAENERGY")
}

I'm happy to help out with getting support for KE100 in. Eventually I'm looking to get some support in HA for the KE100 devices and I see this as an enabler for this.

mihai-dinculescu commented 10 months ago

Help will be most welcome! In that case, it would be best to go through the regular process and get a PR started.

pwoerndle commented 10 months ago

I've created pull request #121 with my initial support for the KE100. The main challenge I have is that the API returns an empty result when setting a device parameter. This currently creates a runtime EmptyResult error.

mihai-dinculescu commented 9 months ago

Released in v0.7.6. Thank you for this amazing effort!