make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.2k stars 489 forks source link

Can't set thermostat temp on 2014.5.* #1948

Closed r-t-s closed 3 months ago

r-t-s commented 3 months ago

Describe the bug When trying to change the temp, it shows a range of 0 - 1. Then of course that fails. This works in 2014.3.3 ... I Tried multiple 2014.4.x and 2014.5.x versions.

To Reproduce Just try to change the temperature

Expected behavior The thermostat temperature should change without any errors in the log file.

Additional context This is an owen PCT513-TY thermostat.

If the bug involves a device, then please include device diagnostics from Settings / Devices & Services / Tuya Local (your device) / "1 device"

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.5.5",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.12.2",
    "docker": true,
    "arch": "aarch64",
    "timezone": "America/Chicago",
    "os_name": "Linux",
    "os_version": "6.6.29-haos",
    "supervisor": "2024.05.1",
    "host_os": "Home Assistant OS 12.3",
    "docker_version": "25.0.5",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "vera_alerts": {
      "documentation": "https://www.home-assistant.io/integrations/vera_alerts",
      "version": "1.0.1",
      "requirements": []
    },
    "tuya_local": {
      "documentation": "https://github.com/make-all/tuya-local",
      "version": "2024.4.0",
      "requirements": [
        "tinytuya==1.13.2"
      ]
    },
    "watchman": {
      "documentation": "https://github.com/dummylabs/thewatchman",
      "version": "0.5.1",
      "requirements": [
        "prettytable==3.0.0"
      ]
    },
    "dynamic": {
      "documentation": "https://home-assistant.io",
      "version": "1.0.1",
      "requirements": []
    },
    "hacs": {
      "documentation": "https://hacs.xyz/docs/configuration/start",
      "version": "1.34.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "envisalink": {
      "documentation": "https://www.home-assistant.io/integrations/envisalink",
      "version": "2.0.0",
      "requirements": [
        "pyenvisalink==4.6"
      ]
    }
  },
  "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": [
      "tinytuya==1.13.2"
    ],
    "version": "2024.4.0",
    "is_built_in": false
  },
  "data": {
    "name": "Bunk Room",
    "type": "owon_pct513_thermostat",
    "device_id": "**REDACTED**",
    "device_cid": "",
    "local_key": "**REDACTED**",
    "host": "**REDACTED**",
    "protocol_version": 3.3,
    "tinytuya_version": "1.13.2",
    "api_version_set": 3.3,
    "api_version_used": 3.3,
    "api_working": false,
    "status": {},
    "cached_state": {
      "updated_at": 0
    },
    "pending_state": {},
    "connected": true,
    "force_dps": [],
    "home_assistant": {
      "name": "Bunk Room",
      "name_by_user": null,
      "disabled": false,
      "disabled_by": null,
      "entities": [
        {
          "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.bunk_room_problem",
            "state": "unavailable",
            "attributes": {
              "device_class": "problem",
              "friendly_name": "Bunk Room Problem"
            },
            "last_changed": "2024-05-25T18:14:57.647274+00:00",
            "last_reported": "2024-05-25T18:14:58.794170+00:00",
            "last_updated": "2024-05-25T18:14:57.647274+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "unit_of_measurement": "min",
          "state": {
            "entity_id": "number.bunk_room_fan_runtime",
            "state": "unavailable",
            "attributes": {
              "min": 0.0,
              "max": 55.0,
              "step": 5.0,
              "mode": "auto",
              "unit_of_measurement": "min",
              "friendly_name": "Bunk Room Fan runtime"
            },
            "last_changed": "2024-05-25T18:14:57.634382+00:00",
            "last_reported": "2024-05-25T18:14:58.794076+00:00",
            "last_updated": "2024-05-25T18:14:57.634382+00:00"
          }
        },
        {
          "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.bunk_room",
            "state": "unavailable",
            "attributes": {
              "hvac_modes": [
                "off",
                "cool",
                "heat",
                "heat_cool"
              ],
              "min_temp": 59.0,
              "max_temp": 113.0,
              "target_temp_step": 0.5,
              "fan_modes": [
                "auto",
                "on",
                "cycle"
              ],
              "preset_modes": [
                "manual",
                "program",
                "temp_override",
                "perm_override"
              ],
              "friendly_name": "Bunk Room",
              "supported_features": 153
            },
            "last_changed": "2024-05-25T18:14:57.622929+00:00",
            "last_reported": "2024-05-25T18:14:58.972891+00:00",
            "last_updated": "2024-05-25T18:14:57.622929+00:00"
          }
        }
      ]
    }
  }
}

Please check if there are messages from Tuya Local in the Home Assistant log (Settings / System / Logs), and include those too.

![Normal](https://github.com/make-all/tuya-local/assets/11230849/0f45879c-a81f-4f8f-9eb4-e90bb27433f9) homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:239
integration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 1:22:17 PM (4 occurrences)
Last logged: 1:29:30 PM

[281472200192576] Unexpected exception
[281472453980608] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2738, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1047, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 913, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/config/custom_components/tuya_local/climate.py", line 240, in async_set_temperature
    await self.async_set_target_temperature(
  File "/config/custom_components/tuya_local/climate.py", line 252, in async_set_target_temperature
    await self._temperature_dps.async_set_value(
  File "/config/custom_components/tuya_local/helpers/device_config.py", line 469, in async_set_value
    settings = self.get_values_to_set(device, value)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tuya_local/helpers/device_config.py", line 875, in get_values_to_set
    return r_dps.get_values_to_set(device, value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tuya_local/helpers/device_config.py", line 939, in get_values_to_set
    raise ValueError(f"{self.name} ({value}) must be between {mn} and {mx}")
ValueError: temp_f (0.5) must be between 41.0 and 90.0

If applicable, add screenshots to help explain your problem. Normal Display (Before Setting temp) Normal While settig temp range between 0 and 1 Setting

make-all commented 3 months ago

You are using HA 2024.5.5 with tuya-local 2024.4.0

This combination will not work, please upgrade tuya-local to 2024.5.3 and make another report if that version is not working.

r-t-s commented 3 months ago

I initially tested with 2014.5.3, that's where it failed. Then worked backwards ... I issued the report while testing different versions. It worked when I went back to 2014.3.3

r-t-s commented 2 months ago

I found the problem ... it is a BUG in the owon_pct513_thermostat.yaml file. It does not handle units in "F" correctly. I have a modified file (I attached) that mostly works. The remaining problem is the STEP is 1/2 degree when unit's is "F" It is supposed to be 1/2 degree for "C". But it's only a minor UI issue. owon_pct513_thermostat.yaml.txt Please reopen this ticket. Tested with 2024.6.0

make-all commented 2 months ago

The suggested changes are conflicting with the logs supplied in earlier reports for this device #100 and #875. So without clear logs on this issue, it is not clear that this is the correct resolution.

I suggest to turn on debug logging and collect some logs of the temperature in Fahrenheit being changed.