renemarc/home-assistant-config

View on GitHub
automations/modes/quiet_mode_stop.yaml

Summary

Maintainability
Test Coverage
#
# When noise makers should be allowed to run
#
# @subscribe input_boolean.nap_mode
# @subscribe input_boolean.night_mode
#
# @publish input_boolean.quiet_mode
#
- id: quiet_mode_stop
  alias: "Quiet Mode STOP"

  trigger:
    # When it's daytime.
    - platform: time
      at: '07:30:00'

    # When night mode is over.
    - platform: state
      entity_id: input_boolean.night_mode
      from: 'on'
      to: 'off'

    # When nap mode is over.
    - platform: state
      entity_id: input_boolean.nap_mode
      from: 'on'
      to: 'off'

  condition:
    # If it has been quiet mode.
    - condition: state
      entity_id: input_boolean.quiet_mode
      state: 'on'

    # If it's not during night mode.
    - condition: state
      entity_id: input_boolean.night_mode
      state: 'off'

    # If it's not during nap mode.
    - condition: state
      entity_id: input_boolean.nap_mode
      state: 'off'

  action:
    # Disable quiet mode.
    - service: input_boolean.turn_off
      entity_id: input_boolean.quiet_mode