NSW Rural Fire Service Feed - How to create an alert for a sensor that does not exist (yet)!

Hi - Welcome to an early bush-fire season in NSW. (I had to report one on Sat eve)!

I have the feed up and running and a map on my Lovelace screen for a year or 2, it all works fine. :grinning_face_with_smiling_eyes:
What I would like to do is create an audible (tts) alert or notification but I donā€™t know how to do this as the integration only creates the sensor entities when a fire is reported. The sensor entities such as ā€œLocationā€ are of course uniquely named so my problem is:

  1. What can I use to trigger the ā€˜appearanceā€™ of a new fire?
  2. How do I point to the new entities without knowing their name (location)?

Ok, to partially answer my own question Iā€™ve managed to create an automation which triggers when something enters the bushfire zone. I put a wildcard ā€œ*ā€ and the code did not complain!

description: Notify when a bushfire is listed on the NSW rural service feed
trigger:
  - platform: geo_location
    source: geo_location.nsw_rural_fire_service_feed*
    zone: zone.bush_fire_alert_zone
    event: enter
    id: Bushfire start
condition:
  - condition: template
    value_template: "\"{{ trigger.to_state.attributes.type == 'Bush Fire' }}\""
action:
  - service: persistent_notification.create
    data:
      message: Bushfire alert
      notification_id: geo_location.nsw_rural_fire_service_feed*
  - service: media_player.play_media
    target:
      entity_id: media_player.living_room_display
    data:
      media_content_id: >-
        media-source://tts/cloud?message=A+bushfire+has+been+reported+within+30+kilometers&language=en-AU&voice=NatashaNeural
      media_content_type: provider
    metadata:
      title: A bushfire has been reported within 30 kilometers
      thumbnail: https://brands.home-assistant.io/_/cloud/logo.png
      media_class: app
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://tts
        - media_content_type: provider
          media_content_id: >-
            media-source://tts/cloud?message=A+bushfire+has+been+reported+within+30+kilometers&language=en-AU&voice=NatashaNeural
  - service: notify.mobile_app_sm_g970f
    data:
      message: Bush Fire Alert
mode: single

You have already found the geo_location automation trigger, and thatā€™s the one I would recommend for this job.

You can access the trigger data of the entity that triggered the automation. Despite not being explicitly mentioned you can use the metadata listed in the ā€˜zoneā€™ trigger section.

I am not currently using TTS message, but for comparison my Pushover notification looks like this:

action:
  - service: notify.pushover_monitoring
    data_template:
      message: >-
        {{trigger.to_state.name}}<br/>Distance: {{trigger.to_state.state}}
        km<br/>Alert Level:
        {{trigger.to_state.attributes.category}}<br/>Location:
        {{trigger.to_state.attributes.location}}<br/>Status:
        {{trigger.to_state.attributes.status}}<br/>Type:
        {{trigger.to_state.attributes.type}}.
      title: Fire Near Us
      data:
        html: 1

OK thanks for the guidance and feedback, I can now get notifications working but not the details of the data_template. Iā€™ve copied your above code, but itā€™s sent to my mobile.

service: notify.mobile_app_sm_g970f
data_template:
  message: >-
    {{trigger.to_state.name}}<br/>Distance: {{trigger.to_state.state}}
    km<br/>Alert Level: 
    {{trigger.to_state.attributes.category}}<br/>Location:
    {{trigger.to_state.attributes.location}}<br/>Status:
    {{trigger.to_state.attributes.status}}<br/>Type:
    {{trigger.to_state.attributes.type}}.
  title: Fire Near Us
  data:
    html: 1

Unfortunately this throws an error when I try to run it.

Error running action

Error rendering data template: UndefinedError: ā€˜triggerā€™ is undefined

I wonder if I have a syntax or formatting error or, is the error due to the fact that the variable ā€˜triggerā€™ does not exist until the automation is triggered? If so how is it possible to test or do I just wait for a bush fire! :grinning_face_with_smiling_eyes:

ā€¦and now there has been a bush fire which got pushed to my phone overnight. I can therefore confirm the message structure above works well. :grinning: The only remaining query I have is would it be possible to trigger/run this automation and test it without a feed coming from the bush fire website?

Good to hear that itā€™s working.

I donā€™t think there is any way to manually trigger an automation and emulate the trigger data. The documentation confirms this limitation.

Thanks for pointing to the documentation. I do try and read things first but sometimes miss key issues!

Everything is working nicely and just in time for a heatwave this weekend. For anyone wanting to see my current automation here it is below. I am going to add a new condition though, just to inhibit the TTS announcements during the night, say 11pm to 6am.

alias: Bush Fire Alert
description: Alert on bush fire starting in a zone
trigger:
  - platform: geo_location
    source: nsw_rural_fire_service_feed
    zone: zone.bush_fire_zone
    event: enter
condition: []
action:
  - service: notify.mobile_app_sm_g970f
    data_template:
      message: >-
        {{trigger.to_state.name}}<br/>Distance: {{trigger.to_state.state}}
        km<br/>Alert Level: 
        {{trigger.to_state.attributes.category}}<br/>Location:
        {{trigger.to_state.attributes.location}}<br/>Status:
        {{trigger.to_state.attributes.status}}<br/>Type:
        {{trigger.to_state.attributes.type}}.
      title: Fire Near You
      data:
        html: 1
  - service: tts.cloud_say
    data_template:
      message: >-
        Please be aware that a bush fire has been reported at
        {{trigger.to_state.name}}. This fire is {{trigger.to_state.state}}
        kilometers away from you and the alert level is
        {{trigger.to_state.attributes.category}}. The full location details are
        {{trigger.to_state.attributes.location}}. The status is
        {{trigger.to_state.attributes.status}} and the type of fire is classed
        as a {{trigger.to_state.attributes.type}}.
    data:
      cache: false
      entity_id: media_player.living_room_display

1 Like