Home Assistant doesn't show the history of a MQTT-sensor anymore?

I have an ESP8266 that sends some information about a window state (closed / open / ventilation):

{ "status": "closed"  }

In Home Assistant I have this MQTT sensor:

sensor:
  - platform: mqtt
    unique_id: "masterbedroom_esp8266_controller"
    name: "Masterbedroom raam status"
    state_topic: "Huis\\MasterBedroom\\RaamStatus"
    expire_after: 10
    qos: 0
    value_template: "{{ value_json.status }}"

This al works good. But the problem is that when I click to see the history, this what I get:

history_masterbedroom_window_state

According to me I think I have nothing changed. Before the history was showing a horizontal bar with the correct texts (that represens the window state).

What do I wrong?

I don’t have an unit of measurement, but there is no measurement for this.

Is it included in recorder ?

Everything is recorded I think so. The only thing I have specified in my configuration.yaml file for the recorder is:

recorder:
  db_url: !secret mariadb_url

so no exclude or include

The problem seems to be that Home Assistant is thinking that my sensor is a numeric value. You see in my screenshot the numeric scale.

It should be a color horinzontal bar with the different states (texts).

This is the same issue on my side since the installation of HASS 2021.12.7 version.
I send from time to time event information from an ESP32 and now the history is empty as HASS try to display a numeric information when it is only text information.

sensor:
- platform: mqtt
    name: "Pump controler event"
    state_topic: "PUMP_CONTROLER_EVENT"
    unit_of_measurement: ''

image

How about adding device_class: window?

I have found a method to work around the problem.
I have defined a sensor which is a copy of my “event” sensor.

template:
      - name: 'Pump controler events'
        state: >
          {{ states('sensor.pump_controler_event') }}

Then I used this sensor copy instead of the original sensor to display the information in the dashboard.
It is now running as expected. :slightly_smiling_face:

screenshot1

1 Like