mirror of
https://github.com/skalavala/mysmarthome.git
synced 2025-09-13 15:05:00 +00:00
Upgraded to 0.105.0!
This commit is contained in:
@@ -1,75 +1,86 @@
|
||||
>
|
||||
{% macro weather_update() -%}
|
||||
Outside temperature is {{ states('sensor.dark_sky_apparent_temperature') | round(0) }} degrees.
|
||||
Outside temperature is {{ states('sensor.dark_sky_apparent_temperature') | round(0) }} degrees.
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro uv_levels() -%}
|
||||
{%- set uv = states('sensor.pws_uv') | int -%}
|
||||
{%- if uv >= 6 and uv <= 7 -%}
|
||||
Current UV index is high. Please be careful outdoors.
|
||||
{%- elif uv >= 8 and uv <= 10 -%}
|
||||
Current UV index is very high. It is not advised to go out.
|
||||
{%- elif uv >= 11 -%}
|
||||
Current UV index is extremely high. It is highly advised to stay indoors.
|
||||
{%- else -%}
|
||||
Good UV levels.
|
||||
{%- endif -%}
|
||||
{%- set uv = states('sensor.pws_uv') | int -%}
|
||||
{%- if uv >= 6 and uv <= 7 -%}
|
||||
Current UV index is high. Please be careful outdoors.
|
||||
{%- elif uv >= 8 and uv <= 10 -%}
|
||||
Current UV index is very high. It is not advised to go out.
|
||||
{%- elif uv >= 11 -%}
|
||||
Current UV index is extremely high. It is highly advised to stay indoors.
|
||||
{%- else -%}
|
||||
Good UV levels.
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro USPS() -%}
|
||||
USPS is going to deliver {{ states('sensor.usps_mail') }} mails today.
|
||||
{%- if states('sensor.usps_mail') | int > 0 -%}
|
||||
USPS is going to deliver {{ states('sensor.usps_mail') }} mails today.
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro alert_battery_levels() %}
|
||||
{% for item in states if 'battery_level' in item.attributes and item.attributes.battery_level | int > 0 and item.attributes.battery_level | float <= 10.0 -%}{{- item.attributes.friendly_name ~ " battery is less than 10 percent" -}}
|
||||
{%- if loop.first %}, {% elif loop.last %}, {% else %}, {% endif -%}
|
||||
{%- endfor -%}
|
||||
{% for item in states if 'battery_level' in item.attributes and item.attributes.battery_level | int > 0 and item.attributes.battery_level | float <= 10.0 -%}{{- item.attributes.friendly_name ~ " battery is less than 10 percent" -}}
|
||||
{%- if loop.first %}, {% elif loop.last %}, {% else %}, {% endif -%}
|
||||
{%- endfor -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro tesla_status() -%}
|
||||
{%- if states("sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor") != "unknown" -%}
|
||||
Your Tesla car battery is at {{ states('sensor.tesla_model_3_5yj3e1ea8jf010610_battery_sensor') }} percent ({{ (states('sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor') | int) | round(0) }} miles).
|
||||
{%- endif -%}
|
||||
{%- if states("sensor.tesla_model_3_range_sensor") != "unknown" -%}
|
||||
Your Tesla car battery is at {{ states('sensor.tesla_model_3_battery_sensor') }} percent ({{ (states('sensor.tesla_model_3_range_sensor') | int) | round(0) }} miles).
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro pollen_levels() -%}
|
||||
Pollen level is {{ states('sensor.pollen_level') }}.
|
||||
{% if states('sensor.pollen_level') != 'unknown' %}
|
||||
Pollen level is {{ states('sensor.pollen_level') }}.
|
||||
{% endif %}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro humidity_status() -%}
|
||||
Home humidity is {{ states('sensor.dining_room_thermostat_humidity') }} percent.
|
||||
Home humidity is {{ states('sensor.dining_room_thermostat_humidity') }} percent.
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro alarm_status() -%}
|
||||
Your home is {{ "SECURED!" if states('alarm_control_panel.simplisafe') == "armed_away" or states('alarm_control_panel.simplisafe') == "armed_home" else "UNSECURED!" }}
|
||||
Your home is {{ "SECURED!" if states('alarm_control_panel.home') == "armed_away" or states('alarm_control_panel.home') == "armed_home" else "UNSECURED!" }}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro single_car_garage_door_status() -%}
|
||||
{%- if states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') |lower == "on" -%}
|
||||
{{ states.binary_sensor.single_car_garage_door_tilt_sensor_sensor.attributes.friendly_name }} is OPEN
|
||||
{%- endif -%}
|
||||
{%- if states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') |lower == "on" -%}
|
||||
{{ states.binary_sensor.single_car_garage_door_tilt_sensor_sensor.attributes.friendly_name }} is OPEN!
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro two_car_garage_door_status() -%}
|
||||
{% if states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') |lower == "on" %}
|
||||
{{ states.binary_sensor.two_car_garage_door_tilt_sensor_sensor.attributes.friendly_name }} is OPEN
|
||||
{% endif %}
|
||||
{% if states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') |lower == "on" %}
|
||||
{{ states.binary_sensor.two_car_garage_door_tilt_sensor_sensor.attributes.friendly_name }} is OPEN!
|
||||
{% endif %}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro garage_status() -%}
|
||||
{%- set single_car_garage = single_car_garage_door_status() -%}
|
||||
{%- set two_car_garage = two_car_garage_door_status() -%}
|
||||
{%- if single_car_garage | trim == "" and two_car_garage | trim == "" -%}
|
||||
Both the garage doors are CLOSED!
|
||||
{%- elif single_car_garage | trim != "" and two_car_garage | trim != "" -%}
|
||||
Warning! Both garage doors are OPEN.
|
||||
{% else %}
|
||||
Warning! {{ single_car_garage }} {{ two_car_garage }}
|
||||
{%- endif -%}
|
||||
{%- set single_car_garage = single_car_garage_door_status() -%}
|
||||
{%- set two_car_garage = two_car_garage_door_status() -%}
|
||||
{%- if single_car_garage | trim == "" and two_car_garage | trim == "" -%}
|
||||
Both the garage doors are closed.
|
||||
{%- elif single_car_garage | trim != "" and two_car_garage | trim != "" -%}
|
||||
Warning! Both garage doors are OPEN!
|
||||
{% else %}
|
||||
Warning! {{ single_car_garage }} {{ two_car_garage }}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro plural(name) -%}
|
||||
{{- "true" if name.endswith("s") else "false" -}}
|
||||
{{- "true" if name.endswith("s") else "false" -}}
|
||||
{%- endmacro -%}
|
||||
|
||||
{# a macro that removes all newline characters, empty spaces, and returns formatted text #}
|
||||
{%- macro cleanup(data) -%}
|
||||
{% for item in data.split("\n") if item | trim != "" -%}
|
||||
{{ item | trim }}
|
||||
{% endfor %}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro light_status() -%}
|
||||
@@ -87,25 +98,25 @@
|
||||
"switch.office_room",
|
||||
"switch.wemobackyardlightswitch",
|
||||
"switch.zwave_smart_switch_switch"] %}
|
||||
{% for item in lights_switches -%}
|
||||
{%- if states[item.split('.')[0]][item.split('.')[1]].state == "on" -%}
|
||||
{%- set friendly_name = states[item.split('.')[0]][item.split('.')[1]].attributes.friendly_name -%}
|
||||
{{ friendly_name }} {{ 'are' if plural(friendly_name) == "true" else 'is' }} ON.
|
||||
{% endif %}
|
||||
{%- endfor -%}
|
||||
{% for item in lights_switches -%}
|
||||
{%- if states[item.split('.')[0]][item.split('.')[1]].state == "on" -%}
|
||||
{%- set friendly_name = states[item.split('.')[0]][item.split('.')[1]].attributes.friendly_name -%}
|
||||
{{ friendly_name }} {{ 'are' if plural(friendly_name) == "true" else 'is' }} ON.
|
||||
{% endif %}
|
||||
{%- endfor -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro mother_of_all_macros() -%}
|
||||
{{ alarm_status() }}
|
||||
{{ garage_status() }}
|
||||
{{ USPS() }}
|
||||
{{ tesla_status() }}
|
||||
{{ weather_update() }}
|
||||
{{ humidity_status() }}
|
||||
{{ uv_levels() }}
|
||||
{{ pollen_levels() }}
|
||||
{{ alert_battery_levels() }}
|
||||
{{ light_status() }}
|
||||
{{ alarm_status() }}
|
||||
{{ garage_status() }}
|
||||
{{ USPS() }}
|
||||
{{ tesla_status() }}
|
||||
{{ weather_update() }}
|
||||
{{ humidity_status() }}
|
||||
{{ uv_levels() }}
|
||||
{{ pollen_levels() }}
|
||||
{{ alert_battery_levels() }}
|
||||
{{ light_status() }}
|
||||
{%- endmacro -%}
|
||||
|
||||
{{- mother_of_all_macros() -}}
|
||||
{{- cleanup(mother_of_all_macros()) -}}
|
||||
|
@@ -10,7 +10,7 @@
|
||||
{%- for item in states.device_tracker if '_' in item.entity_id.split('.')[1] and state_attr(item.entity_id, "battery") |lower != "none" -%}
|
||||
{%- if item.attributes.battery|int < level -%}
|
||||
{%- if states("sensor." ~ item.friendly_name |lower ~"s_iphone_battery_state") | lower != "charging" %}
|
||||
{{- item.attributes.friendly_name}}s iPhone battery is at {{ item.attributes.battery }} percent.
|
||||
{{- item.attributes.friendly_name | replace("life360", "") |title }}'s iPhone battery is at {{ item.attributes.battery }} percent.
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- endfor -%}
|
||||
@@ -46,11 +46,11 @@
|
||||
|
||||
{#- Provides Home Security System Status -#}
|
||||
{%- macro alarm_status() -%}
|
||||
{%- if states('alarm_control_panel.simplisafe') | lower == "disarmed" -%}
|
||||
{%- if states('alarm_control_panel.home') | lower == "disarmed" -%}
|
||||
Your home security system is switched OFF. You may want to turn it ON.
|
||||
{%- elif states('alarm_control_panel.simplisafe') | lower == "armed_away" -%}
|
||||
{%- elif states('alarm_control_panel.home') | lower == "armed_away" -%}
|
||||
Your home security system is set to away mode.
|
||||
{%- elif states('alarm_control_panel.simplisafe') | lower == "armed_home" -%}
|
||||
{%- elif states('alarm_control_panel.home') | lower == "armed_home" -%}
|
||||
Your home security system is ON, and your home is secured.
|
||||
{%- endif %}
|
||||
{%- endmacro -%}
|
||||
@@ -87,7 +87,7 @@
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro charging_status() -%}
|
||||
{%- for item in states if "iphone_battery_state" in item.entity_id and item.state != "Charging" %}
|
||||
{%- for item in states if "_iphone_battery_state" in item.entity_id and item.state != "Charging" %}
|
||||
{%- if loop.first %}{% elif loop.last %} and {% else %}, {% endif -%}{{- item.name.split(' ')[0] -}}
|
||||
{%- endfor -%}
|
||||
{%- endmacro -%}
|
||||
@@ -115,12 +115,12 @@
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro tesla_status() %}
|
||||
{%- if states("binary_sensor.tesla_model_3_5yj3e1ea8jf010610_charger_sensor") != "unknown" -%}
|
||||
Your Tesla Car is {{ 'not' if states('binary_sensor.tesla_model_3_5yj3e1ea8jf010610_charger_sensor') == "off" }} plugged in.
|
||||
{%- if states("binary_sensor.tesla_model_3_charger_sensor") != "unknown" -%}
|
||||
Your Tesla Car is {{ 'not' if states('binary_sensor.tesla_model_3_charger_sensor') == "off" }} plugged in.
|
||||
{% endif %}
|
||||
|
||||
{%- if states("sensor.tesla_model_3_5yj3e1ea8jf010610_battery_sensor") != "unknown" and states("sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor") != "unknown" and states('sensor.tesla_model_3_5yj3e1ea8jf010610_battery_sensor') | int > 0 -%}
|
||||
Tesla Car battery is at {{ states('sensor.tesla_model_3_5yj3e1ea8jf010610_battery_sensor') }}%, and you can drive about {{ (states.sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor.state | int) | round(0) }} miles.
|
||||
{%- if states("sensor.tesla_model_3_battery_sensor") != "unknown" and states("sensor.tesla_model_3_range_sensor") != "unknown" and states('sensor.tesla_model_3_battery_sensor') | int > 0 -%}
|
||||
Tesla Car battery is at {{ states('sensor.tesla_model_3_battery_sensor') }}%, and you can drive about {{ (states.sensor.tesla_model_3_range_sensor.state | int) | round(0) }} miles.
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
|
@@ -19,10 +19,10 @@
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro tesla_status() -%}
|
||||
{% if states("sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor") != "unknown" %}
|
||||
{%- if (states('sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor') | int) | round(0) < 75 and
|
||||
(states('sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor') | int) | round(0) > 0 -%}
|
||||
Attention!. Your Tesla car battery is at {{ states('sensor.tesla_model_3_5yj3e1ea8jf010610_battery_sensor') }} percent. and you can only drive about {{ (states('sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor') | int) | round(0) }} miles. Please charge your car if you want to go anywhere.
|
||||
{% if states("sensor.tesla_model_3_range_sensor") != "unknown" %}
|
||||
{%- if (states('sensor.tesla_model_3_range_sensor') | int) | round(0) < 75 and
|
||||
(states('sensor.tesla_model_3_range_sensor') | int) | round(0) > 0 -%}
|
||||
Attention!. Your Tesla car battery is at {{ states('sensor.tesla_model_3_battery_sensor') }} percent. and you can only drive about {{ (states('sensor.tesla_model_3_range_sensor') | int) | round(0) }} miles. Please charge your car if you want to go anywhere.
|
||||
{%- endif -%}
|
||||
{% endif %}
|
||||
{%- endmacro -%}
|
||||
|
Reference in New Issue
Block a user