How to get home assistant to write to a text file?

I’m trying to create a blue iris overlay for temperature and humidity from sensors.
No matter what I do, I can’t seem to get it to write to a text file. I’ve been pulling my hair on on AI all day. I think AI just has old standards and doesn’t know what is required with the latest HA

output similar to this
72.5°F | 45% RH
/config/www/temperature.txt

alias: Update Blue Iris Overlay
trigger:
  - platform: time_pattern
    minutes: "/1"  # Updates every minute
action:
  - service: notify.file
    data:
      message: "{{ states('sensor.gw1100b_temperature_1') }}°F | {{ states('sensor.gw1100b_humidity_1') }}% RH"

output similar to this
72.5°F | 45% RH

The automation looks ok.

How is your file notify service set up?

Did you do this?
https://www.home-assistant.io/integrations/file/#notifications

I have /config/www on the allow list

Errors in your log?

Did you restart HA after adding the file notifier integration?

You have to restart the fist time you use a new integration. Reload is not sufficient.

EDIT: the notification service has changed, you have to use

action: notify.send_message.

Not service: notify.file

After like 15 hours of trying to get this working, I ended up just using a powershell script on the BI machine to grab the states straight off the API. Works good and I figure it’s more futureproof from HA updates. Hope this helps someone in the future.

config:


template:
  - sensor:
      - name: "Blue Iris Overlay"
        state: "{{ states('sensor.gw1100b_temperature_1') }}°F | {{ states('sensor.gw1100b_humidity_1') }}%"

Powershell on remote machine:


$ha_url = "IP ADDRESS:8123/api/states"
$token = "LONG ACCESS TOKEN"

$headers = @{
    "Authorization" = "Bearer $token"
    "Content-Type"  = "application/json"
}

# Overlay file path
$overlayFile = "C:\BlueIris\overlays\UpdatePepperOverlay.txt"  # File for updating the overlay

# Function to update overlay text file
function Update-Overlay {
    param (
        [string]$text
    )
    # Write the text to the overlay file
    Set-Content -Path $overlayFile -Value $text
}

# Retrieve temperature and humidity from Home Assistant and update overlay
$temp = Invoke-RestMethod -Uri "$ha_url/sensor.gw1100b_temperature_1" -Headers $headers -Method Get
$humidity = Invoke-RestMethod -Uri "$ha_url/sensor.gw1100b_humidity_1" -Headers $headers -Method Get

# Prepare the overlay text
$text = "Temp: $($temp.state)°F`nHumidity: $($humidity.state)%"

# Update the overlay file
Update-Overlay -text $text