Add unit of measurement to trigger

Hello all,
I have an entity measuring home PM2.5 in µg/m³, and I can see the historical chart.
I defined a time-based trigger that reads the value of this entity every 30 minutes:

- trigger:
    - platform: time_pattern
      minutes: "/30"
  sensor:
    - name: "PM25 campionato"
      state: "{{ states('sensor.PM25_interno_ogni_30_minuti') }}"

I think I should add the unit of measurement to the trigger in order to display it as a chart. As you can see, the top bar is the trigger value, the bottom chart is the original entity.

Is that possible? Is there any other way to display it as a chart?
Thank you very much,

Fabio

Yes it is possible:

- trigger:
    - platform: time_pattern
      minutes: "/30"
  sensor:
    - name: "PM25 campionato"
      state: "{{ states('sensor.PM25_interno_ogni_30_minuti') }}"
      unit_of_measurement: "µg/m³"

But why are you doing this?

It seems a very odd thing to do.

Thank you, it works!!
I’m doing this because the sensor.PM25_interno_ogni_30_minuti is a rolling average over 30 minutes of a sensor that has a super wide variance, I read the average value every 30 minutes with the trigger and thus I have a more stable value, to use for automations.

Sampling one point in time is not going to reduce this “variance”. You just get a stable snapshot of the noise that is unrepresentative of the real value. You would be better off using this:

1 Like

Thank you for the suggestion!
I’ve added a filter sensor, to analyze the results!