Store sensor values in a .txt file

Hi,

I have temperature sensor connected from NodeMCU to Home Assistant. Logging is available for errors and warnings. In Home Assistant, can I create a separate new log file which only has the sensor name and it’s values? Using the logger feature isn’t suitable for this because it stores the complete thread with timestamp and other information.

My goal is to take these sensor values and publish them to a database which is not supported by Home Assistant. I’m trying to get the values and then write a script that sends these values to the database. I have looked up UART communication from Home Assistant, MQTT communication and now logging the values to a .txt file. Through a .txt file, I can parse the values to the database eventually.

I’m a beginner so any suggestions would help. Thanks.

Why? Or better what is your end goal with all this?

I’m sorry, I have updated the thread now.

Ok, now I understand.

Which database are you using? Is there a reason for using home assistant as a middle man between the sensor and the database, meaning do you actually use the sensor data in home assistant or do you only want to have it in the database? Do you know that you can flash Tasmota onto the Wemos, which then allows publishing the sensor data to MQTT?

For this i would use a file notification: https://www.home-assistant.io/integrations/file/

Setup an automation triggered on the state change of the appropriate sensor and use the notify service to write the state to the file.

  - id: example_file_notify
    alias: 'Example File Notify'
    trigger:
      platform: state
      entity_id: sensor.test
    action:
    - service: notify.file_log
      data_template:
        message: "{{ states('sensor.test') }}"