Xiaomi Temperature Sensor data to log File

Hi to all.

I Have a xiaomi gateway and a sensor temperature working with my HA configuration.

I want to save the sensor state in a log file, I tried with a Shell Command and a Automation but the Shell Command won’t work.

Here my Shell Command:

temp2log: 'echo {{ states.sensor.temperature_158d0001a2c25c.state }} >> /home/setterlee/logs/temperature.log'

Any idea?

thanks

Well,

I found the solution with this workaround:

temp2log: /bin/bash -c "echo '{{ states.sensor.temperature_158d0001a2c25c.state }}' >> /home/setterlee/logs/temperature.log"

This is neat. I’m looking for something that can collect historical temperature over a period of about one month. Any suggestion on how I can accomplish this will be appreciated.