Adding syntax highlighting to MarkDown

main
Stuart Lamont 3 years ago
parent 33ad3111e5
commit 52d9986aac

@ -0,0 +1,36 @@
Get a Morning Briefing from your Smart Home
*** Links ***
Hive Mind Automation on YouTube: https://www.youtube.com/c/HiveMindAutomation
*** Support the Channel***
Buy Me a Coffee: https://buymeacoffee.com/HiveMindAuto
*** Find Hive Mind Automation on Social Media ***
Twitter: https://twitter.com/HiveMindAuto
Instagram: https://www.instagram.com/HiveMindAutomation/
Facebook: https://www.facebook.com/HiveMindAutomation
*** Affiliate Links ***
*** These links help the channel by providing a commission on purchases
*** TIMESTAMPS ***
0:00 Intro
*** Helpful Links ***
Home Assistant: https://www.home-assistant.io/
Raspberry Pi: https://www.raspberrypi.org/
Balena Etcher: https://www.balena.io/etcher/
Home Assistant for iOS: https://apple.co/34JATce
Home Assistant for Android: https://bit.ly/30VUsNh
*** CREDITS ***
Music: https://www.purple-planet.com

@ -0,0 +1,63 @@
# Home Assistant Pending Updates Announcement
I also wanted The Briefing to announce if there's any pending Home Assistant updates to be installed, but I want to limit it down to only the Home Assistant Core, Home Assistant OS, and ESPHome.
![Home Assistant OS Pending Update](pendingUpdate.png)
So I came up with the following Template
In hindsight, I should probably put this into a for loop.
I'll do that for version 2 maybe....
### The Template
```jinja
{% if states('update.home_assistant_operating_system_update') == 'off' %}
There's a Home Assistant O S Update pending.
The Installed version is {{ state_attr('update.home_assistant_operating_system_update', 'installed_version') }}
The Available version is {{ state_attr('update.home_assistant_operating_system_update', 'latest_version') }}
{% endif %}
{% if states('update.home_assistant_core_update') == 'off' %}
There's a Home Assistant Core Update pending.
The Installed version is {{ state_attr('update.home_assistant_core_update', 'installed_version') }}
The Available version is {{ state_attr('update.home_assistant_core_update', 'latest_version') }}
{% endif %}
{% if states('update.esphome_update') == 'off' %}
There's an E S P Home Update pending.
The Installed version is {{ state_attr('update.esphome_update', 'installed_version') }}
The Available version is {{ state_attr('update.esphome_update', 'latest_version') }}
{% endif %}
```
### The Home Assistant Script
Here's the script I put into my `scripts.yaml` or you can just paste it into the Home Assistant UI when editing the script in YAML mode.
```yaml
alias: Announce Pending Updates
sequence:
- service: notify.alexa_media
data:
message: >-
{% if states('update.home_assistant_operating_system_update') == 'on' %}
There's a Home Assistant O S Update pending. The Installed version is
{{ state_attr('update.home_assistant_operating_system_update',
'installed_version') }}.
The Available version is {{ state_attr('update.home_assistant_operating_system_update', 'latest_version') }}.
{% endif %}
{% if states('update.home_assistant_core_update') == 'on' %}
There's a Home Assistant Core Update pending. The Installed version is
{{ state_attr('update.home_assistant_core_update', 'installed_version') }}.
The Available version is {{ state_attr('update.home_assistant_core_update', 'latest_version') }}.
{% endif %}
{% if states('update.esphome_update') == 'on' %}
There's an E S P Home Update pending. The Installed version is
{{ state_attr('update.esphome_update', 'installed_version') }}.
The Available version is
{{ state_attr('update.esphome_update', 'latest_version') }}.
{% endif %}
target:
- media_player.dining_room_echo_plus
mode: single
icon: mdi:update
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

@ -1,20 +1,20 @@
# Jinja template for Home Assistant for Time
## get Current Time from Home Assistant
```
```jinja
{% set current_time = states('sensor.time') %}
```
### extract the current hour
```
```jinja
{% set hour = current_time.split(':')[0] | int %}
```
### and Minute
```
```jinja
{% set minute = current_time.split(':')[1] %}
```
## Say a time appropriate greeting
```
```jinja
{% if hour >= 6 and hour < 12 %}
Good morning!
{% elif hour >= 12 and hour < 18 %}
@ -25,18 +25,20 @@
```
## Add AM or PM Suffix for announcement
```
```jinja
{% set suffix = 'AM' if hour < 12 else 'PM' %}
```
## convert 24 hour time to 12 hour time
```
```jinja
{% set hour_12 = hour if hour <= 12 else hour - 12 %}
```
## Announce the current Time
```jinja
It's currently {{ hour_12 }}:{{ minute }} {{ suffix }}.
```
## Put it all together:
```
```jinja
# get Current Time from Home Assistant
{% set current_time = states('sensor.time') %}
# Split time into hour
@ -59,4 +61,34 @@ It's currently {{ hour_12 }}:{{ minute }} {{ suffix }}.
# Announce the current Time
It's currently {{ hour_12 }}:{{ minute }} {{ suffix }}.
```
## The Home Assistant Script
```yaml
announce_time:
alias: Announce Time
sequence:
- service: notify.alexa_media
data:
message: "
{% set current_time = states('sensor.time') %}
{% set hour = current_time.split(':')[0] | int %}
{% set minute = current_time.split(':')[1] %}
{% if hour >= 6 and hour < 12 %}
Good morning!
{% elif hour >= 12 and hour < 18 %}
Good afternoon!
{% elif hour >= 18 or hour < 6 %}
Good evening!
{% endif %}
{% set suffix = ''AM'' if hour < 12 else 'PM' %}
{% set hour_12 = hour if hour <= 12 else hour - 12 %}
It's currently {{ hour_12 }}:{{ minute }} {{ suffix }}.
"
target:
- media_player.dining_room_echo_plus
mode: single
```

@ -1,13 +1,14 @@
# Home Assistant Jinja Templating to anmnounce Wind Details
## get the current wind speed and wind bearing in degrees from Home Assistant
```
```jinja
{% set wind_bearing = state_attr('weather.home', 'wind_bearing') | float %}
{% set wind_speed = state_attr('weather.home','wind_speed') | float %}
```
## This array is a list of Cardinal Directions allowing us to convert the
```
## This array is a list of Cardinal Directions allowing us to convert the bearing into one of them.
### Admittedly, This is more complicated than it needs to be.
```jinja
{% set directions = {
(0.0, 11.25): 'North',
(11.25, 33.75): 'North North East',
@ -30,7 +31,7 @@
```
## Announce a qualitative description of wind speed
```
```jinja
{% if wind_speed > 50 %}
Its very windy outside.
{% elif 40 < wind_speed < 50 %}
@ -46,8 +47,9 @@
{% endif %}
```
###
```
### Announce the Cardinal Direction and Wind Speed
```jinja
{% for rng, direction in directions.items() %}
{% if wind_bearing >= rng[0] and wind_bearing < rng[1] %}
The wind is currently blowing from the {{ direction }} direction, at {{ wind_speed }} kilometres per hour

Loading…
Cancel
Save

Powered by TurnKey Linux.