rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.92k stars 561 forks source link

Climate Type Not Working #1137

Open MosheTzvi opened 1 year ago

MosheTzvi commented 1 year ago

The problem

Trying to add a Tuya thermostat as a Climate device via localTuya. While I can add/modify parameters on the thermostat as switches/select types, when I try and add the thermostat as a climate type, that entity shows as "Unavailable." It's possible the issue is that the temperatures are coming across as whole numbers without a decimal? e.g. 220 for 22.0 degrees? You can see in the dump below.

Environment

Steps to reproduce

1.Add New Device

  1. Entity type climate

Configuration configuration.yaml or config_flow

DP dump

Provide Home Assistant taceback/logs

{ "home_assistant": { "installation_type": "Home Assistant OS", "version": "2022.11.3", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.10.7", "docker": true, "arch": "aarch64", "timezone": "Asia/Jerusalem", "os_name": "Linux", "os_version": "5.15.74", "supervisor": "2022.10.2", "host_os": "Home Assistant OS 9.3", "docker_version": "20.10.18", "chassis": "embedded", "run_as_root": true }, "custom_components": { "hacs": { "version": "1.28.3", "requirements": [ "aiogithubapi>=22.2.4" ] }, "yi_hack": { "version": "0.4.2", "requirements": [] }, "entities_calendar": { "version": "0.0.9", "requirements": [] }, "gmg": { "version": "1.0.0", "requirements": [] }, "home_connect_alt": { "version": "0.5.9", "requirements": [ "home-connect-async==0.7.5" ] }, "localtuya": { "version": "4.1.1", "requirements": [] }, "dahua": { "version": "0.5.0", "requirements": [] } }, "integration_manifest": { "domain": "localtuya", "name": "LocalTuya integration", "version": "4.1.1", "documentation": "https://github.com/rospogrigio/localtuya/", "dependencies": [], "codeowners": [ "@rospogrigio", "@postlund" ], "issue_tracker": "https://github.com/rospogrigio/localtuya/issues", "requirements": [], "config_flow": true, "iot_class": "local_push", "is_built_in": false }, "data": { "device_config": { "friendly_name": "Office Heat", "host": "192.168.0.32", "local_key": "b66275b41f3e4116", "protocol_version": "3.3", "entities": [ { "friendly_name": "Mode", "select_options": "cold;hot;wind", "select_options_friendly": "AC;Heat;Fan", "restore_on_reconnect": true, "is_passive_entity": false, "id": 4, "platform": "select" }, { "friendly_name": "On", "current": 1, "restore_on_reconnect": true, "is_passive_entity": false, "id": 1, "platform": "switch" }, { "friendly_name": "Office Temperature", "target_temperature_dp": 2, "current_temperature_dp": 3, "temperature_step": 1, "max_temperature_dp": 21, "min_temperature_dp": 20, "precision": 1, "temperature_unit": "celsius", "id": 3, "platform": "climate" } ], "model": "Temp", "device_id": "bf490317a84d8f651e3agl", "dps_strings": [ "1 (value: True)", "2 (value: 220)", "3 (value: 213)", "4 (value: hot)", "5 (value: 1)", "8 (value: False)", "13 (value: False)", "16 (value: 0)", "20 (value: -20)", "21 (value: 60)", "25 (value: 1)", "26 (value: False)", "31 (value: False)", "41 (value: 2)", "42 (value: 1)", "101 (value: False)", "105 (value: 10)", "107 (value: 35)" ], "product_key": "gw173aldekvpzalg" }, "device_cloud_info": { "active_time": 1663937130, "biz_type": 18, "category": "wk", "create_time": 1663937130, "icon": "smart/program_category_icon/wk.png", "id": "bf490317a84d8f651e3agl", "ip": "164.138.117.124", "lat": "33.0111", "local_key": "b66275b41f3e4116", "lon": "35.2903", "model": "Temp", "name": "Office Heat", "online": true, "owner_id": "61792271", "product_id": "gw173aldekvpzalg", "product_name": "Temp", "status": [ { "code": "switch", "value": true }, { "code": "temp_set", "value": 220 }, { "code": "temp_current", "value": 212 }, { "code": "mode", "value": "hot" }, { "code": "work_state", "value": "1" }, { "code": "child_lock", "value": false }, { "code": "sound", "value": false }, { "code": "fault", "value": 0 }, { "code": "temp_correction", "value": -20 }, { "code": "upper_temp", "value": 60 }, { "code": "sensor_choose", "value": "1" }, { "code": "frost", "value": false }, { "code": "reset", "value": false }, { "code": "backlight", "value": "2" }, { "code": "work_days", "value": "1" }, { "code": "week_program3", "value": "BgAAyAgAAKALHgCgDB4AoBEAANwWAACgCAAA3BcAAKA=" }, { "code": "zhufan", "value": false }, { "code": "qidongwencha", "value": 10 }, { "code": "xianwen", "value": 35 } ], "sub": false, "time_zone": "+03:00", "uid": "eu1658465975439W753w", "update_time": 1668579162, "uuid": "2261917ab95ae1a3" } } }

Additional information

RithyNicolasTAN commented 1 year ago

Hi.

I think I have the same issue : [ "integration_manifest": { "domain": "localtuya", "name": "LocalTuya integration", "version": "4.1.1", "documentation": "https://github.com/rospogrigio/localtuya/", "dependencies": [], "codeowners": [ "@rospogrigio", "@postlund" ], "issue_tracker": "https://github.com/rospogrigio/localtuya/issues", "requirements": [], "config_flow": true, "iot_class": "local_push", "is_built_in": false }, "data": { "device_config": { "friendly_name": "Pompe \u00e0 chaleur", "host": "192.168.1.244", "local_key": "XXX", "protocol_version": "3.3", "entities": [ { "friendly_name": "POMPE A CHALEUR LOCAL", "target_temperature_dp": 2, "current_temperature_dp": 3, "temperature_step": 0.5, "id": 1, "platform": "climate" } ], "scan_interval": 60, "model": "Smart RM", "device_id": "731030578cce4ef6da59", "dps_strings": [ "1 (value: True)", "2 (value: 185)", "3 (value: 185)", "4 (value: Manual)", "6 (value: False)", "12 (value: 0)", "101 (value: False)", "102 (value: False)", "103 (value: 0)", "104 (value: 3)", "105 (value: 15)", "106 (value: True)", "107 (value: True)", "108 (value: False)", "109 (value: 0)", "110 (value: 5)", "111 (value: 2)", "112 (value: 45)", "113 (value: 5)", "114 (value: 25)", "115 (value: 10)", "116 (value: in)", "117 (value: off)", "118 (value: 0days)" ], "product_key": "XXX" },

rootd commented 1 year ago

I'm having the same issue.

{ "home_assistant": { "installation_type": "Home Assistant OS", "version": "2022.12.1", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.10.7", "docker": true, "arch": "aarch64", "timezone": "Europe/Berlin", "os_name": "Linux", "os_version": "5.15.61-v8", "supervisor": "2022.11.2", "host_os": "Home Assistant OS 9.3", "docker_version": "20.10.18", "chassis": "embedded", "run_as_root": true }, "custom_components": { "tuya_local": { "version": "0.21.0", "requirements": [ "pycryptodome~=3.16.0", "tinytuya==1.9.1" ] }, "localtuya": { "version": "4.1.1", "requirements": [] }, "hacs": { "version": "1.28.3", "requirements": [ "aiogithubapi>=22.2.4" ] } }, "integration_manifest": { "domain": "localtuya", "name": "LocalTuya integration", "version": "4.1.1", "documentation": "https://github.com/rospogrigio/localtuya/", "dependencies": [], "codeowners": [ "@rospogrigio", "@postlund" ], "issue_tracker": "https://github.com/rospogrigio/localtuya/issues", "requirements": [], "config_flow": true, "iot_class": "local_push", "is_built_in": false }, "data": { "device_config": { "friendly_name": "Thermostat Schlafzimmer", "host": "192.168.178.38", "local_key": "XXX", "protocol_version": "3.3", "entities": [ { "friendly_name": "Thermostat Schlafzimmer", "target_temperature_dp": 3, "current_temperature_dp": 2, "temperature_step": 0.5, "max_temperature_dp": 21, "precision": 0.1, "temperature_unit": "celsius", "target_precision": 0.1, "id": 1, "platform": "climate" } ], "model": "Temp", "device_id": "bf24f286ebdafb9c2c56d0", "dps_strings": [ "1 (value: True)", "2 (value: 210)", "3 (value: 223)", "4 (value: cold)", "5 (value: 0)", "8 (value: False)", "13 (value: False)", "16 (value: 0)", "20 (value: -43)", "21 (value: 28)", "25 (value: 1)", "26 (value: False)", "31 (value: False)", "41 (value: 1)", "42 (value: 1)", "101 (value: False)", "105 (value: 5)", "107 (value: 35)" ], "product_key": "gw173aldekvpzalg" }, "device_cloud_info": { "active_time": 1670783036, "biz_type": 18, "category": "wk", "create_time": 1670783036, "icon": "smart/program_category_icon/wk.png", "id": "bf24f286ebdafb9c2c56d0", "ip": "84.177.141.48", "lat": "49.9618", "local_key": "XXX", "lon": "11.6256", "model": "Temp", "name": "Thermostat Schlafzimmer", "online": true, "owner_id": "54419249", "product_id": "gw173aldekvpzalg", "product_name": "Temp", "status": [ { "code": "switch", "value": true }, { "code": "temp_set", "value": 210 }, { "code": "temp_current", "value": 223 }, { "code": "mode", "value": "cold" }, { "code": "child_lock", "value": false } ], "sub": false, "time_zone": "+01:00", "uid": "eu1649006185139juaPH", "update_time": 1670783049, "uuid": "d7325c5840a5fda2" } } }

rootd commented 1 year ago

Using a friendly name without spaces seems to have fixed the problem for me.

gwilford commented 1 year ago

I'm having the same issue. Tried numerous climate entity configurations. The state always shows as unknown in HA. Using a friendly name without spaces didn't work for me. Could you post a full working config?

However, the climate entity does have valid attributes;

hvac_modes: null
min_temp: 7
max_temp: 35
target_temp_step: 0.5
friendly_name: Floor
supported_features: 1
current_temperature: 18.8
temperature: 12
raw_state: true
rootd commented 1 year ago

this works for me. If you need any other config file just let me know

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.1.1",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.10.7",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Europe/Berlin",
    "os_name": "Linux",
    "os_version": "5.15.76-v8",
    "supervisor": "2022.12.1",
    "host_os": "Home Assistant OS 9.4",
    "docker_version": "20.10.19",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "dwains_dashboard": {
      "version": "3.3.0",
      "requirements": []
    },
    "localtuya": {
      "version": "5.0.0",
      "requirements": []
    },
    "hacs": {
      "version": "1.28.4",
      "requirements": [
        "aiogithubapi>=22.2.4"
      ]
    }
  },
  "integration_manifest": {
    "domain": "localtuya",
    "name": "LocalTuya integration",
    "version": "5.0.0",
    "documentation": "https://github.com/rospogrigio/localtuya/",
    "dependencies": [],
    "codeowners": [
      "@rospogrigio",
      "@postlund"
    ],
    "issue_tracker": "https://github.com/rospogrigio/localtuya/issues",
    "requirements": [],
    "config_flow": true,
    "iot_class": "local_push",
    "is_built_in": false
  },
  "data": {
    "device_config": {
      "friendly_name": "Thermostat",
      "host": "192.168.178.38",
      "local_key": "******************",
      "protocol_version": "3.3",
      "entities": [
        {
          "friendly_name": "Thermostat",
          "target_temperature_dp": 2,
          "current_temperature_dp": 3,
          "temperature_step": 0.5,
          "precision": 0.1,
          "temperature_unit": "celsius",
          "target_precision": 0.1,
          "heuristic_action": false,
          "id": 1,
          "platform": "climate"
        }
      ],
      "model": "Temp",
      "device_id": "bf24f286ebdafb9c2c56d0",
      "dps_strings": [
        "1 (value: True)",
        "2 (value: 160)",
        "3 (value: 222)",
        "4 (value: hot)",
        "5 (value: 0)",
        "8 (value: False)",
        "13 (value: False)",
        "16 (value: 0)",
        "20 (value: -43)",
        "21 (value: 28)",
        "25 (value: 1)",
        "26 (value: False)",
        "31 (value: False)",
        "41 (value: 1)",
        "42 (value: 1)",
        "101 (value: False)",
        "105 (value: 5)",
        "107 (value: 35)"
      ],
      "product_key": "gw173aldekvpzalg"
    }
  }
}
type: thermostat
entity: climate.thermostat
name: Thermostat
bdkacz commented 1 year ago

I have the same problem - after add climate device it state is "unknown" - both with version 4.1.1 and 5.0

localtuya-c696f85a6b359bb8bfb236084538a021-Malgosia-7045d870878adefcea8dadd696ba080a.json.txt

dkitz commented 1 year ago

Same issue here, state unavailable. Version 5.0 and tested with 3.5.0.

jawn22 commented 1 year ago

Having the same problem here too

JDJuergenD commented 1 year ago

It works with AVATTO WT50-EH-wifi. You must set "HVAC Mode DP" and "HVAC Mode Set" Setting for all functions not tested.

Screenshot (284) Settings: Screenshot (281) Screenshot (283)

miki3421 commented 1 year ago

It works with AVATTO WT50-EH-wifi. You must set "HVAC Mode DP" and "HVAC Mode Set" Setting for all functions not tested.

Screenshot (284) Settings: Screenshot (281) Screenshot (283)

Worked for me as well, thanks. I needed to set also Precision to 1; otherwise, the values where x.x instead of xx.x

KazaiTg commented 11 months ago

Hi

I have device working as it suposed to. All other sugestions are good but this options must be changed. You must remove device and add it again in localtuya. ID must be set to value: 4 ( can only be set on adding device on start ) HVAC MODE DP ( set to value ): 1 and HVAC Mode Set to value: True/False In this configuration thermostat have two options ON and OFF and is properly set to heating.

In addition I have managed to fix information on device status - when it is working ( HEATING ) You must set HVAC Current Action DP ( must be set to value ): 5
But this attribute has in this device values between 1 and 0 and local tuya has only TRUE FALSE so we need to edit file in /root/homeassistant/custom_components/localtuya EDIT file named "climate.py" and add this four lines: "1/0": { CURRENT_HVAC_HEAT: "1", CURRENT_HVAC_IDLE: "0", }, to section HVAC_ACTION_SETS = { ...... } after change it will looke like this HVAC_ACTION_SETS = { "True/False": { CURRENT_HVAC_HEAT: True, CURRENT_HVAC_IDLE: False, }, "open/close": { CURRENT_HVAC_HEAT: "open", CURRENT_HVAC_IDLE: "close", }, "heating/no_heating": { CURRENT_HVAC_HEAT: "heating", CURRENT_HVAC_IDLE: "no_heating", }, "Heat/Warming": { CURRENT_HVAC_HEAT: "Heat", CURRENT_HVAC_IDLE: "Warming", }, "1/0": { CURRENT_HVAC_HEAT: "1", CURRENT_HVAC_IDLE: "0", }, }

Save file. AFTER that you must restart yout home assistant end choose CONFIGURE in local tuya and EDIT device and change HVAC current action set
to value you just added in climate.py file
1/0 After that you have proper climate device with on off whole thermostat and heating status proper sended from device when it trigers it.