Achronite / mqtt-energenie-ener314rt

MQTT interface for Energenie ENER314-RT add-on board for the Raspberry Pi, designed for use by Home Assistant.
MIT License
13 stars 5 forks source link

Enable long-term statistics in home assistant #68

Open Achronite opened 6 months ago

Achronite commented 6 months ago

Modify the MQTT discovery sections of the devices to capture long-term statistics in HA.

This will allow the entities to capture usage data over time within HA.

genestealer commented 6 months ago

Curious to which sensors you are thinking of?

Assume you mean adding "stat_cla": "measurement", to some sensors?

I am testing this already by adding "stat_cla": "measurement", to some sensors, such as the Smart Plug+

{
    "mdl": "Smart Plug+",
    "mdlpn": "MIHO005",
    "parameters": [
       {
          "id": "switch",
          "component": "switch",
          "stat_t": "~@/state",
          "cmd_t": "~@/command",
          "config": {
             "dev_cla": "outlet",
             "icon": "mdi:power-socket-uk",
             "opt": false
          }
       },
       {
          "id": "REAL_POWER",
          "component": "sensor",
          "stat_t": "~@/state",
          "config": {
             "stat_cla": "measurement",
             "dev_cla": "power",
             "unit_of_meas": "W"
          }
       },
       {
          "id": "REACTIVE_POWER",
          "component": "sensor",
          "stat_t": "~@/state",
          "config": {
             "stat_cla": "measurement",
             "dev_cla": "reactive_power",
             "unit_of_meas": "var"
          }
       },
       {
          "id": "FREQUENCY",
          "component": "sensor",
          "stat_t": "~@/state",
          "config": {
             "stat_cla": "measurement",
             "val_tpl": "{{ value|round(2) }}",
             "dev_cla": "frequency",
             "unit_of_meas": "Hz",
             "en": "false"
          }
       },
       {
          "id": "VOLTAGE",
          "component": "sensor",
          "stat_t": "~@/state",
          "config": {
             "stat_cla": "measurement",
             "dev_cla": "voltage",
             "unit_of_meas": "V",
             "en": "false"
          }
       }
    ]
 }

image

I have been trying it with eTRV temperatures, by creating a separate sensor for the Room Temperature

       {
         "id": "Room_Temperature",
         "component": "sensor",
         "stat_t": "~TEMPERATURE/state",
         "config": {
             "stat_cla": "measurement",
             "dev_cla": "temperature",
             "unit_of_meas": "°C"
         }
     }

image

image

Achronite commented 6 months ago

Curious to which sensors you are thinking of?

The Current Temperature and Humidity.

I have been trying it with eTRV temperatures, by creating a separate sensor for the Room Temperature

@genestealer Did you try adding them to the Climate entity? Or does it need to be kept separate?

genestealer commented 5 months ago

@Achronite The issue is, that Climate entity is not a "sensor" as such, so has no option to enable it's state_class to measurement enabling its long-term statistics.

The only option at present is to create standalone sensors for Current Temperature and Humidity, with the state_class of measurement .

genestealer commented 5 months ago

@Achronite are you planning to add Room Temperature to the eTRV for long-term statistics?

      {
         "id": "Room_Temperature",
         "component": "sensor",
         "stat_t": "~TEMPERATURE/state",
         "config": {
            "stat_cla": "measurement",
            "dev_cla": "temperature",
            "unit_of_meas": "°C"
         }
      }