User Tools

Site Tools


hass:high_availability

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
hass:high_availability [2020/06/03 09:59] ahass:high_availability [2020/06/03 10:32] a
Line 105: Line 105:
 This arrangement also allows for automations which should run regardless of whether the instance is active or not, or automations which run specifically when the instance is inactive. It does however require each automation to be modified with this condition, which may be onerous for an established setup. This arrangement also allows for automations which should run regardless of whether the instance is active or not, or automations which run specifically when the instance is inactive. It does however require each automation to be modified with this condition, which may be onerous for an established setup.
          
 +==== Disabling/Enabling Automations ====
 +This method is a little more involved to implement, but does allow existing automations to be used unmodified. The first part of the puzzle is a script to create a group which contains all the current automations:
  
 +<code>
 +create_every_automation_group:
 +  sequence:
 +  - service: group.set
 +    data_template:
 +      object_id: every_automation
 +      entities: '{{ states.automation | map(attribute=''entity_id'') | join('','')}}'
 +</code>
 +
 +With this group created we can now control the status of each automation with the ''automation.turn_on'' service. Two automations are used to switch Home Assistant into and out of the active state:
 +
 +<code>
 +- id: '1582909860207'
 +  alias: HASS:Standby
 +  description: ''
 +  trigger:
 +  - entity_id: sensor.active
 +    platform: state
 +    to: !secret partner
 +  condition: []
 +  action:
 +  - data: {}
 +    service: script.create_every_automation_group
 +  - data: {}
 +    entity_id: group.every_automation
 +    service: automation.turn_off
 +  - data: {}
 +    entity_id: automation.hass_active
 +    service: automation.turn_on
 +- id: '1582910169504'
 +  alias: HASS:Active
 +  description: ''
 +  trigger:
 +  - entity_id: sensor.active
 +    from: !secret partner
 +    platform: state
 +  condition: []
 +  action:
 +  - data: {}
 +    service: script.create_every_automation_group
 +  - data: {}
 +    entity_id: group.every_automation
 +    service: automation.turn_on
 +</code>
 +
 +Note that after the instance is moved into standby, the last action of the HASS:Standby automation is to re-enable the HASS:Active automation. This allows the standby instance to become active if its partner goes offline.
hass/high_availability.txt · Last modified: 2021/08/13 23:36 by a