MindrustUK / Heatmiser-for-home-assistant

Heatmiser Neo-Hub / Neostat support for home-assistant.io
86 stars 32 forks source link

Feature: Add support for statistics / long term statistics on data returned by integration #158

Closed Vladdy65 closed 1 day ago

Vladdy65 commented 8 months ago

Not sure if this is a bug or one is simply not meant to be able to add a climate.xxxx entity to a dashboard Statistics Graph. I can't test as I only have Heatmiser climate entities. None of the Heatmiser integration climate entities appear in the "Add a statistic" options list. A Home Assistant message leads one to the following link if expected data source is not listed: https://www.home-assistant.io/more-info/statistics/. The latter claims this may be a bug, and suggests one open an issue with the author of the integration, linking them to this link: https://developers.home-assistant.io/docs/core/entity/sensor#long-term-statistics. So here I am.

MindrustUK commented 8 months ago

Acknowledging this, investigation required when I get some time.

MindrustUK commented 1 week ago

Haven't looked too far into this but it mainly seems to be around sensors that should be reasonably doable. Not too sure how I'd get this to work with the Climate entity. I'll have a further look into this when I get some more time.

ocrease commented 4 days ago

@Vladdy65 just checking, is it only the current temperature of the thermostat that you are interested in using in a statistics graph? Floor temperature for those with floor sensors might be interesting too, but I can't think of other attributes that would be useful for long term statistics.

Vladdy65 commented 3 days ago

@ocrease the way I understand the controller units is that(a) you have the set temperature which is then compared to the room temperature that is either (b) air temperature as measured on the controller or (c) a wireless remote temp sensor or (d) an average of the two. These are setting options on the controller. The (e) floor temperature is set as a max level and the controller will aim to get the room temperature (b) or (c) or (d) to the set value (a) but without exceeding (e). So having floor temperature (e) if available would be great. Where this would be practically helpful is e.g. in identifying situations where it is set too low and the room never reaches set temperature whilst the controller is continuously switching the element on/off in a narrow range to keep the floor from exceeding the set max temperature.

ocrease commented 3 days ago

@Vladdy65 that's my understanding too, although I don't have floor sensors on my thermostats. However, my question was which attributes/parameters need to be supported in the statistics graph. I think we can agree the the current temperature and floor temperature make sense, but nothing else is relevant for statistics?

Long term statistics for current temperature and floor temperature should work after my changes in #201 are done.

BTW, you can already get the floor temperature as an attribute of the device:

image

The value on mine is irrelevant because the sensor is not connected, but if you have a sensor I think you should see the temperature there

Vladdy65 commented 3 days ago

@ocrease looking at the attribute list, my wish list for long term stats would be: temperature current_temperature floor_temperature hc_mode if possible so one can see when it was on and off, possibly as numeric (0/1)? Many thanks for your efforts on this.

ocrease commented 3 days ago

@Vladdy65 I think temperature (eg the current set temperature) and mode don't belong in long term statistics. The way this is enabled on sensors (not binary sensors or any other entity types) is by adding a state class of Measurement. The set temperature and mode are more like reporting the state of a device, it's not really measuring anything. It also feels like something not specific to this integration, eg the same request could be made on any climate integration, so perhaps this should be a feature request for Home Assistant itself?

201 is now merged to the dev branch (installation instructions here. This should at least take care of the current temperature and floor temperature (those two sensors are disabled by default). Note that going to the dev branch might be overkill just for this feature.

For the other two, I think you could create a template sensor in HA and you can assign the state class there yourself.

Vladdy65 commented 3 days ago

@ocrease many thanks for this.

ocrease commented 3 days ago

@Vladdy65 here is an example template sensor. This one is no longer needed on the dev branch, but it should give you an idea of what to do:

    - name: Kitchen Current Temperature
      unique_id: 2e68ea51-c385-4121-86e3-6dd09b15c64f
      unit_of_measurement: "°C"
      state_class: measurement
      device_class: temperature
      state: "{{ state_attr('climate.kitchen', 'current_temperature') }}"
ocrease commented 2 days ago

@MindrustUK can probably be closed now?

MindrustUK commented 1 day ago

@ocrease Agreed, looks feature complete to me. Thanks!