Fire Danger Rating

Do you live in New South Wales and are interested in integrating the local fire danger rating and fire ban indication? Have a look at how I have done exactly that with a simple custom component leveraging an XML feed provided by the NSW Rural Fire Service:

3 Likes

You are the best!!! :heart_eyes::kissing_heart: I was looking at this a week or so ago and couldn’t work out how to scrape the XML file. Pretty much gave up and moved on to something else as custom components are beyond me.

Just installed and it works great!! I’ll have a look later at getting this into a nice looking card, or even a custom card if I can.

1 Like

Adding this right now!

1 Like

I don’t suppose you are able to do the same thing for qld at all?

The Rural Fire Service’s Fire Danger Rating page just shows maps; maybe you could integrate the current day’s map (https://www.qfes.qld.gov.au/FDR/bomfdrday1.png) using a picture card?

I just had a look at what the BoM publishes, and the data published for Queensland may be suitable as it contains exactly one fire danger entry per area (unlike NSW or WA where each area is sub-divided and contains multiple fire danger ratings).
How good are your Python skills? :slight_smile: You could certainly use my code as a blueprint and adopt it to parse the data from the BoM feed.

1 Like

For anyone interested… I’m using the geo-location as well as this on a Lovelace card and it looks like this:

My package is here:

# Download the fire-danger icons from my github https://github.com/DavidFW1960/home-assistant/tree/master/www/icons/firedanger
# and save them under /www/icons/firedanger/ in your configuration folder.

homeassistant:
  customize:
    sensor.fire_danger_in_greater_sydney_region:
      hidden: true

geo_location:
  - platform: nsw_rural_fire_service_feed
    entity_namespace: 'nsw_fire_service_feed'
    radius: 100
    categories:
      - 'Emergency Warning'
      - 'Watch and Act'
      - 'Advice'
      - 'Not Applicable'

sensor:
  - platform: nsw_rural_fire_service_fire_danger
    district_name: Greater Sydney Region
  - platform: template
    sensors:
      fire_danger_level_today:
        friendly_name: "Danger Level Today"
        value_template: "{{ state_attr('sensor.fire_danger_in_greater_sydney_region', 'danger_level_today') | title }}"
        icon_template: mdi:fire

binary_sensor:
  - platform: template
    sensors:
      fire_ban_today:
        friendly_name: "Fire Ban Today"
        value_template: "{{ state_attr('sensor.fire_danger_in_greater_sydney_region', 'fire_ban_today') }}"
        device_class: safety

You can download the icons as per my first link. If anyone can improve on these I’m happy to update… mine are pretty crappy!

My lovelace for this card:

          - type: entities
            title: NSW Warnings & Events
            show_header_toggle: false
            entities:
              - binary_sensor.fire_ban_today
              - sensor.fire_danger_level_today
          - type: conditional
            conditions:
              - entity: sensor.fire_danger_level_today
                state: 'Low Moderate'
            card:
              type: picture-entity
              entity: sensor.fire_danger_level_today
              show_name: false
              show_state: false
              image: /local/icons/firedanger/low-moderate.png
          - type: conditional
            conditions:
              - entity: sensor.fire_danger_level_today
                state: 'High'
            card:
              type: picture-entity
              entity: sensor.fire_danger_level_today
              show_name: false
              show_state: false
              image: /local/icons/firedanger/high.png
          - type: conditional
            conditions:
              - entity: sensor.fire_danger_level_today
                state: 'Very High'
            card:
              type: picture-entity
              entity: sensor.fire_danger_level_today
              show_name: false
              show_state: false
              image: /local/icons/firedanger/very-high.png
          - type: conditional
            conditions:
              - entity: sensor.fire_danger_level_today
                state: 'Severe'
            card:
              type: picture-entity
              entity: sensor.fire_danger_level_today
              show_name: false
              show_state: false
              image: /local/icons/firedanger/severe.png
          - type: conditional
            conditions:
              - entity: sensor.fire_danger_level_today
                state: 'Extreme'
            card:
              type: picture-entity
              entity: sensor.fire_danger_level_today
              show_name: false
              show_state: false
              image: /local/icons/firedanger/extreme.png
          - type: conditional
            conditions:
              - entity: sensor.fire_danger_level_today
                state: 'Catastrophic'
            card:
              type: picture-entity
              entity: sensor.fire_danger_level_today
              show_name: false
              show_state: false
              image: /local/icons/firedanger/catastrophic.png
          - type: entities
            entities: 
              - type: custom:auto-entities
                card:
                  type: custom:fold-entity-row
                  head:
                    type: section
                    label: Current Incidents
                  open: true
                filter:
                  include:
                    - entity_id: "geo_location.nsw_fire_service_feed_*"
                show_empty: true
          - type: map
            show_header_toggle: false
            geo_location_sources:
              - nsw_rural_fire_service_feed
            entities:
              - zone.home

You’ll also need the custom auto-entities and fold entities row cards by Thomas Lovern

3 Likes

Thanks very much for sharing your Lovelace UI configuration here. That’s a great way to display the fire rating.

1 Like

Thanks for sharing David. I’ve implemented what you have shared and it works great. As I have a dark theme, the danger rating sign just isn’t working for me as it is now. I think it’s the big white area behind the sign (which I could edit out with Photoshop).

Yeah for a dark theme… I will make the background transparent which should fix it…

1 Like

OK I have redone the icons as Transparent so should work on a dark background now. Also made the indicatoe hand much nicer

Nice. Have you updated your repo yet? It’s still showing the old ones.

oh shit! sorry I meant to. Done now.

Hmm, the black pointer is a bit hard to see, but it’s looking great!!!

Annotation%202019-02-05%20142220

maybe an arrow like this would work well for all background colours…

If you can give me an image of the pointer I can adjust them… It wasn’t easy getting an image to use…

Ah, ok. I’ll have a look and see what I can find. I might be able to extract that one.

@DavidFW1960 I’ve saved you the trouble. Found a bunch of facebook pages for Fire Danger Ratings for all the different regions in NSW. They have the graphic there for most of the conditions (Couldn’t find Extreme or Catastrophic), so pulled out Photoshop and hey presto!! There is a faint line around the border, but for now, I’m happy with what I have.

If you or anyone else is interested, you can grab them from here. https://github.com/cjsmns/icons/tree/master/firedanger

Annotation%202019-02-05%20164734

3 Likes

Getting this error today:

Sat Feb 09 2019 11:20:53 GMT+1100 (Australian Eastern Daylight Time)
Error fetching data: <PreparedRequest [GET]> from http://www.rfs.nsw.gov.au/feeds/fdrToban.xml failed with HTTPConnectionPool(host='www.rfs.nsw.gov.au', port=80): Max retries exceeded with url: /feeds/fdrToban.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fcc92da8a20>: Failed to establish a new connection: [Errno -3] Try again',))
Service persistent_notification/dismiss called.

I can go to the xml address and get an answer but the sensor says unavailable

Just refreshed the entity

I have had several slightly different error message while developing this custom component, but I can’t remember “Try again”.
Was this just intermittent or did the error occur over a longer period of time? In its current implementation the sensor will just try again every 10 minutes.

Last weekend Optus cut me off the Internet for 3 days, and I got “Temporary failure in name resolution” errors which makes sense because HA simply couldn’t access the webserver.

Yeah it was transient and I haven’t seen it again…

If you have been enjoying this custom component, please be aware that at some point in the near future you will have to modify the folder structure a bit. Please follow these steps to migrate when you upgrade to Home Assistant version 0.88 or later:

  • Create new folder nsw_rural_fire_service_fire_danger underneath <config>/custom_components.
  • Move the file <config>/custom_components/sensor/nsw_rural_fire_service_fire_danger.py to folder <config>/custom_components/nsw_rural_fire_service_fire_danger.
  • Rename nsw_rural_fire_service_fire_danger.py to sensor.py.
  • Create an empty file __init__.py inside folder <config>/custom_components/nsw_rural_fire_service_fire_danger.
  • Restart Home Assistant.

I have updated the original blog post to reflect these changes as well.