Last active
December 24, 2024 16:32
-
-
Save Didgeridrew/059ed31daf4efe8493481d5263c08ad5 to your computer and use it in GitHub Desktop.
HA - Assist Event Scheduler: Use dashboard card to schedule one-time home automation actions via formatted calendar event.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #----------------------- PRE-REQUISITES ------------------------- | |
| # You will need to install the following custom cards to use the include card configuration: | |
| # - Text-input-row Card (https://github.com/gadgetchnnel/lovelace-text-input-row) | |
| # - Custom Button Card (https://github.com/custom-cards/button-card) | |
| # - Custom Stack-In-Card (https://github.com/custom-cards/stack-in-card) | |
| # | |
| # You will need to create the following helpers: | |
| # - input_datetime.scheduled_action | |
| # - input_text.scheduled_action_message | |
| # | |
| #------------------------------------------------------------------ | |
| #---------- Script ---------------- | |
| alias: New Scheduled Action Event | |
| description: | | |
| Use values from dashboard card to create a calendar event to trigger | |
| automation.calendar_scheduled_conversation_actions. | |
| sequence: | |
| - service: calendar.create_event | |
| data: | |
| summary: | | |
| {{ {'message': states('input_text.scheduled_action_message')} }} | |
| description: Scheduled Action Added via UI | |
| start_date_time: >- | |
| {{ (states('input_datetime.scheduled_action') | |
| |as_datetime).isoformat()[:19]}} | |
| end_date_time: >- | |
| {{ (states('input_datetime.scheduled_action') |as_datetime + | |
| timedelta(minutes=5)).isoformat()[:19] }} | |
| target: | |
| entity_id: calendar.home_assistant_events | |
| - delay: 2 | |
| - alias: Clear input text so field is blank | |
| data: | |
| value: "{{''}}" | |
| target: | |
| entity_id: input_text.scheduled_action_message | |
| action: input_text.set_value | |
| - delay: 20 | |
| - action: homeassistant.reload_config_entry | |
| target: | |
| entity_id: calendar.home_assistant_events | |
| data: {} | |
| mode: single | |
| #---------- Automation ---------------- | |
| alias: Calendar - Scheduled Conversation Actions | |
| description: | | |
| Use specifically formatted calendar event to schedule one-time home automation actions. | |
| trigger: | |
| - platform: calendar | |
| event: start | |
| entity_id: calendar.home_assistant_events | |
| variables: | |
| summary_from: | | |
| {{ trigger.calendar_event.summary | |
| |replace("\'","\"")|string|from_json }} | |
| condition: | |
| - condition: template | |
| value_template: | | |
| {{ trigger.calendar_event.description | |
| == 'Scheduled Action Added via UI' }} | |
| action: | |
| - service: conversation.process | |
| data: | |
| agent_id: homeassistant | |
| text: "{{ summary_from.message }}" | |
| mode: parallel | |
| max: 10 | |
| #---------- Dashboard Card Configuration ---------------- | |
| type: custom:stack-in-card | |
| cards: | |
| - type: entities | |
| title: Schedule Assist Actions | |
| entities: | |
| - entity: input_datetime.scheduled_action | |
| name: Action Date & Time | |
| - entity: input_text.scheduled_action_message | |
| name: 'Action for Assist:' | |
| type: custom:text-input-row | |
| - show_name: true | |
| show_icon: true | |
| type: custom:button-card | |
| tap_action: | |
| action: call-service | |
| service: script.turn_on | |
| target: | |
| entity_id: script.new_scheduled_action_event | |
| data: {} | |
| entity: script.new_scheduled_action_event | |
| name: Schedule Action | |
| styles: | |
| card: | |
| - height: 100px |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment