{%- 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.state }}%, and you can drive about {{ (states.sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor.state | int) | round(0) }} miles.
{% endif %}
{%- endmacro %}
{#- Check for low humidity levels in autumn, winter and high levels during rest of the year -#}
{%- macro humidity_status() -%}
{%- if states.sensor.season.state| lower == "autumn" or states.sensor.season.state| lower == "winter" %}
{%- if states.sensor.dining_room_thermostat_humidity.state | int < 30 -%}
Home humidity is less than 30%.
{%- endif -%}
{% else %}
{%- if states.sensor.dining_room_thermostat_humidity.state | default(0) | int > 60 -%}
Home humidity is more than 60%.
{%- endif -%}
{%- endif -%}
{%- endmacro -%}
{%- macro clean_up(data) -%}
{%- for item in data.split("\n") if item | trim != "" -%}
{{item | trim }} {% endfor -%}
{%- endmacro -%}
{%- macro getGreeting() -%}
{%- if greeting | default('yes', true ) == "yes" -%}
{% if now().hour|int < 12 %}
Have a great day!
{% elif now().hour|int < 18 %}
Enjoy your afternoon!
{% elif now().hour|int < 20 %}
Enjoy your evening!
{% else %}
Have a good night!
{% endif %}
{%- endif -%}
{%- endmacro -%}
{#- Main macro that runs all other macros and combines the information -#}
{%- macro run_script() -%}
It is {% if now().hour > 12 %}{{ now().hour | int - 12 }}: {{- now().minute }} PM{% else %}{{ now().hour }}: {{- now().minute }} PM{% endif %}. Here is the status of your home.{{- alarm_status() -}}
{%- set battery_output = low_battery_check() -%}
{%- if battery_output | trim != "" -%}
{{- battery_output -}} Please make sure you put the phones to charge.
{%- endif -%}
{%- set light_output = light_status() -%}
{%- if light_output | trim == "" -%}
All the lights in the house are OFF.
{%- else -%}
{{- light_output -}}
{%- 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 == "" -%}
The garage doors are closed.
{%- elif single_car_garage | trim != "" and two_car_garage | trim != "" -%}