Fire Danger Rating

Each time I drive past our local fire station I see that fire danger rating sign and take a quick look. Wouldn’t it be great to have this information right in your favourite home automation system?

Luckily the NSW Rural Fire Service provides an XML feed that contains the fire danger details for today and tomorrow for districts in the state.

There is currently no simple way that I am aware of to scrap random XML in Home Assistant and convert and then display values from that XML as sensor values.

I decided to develop a small custom platform that retrieves the XML and then stores the relevant values in state attributes. You can then use template sensors to extract the data you actually want to display.

Just a quick note on using custom components in Home Assistant: The code may or may not work in future versions of Home Assistant.

After a restart of Home Assistant, a new sensor should now show up. In this example its entity id will be sensor.fire_danger_in_greater_sydney_region, so your entity id will be different if you have chosen a different district.

Fire danger retrieval sensor

The retrieval sensor’s state will either be ok or unknown, depending on if it was able to retrieve data from the XML feed or not, and you will find all the interesting bits in its state attributes.

Attribute

Description

district

District name

region_number

Internal number of this district

councils

List of all councils in this district

danger_level_today

Today’s danger level

danger_level_tomorrow

Tomorrow’s danger level

fire_ban_today

Indicates whether there is a fire ban today

fire_ban_tomorrow

Indicates whether there is a fire ban today

By default, the retrieval sensor updates from the feed every 10 minutes which should be fine under normal circumstances. You can change this by modifying the line SCAN_INTERVAL = timedelta(minutes=10) in the sensor’s code and pick a different interval.

Fire danger retrieval sensor more info dialogue

Configuring template sensors

At a minimum you are probably interested in today’s conditions, so let’s add two new template sensors, one that shows today’s danger level and the other one indicating whether there is a fire ban today.

In the below examples I am using my previously configured sensor from above, so please check your sensor’s entity id and replace that in the configuration below.

Fire Ban Today

The fire ban indicator is already transformed into a true/false value above, and can be used in a template binary sensor as follows:

I am using the safety device class here which I believe works well in badge mode:

Fire ban today off as badge

Fire ban today on as badge

But it may be a bit misleading when presented in a group. If there is a fire ban, the XML feed will contain the value “yes” which is turned into “true” in the retrieval sensor above. The safety device class defines “true” as unsafe and displays a warning sign. Likewise the badge displays as a shield with tick if the sensor value is “false”. However, the textual representation would be “Safe” = no fire ban, or “Unsafe” = fire ban. Please have a think about if this works for you or not.

Fire ban today on

Danger Level Today

The danger level is a textual description that can be used in a template sensor as follows:

Outlook

So far I find it useful to have the fire danger information available in Home Assistant, but would yet need to come up with any more sophisticated use-cases – other than a simple notification – to make use of this information.

At this point in time I am not sure if it is worth it transforming this custom component into a proper contribution for Home Assistant. What do you think?

The XML feed provided by the NSW Rural Fire Service is in a custom format, and I haven’t found any comparable feeds from other states. If anyone is aware of anything suitable, please let me know.

Compatibility

At the time of writing this post, I used:

Home Assistant 0.86.3 with Python 3.6.7

Update 04 Feb 2019

After publishing this on the Home Assistant community forum, I received some good feedback on this topic, and I just wanted to share one improvement in particular:

2 Replies to “Fire Danger Rating”

Hi, I posted this reply on your thread in HA, but in case you don’t see it, thought I should reply here too.

I’m having troubles getting this started – I have a sneaking suspicion it has something to do with the third-party library and my installing it incorrectly. I’m running the latest version of Hassbian. Here’s what I do.

I then proceed to follow the rest of your instructions – creating a folder in custom_components called `nsw_rural_fire_service_fire_danger` and then placing `sensory.py` and `__init__.py` into that folder.

When you manually copy files from GitHub, please make sure that you copy the raw file, not the HTML source of the file representation (i.e. don’t right-click on a filename and then “Save file as”). There is a “Raw” button in the UI that gives you the actual Python source code.