tuya-home-assistant icon indicating copy to clipboard operation
tuya-home-assistant copied to clipboard

Thermostat updates current_temperature only then Smart Life app is opened

Open mistrello96 opened this issue 1 year ago • 6 comments

Describe the bug

Thermostat current_temperature is updated only when smart life app is opened on the phone

Expected behavior

The thermostat current_temperature should be updatet regurarly, without the smart life opened on the phone

Diagnostics for integrations and devices

config_entry-tuya-f2e10bb6901610d9d311082b6b9011bd.json.txt

Screenshots

The problem is that the thermostat reports the current temperature only when smart life app is opened. As soon as the app is opened, this call is made to tuya servers Screenshot 2024-01-11 093249 that triggers a new data report from the thermostat. The same call should be done regurarly from the integration to "ask" the updated data from the thermostat

Home Assistant Version

  • e.g. 2024.1.2

mistrello96 avatar Jan 11 '24 08:01 mistrello96

I have found a workaround that works for me.

Using the IOT TUYA API, I have discovered all the device properties and found out that 唤醒通知 is a property called "week_up_btn" (probably misspelled wake).

If you set that property to true, it triggers the device to report the status and then reset to default.

The workaround is setting this property to true every x seconds, making the device report regularly.

I'm not sure if this applies to other devices, but for my thermostat works.

mistrello96 avatar Jan 12 '24 09:01 mistrello96

@mistrello96 which API have you used to see and set the property? I've tried multiple ones and only see the same properties as in android app / HASS

  • /v1.0/iot-03/devices/{{device_id}}/functions
  • /v1.2/iot-03/devices/{{device_id}}/specification
  • /v1.2/iot-03/devices/{{device_id}}/properties
  • /v1.0/iot-03/devices/{{device_id}}/properties
  • /v2.0/cloud/thing/{device_id}/shadow/properties

carlossg avatar Mar 04 '24 21:03 carlossg

I used the "query things data model" to extract the correct property, should be

  • /v2.0/cloud/thing/{{device_id}}/model

Once you identify the property you want to edit, i used the "send property" api to set it/trigger it

  • v2.0/cloud/thing/{{device_id}}/shadow/properties/issue

mistrello96 avatar Mar 05 '24 09:03 mistrello96

I've tried that but the model for my temperature sensor don't have that property

{
    "modelId": "e8edx0",
    "services": [
        {
            "actions": [],
            "code": "",
            "description": "",
            "events": [],
            "name": "默认服务",
            "properties": [
                {
                    "abilityId": 1,
                    "accessMode": "ro",
                    "code": "temp_current",
                    "description": "",
                    "extensions": {
                        "iconName": "icon-dp_temp",
                        "attribute": "1664",
                        "trigger": "direct"
                    },
                    "name": "温度",
                    "typeSpec": {
                        "max": 600,
                        "min": -99,
                        "scale": 1,
                        "step": 1,
                        "type": "value",
                        "typeDefaultValue": -99,
                        "unit": "℃"
                    }
                },
                {
                    "abilityId": 2,
                    "accessMode": "ro",
                    "code": "humidity_value",
                    "description": "",
                    "extensions": {
                        "iconName": "icon-shidu",
                        "attribute": "1664",
                        "trigger": "direct"
                    },
                    "name": "湿度",
                    "typeSpec": {
                        "max": 99,
                        "min": 0,
                        "scale": 0,
                        "step": 1,
                        "type": "value",
                        "typeDefaultValue": 0,
                        "unit": "%"
                    }
                },
                {
                    "abilityId": 4,
                    "accessMode": "ro",
                    "code": "battery_percentage",
                    "description": "",
                    "extensions": {
                        "iconName": "icon-dp_battery",
                        "attribute": "1152",
                        "trigger": "direct"
                    },
                    "name": "电池电量",
                    "typeSpec": {
                        "max": 100,
                        "min": 0,
                        "scale": 0,
                        "step": 1,
                        "type": "value",
                        "typeDefaultValue": 0,
                        "unit": "%"
                    }
                },
                {
                    "abilityId": 9,
                    "accessMode": "rw",
                    "code": "temp_unit_convert",
                    "description": "",
                    "extensions": {
                        "iconName": "icon-dp_mode",
                        "attribute": "1152"
                    },
                    "name": "温标",
                    "typeSpec": {
                        "range": [
                            "c",
                            "f"
                        ],
                        "type": "enum",
                        "typeDefaultValue": "c"
                    }
                },
                {
                    "abilityId": 23,
                    "accessMode": "rw",
                    "code": "temp_calibration",
                    "description": "",
                    "extensions": {
                        "iconName": "icon-dp_loop"
                    },
                    "name": "温度校准",
                    "typeSpec": {
                        "max": 20,
                        "min": -20,
                        "scale": 1,
                        "step": 1,
                        "type": "value",
                        "typeDefaultValue": -20,
                        "unit": "℃"
                    }
                },
                {
                    "abilityId": 24,
                    "accessMode": "rw",
                    "code": "hum_calibration",
                    "description": "",
                    "extensions": {
                        "iconName": "icon-icon-percent"
                    },
                    "name": "湿度校准",
                    "typeSpec": {
                        "max": 10,
                        "min": -10,
                        "scale": 0,
                        "step": 1,
                        "type": "value",
                        "typeDefaultValue": -10,
                        "unit": "%"
                    }
                }
            ]
        }
    ]
}

Tried POST to v2.0/cloud/thing/{{device_id}}/shadow/properties/issue but no luck, got a 501 request fail with unkown error

{
  "properties": {
    "week_up_btn": true
  }
}

@mistrello96 where did you get the low level logs to know what messages are sent when the smart life app is open?

carlossg avatar Mar 05 '24 10:03 carlossg

I got them in the device log

mistrello96 avatar Mar 05 '24 14:03 mistrello96