What I’d like
I have a local calendar—let’s call it “Work Sessions”—which contains one event for each client I will see that day. I also have a Workday sensor, binary_sensor.spencer_workday
that defines the days of the week I work (or, rather, lists them as an attribute).
I would like to script three different responses that can be used in TTS or conversation responses:
- Clients on next workday: “Next Tuesday, you have 3 clients scheduled.”
- Detailed agenda today: “Today, you have 3 clients scheduled, starting at 10am and ending at 3pm.”
- Week summary: “You have a total of 6 clients scheduled this week, on Tuesday and Thursday.”
When the script is built, I’m hoping not to permanently store the response variable data in sensors, because that’s a lot of data that I only really need to reference at runtime.
I’m also trying to avoid hardcoding days of the week when possible, for the sake of future flexibility—this is why I’m trying to get workdays from the Workday sensor’s attributes instead of just declaring in the script or template that I want data for Tuesdays and Thursdays.
The issue I’m running into
Formulating any of this would require tinkering with Jinja filters. I am not nearly practiced enough at manipulating response data from the calendar.get_events
action or using Jinja filters to know how to do this offhand, which means I want to rely on the Template Editor to preview and build this template.
But the calendar data is delivered as a response variable, and I don’t believe there’s any way to call the calendar.get_events
action to get that variable in the Template Editor. I’m flying blind.
I know I can call calendar.get_events
from the Developer Tools settings, and get a response. That response would be perfectly suitable as dummy content for the purposes of troubleshooting; I don’t need the content to actually be up-to-date while I’m writing the template, I just need it to be accurate to the form and structure. But I don’t know how to properly define the hardcoded variable using that response data.
My asks
I could use help in either of these ways:
- Can you suggest how I can store the response variable so I can use it in the Template Editor? I assume this will look like storing it in a template sensor—but I’d love a direct example of how to write that template. I’m also open to just storing a “dummy” version of the data in a manually defined variable in the editor, as mentioned above, but I don’t know quite how to take the response I get from the actions dev tool and properly store it in a variable.
- If someone is feeling particularly generous, I’d love a nudge suggesting how to write the Jinja2 to do what I’ve described above. Even just walking me verbosely through the steps of the filters would be a big help, since I’m only barely grasping what data the returned variable will contain and how to manipulate it to get what I want.
These are the two biggest thorns; I’m fairly confident that I can start piecing things together if I can just figure out how to make some data accessible for use in the Template Editor.
Thanks in advance.