@Tamsy
Thanks - the offset isn’t the issue here, I wasn’t clear which issue I was trying to solve - it’s trying to make the temperature depend on something about the triggering event. For instance a coffee morning attended by more elderly guests needs the room warmer than a very active dance class.
@myle
That looks like a fairly simple “heater on/off” setup, which I can now confirm I have working (since the heating got turned on this morning automagically, hurrah). The issue I have is that I want to control the temperature based on “some information” in the calendar event - that means that when a booking is taken, we can specify a specific temperature (and have a default if nothing is explicitly set).
Hopefully that makes sense…
Slightly longer description now that I’ve found the calendar triggering event details (thanks @Didgeridrew), and have automations running:
I currently have three automations which are all of the form listed below.
The trigger is either an event starting (on a calendar pulled from our bookings system), or it stopping. The “starting” has an offset of an hour to give time for the building to heat up. The action then sets the relevant rooms to 19 degrees (and this is the number I want to be able to change based on the booking) an hour before the booking starts, and returns them to a setback temperature (which I’ve defined as a helper so that I don’t need to keep adjusting the automations) at the end of the booking.
Looking at the calendar entity under the GCal integration when there is a triggering event active I can see the event listed as:
Attributes
Message: [B] Noah's Ark
All day: No
Start time: 16 September 2024 at 09:30:00
End time: 16 September 2024 at 12:00:00
Location: Auditorium | Hall
Description:
Offset reached: false
Description is the only thing in there I can reasonably control, so it’s going to have to be another template - probably extracting T:18 or similar from a potentially much longer string?
A test event showed that the carriage returns I put into the description on the booking system get thrown away by the time the event is listed on HA, so it’s going to have to be a regex extraction of the form T:(\d+) I think…
It’s a shame the visual editor can’t cope with templates for the climate temperature setting.
Looking around I found Help with Regex template sensor
So maybe I want…
{% set caldesc = "This is a long description with a T:0 temperature request" %}
{{ float(caldesc | regex_findall_index('T:(\d+\.?\d?)'), states('input_number.default_heating_temperature')) }}
That works, but only if there is a temp defined… the findall_index throws a fit if it isn’t.
Multi line template, if I can just shove that in as is???:
{% set caldesc = "This is a long description with a T:17.8 temperature request" %}
{% if caldesc | regex_search('T:(\d+\.?\d?)') %}
{{ float(caldesc | regex_findall_index('T:(\d+\.?\d?)'), states('input_number.default_heating_temperature')) }}
{% else %}
{{ states('input_number.default_heating_temperature') }}
{% endif %}
Current Automation:
alias: Hall Heating
description: |-
Triggered by bookings which use the hall
trigger:
- alias: Hour before calendar event starts
platform: calendar
entity_id: calendar.webcal_...
event: start
offset: "-1:0:0"
- alias: Calendar event ends
platform: calendar
entity_id: calendar.webcal_...
event: end
offset: "0:0:0"
condition: []
action:
- if:
- condition: template
value_template: "{{ trigger.event == 'start' }}"
alias: If calendar event is starting
then:
- action: climate.set_temperature
metadata: {}
data:
temperature: 19
target:
entity_id:
- climate.foyer
- climate.hall
- climate.front_room
- climate.changing_place
- climate.ladies
- climate.gents
- climate.office
- climate.kitchen
- climate.quiet_room
else:
- action: climate.set_temperature
alias: Return to setback temperature
metadata: {}
data:
temperature: "{{ states('input_number.setback_temperature') }}"
target:
entity_id:
- climate.foyer
- climate.hall
- climate.front_room
- climate.changing_place
- climate.ladies
- climate.gents
- climate.office
- climate.kitchen
- climate.quiet_room
mode: single