make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.31k stars 512 forks source link

Pool heat pump preset modes not correct #838

Closed bezigebever closed 1 year ago

bezigebever commented 1 year ago

Describe the bug I have a pool heat that shows in home assistant following attributes:

hvac_modes: off, heat 
min_temp: 18 
max_temp: 40 
target_temp_step: 1 
preset_modes: sleep, activity 
current_temperature: 28 
temperature: 28 
hvac_action: idle 
preset_mode: activity 
error: OK 
error_2: 0 icon: mdi:hot-tub 
friendly_name: Warmtepomp 
supported_features: 17

When using the Tuya smart app I have following options: Mode: Intelligent or Mute (which is silent mode) Heating, Refrigeration, Intelligent (which is auto mode)

Expected behavior I would expect to have similiar naming as in the Tuya app.

Additional context Diagnostics

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.6.3",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.4",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Brussels",
    "os_name": "Linux",
    "os_version": "6.1.29",
    "supervisor": "2023.06.2",
    "host_os": "Home Assistant OS 10.2",
    "docker_version": "23.0.6",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "adaptive_lighting": {
      "version": "1.14.0",
      "requirements": [
        "ulid-transform"
      ]
    },
    "hikvision_next": {
      "version": "1.0.6",
      "requirements": [
        "xmltodict==0.13.0",
        "hikvisionapi==0.3.2",
        "requests-toolbelt==0.10.1"
      ]
    },
    "tuya_local": {
      "version": "2023.6.1",
      "requirements": [
        "pycryptodome~=3.18",
        "tinytuya==1.12.8"
      ]
    },
    "tesla_custom": {
      "version": "3.14.0",
      "requirements": [
        "teslajsonpy==3.9.0"
      ]
    },
    "robonect": {
      "version": "v1.0.11",
      "requirements": [
        "aiorobonect>=0.2.5",
        "jsonpath"
      ]
    },
    "solaredge_modbus": {
      "version": "1.4.0",
      "requirements": [
        "pymodbus==3.1.1"
      ]
    },
    "hacs": {
      "version": "1.32.1",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "afvalbeheer": {
      "version": "5.2.6",
      "requirements": [
        "rsa",
        "pycryptodome"
      ]
    },
    "lms_tts_notify": {
      "version": "0.3.13",
      "requirements": []
    },
    "frigate": {
      "version": "4.0.0",
      "requirements": [
        "pytz==2022.7"
      ]
    },
    "browser_mod": {
      "version": "1.5.3",
      "requirements": []
    },
    "ltss": {
      "version": "2.1.0",
      "requirements": [
        "sqlalchemy>=2.0,<3.0",
        "psycopg2-binary>=2.8,<3.0",
        "geoalchemy2>=0.13,<1.0"
      ]
    },
    "youfone_be": {
      "version": "4.0.0",
      "requirements": []
    },
    "panasonic_cc": {
      "version": "1.0.32",
      "requirements": []
    },
    "esxi_stats": {
      "version": "0.6.4",
      "requirements": [
        "pyvmomi==7.0.3"
      ]
    },
    "solaredgeoptimizers": {
      "version": "1.2.2",
      "requirements": [
        "solaredgeoptimizers==1.0.12",
        "jsonfinder==0.4.2"
      ]
    },
    "weatherflow": {
      "version": "1.0.14",
      "requirements": [
        "pyweatherflowrest==1.0.9"
      ]
    }
  },
  "integration_manifest": {
    "domain": "tuya_local",
    "name": "Tuya Local",
    "codeowners": [
      "@make-all"
    ],
    "config_flow": true,
    "dependencies": [],
    "documentation": "https://github.com/make-all/tuya-local",
    "integration_type": "device",
    "iot_class": "local_push",
    "issue_tracker": "https://github.com/make-all/tuya-local/issues",
    "requirements": [
      "pycryptodome~=3.18",
      "tinytuya==1.12.8"
    ],
    "version": "2023.6.1",
    "is_built_in": false
  },
  "data": {
    "name": "Warmtepomp",
    "type": "gardenpac_heatpump",
    "device_id": "**REDACTED**",
    "device_cid": "",
    "local_key": "**REDACTED**",
    "host": "**REDACTED**",
    "protocol_version": "auto",
    "tinytuya_version": "1.12.8",
    "api_version_set": 3.3,
    "api_version_used": 3.3,
    "api_working": true,
    "status": {},
    "cached_state": {
      "updated_at": 1687681222.2206607,
      "1": true,
      "102": 28,
      "103": true,
      "104": 60,
      "105": "warm",
      "106": 32,
      "107": 18,
      "108": 40,
      "115": 0,
      "116": 0,
      "117": true
    },
    "pending_state": {},
    "connected": true,
    "force_dps": [],
    "home_assistant": {
      "name": "Warmtepomp",
      "name_by_user": null,
      "disabled": false,
      "disabled_by": null,
      "entities": [
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "climate.warmtepomp",
            "state": "heat",
            "attributes": {
              "hvac_modes": [
                "off",
                "heat"
              ],
              "min_temp": 18,
              "max_temp": 40,
              "target_temp_step": 1.0,
              "preset_modes": [
                "sleep",
                "activity"
              ],
              "current_temperature": 28,
              "temperature": 32,
              "hvac_action": "idle",
              "preset_mode": "activity",
              "error": "OK",
              "error_2": 0,
              "icon": "mdi:hot-tub",
              "friendly_name": "Warmtepomp",
              "supported_features": 17
            },
            "last_changed": "2023-06-25T08:06:20.735581+00:00",
            "last_updated": "2023-06-25T08:18:41.648308+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": "power_factor",
          "icon": null,
          "unit_of_measurement": "%",
          "state": {
            "entity_id": "sensor.warmtepomp_power_level",
            "state": "60",
            "attributes": {
              "state_class": "measurement",
              "unit_of_measurement": "%",
              "device_class": "power_factor",
              "icon": "mdi:signal",
              "friendly_name": "Warmtepomp Power level"
            },
            "last_changed": "2023-06-25T08:19:50.594335+00:00",
            "last_updated": "2023-06-25T08:19:50.594335+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": "problem",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "binary_sensor.warmtepomp_water_flow",
            "state": "off",
            "attributes": {
              "device_class": "problem",
              "friendly_name": "Warmtepomp Water flow"
            },
            "last_changed": "2023-06-24T10:05:13.302890+00:00",
            "last_updated": "2023-06-24T10:05:13.302890+00:00"
          }
        }
      ]
    }
  }
}
make-all commented 1 year ago

It is not an aim of this project to replicate exactly what is in the official Tuya app. Presets are limited to a common set to aid with translation, so the mapping of mute to sleep and intelligent to activity is expected. The previous reports for the GardenPAC device did not mention any cooling mode, so that is not implemented. But maybe this is limited to only some models?

bezigebever commented 1 year ago

@make-all many thanks for your support ! I understand you don't wan't to use the same terms as Tuya, it's just that sleep and activity aren't really intuitive. Sleep isn't sleep but silent mode or eco mode or whatever... I don't know what common translation would be usable ? For cooling mode, probably depending on models.

make-all commented 1 year ago

Many pool heatpumps have both "silent" and "eco", so I chose to map "silent" to "sleep" (as sleep modes normally imply silence) rather than "eco". For consistency between devices, I think it is better to keep the same mapping even for devices that do not implement eco mode.

make-all commented 1 year ago

I see I picked from the list of standard preset modes for this device, and those were the closest available - sleep does suggest a mode designed to be quiet, and activity seems to be designed for an on-demand type preset that responds to activity. But it might be better to pick from the list of non-standard presets I made for pool heatpumps which had presets that don't all fit into the standard HA presets, in which case we could use "Quiet heat" and "Smart heat" instead. You also say you have a Refrigeration and another Intelligent mode, which are not supported by the current config. These maybe correspond to the Quiet Cool and Smart Cool presets, which does require the use of the pool heatpump non-standard presets.

make-all commented 1 year ago

On second thoughts, the way this device implements its presets differs from other pool heatpumps. Instead of having separate presets for heat and cool modes, it has a single boolean for "Intelligent" mode, and if it supports cool mode, presumably does so through dp 105, which currently is set to read-only with "warm" being the only known value. So I don't think the pool heatpump specific presets can be used, and you will have to live with the standard presets, which I think the ones currently chosen are the closest matches.