Repository: zigpy/zha-device-handlers

Issue:
[Device Support Request] TS0601 _TZE200_h4cgnbzg
**Is your feature request related to a problem? Please describe.**
I've bought multiple trvs "hama smart thermostat". Two of them do not appear as trv in ZHA and are only of type "device".

After modifiying ts0601_trv_sas.py (according to https://github.com/zigpy/zha-device-handlers/issues/819#issuecomment-800488953) the trv is recognized and does show me current and wanted temperature, but im not able to control ist e.g. turn it off or modifiy the temperature.

Here are the zigbee signatures:
<details>
<summary>Device signature working</summary>

```yaml
{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>,
	complex_descriptor_available=0,
	user_descriptor_available=0,
	reserved=0,
	aps_flags=0,
	frequency_band=<FrequencyBand.Freq2400MHz: 8>,
	mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>,
	manufacturer_code=4098,
	maximum_buffer_size=82,
	maximum_incoming_transfer_size=82,
	server_mask=11264,
	maximum_outgoing_transfer_size=82,
	descriptor_capability_field=<DescriptorCapability.NONE: 0>,
	*allocate_address=True,
	*is_alternate_pan_coordinator=False,
	*is_coordinator=False,
	*is_end_device=True,
	*is_full_function_device=False,
	*is_mains_powered=False,
	*is_receiver_on_when_idle=False,
	*is_router=False,
	*is_security_capable=False)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0301",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0004",
        "0x0005",
        "0x0201",
        "0xef00"
      ],
      "out_clusters": [
        "0x0001",
        "0x000a",
        "0x0019",
        "0x0201"
      ]
    }
  },
  "manufacturer": "_TZE200_yw7cahqs",
  "model": "TS0601",
  "class": "zhaquirks.tuya.ts0601_trv_sas.Thermostat_TZE200_c88teujp"
}
```

</details>
<details>
<summary>Device signature NOT working</summary>

```yaml
{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>,
	complex_descriptor_available=0,
	user_descriptor_available=0,
	reserved=0,
	aps_flags=0,
	frequency_band=<FrequencyBand.Freq2400MHz: 8>,
	mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>,
	manufacturer_code=4417,
	maximum_buffer_size=66,
	maximum_incoming_transfer_size=66,
	server_mask=10752,
	maximum_outgoing_transfer_size=66,
	descriptor_capability_field=<DescriptorCapability.NONE: 0>,
	*allocate_address=True,
	*is_alternate_pan_coordinator=False,
	*is_coordinator=False,
	*is_end_device=True,
	*is_full_function_device=False,
	*is_mains_powered=False,
	*is_receiver_on_when_idle=False,
	*is_router=False,
	*is_security_capable=False)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0301",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0004",
        "0x0005",
        "0x0201",
        "0xef00"
      ],
      "out_clusters": [
        "0x0001",
        "0x000a",
        "0x0019",
        "0x0201"
      ]
    }
  },
  "manufacturer": "_TZE200_h4cgnbzg",
  "model": "TS0601",
  "class": "zhaquirks.tuya.ts0601_trv_sas.Thermostat_TZE200_c88teujp"
}
```

</details>


<details>
<!-- Diagnostic information can be acquired by clicking on the "Download Diagnostics" button in the device settings view -->
<summary>Diagnostic information</summary>

```yaml
{
  "home_assistant": {
    "installation_type": "Home Assistant Container",
    "version": "2022.9.7",
    "dev": false,
    "hassio": false,
    "virtualenv": false,
    "python_version": "3.10.5",
    "docker": true,
    "arch": "armv7l",
    "timezone": "Europe/Berlin",
    "os_name": "Linux",
    "os_version": "5.15.61-v7l+",
    "run_as_root": true
  },
  "custom_components": {
    "wemportal": {
      "version": "1.3.9",
      "requirements": [
        "scrapyscript==1.1.0",
        "scrapy==2.6.3",
        "fuzzywuzzy==0.18.0"
      ]
    },
    "xiaomi_cloud_map_extractor": {
      "version": "v2.2.0",
      "requirements": [
        "pillow",
        "pybase64",
        "python-miio",
        "requests",
        "pycryptodome"
      ]
    }
  },
  "integration_manifest": {
    "domain": "zha",
    "name": "Zigbee Home Automation",
    "config_flow": true,
    "documentation": "https://www.home-assistant.io/integrations/zha",
    "requirements": [
      "bellows==0.33.1",
      "pyserial==3.5",
      "pyserial-asyncio==0.6",
      "zha-quirks==0.0.79",
      "zigpy-deconz==0.18.1",
      "zigpy==0.50.3",
      "zigpy-xbee==0.15.0",
      "zigpy-zigate==0.9.2",
      "zigpy-znp==0.8.2"
    ],
    "usb": [
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*2652*",
        "known_devices": [
          "slae.sh cc2652rb stick"
        ]
      },
      {
        "vid": "1A86",
        "pid": "55D4",
        "description": "*sonoff*plus*",
        "known_devices": [
          "sonoff zigbee dongle plus v2"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*sonoff*plus*",
        "known_devices": [
          "sonoff zigbee dongle plus"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*zigstar*",
        "known_devices": [
          "ZigStar Coordinators"
        ]
      },
      {
        "vid": "1CF1",
        "pid": "0030",
        "description": "*conbee*",
        "known_devices": [
          "Conbee II"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8A2A",
        "description": "*zigbee*",
        "known_devices": [
          "Nortek HUSBZB-1"
        ]
      },
      {
        "vid": "0403",
        "pid": "6015",
        "description": "*zigate*",
        "known_devices": [
          "ZiGate+"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*zigate*",
        "known_devices": [
          "ZiGate"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8B34",
        "description": "*bv 2010/10*",
        "known_devices": [
          "Bitron Video AV2010/10"
        ]
      }
    ],
    "codeowners": [
      "@dmulcahey",
      "@adminiuga",
      "@puddly"
    ],
    "zeroconf": [
      {
        "type": "_esphomelib._tcp.local.",
        "name": "tube*"
      },
      {
        "type": "_zigate-zigbee-gateway._tcp.local.",
        "name": "*zigate*"
      }
    ],
    "dependencies": [
      "file_upload"
    ],
    "after_dependencies": [
      "onboarding",
      "usb",
      "zeroconf"
    ],
    "iot_class": "local_polling",
    "loggers": [
      "aiosqlite",
      "bellows",
      "crccheck",
      "pure_pcapy3",
      "zhaquirks",
      "zigpy",
      "zigpy_deconz",
      "zigpy_xbee",
      "zigpy_zigate",
      "zigpy_znp"
    ],
    "is_built_in": true
  },
  "data": {
    "ieee": "**REDACTED**",
    "nwk": 3161,
    "manufacturer": "_TZE200_h4cgnbzg",
    "model": "TS0601",
    "name": "_TZE200_h4cgnbzg TS0601",
    "quirk_applied": true,
    "quirk_class": "zhaquirks.tuya.ts0601_trv_sas.Thermostat_TZE200_c88teujp",
    "manufacturer_code": 4417,
    "power_source": "Battery or Unknown",
    "lqi": 183,
    "rssi": -71,
    "last_seen": "2022-11-06T21:46:41",
    "available": true,
    "device_type": "EndDevice",
    "signature": {
      "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False)",
      "endpoints": {
        "1": {
          "profile_id": 260,
          "device_type": "0x0301",
          "in_clusters": [
            "0x0000",
            "0x0001",
            "0x0004",
            "0x0005",
            "0x0201",
            "0xef00"
          ],
          "out_clusters": [
            "0x0001",
            "0x000a",
            "0x0019",
            "0x0201"
          ]
        }
      }
    },
    "active_coordinator": false,
    "entities": [
      {
        "entity_id": "sensor.heizung_wohnzimmer_links_battery",
        "name": "_TZE200_h4cgnbzg TS0601"
      },
      {
        "entity_id": "climate.heizung_wohnzimmer_links_thermostat",
        "name": "_TZE200_h4cgnbzg TS0601"
      },
      {
        "entity_id": "sensor.heizung_wohnzimmer_links_thermostathvacaction",
        "name": "_TZE200_h4cgnbzg TS0601"
      }
    ],
    "neighbors": [],
    "endpoint_names": [
      {
        "name": "THERMOSTAT"
      }
    ],
    "user_given_name": "Heizung Wohnzimmer Links",
    "device_reg_id": "e0e4ddbadbd01d5b3c3dfe189a9194b8",
    "area_id": "wohnzimmer",
    "cluster_details": {
      "1": {
        "device_type": {
          "name": "THERMOSTAT",
          "id": 769
        },
        "profile_id": 260,
        "in_clusters": {
          "0x0000": {
            "endpoint_attribute": "basic",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0004": {
            "endpoint_attribute": "groups",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0005": {
            "endpoint_attribute": "scenes",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0xef00": {
            "endpoint_attribute": "tuya_manufacturer",
            "attributes": {
              "0x0165": {
                "attribute_name": "system_mode",
                "value": 1
              },
              "0x0267": {
                "attribute_name": "occupied_heating_setpoint",
                "value": 180
              },
              "0x0266": {
                "attribute_name": "local_temperature",
                "value": 187
              },
              "0x0569": {
                "attribute_name": "battery_state",
                "value": 0
              }
            },
            "unsupported_attributes": {}
          },
          "0x0001": {
            "endpoint_attribute": "power",
            "attributes": {
              "0x0021": {
                "attribute_name": "battery_percentage_remaining",
                "value": 200
              }
            },
            "unsupported_attributes": {
              "0x0020": {
                "attribute_name": "battery_voltage"
              },
              "0x0021": {
                "attribute_name": "battery_percentage_remaining"
              },
              "0x0031": {
                "attribute_name": "battery_size"
              },
              "0x0033": {
                "attribute_name": "battery_quantity"
              }
            }
          },
          "0x0201": {
            "endpoint_attribute": "thermostat",
            "attributes": {
              "0x0000": {
                "attribute_name": "local_temperature",
                "value": 1870
              },
              "0x0012": {
                "attribute_name": "occupied_heating_setpoint",
                "value": 1800
              },
              "0x0015": {
                "attribute_name": "min_heat_setpoint_limit",
                "value": 500
              },
              "0x0016": {
                "attribute_name": "max_heat_setpoint_limit",
                "value": 3000
              },
              "0x001b": {
                "attribute_name": "ctrl_sequence_of_oper",
                "value": 2
              },
              "0x001c": {
                "attribute_name": "system_mode",
                "value": 4
              },
              "0x001e": {
                "attribute_name": "running_mode",
                "value": 4
              }
            },
            "unsupported_attributes": {
              "0x0000": {
                "attribute_name": "local_temperature"
              },
              "0x0002": {
                "attribute_name": "occupancy"
              },
              "0x0003": {
                "attribute_name": "abs_min_heat_setpoint_limit"
              },
              "0x0004": {
                "attribute_name": "abs_max_heat_setpoint_limit"
              },
              "0x0005": {
                "attribute_name": "abs_min_cool_setpoint_limit"
              },
              "0x0006": {
                "attribute_name": "abs_max_cool_setpoint_limit"
              },
              "0x0007": {
                "attribute_name": "pi_cooling_demand"
              },
              "0x0008": {
                "attribute_name": "pi_heating_demand"
              },
              "0x0011": {
                "attribute_name": "occupied_cooling_setpoint"
              },
              "0x0012": {
                "attribute_name": "occupied_heating_setpoint"
              },
              "0x0013": {
                "attribute_name": "unoccupied_cooling_setpoint"
              },
              "0x0014": {
                "attribute_name": "unoccupied_heating_setpoint"
              },
              "0x0017": {
                "attribute_name": "min_cool_setpoint_limit"
              },
              "0x0018": {
                "attribute_name": "max_cool_setpoint_limit"
              },
              "0x001c": {
                "attribute_name": "system_mode"
              },
              "0x001e": {
                "attribute_name": "running_mode"
              },
              "0x0029": {
                "attribute_name": "running_state"
              }
            }
          }
        },
        "out_clusters": {
          "0x000a": {
            "endpoint_attribute": "time",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0019": {
            "endpoint_attribute": "ota",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0001": {
            "endpoint_attribute": "power",
            "attributes": {
              "0x0021": {
                "attribute_name": "battery_percentage_remaining",
                "value": 200
              }
            },
            "unsupported_attributes": {}
          },
          "0x0201": {
            "endpoint_attribute": "thermostat",
            "attributes": {
              "0x0000": {
                "attribute_name": "local_temperature",
                "value": 1870
              },
              "0x0012": {
                "attribute_name": "occupied_heating_setpoint",
                "value": 1800
              },
              "0x001c": {
                "attribute_name": "system_mode",
                "value": 4
              },
              "0x001e": {
                "attribute_name": "running_mode",
                "value": 4
              }
            },
            "unsupported_attributes": {}
          }
        }
      }
    }
  }
}
```

</details>




Discussion:
According to Z2M it seems that this is the quirk for your device.
Have you tried to remove and pair the device again? If not, remove the device, let pass one minute and pair the device again.
The device shall being supported with basic functionality for the working ones.
Then adding the new device ID in the quirk (as you have done OK) the new shall also working OK if the firmware is not changed functionality (tuya MCU firmware).
ZHA is sometime not loading the quirk OK so try restarting HA and see if the device is having the same functionality.

If you like getting more functionality you can trying one extender quirk but its not merged in the main repro so need installing it as local quirk https://github.com/zigpy/zha-device-handlers/issues/1189.


Resolving patch:
diff --git a/zhaquirks/tuya/ts0601_trv_sas.py b/zhaquirks/tuya/ts0601_trv_sas.py
--- a/zhaquirks/tuya/ts0601_trv_sas.py
+++ b/zhaquirks/tuya/ts0601_trv_sas.py
@@ -203,6 +203,11 @@ class Thermostat_TZE200_c88teujp(TuyaThermostat):
             ("_TZE200_9gvruqf5", "TS0601"),
             ("_TZE200_zuhszj9s", "TS0601"),
             ("_TZE200_2ekuz3dz", "TS0601"),
+            ("_TZE200_zr9c0day", "TS0601"),
+            ("_TZE200_0dvm9mva", "TS0601"),
+            ("_TZE200_h4cgnbzg", "TS0601"),
+            ("_TZE200_exfrnlow", "TS0601"),
+            ("_TZE200_9m4kmbfu", "TS0601"),
         ],
         ENDPOINTS: {
             # <SimpleDescriptor endpoint=1 profile=260 device_type=81


Test patch: