Logging historical zigbee2mqtt sensor data in HomeAssistant?

I have an external Mosquitto instance, along with zigbee2mqtt. I’ve connected this to my HomeAssistance instance using the “MQTT” integration in Home Assistant.

I can see some of my Zigbee devices - e.g. Aqara WSDCGQ12LM, and it is pulling sensor data:

My question is around history or logging of the sensor data - is there some way to enable HomeAssistant to log this data (e.g. temperature/humidity) over time? How do you view this?

And can you push it via say, the InfluxDB integration as well?

It logs your sensors like any other sensor.

Sorry for the "basic Question.

I have an external Mosquitto instance, along with zigbee2mqtt. I’ve connected this to my HomeAssistance instance using the “MQTT” integration in Home Assistant.

I cannot “find” my zigbee2mqtt logging data . I used to use ZHA and it automatically displayed my logged data in a nice graph,
I would like to see the zigbee2mqtt data in a graph.
The picture with “current” data is all that I can find…

Yes, this is possible. You have to set up recorder and history in your configuation.yaml file. It was a bit long time I done this and didn’t wrote any notes on my config so please check doc.
This is my configration.yaml on history and recorder

history:
  include:
    domains:
      - sensor
      - switch
recorder:
  purge_keep_days: 8
  exclude:
    domains:
      - automation
      - updater
    entity_globs:
      - sensor.weather_*
    entities:
      - sun.sun 
    event_types:
      - call_service

As I remember you can configure influxdb in configuration.yaml something like this

influxdb:
  host: a0d7b954-influxdb
  port: 8086
  database: xxxxxxxx
  username: xxxxxxxxxxx
  password: xxxxxxxxxxxx
  max_retries: 3
  default_measurement: state
  include:
    entity_globs:
      - sensor.monthly_energy_*
      - sensor.daily_energy_*
    entities:
      - sensor.xxxxxxxxxxxxxxx_sensor_temperature
      - sensor.xxxxxxxxxxxxxxxxx_humidity

You can show your historical data in a way you want. You can use a statistics graph card or use a influxdb with grafana to display your data. Its up to yours preferences.

Z2m data is preserved in the same way as any other data. No special configuration needed.

If you are going to keep historical data then setting up a recorder and history is a must. You will run out of space or system will became slow and unresponsive and you will end up with huge database.
Anyway no one need historical data of everything.

You are looking at the data in the Z2M dashboard, this is only there for creating a overview when handling the zigbee network. All the information is stored in HA, just as for ZHA, in entities. You will have the same posibilities.

If you can not find the devices and entities in HA, then something is wrong with MQTT setup

Rubbish. No extra setup is needed to keep data.

You are way too smart for me.

You are all too smart for me… I am very new to HA, zigbee, and especially Z2M

I have found these entities in my HA Overview as shown in the picture

  1. Pump 1-f is automated and works plus I can manually use the switch.
  2. Vegetation light has those lightning bolts, the automation does not work, but I can manually operate in Zigbee2mqtt.
  3. T & H readings say "Unknown " graph is blank
    4) the CO2 and ph show in Z2Mqtt but not in my HA entities (first screen shot)

Thanks,

2smart4U was just cynical comment from me.
In my opinion you have connection problems with your zigbee devices. It might be due to poor coordinator or maybe you need to expand your zigbee network with some routers. Usually zigbee smart plugs acts as routers on zigbee network allowing other end zigbee devices to connect to it.

The Devices are all recognized in Zigbee2mqtt with good LQI (see this screen shot)
And I get sensor Readings, and can operate switches in Z2M but not HA>Overview
There are 2 switches that are in automations…
Pump 1-f works automatically as it should and displays a on/off switch,
Vegetation light can be controlled in Z2mqtt no problem…but on the HA dashboard It has The lightning bolts(see blue circle in prior post) instead of a on/off and the automation fails to act ?

The PH meter and CO2 meter work in Zigbee2mqtt but are not showing as entities in
HA >Settings>Entities

My goal is " I cannot “find” my zigbee2mqtt logging data .
I used to use ZHA and it automatically displayed my logged data in a nice graph,
I would like to see the zigbee2mqtt data in a graph.
The picture with “current” data in Zigbee2Mqtt is all that I can find…

There is a problem with your alab sensors/devices. Try permit join in z2m and pair again those devices.
I don’t know what you mean by cannot find logging data. I never used zha so I don’t know what do you mean by that.

The logs for z2m are in your screenshot, where it says Logs.

But if you’re looking for data history, you have to get the entity properly into ha. I concur that you should try re-pairing.

This Sonoff Temp and humidity sensor is on my dash board but both T&H say “unknown” instead of displaying the T&H . I can view the T&H in Z2M and I can watch them respond. so zigbee is communicatiing. I will try re-pairing

Shows no History on graph

As it works in Z2M, i do not believe it is related to zigbee. You mention your MQTT setup are a external. Are you sure Z2M connect correctly to this? That it populates correctly to MQTT? Do you ave other MQTTD3vices in HA working correctly?

The sensor in your screenshot, was that created by Z2M? Or is it from when you used to use ZHA? Since you said you switched from one to the other right?

The empty graph is in HA dashboard (black backround)

All sensors read accurately and switches work in Z2M (blueish screens)

Even though all sensors and switches work in Z2M they are not showing up in HA>devices

  Pump 1-f automation and switch   works as it should In both  Z2M & HA dashboard

 Vegetation light switch works in Z2M.... 

I need the history of my sensors and automations whether it is Z2M or on the HA dashboard
It all worked great in ZHA but I purchased 2 sensors that needed Z2M

Solved by my Sensor Vendor===
Aleksy at ALAB sensors
in Zigbee2mqtt I needed to:
Activate each device in HA. I am so relieved to get past that hurdle.

Solved by following the instructions :slight_smile: