Put sensor data in a file

Hi,

I would like to put in a text file the latest temperature read from a sensor (aeontec here), how can i acheive that ?

Thanks

Michael

My guess from googling txt file and HA shell command instructions. (the quotes might be wrong, perhaps outside ones are double)

shell_command:
  temp2txt: 'echo '{{ states.input_number.ac_temperature.state }}' >foo.txt'

Thank you Roby, but how to update that file each time the temperature is changing ?

Thanks

Michael

an automation that is triggered on the state change of the sensor and the action is the shell command.

almost exactly like the documentation example

Apply value of a GUI slider to the shell_command

automation:
  - alias: run_set_ac
    trigger:
      platform: state
      entity_id: input_number.ac_temperature
    action:
      service: shell_command.set_ac_to_slider

What is the synthax exactly to retreive the data sensor ? i have try many thing whithout making it works :frowning:

In the developper tools menu, the name of my sensor is :
sensor.aeotec_zw100_multisensor_6_temperature

i have tried
shell_command:
put_temp_in_file: echo '{{ states.sensor.aeotec_zw100_multisensor_6_temperature.state }}’ > foo.txt
put_temp_in_file: echo '{{ (states.sensor.aeotec_zw100_multisensor_6_temperature.state) }}’ > foo.txt
put_temp_in_file: “echo '{{ states.sensor.aeotec_zw100_multisensor_6_temperature.state }}’ > foo.txt”

This has worked
put_temp_in_file: echo ‘hello’ > /tmp/temperature.txt

So the issue is the way i’m calling the sensor data.

Thx

Hi

I’m experiencing the same.

Have you found a way to do it?

Does this help here