How to display mqtt sensor state history in numeric?

I know that all mqtt sensor state is a string but I want to display the history in a value graph, how can I do that?

I have a script analyze how many eggs in the picture and send the value to mqtt.

mqtt:
  sensor:
    - state_topic: "/places/chickencoop/egg"
      name: "Egg"

I did try adding device_class: humidity / temperature also didn’t work


2

Thank you for your time.

For a sensor state to be treated as a numeric value you need to add a unit_of_measurement to the sensor config. It can be anything, including a quoted space " " if you want nothing to show. e.g.

mqtt:
  sensor:
    - state_topic: "/places/chickencoop/egg"
      name: "Egg"
      unit_of_measurement: "eggs"

Or

mqtt:
  sensor:
    - state_topic: "/places/chickencoop/egg"
      name: "Egg"
      unit_of_measurement: " "
1 Like