Notification files not created. What on earth is wrong with this code?

I want to set up some files to receive notifications.

I copied and pasted the examples below from The Home Assistant documentation and another postings on this forumand another.

Not a single log file is created. No error is reported in the configuration checker before restart and none in the log after the system is restarted. I did a full restart (several times), not just a quick reload.

I have stared at this for a long while but that is an ineffective debugging method (!).

What on earth is wrong with this code? Or what am I missing?

notify:
  - name: log_test
    platform: file
    filename: log_test1.txt
    timestamp: true
  - name: log_test2
    platform: file
    filename: log_files/log_test2.txt
    timestamp: true 
  - name: filed_notifications
    platform: file
    filename: filed_notifications.txt
    timestamp: true
  - platform: file
    name: critical_event
    filename: www/log_files/critical_events.txt
    timestamp: false
  - platform: file
    name: diagnostics
    filename: www/log_files/diagnostics.txt
    timestamp: false

Are the services created? I don’t think the file is created until the service is called the first time.

1 Like

just do it like here: How to forward all notifications to notify.file
and check the syntax carefully.

It has been a while since setting something like this up. But, I think I had to create the file ahead of time.

I might be wrong.

That is exactly what I did

Ah, that seems to be the crucial detail not mentioned in the documentation! Thanks. I ran a dummy automation to test it.

Now log_test1 works, but log_test2 (the one with the folder name in front does not. Is that syntax wrong?

you’ve got to try to understand the folder naming conventions, and where to use relative and/or absolute paths.

Not using the prefix slash tries to find the path relative to your current.

its safest to use absolute from /config/ … on and be sure

##########################################################################################
# Sensors for the filed notifications
##########################################################################################

sensor:

  - platform: file
    file_path: /config/logging/filed/filed_notifications.txt
    name: Filed notifications
    <<: &truncate_value
      value_template: >
        {% if value is not none %}
          {% if value|length < 255 %} {{value}}
          {% else %} Truncated: {{value|truncate(240,True, '')}}
          {% endif %}
        {% endif %}

and

notify:

# https://www.home-assistant.io/integrations/file/#notifications
  - name: filed_notifications
    platform: file
    filename: /config/logging/filed/filed_notifications.txt
  #  timestamp: False
1 Like

I now have it working relative to config, which is what I wanted

Thanks all