ebaauw / homebridge-deconz

Homebridge plugin for deCONZ
Apache License 2.0
137 stars 7 forks source link

ZHAThermostat - display temperature of external sensor #202

Closed jan666 closed 10 months ago

jan666 commented 10 months ago

I am using a Ubisys H1 thermostat. In the latest firmware (1.5 / 1.5.1) they added the ability to bind external sensor to the thermostat. I bound a SONOFF sensor and this works great. But in Home I still see the temperature of the H1 internal sensor. It looks like they don't disable it and don't expose the temperature of the external sensor. So it would be nice to link the sensor to the thermostat in homebridge-deconz, too. Could you add this?

1216-1332-max

(this could be one item because the Thermostat uses the temperature of the sensor)

ebaauw commented 10 months ago

they added the ability to bind external sensor to the thermostat.

That's a standard Zigbee feature, but not exposed by the deCONZ REST API. Homebridge deCONZ has no way of knowing whether such binding exists.

So it would be nice to link the sensor to the thermostat in homebridge-deconz, too. Could you add this?

No. I won't be combining multiple devices into a single accessory. And even if I would consider that, Homebridge deCONZ wouldn't know when to do this, as it has no knowledge of the Zigbee bindings.

It looks like they don't disable it and don't expose the temperature of the external sensor.

Maybe there's a setting on the H1 to report the temperature of the external sensor instead of the internal sensor? Otherwise: How does deCONZ expose the H1? If the temperature of the external sensor is exposed through some other REST API attribute, it might use it en lieu of the internal state/temperature. I cannot expose both on a single accessory, as that would break Eve history for the thermostat.

jan666 commented 10 months ago

I think even deCONZ does not know there is a binding (I never found a way to view all bindings of a device)?

No. I won't be combining multiple devices into a single accessory. And even if I would consider that, Homebridge deCONZ wouldn't know when to do this, as it has no knowledge of the Zigbee bindings.

The question was to ask if that could be done manually. Something like linking 2 sensors together via resource-item (in homebridge-hue times). Because you're already merging multiple sensor endpoints to one accessory (temperature and humidity for example).

The H1 DDF was done for firmware version 1.4.0 and the binding feature was added in 1.5.0. It is exposed like this:

{
  "config": {
    "battery": 100,
    "group": "20006",
    "heatsetpoint": 1700,
    "mode": "heat",
    "offset": 0,
    "on": true,
    "reachable": true,
    "schedule": {
      "W127": [
        {
          "heatsetpoint": 1400,
          "localtime": "T00:00"
        },
        {
          "heatsetpoint": 1700,
          "localtime": "T07:00"
        },
        {
          "heatsetpoint": 2000,
          "localtime": "T16:00"
        },
        {
          "heatsetpoint": 1400,
          "localtime": "T20:30"
        }
      ]
    },
    "schedule_on": true,
    "unoccupiedheatsetpoint": 1600
  },
  "etag": "992b61a30a01a2137e2928aec4823b05",
  "lastannounced": null,
  "lastseen": "2024-01-04T06:17Z",
  "manufacturername": "ubisys",
  "modelid": "H1",
  "name": "Thermostat DG Erik",
  "state": {
    "lastupdated": "2024-01-04T06:17:49.094",
    "on": false,
    "temperature": 2200,
    "utc": "2024-01-04T06:17:43Z",
    "valve": 0
  },
  "swversion": "1.5.1",
  "type": "ZHAThermostat",
  "uniqueid": "00:1f:ee:00:00:00:98:af-01-0201"
}

The real temperature from the external SONOFF sensor is

  "name": "Sensor DG Erik",
  "state": {
    "lastupdated": "2024-01-04T06:18:53.965",
    "temperature": 1786
  },

I already looked at the clusters listed in the deCONZ UI but I can't find anything releated to the external sensor. Its only the display of the device that shows it. I don't know if there are clusters that deCONZ does not show?

Is there a best practice how other manufacturer expose the external temperature? Maybe I could Ubisys ask to implement it like it.

jan666 commented 10 months ago

I already contacted Ubisys and they sent me their in-draft technical reference.

image

This is the temperature I am looking for:

image

So I guess the correct way is to expose this as config/externalsensortemp? And homebridge-deconz could use this as current temperature instead of state/temperature?

ebaauw commented 10 months ago

The question was to ask if that could be done manually. Something like linking 2 sensors together via resource-item (in homebridge-hue times). Because you're already merging multiple sensor endpoints to one accessory (temperature and humidity for example).

Those are resources for the same device. You’re asking to combine (resources for) multiple devices into one accessory.

So I guess the correct way is to expose this as config/externalsensortemp? And homebridge-deconz could use this as current temperature instead of state/temperature?

Yes. I think it should probably be a state attribute, though. The resource item might already exist and be used for some other TRVs. https://github.com/dresden-elektronik/deconz-rest-plugin/blob/master/devices/generic/items/config_externalsensortemp_item.json

jan666 commented 10 months ago

I can't really get it to work. I tried

        {
          "name": "config/externalsensortemp",
          "refresh.interval": 3660,
          "parse": {
            "at": "0x0013",
            "cl": "0x0201",
            "ep": 1,
            "eval": "Item.val = Attr.val;",
            "fn": "zcl:attr"
          },
          "default": 0
        },

(basically copied from state/temperature, but changed the "at") but it always stays at

{
  "config": {
    "battery": 90,
    "externalsensortemp": 0,

this DDF stuff is a little bit confusing...

ebaauw commented 10 months ago

I think you need to add the manufacturer code.

jan666 commented 10 months ago

You're right (again)

Now I have

{
  "config": {
    "battery": 100,
    "externalsensortemp": 1804,
    "group": "20006",
    "heatsetpoint": 1400,
    "mode": "heat",
    "offset": 0,
    "on": true,
    "reachable": true,
    "schedule": {
      "W127": [
        {
          "heatsetpoint": 1400,
          "localtime": "T00:00"
        },
        {
          "heatsetpoint": 1700,
          "localtime": "T07:00"
        },
        {
          "heatsetpoint": 2000,
          "localtime": "T16:00"
        },
        {
          "heatsetpoint": 1400,
          "localtime": "T20:30"
        }
      ]
    },
    "schedule_on": true,
    "unoccupiedheatsetpoint": 1600
  },
  "etag": "8e666c8d585b82ea807a8f5fe711daae",
  "lastannounced": null,
  "lastseen": "2024-01-05T05:51Z",
  "manufacturername": "ubisys",
  "modelid": "H1",
  "name": "Thermostat DG Erik",
  "state": {
    "lastupdated": "2024-01-03T11:45:26.565",
    "on": false,
    "temperature": 2200,
    "utc": null,
    "valve": 58
  },
  "swversion": "1.5.1",
  "type": "ZHAThermostat",
  "uniqueid": "00:1f:ee:00:00:00:98:af-01-0201"
}
jan666 commented 10 months ago

Sorry for the question - but will add this (config/externalsensortemp overrides state/temperature)? Should work for the Bosch II Thermostat too I think.

I made a pull request for the H1 DDF change

ebaauw commented 10 months ago

Above commit adds a dynamic setting useExternalTemperature for thermostats that expose config/externalsensortemp. When set, Current Temperature will be based on config/externalsensortemp instead of on state/temperature. Note that Current Temperature will be updated only on the next poll.

Unfortunately, I cannot test this myself. Could you please try beta v1.0.10-0?

jan666 commented 10 months ago
$ ui put /accessories/<address> '{"useExternalTemperature": true}'
{
  "useExternalTemperature": true
}

Before:

image

After:

image

Works!

image

Thanks!

ebaauw commented 9 months ago

In v1.0.10.