Skip to content

Instantly share code, notes, and snippets.

@jkap
Created January 21, 2025 16:02
Show Gist options
  • Save jkap/cacf6e10235e6e8ed0af79c00babbbf5 to your computer and use it in GitHub Desktop.
Save jkap/cacf6e10235e6e8ed0af79c00babbbf5 to your computer and use it in GitHub Desktop.
French Toast Alert for Home Assistant

French Toast Alert for Home Assistant

Display the current French Toast Alert in your Home Assistant instance.

How to use

Merge the contents of configuration.yaml into your config. These shouldn't require a full home assistant restart, just a quick reload.

sensor:
# REST sensor for the raw french toast data. processed by a template sensor below.
- platform: rest
value_template: "OK"
resource: "https://www.universalhub.com/toast.xml"
name: "french toast raw status"
json_attributes_path: "$.frenchtoast"
json_attributes:
- status
template:
# the actual sensor that you want to use in your dashboards, automations, etc.
# `icon_color` is an undocumented hack to have the state color set correctly in lovelace.
# I'm using CSS vars here so if you want to use that attribute for light colors,
# discord webhook color, etc, then you'll want to make those raw values.
- sensor:
- name: "French Toast Alert"
state: "{{ state_attr('sensor.french_toast_raw_status', 'status') | regex_findall(find='^\\d') | first }}"
attributes:
state_text: "{{ state_attr('sensor.french_toast_raw_status', 'status') | regex_findall(find='- (\\w+)$') | first }}"
icon_color: >
{% if this.state == "1" %}
var(--green-color)
{% elif this.state == "2" %}
var(--blue-color)
{% elif this.state == "3" %}
var(--yellow-color)
{% elif this.state == "4" %}
var(--orange-color)
{% elif this.state == "5" %}
var(--red-color)
{% else %}
magenta
{% endif %}
state_class: "measurement"
unit_of_measurement: "slices"
icon: mdi:bread-slice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment