mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-08-15 10:04:35 +00:00
Updated with @Brianhanifin 's excellent code updates! New speech helpers and formatted light codes!
This commit is contained in:
@@ -74,16 +74,27 @@ speech_engine:
|
||||
{%- macro outside_weather() -%}
|
||||
Outside, it is going to be {{ states('sensor.dark_sky_minutely_summary') }}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro friendly_list(list) -%}
|
||||
{%- set temp = list|replace('_',' ')|replace(' ,',',')|replace(',',', ')|trim|title -%}
|
||||
{%- if list.split(',')|length > 1 -%}
|
||||
{%- set temp = temp+'^' -%}
|
||||
{%- set lastitem = temp.split(',')|last -%}
|
||||
{{ temp|replace(lastitem, ' and' + lastitem)|replace('^','') }}
|
||||
{%- else -%}
|
||||
{{ temp }}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro light_check() -%}
|
||||
{% if states.group.all_lights.state != 'off' -%}
|
||||
There are
|
||||
{%- set lights_on_count = sensor.lights_on_friendly|length + 1 -%}
|
||||
{%- if states.sensor.lights_on.state|length != 0 -%}
|
||||
{%- set lights_on_count = states.sensor.lights_on.state.split(',')|length -%}
|
||||
{%- set lights_on_friendly = friendly_list(states.sensor.lights_on.state|replace('light.','')|replace('switch.','')|replace('light','')|replace('lamp','')) -%}
|
||||
{%- if lights_on_count == 1 -%}
|
||||
The {{ sensor.lights_on_friendly }} is the only light on right now.
|
||||
The {{ lights_on_friendly }} light is on.
|
||||
{%- else -%}
|
||||
There are {{ lights_on_count }} lights on right now.
|
||||
The {{ sensor.lights_on_friendly }} are on.
|
||||
The {{ lights_on_friendly }} lights are on.
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
Reference in New Issue
Block a user