Hello Community,
I have hit a bit of a road block and are seeking advice.
I am creating a schedule using @neliss scheduling component. I take the scheduling attributes and create a template sensor which I want to send to my ESP32 device, where I will use the schedule to provide local control of a heating system (similar to @BrianHanifin irrigation controller, but with on / off state control using a RTC, so if HA is down the device continues follow the schedule) .
The issue I am having is once I combine the attributes into a string via the template I get a unknown value if the length is over 255 chars.
My template code is as follows:-
{% set days = state_attr('switch.schedule_24abce','weekdays')%}
{% set times = state_attr('switch.schedule_24abce','timeslots')%}
{% set actions = state_attr('switch.schedule_24abce','actions.service')%}
{% set ns = namespace(counter=0) %}
{%- for day in days -%}
{% set day_var = {"sun": "1", "mon": "2", "tue": "3", "wed": "4", "thu": "5", "fri": "6", "sat": "7"}[day] | default("") %}
{%- set ns.counter = 0 %}
{%- for time in times %}
{%- set actions = state_attr('switch.schedule_24abce','actions')[ns.counter].service %}
{%- set action = actions.split('_') %}
{%- set start_time = time.split(' - ') -%}
{{ day_var }}:{{ start_time[0] }}={{action[1]}},
{%- set ns.counter = ns.counter + 1 %}
{%- endfor %}
{%- endfor %}
{%- set daysa = state_attr('switch.schedule_873981','weekdays') %}
{%- set timesa = state_attr('switch.schedule_873981','timeslots') %}
{%- set actionsa = state_attr('switch.schedule_873981','actions.service') %}
{%- set ns = namespace(counter=0) %}
{%- for day in daysa -%}
{% set day_var = {"sun": "1", "mon": "2", "tue": "3", "wed": "4", "thu": "5", "fri": "6", "sat": "7"}[day] | default("") %}
{%- set ns.counter = 0 %}
{%- for timea in timesa %}
{%- set actions = state_attr('switch.schedule_873981','actions')[ns.counter].service %}
{%- set action = actions.split('_') %}
{%- set start_time = timea.split(' - ') -%}
{{ day_var }}:{{ start_time[0] }}={{action[1]}}{%if not loop.last %},{% endif %}
{%- set ns.counter = ns.counter + 1 %}
{%- endfor %}
{%- endfor %}
The resultant string using the template editor in dev tools is
7:00:00:00=off,7:17:00:00=on,7:22:50:00=off,1:00:00:00=off,1:17:00:00=on,1:22:50:00=off,2:00:00:00=off,2:18:00:00=on,2:20:50:00=off3:00:00:00=off,3:18:00:00=on,3:20:50:00=off4:00:00:00=off,4:18:00:00=on,4:20:50:00=off5:00:00:00=off,5:18:00:00=on,5:20:50:00=off6:00:00:00=off,6:18:00:00=on,6:20:50:00=off
The scheduler looks like this (note have to use 2 schedulers weekdays and weekend schedule)
So I am looking for advice as to how to get this data to the esp device running ESPhome in a efficient way that can be easily consumed by ESPhome
Thanks in advanced