Try to find my log.txt

Hi there,

i did follow https://brentsaltzman.com/using-the-file-integration-home-assistant/ to make a pomplog.txt file in home assistant. however, not being as bright as i think i am, i don’t know how to read the pomplog.txt. Where can i find this?

notify:
  - name: pomplog
    platform: file
    filename: pomplog.txt
    timestamp: true
    action:
      - service: notify.pomplog
        data:
          message: "pomplog | Watt: {{ states('sensor.0xa4c138a1984aa399_power') }} | Amps: {{states('sensor.0xa4c138a1984aa399_current') }} | Total: {{states('sensor.0xa4c138a1984aa399_energy')}}"


you’ve already looked in your config folder? so peer to where you have configuration.yaml? i thought the config was the default… but why not specify it explicitly to leave no ambiguation?

no pomplog.txt found…

oh wait, you’ve got things mixed up here. you’re mixing configuration and action together. put the defiition of your pomplog notification in your config yaml. put the invocation of it in your automation.

this belongs in configuration.yaml

notify:
  - name: pomplog
    platform: file
    filename: pomplog.txt
    timestamp: true

call notify.pomplog in the automation or script when you want to invoke it.

Ok, so i deleted the part in configuration.yaml image

and made a node.red automation, where the pomplog is invoked every time the pump power goes over 0.

image

i hope this is the way…

i’m not a nr user, so i don’t know for certain. however it looks generally more sensical

let us know how it goes!

nop, something is still wrong. no pomplog.txt is made, and no entery when pomp turns.

You need this in configuration.yaml

notify:
  - name: pomplog
    platform: file
    filename: pomplog.txt
    timestamp: true

and this in automations.yaml

- id: '1564487130669'
  alias: pomplog
  trigger:
  - entity_id: sensor.0xa4c138a1984aa399_power
    platform: state
  action:
  - service: notify.pomplog
    data:
       message: "pomplog | Watt: {{ states('sensor.0xa4c138a1984aa399_power') }} | Amps: {{states('sensor.0xa4c138a1984aa399_current') }} | Total: {{states('sensor.0xa4c138a1984aa399_energy')}}"


And restart HA after adding these, just to be sure the notify integration is loaded.

your config does seem right. I really don’t know about node red. do you do any work direct automation or yaml scripting? I’d recommend you do that or just do devtools-> services to eliminate variables.

Can u go to devtools- services, choose notify.pumplog

The put “hello world” in for the message and see if it works? just do the simplest thing first…

btw, you did restart home assistant after making the configuration.yaml change right?

like this:

ok, first things first; “Hello World” works
image

i never made a automation in yaml only node red.
but i’ll try.

Where does the id number come from?

- id: '1564487130669'
  alias: pomplog
  trigger:
  - entity_id: sensor.0xa4c138a1984aa399_power
    platform: state
  action:
  - service: notify.pomplog
    data:
       message: "pomplog | Watt: {{ states('sensor.0xa4c138a1984aa399_power') }} | Amps: {{states('sensor.0xa4c138a1984aa399_current') }} | Total: {{states('sensor.0xa4c138a1984aa399_energy')}}"```

Just a random id (unique identifier)

Great. Then the config works and your automation invocation is screwy… progress. :slight_smile:

your automation is pretty simple. anything wrong with using home assistants automation?

@francisp has kindly written it for you

Either add it in automations.yaml if you know how to do that safely.

Otherwise
Create a blank automation in the UI
Paste in the code
Delete the id line,
Outdent it (remove 2 spaces at the lead of each)

The docs say you have to specify the path

filename string REQUIRED

Name of the file to use. The file will be created if it doesn’t exist. Add the path of your configuration folder (e.g., /config) to save the file there.

you don’t strictly have to… As above, I recommend it… But op tested it without and using Dev tools he validated that it works

i made an automation (not node red) with this as automation.yaml

- id: '1711358536633'
  alias: Pomplog
  description: ''
  trigger:
  - platform: numeric_state
    entity_id:
    - sensor.0xa4c138a1984aa399_power
    above: 1
  condition: []
  action:
  - service: notify.pomplog
    data:
      message: 'pomplog | Watt: {{ states(''sensor.0xa4c138a1984aa399_power'') }}
        | Amps: {{states(''sensor.0xa4c138a1984aa399_current'') }} | Total: {{states(''sensor.0xa4c138a1984aa399_energy'')}}'

Did a manual run and guess what?!

image

You are the best!
Thx a lot to you all!!

2 Likes

great! :slight_smile: glad it works!!

one small issue:

i’m from Belgium, my time is UTC +1, this is set in settings.
but the log file takes UTC time. is it possible to set UTC +1?

there are two primary ways to make the timestamp and your local time match up.

  1. move to London
  2. do the timestamp yourself.

I’d recommend #2 unless you really like mushy peas. just set timestamp: false in your config. And add {{now()}} at the start of your message line.

1 Like

@armedad: i really like the way u think!

#1: nah, not going to happen.
#2: i’ll give it a try
suggestion #3: i think i have to invest in a propper way to teach myself some coding…

Go to developer tools/templates in ha.

Type {{now()}} in the template editor box. See that it gives the local time. For contrast in a second line put {{utcnow()}} and observe the difference.

This is a good start :wink:

1 Like