Where does notify.notify put files?

There was a similar post a few days ago, but I can’t find it now…

Home Assistant OS. (No virtuals or containers)

I’ve had an automation to record my garden moisture sensor values to a text file for later analysis. The output file had been gathering data for a couple of years and is located in the same directory as the configuration.yaml. When I updated to core 2024.6.2, it stopped working.

The post I can’t find said that I needed to add " allowlist_external_dirs:" to my configuration.yaml file. Here’s the modified notify component section of my configuration.yaml:

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

allowlist_external_dirs:
  - "/config"

Now, I get an Invalid Config error:

Invalid config
The following integrations and platforms could not be set up:

allowlist_external_dirs (Show logs)

Log file:
2024-06-15 16:59:52.451 WARNING (MainThread) [homeassistant.helpers.translation] Failed to load integration for translation: Integration 'allowlist_external_dirs' not found.

Any tips of what is wrong here would be appreciated.

Notify File
is called by a service now, as you should have gotten some info about in your HA

Notifications - Home Assistant.

Migrate legacy file notify service.

Thanks for the tip. I should have posted the automation that has been working:

alias: Sprinkler Moisture log
description: ""
trigger:
  - platform: state
    entity_id: sensor.garden_moisture
condition: []
action:
  - service: notify.notify
    data:
      message: "{{ states('sensor.garden_moisture') }}"
mode: single

I don’t find ‘notify.file’ in the docs. Yes, there was a message in my ‘notifications’ but it got lost in the confusion of fixing other broken configurations.

just want to save data to a text file…

This should be under homeassistant:

homeassistant:
  allowlist_external_dirs:
    - "/config"

It is. Here’s the top of my configuration.yaml:

homeassistant:
  external_url: "https://bq7qv.........redacted..................bu.casa:8123"
  internal_url: "http://home.local:8123"


# MyHomeAssistant
# Allows the documentation to link directly to the right page in their instance.
# https://www.home-assistant.io/integrations/my/
my:

default_config:

# Used for securely connecting to your Home Assistant via Nabu Casa 
cloud:

# Sprinkler Moisture log
notify:
  - name: notify
    platform: file
    timestamp: true
    filename: notify.txt

allowlist_external_dirs:
  - "/config"

wake_on_lan:

So, nomeassistant is on top, put it under there, two spaces more indented.

1 Like

We’re getting closer:

homeassistant:
  external_url: "https://bq7qvbi................ redacted .......................u.casa:8123"
  internal_url: "http://home.local:8123"
  
  allowlist_external_dirs:
    - "/config"

Mostly successful- my automation that writes the sensor data to a text file is working again.

Now when I restart Home Assistant I get a repair notification:

The File notify.notify service is migrated, but it seems the old notify service is still being used.

A new notify entity is available now to replace each legacy notify service.

Update any automations or scripts to use the new notify.send_message service exposed with this new entity. When this is done, select Submit and restart Home Assistant.

But, I can’t find any documentation for using the notify entity to write to a text file.

Should I continue on this thread or start a new one because you solved the initial issue?

If i was to decide, you continue here. ( But mark Edwin’s post as solution )

Partly there is a few post already out there, and as you state, The Documentation of this New(Ongoing) “Integration” is atleast confusing/Spread
Below is 1 link found in another Topic
However it’s not the last we see/hear from this
New notify entity platform | Home Assistant Developer Docs.

EDIT: It seems like the Documentation of this “Notify” is going to be “Spread” in the Various “Platforms” supporting this “Notify” Service, which to me seems “Odd” , Not to mention that the "
allowlist_external_X

Is to be found elsewhere

Don’t use that. It could be anything.

https://www.home-assistant.io/integrations/notify/#notify-entity-service

Use the service shown in the docs:

notify.send_message

There are examples here: https://www.home-assistant.io/integrations/notify/#example-with-the-entity-platform-notify-service

So:

action:
  - service: notify.send_message
    target:
      - entity_id: # your file notification entity here
    data:
      message: "Your message."
1 Like

Yes, i also came to the same conclusion, after reading Integrations/ Notify , Integrations/Notifications, Integrations /homeassistant (the allow_list )

This would be ok, if there would just be links in the various places, so there atleast is some kind “red tread/coherent context” , right now it’s not easy to get a grip of it

This is the basic structure of the documentation that a lot of people do not understand. Domains have their own documentation pages (Light, Cover, Notify, Media Player, etc…) that list the services so that they do not have to be repeated on all the other device specific pages. e.g.

These domain pages are searchable in the integrations index.

I might write a short community guide about using the documentation for core integrations at some stage.

4 Likes

Yes i use to just click the “Integration” url in top-bar, easy way into documentation, when im sitting with something new, or " forgot what i did last summer " :slight_smile:

Anyways, i change most of my “Messages” to short TTS, so i don’t have to “pick up the phone” :slight_smile: , it’s mostly for Warnings/Attention purposes

2 posts were merged into an existing topic: Home Assistant Cookbook - Discussion Thread

Thanks for the tip…
So as I read the docs, in dev tools → services, this should put the text into the file “notify.txt” in the config folder.

service: notify.send_message
target:
  entity_id: "test.txt"
data: {
  message: "This is a test"
}

The test.txt file is not in /config. Where is it? Or is the example wrong?

service: notify.send_message
target:
  entity_id: "test.txt" # this is not a notify entity. 
data: { # what is this?
  message: "This is a test"
} # what is this?
- service: notify.send_message
  target:
    entity_id: notify.something # look in Dev Tools -> States
  data: 
    message: "This is a test"

I never claimed to understand YAML.

This runs. No errors, and no file:

service: notify.send_message
target:
  entity_id: "test.txt"
data:
  message: "This is a test"

OH. You mean the “file notification entity”?

How do I make a file notification entity? I already have this in my configuration.yaml:

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

But this makes a notify.notify entity that the repair message is warning me of. The examples in the docs demonstrate notification messages to an SMS, an eMail, a DM or Chat, or a screen message. But not to a text file.

Change that to:

notify:
  - name: Text File
    platform: file
    timestamp: true
    filename: notify.txt

Then your entity id will be notify.text_file.

Calling it “notify” will give you notify.notify which as explained above is a special case you should not use.

Thanks, it’s making more sense now.
And, still confusing.
Here are the changes to my configuration.yaml:

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

notify:
  - name: Text File
    platform: file
    filename: notify.txt
    timestamp: true

I restart Home Assistant and in developer tools → states, there is still a notify.notify, and no notify.text_file.

I just set up one from the UI. It created notify.file. There was no option for a name.

Then I set this up in yaml:

notify:
  - name: Text File
    platform: file
    filename: test.txt
    timestamp: true

It created: notify.text_file however it also warned that YAML configuration is being removed:

Screenshot 2024-06-16 at 17-25-53 Settings – Home Assistant

There always will be if you have one or more notification integrations set up. As Above it is a special notifier:

Did you restart HA?

Wait, are you saying there’s no way to give the entity a name using the new UI? That seems to me to be a pretty important feature, not one which can simply be abandoned. Am I missing something here?