diff options
Diffstat (limited to 'blueprints')
| -rw-r--r-- | blueprints/automation/camera/intrusion.yaml | 91 | ||||
| -rw-r--r-- | blueprints/automation/homeassistant/motion_light.yaml | 54 | ||||
| -rw-r--r-- | blueprints/automation/homeassistant/notify_leaving_zone.yaml | 46 | ||||
| -rw-r--r-- | blueprints/automation/lights/knob-bulb-control.yaml | 271 | ||||
| -rw-r--r-- | blueprints/automation/lights/knob-multi-bulb-control.yaml | 191 | ||||
| -rw-r--r-- | blueprints/automation/lights/light_button.yaml | 171 | ||||
| -rw-r--r-- | blueprints/automation/lights/light_switch.yaml | 115 | ||||
| -rw-r--r-- | blueprints/automation/lights/light_switch_combo.yaml | 92 | ||||
| -rw-r--r-- | blueprints/automation/lights/light_sync.yaml | 55 | ||||
| -rw-r--r-- | blueprints/automation/motion/motion_switch.yaml | 163 | ||||
| -rw-r--r-- | blueprints/script/camera/security_camera.yaml | 142 | ||||
| -rw-r--r-- | blueprints/script/camera/send_photo.yaml | 37 | ||||
| -rw-r--r-- | blueprints/script/devices/aircon.yaml | 135 | ||||
| -rw-r--r-- | blueprints/script/devices/kodi-alarm.yaml | 29 | ||||
| -rw-r--r-- | blueprints/script/homeassistant/confirmable_notification.yaml | 84 | ||||
| -rw-r--r-- | blueprints/script/lights/turn_off_lights.yaml | 32 | 
16 files changed, 1708 insertions, 0 deletions
| diff --git a/blueprints/automation/camera/intrusion.yaml b/blueprints/automation/camera/intrusion.yaml new file mode 100644 index 0000000..4d2b62c --- /dev/null +++ b/blueprints/automation/camera/intrusion.yaml @@ -0,0 +1,91 @@ +blueprint: +  name: Intrusion +  description: Script to execute in case of intrusion, e.g. streaming photos from Security Camera +  domain: automation +  input: +    sensors: +      name: Sensors +      description: Trigger on motion, open doors, etc. +      default: [] +      selector: +        entity: +          multiple: true +          domain: [ binary_sensor, light, switch ] +    mode: +      name: Mode +      description: Switch enabling/disabling shooting +      selector: +        entity: +          domain: input_boolean +    arm_delay: +      name: Arm Delay +      description: Delay before 'Away' mode activated and intrusion detection is operational (to allow you leaving the flat) +      default: 15 +      selector: +        number: +          min: 0 +          max: 60 +          unit_of_measurement: m +    disarm_delay: +      name: Disarm Delay +      description: Delay before alarms triggered after motion is detected (to allow disarm on arrival), camera shots are made without delay +      default: 5 +      selector: +        number: +          min: 0 +          max: 60 +          unit_of_measurement: m +    camera_script: +      name: camera_script +      description: Streaming Script for Security Camera +      default: [] +      selector: +        action: +    script: +      name: script +      description: Alarming scipt to issue notifications once intrusion is confirmed +      default: [] +      selector: +        action: + +trigger: +  - platform: state +    entity_id: !input "sensors" +    to: 'on' + +condition: +  - condition: state +    entity_id: !input "mode" +    state: 'on' +    enabled: true +    for: +      hours: 0 +      minutes: !input arm_delay +      seconds: 0 + +variables: +  disarm_delay: !input disarm_delay +  disarm_delay_seconds: '{{ (( disarm_delay * 60 )) }}' + +mode: single +action: +  - parallel: +    - choose: [] +      default: !input "camera_script" +    - sequence: +      - service: input_button.press +        target: +          entity_id: input_button.button_confirm +      - wait_for_trigger: +        - platform: state +          entity_id: !input mode +          to: 'off' +        timeout: '{{ disarm_delay_seconds }}' +        continue_on_timeout: true + +      - if: +        - condition: template +          value_template: '{{ wait.trigger == None }}' +        then: +        - choose: [] +          default: !input "script" diff --git a/blueprints/automation/homeassistant/motion_light.yaml b/blueprints/automation/homeassistant/motion_light.yaml new file mode 100644 index 0000000..54a4a4f --- /dev/null +++ b/blueprints/automation/homeassistant/motion_light.yaml @@ -0,0 +1,54 @@ +blueprint: +  name: Motion-activated Light +  description: Turn on a light when motion is detected. +  domain: automation +  source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml +  input: +    motion_entity: +      name: Motion Sensor +      selector: +        entity: +          domain: binary_sensor +          device_class: motion +    light_target: +      name: Light +      selector: +        target: +          entity: +            domain: light +    no_motion_wait: +      name: Wait time +      description: Time to leave the light on after last motion is detected. +      default: 120 +      selector: +        number: +          min: 0 +          max: 3600 +          unit_of_measurement: seconds + +# If motion is detected within the delay, +# we restart the script. +mode: restart +max_exceeded: silent + +trigger: +  platform: state +  entity_id: !input motion_entity +  from: "off" +  to: "on" + +action: +  - alias: "Turn on the light" +    service: light.turn_on +    target: !input light_target +  - alias: "Wait until there is no motion from device" +    wait_for_trigger: +      platform: state +      entity_id: !input motion_entity +      from: "on" +      to: "off" +  - alias: "Wait the number of seconds that has been set" +    delay: !input no_motion_wait +  - alias: "Turn off the light" +    service: light.turn_off +    target: !input light_target diff --git a/blueprints/automation/homeassistant/notify_leaving_zone.yaml b/blueprints/automation/homeassistant/notify_leaving_zone.yaml new file mode 100644 index 0000000..1dc8a0e --- /dev/null +++ b/blueprints/automation/homeassistant/notify_leaving_zone.yaml @@ -0,0 +1,46 @@ +blueprint: +  name: Zone Notification +  description: Send a notification to a device when a person leaves a specific zone. +  domain: automation +  source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/notify_leaving_zone.yaml +  input: +    person_entity: +      name: Person +      selector: +        entity: +          domain: person +    zone_entity: +      name: Zone +      selector: +        entity: +          domain: zone +    notify_device: +      name: Device to notify +      description: Device needs to run the official Home Assistant app to receive notifications. +      selector: +        device: +          integration: mobile_app + +trigger: +  platform: state +  entity_id: !input person_entity + +variables: +  zone_entity: !input zone_entity +  # This is the state of the person when it's in this zone. +  zone_state: "{{ states[zone_entity].name }}" +  person_entity: !input person_entity +  person_name: "{{ states[person_entity].name }}" + +condition: +  condition: template +  # The first case handles leaving the Home zone which has a special state when zoning called 'home'. +  # The second case handles leaving all other zones. +  value_template: "{{ zone_entity == 'zone.home' and trigger.from_state.state == 'home' and trigger.to_state.state != 'home' or trigger.from_state.state == zone_state and trigger.to_state.state != zone_state }}" + +action: +  - alias: "Notify that a person has left the zone" +    domain: mobile_app +    type: notify +    device_id: !input notify_device +    message: "{{ person_name }} has left {{ zone_state }}" diff --git a/blueprints/automation/lights/knob-bulb-control.yaml b/blueprints/automation/lights/knob-bulb-control.yaml new file mode 100644 index 0000000..5b6c3c7 --- /dev/null +++ b/blueprints/automation/lights/knob-bulb-control.yaml @@ -0,0 +1,271 @@ +blueprint: +  name: Knob Bulb Control +  description: Knob (clicking/rotating) to control bulb (or LED band) brightness, color temperature, and hue +  domain: automation +  input: +    knob: +      name: knob +      description: controller (select _action entity) +      selector: +        entity: +          domain: sensor +    light: +      name: Bulb +      description: smart bulb or power socket +      selector: +        entity: +          multiple: true +          domain: light +    toggle: +      name: toggle +      description: Script to run on clicking knob button (e.g. turn-of bulb power on/off) +      default: [] +      selector: +        action: + +    brightness: +      name: Brightness +      description: Current brightness of the bulb +      selector:  +        entity: +          domain: input_number +    temperature: +      name: Temperature +      description: Current color temperature of the bulb +      selector:  +        entity: +          domain: input_number +    hue: +      name: Hue +      description: Current hue of the bulb +      selector:  +        entity: +          domain: input_number +    state: +      name: State +      description: Indicates if button is pressed and we currently changing the hue  +      selector:  +        entity: +          domain: input_boolean + +    brightness_step: +      name: Brightness Step +      description: Increment/Decrement of brightness +      default: 50 +      selector: +        number: +          min: 10 +          max: 100 +    hue_delay: +      name: Hue Delay +      description: Delay between hue changes +      default: 500 +      selector: +        number: +          min: 100 +          max: 10000 + +# Light is triggering when bulb is controlled by other means. So, I think it is better to follow 'multi' way  +# and just store knob settings for the bulb ignoring how it is changed in other ways (in the end use-cases differ also) +trigger: +  - platform: state +    id: knob +    entity_id: !input "knob" +    to: +      - "toggle" +      - "brightness_step_up" +      - "brightness_step_down" +      - "color_temperature_step_up" +      - "color_temperature_step_down" +      - "hue_move" + +  - platform: state +    id: brightness_change +    entity_id: !input light +    attribute: brightness +#  - platform: state +#    id: hue_move +#    entity_id: !input state +#    to: 'on' + +variables: +  light: !input light +  brightness: !input brightness +  temperature: !input temperature +  hue: !input hue + +  brightness_step: !input brightness_step +  hue_delay: !input hue_delay + +mode: queued +action: +- choose: +  - conditions: +    - condition: trigger +      id: knob +    sequence: +    - choose: +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "brightness_step_up" }}' +        sequence: +        - service: light.turn_on +          data: +            brightness_step: '{{ brightness_step }}' +          target: +            entity_id: !input light  +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "brightness_step_down" }}' +        sequence: +        - service: light.turn_on +          data: +            brightness_step: '-{{ brightness_step }}' +          target: +            entity_id: !input light +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "color_temperature_step_up" }}' +        sequence: +        - service: input_number.increment +          target: +            entity_id: !input temperature +        - service: light.turn_on +          data: +            kelvin: '{{ states(temperature) }}' +          target: +            entity_id: !input light +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "color_temperature_step_down" }}' +        sequence: +        - service: input_number.decrement +          data: {} +          target: +            entity_id: !input temperature +        - service: light.turn_on +          data: +            kelvin: '{{ states(temperature) }}' +          target: +            entity_id: !input light +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "hue_move" }}' +        sequence: +        - service: input_boolean.turn_on +          target: +            entity_id: !input state +        - repeat: +            until: +#            - condition: state +#              entity_id: !input state +#              state: 'off' +            - condition: template +              value_template: '{{ wait.trigger != None }}' +            sequence: +            - if: +              - condition: template +                value_template: '{{ states(hue) | float < 359 }}' +              then: +              - service: input_number.increment +                data: {} +                target: +                  entity_id: !input hue +              else: +              - service: input_number.set_value +                data: +                  value: 0 +                target: +                  entity_id: !input hue +            - service: light.turn_on +              data: +                hs_color: '{{ states(hue) }}, 100' +              target: +                entity_id: !input light +            - wait_for_trigger: +              - platform: state +                entity_id: !input knob +                to: 'hue_stop' +              timeout: +                milliseconds: !input hue_delay +              continue_on_timeout: true +        - service: input_boolean.turn_off +          target: +            entity_id: !input state +#      - conditions: +#        - condition: template +#          value_template: '{{ trigger.to_state.state == "hue_stop" }}' +#        sequence: +#        - service: input_boolean.turn_off +#          target: +#            entity_id: !input state +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "toggle" }}' +        sequence: +        - choose: [] +          default: !input "toggle" + +  - conditions: +    - condition: trigger +      id: brightness_change +    - condition: state +      entity_id: !input light +      state: 'on' +    sequence: +    - service: input_number.set_value +      data: +        value: '{{ state_attr(light, ''brightness'') }}' +      target: +        entity_id: !input brightness + +#  - conditions: +#    - condition: trigger +#      id: hue_move +#    sequence: +#    - repeat: +#        until: +#        - condition: state +#          entity_id: !input state +#          state: 'off' +#        - condition: template +#          value_template: '{{ wait.trigger != None }}' +#        sequence: +#        - if: +#          - condition: template +#            value_template: '{{ states(hue) | float < 359 }}' +#          then: +#          - service: input_number.increment +#            data: {} +#            target: +#              entity_id: !input hue +#          else: +#          - service: input_number.set_value +#            data: +#              value: 0 +#            target: +#              entity_id: !input hue +#        - service: light.turn_on +#          data: +#            hs_color: '{{ states(hue) }}, 100' +#          target: +#            entity_id: !input light +# +#        - wait_for_trigger: +#          - platform: state +#            entity_id: !input knob +#            to: 'hue_stop' +#          timeout: +#            milliseconds: !input hue_delay +#          continue_on_timeout: true +# +#        - if: +#          - condition: template +#            value_template: '{{ wait.trigger != None }}' +#          then: +#            - service: input_boolean.turn_off +#              target: +#                entity_id: !input state +#            - delay: +#                timeout: +#                  milliseconds: !input hue_delay diff --git a/blueprints/automation/lights/knob-multi-bulb-control.yaml b/blueprints/automation/lights/knob-multi-bulb-control.yaml new file mode 100644 index 0000000..412ce3d --- /dev/null +++ b/blueprints/automation/lights/knob-multi-bulb-control.yaml @@ -0,0 +1,191 @@ +blueprint: +  name: Knob Multi-Bulb Control +  description: Knob (clicking/rotating) to control bulb (or LED band) brightness, color temperature, and hue +  domain: automation +  input: +    knob: +      name: knob +      description: controller (select _action entity) +      selector: +        entity: +          domain: sensor +    lights: +      name: Bulb +      description: smart bulb or power socket +      selector: +        entity: +          multiple: true +          domain: light +    toggle: +      name: toggle +      description: Script to run on clicking knob button (e.g. turn-of bulb power on/off) +      default: [] +      selector: +        action: + +    name: +      name: name +      description: Name of variables tracking bulb parameters (should include ***_current, ***_brighness0, ***_temperature0, ***_hue0 +      default: knob_office + +    hue_delay: +      name: Hue Delay +      description: Delay between hue changes +      default: 500 +      selector: +        number: +          min: 100 +          max: 10000 + +trigger: +  - platform: state +    id: knob +    entity_id: !input "knob" +    to: +      - "toggle" +      - "brightness_step_up" +      - "brightness_step_down" +      - "color_temperature_step_up" +      - "color_temperature_step_down" +      - "hue_move" + +variables: +  name: !input name +  current: 'input_number.{{ name + "_current"  }}' +  brightness: 'input_number.{{ name + "_brightness" }}{{ states(current) | int }}' +  temperature: 'input_number.{{ name + "_temperature" }}{{ states(current) | int }}' +  hue: 'input_number.{{ name + "_hue" }}{{ states(current) | int }}' + +  lights: !input lights +  light: '{{ lights[states(current) | int] }}' + +  hue_delay: !input hue_delay + +mode: queued +action: +- choose: +  - conditions: +    - condition: trigger +      id: knob +    sequence: +    - choose: +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "brightness_step_up" }}' +        sequence: +        - service: input_number.increment +          target: +            entity_id: '{{ brightness }}' +        - service: light.turn_on +          data: +            brightness: '{{ states(brightness) }}' +          target: +            entity_id: '{{ light }}' +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "brightness_step_down" }}' +        sequence: +        - service: input_number.decrement +          data: {} +          target: +            entity_id: '{{ brightness }}' +        - service: light.turn_on +          data: +            brightness: '{{ states(brightness) }}' +          target: +            entity_id: '{{ light }}' +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "color_temperature_step_up" }}' +        sequence: +        - service: input_number.increment +          target: +            entity_id: '{{ temperature }}' +        - service: light.turn_on +          data: +            kelvin: '{{ states(temperature) }}' +          target: +            entity_id: '{{ light }}' +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "color_temperature_step_down" }}' +        sequence: +        - service: input_number.decrement +          target: +            entity_id: '{{ temperature }}' +        - service: light.turn_on +          data: +            kelvin: '{{ states(temperature) }}' +          target: +            entity_id: '{{ light }}' +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "hue_move" }}' +        sequence: +        - repeat: +            until: +            - condition: template +              value_template: '{{ wait.trigger != None }}' +            sequence: +            - if: +              - condition: template +                value_template: '{{ states(hue) | float < 359 }}' +              then: +              - service: input_number.increment +                data: {} +                target: +                  entity_id: '{{ hue }}' +              else: +              - service: input_number.set_value +                data: +                  value: 0 +                target: +                  entity_id: '{{ hue }}' +            - service: light.turn_on +              data: +                hs_color: '{{ states(hue) }}, 100' +              target: +                entity_id: '{{ light }}' +            - wait_for_trigger: +              - platform: state +                entity_id: !input knob +                to: 'hue_stop' +              timeout: +                milliseconds: !input hue_delay +              continue_on_timeout: true +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "toggle" }}' +        sequence: +          - if: +              - condition: template +                value_template: '{{ toggle | length > 0 }}' +            then: +            - choose: [] +              default: !input "toggle" +            else: +            - service: input_number.increment +              target: +                entity_id: '{{ current }}' +            - if: +              - condition: template +                value_template: '{{ states(current) | float == (lights | length) }}' +              then: +              - service: input_number.set_value +                data: +                  value: 0 +                target: +                  entity_id: '{{ current }}' + +            - service: light.turn_off +              target: +                entity_id: '{{ lights[states(current) | int] }}' +            - delay: +                seconds: 1 +            - service: light.turn_on +              data: +                kelvin: '{{ states("input_number." + name + "_temperature" + (states(current) | int | string)) }}' +                brightness: '{{ states("input_number." + name + "_brightness" + (states(current) | int | string)) }}' +#                hs_color: '{{ states("input_number." + name + "_hue" + (states(current) | int | string)) }}, 100' +              target: +                entity_id: '{{ lights[states(current) | int] }}' diff --git a/blueprints/automation/lights/light_button.yaml b/blueprints/automation/lights/light_button.yaml new file mode 100644 index 0000000..7aeb0ab --- /dev/null +++ b/blueprints/automation/lights/light_button.yaml @@ -0,0 +1,171 @@ +blueprint: +  name: Light Button +  description: Button to control smart bulb and perform other actions when bulb turns on/off, plus additional actions on double-click and long-press (select *_action entity) +  domain: automation +  input: +    button: +      name: button +      description: controller +      selector: +        entity: +          domain: sensor +    light: +      name: light +      description: another switch, smart bulb, or power socket +      selector: +        entity: +          domain: light +    temperature: +      name: Temperature +      description: Color Temperature +      default: 6500 +      selector: +        number: +          min: 2000 +          max: 6500 +    on_click: +      name: on_click +      description: Additional actions to perform while turning on master light +      default: [] +      selector: +        action: +    off_click: +      name: off_click +      description: Additional actions to perform while turning off master light +      default: [] +      selector: +        action: +    dblclick: +      name: dblclick +      description: Actions to perform on double click +      default: [] +      selector: +        action: +    longclick: +      name: longclick +      description: Actions to perform on long-press (single action) +      default: [] +      selector: +        action: +    hold: +      name: hold +      description: Actions to perform on hold (iterative until released) +      default: [] +      selector: +        action: +    hold_delay: +      name: Hold Delay +      description: Delay between calling hold actions (milliseconds) +      default: 500 +      selector: +        number: +          min: 100 +          max: 10000 + +    state: +      name: State +      description: Indicates if button is pressed and we currently changing the brightness +      default: None +      selector:  +        entity: +          domain: input_boolean + +trigger: +  - platform: state +    id: button +    entity_id: !input "button" +    to: +      - "single" +      - "double" +      - "hold" + + +variables: +   state: !input state +   hold: !input hold + +# Can't do 'restart' since it will break wait_for_trigger +mode: single + +action: +- choose: +  - conditions: +    - condition: trigger +      id: button +    sequence: +    - choose: +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "single" }}' +        sequence: +          - if: +              - condition: state +                entity_id: !input light +                state: 'on' +            then: +              - parallel: +                - service: light.turn_off +                  target: +                    entity_id: !input light +                - choose: [] +                  default: !input "off_click" +            else: +              - parallel: +                - service: light.turn_on +                  data: +                    brightness_pct: 100 +                    kelvin: !input temperature +                  target: +                    entity_id: !input light +                - choose: [] +                  default: !input "on_click" + +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "double" }}' +        sequence: +          - choose: [] +            default: !input "dblclick" + +      - conditions: +        - condition: template +          value_template: '{{ trigger.to_state.state == "hold" }}' +        sequence: +          - choose: [] +            default: !input "longclick" + +          - if: +              - condition: template +                value_template: '{{ hold | length > 0 }}' +            then: +              - if: +                  - condition: template +                    value_template: '{{ state }}' +                then: +                  - service: input_boolean.turn_on +                    target: +                      entity_id: !input state + +              - repeat: +                  until: +                    - condition: template +                      value_template: '{{ wait.trigger != None }}' +                  sequence: +                  - choose: [] +                    default: !input "hold" + +                  - wait_for_trigger: +                      - platform: state +                        entity_id: !input button +                        to: 'release' +                    timeout:  +                      milliseconds: !input hold_delay +                    continue_on_timeout: true + +              - if: +                  - condition: template +                    value_template: '{{ state }}' +                then: +                  - service: input_boolean.turn_off +                    target: +                      entity_id: !input state diff --git a/blueprints/automation/lights/light_switch.yaml b/blueprints/automation/lights/light_switch.yaml new file mode 100644 index 0000000..b3a4f81 --- /dev/null +++ b/blueprints/automation/lights/light_switch.yaml @@ -0,0 +1,115 @@ +blueprint: +  name: Light Switch +  description: Switch to control light bulb or power plug (including two-way synchronization) +  domain: automation +  input: +    switch: +      name: Switch +      description: controller +      selector: +        entity: +          domain: switch +    light: +      name: Bulb +      description: smart bulb or power socket +      selector: +        entity: +          domain: [light, switch] +    dblclick: +      name: dblclick +      description: Actions to perform on double click +      default: [] +      selector: +        action: +    on_click: +      name: on_click +      description: Additional actions to perform while turning on master switch +      default: [] +      selector: +        action: +    off_click: +      name: off_click +      description: Additional actions to perform while turning off master switch +      default: [] +      selector: +        action: + +variables: +  switch_entity: !input switch +  light_entity: !input light +  dblclick: !input dblclick + +trigger: +  - platform: state +    entity_id: !input "switch" +  - platform: state +    entity_id: !input "light" + +mode: single +action: +  - choose: +      - conditions: +          - "{{ trigger.entity_id == switch_entity }}" +        sequence: +          - if: +              - condition: template +                value_template: '{{ dblclick | length > 0 }}' +            then: +              - wait_for_trigger: +                  - platform: state +                    entity_id: !input switch +                timeout: '1' +                continue_on_timeout: true +              - if: +                  - condition: template +                    value_template: '{{ wait.trigger == None }}' +                then: +                  - if: +                      - condition: template +                        value_template: '{{trigger.to_state.state == "on" }}' +                    then: +                      - parallel: +                          - choose: [] +                            default: !input "on_click" +                          - service: homeassistant.turn_on +                            target: +                              entity_id: !input light +                    else: +                      - parallel: +                          - choose: [] +                            default: !input "off_click" +                          - service: homeassistant.turn_off +                            target: +                              entity_id: !input light +                else: +                  - choose: [] +                    default: !input "dblclick" +            else: +              - if: +                  - condition: template +                    value_template: '{{trigger.to_state.state == "on" }}' +                then: +                  - parallel: +                      - choose: [] +                        default: !input "on_click" +                      - service: homeassistant.turn_on +                        target: +                          entity_id: !input light +                else: +                  - parallel: +                      - choose: [] +                        default: !input "off_click" +                      - service: homeassistant.turn_off +                        target: +                          entity_id: !input light +      - conditions: +          - "{{ trigger.entity_id == light_entity  }}" +        sequence: +          - service: > +              {% if trigger.to_state.state == "on" %} +                switch.turn_on +              {% else %} +                switch.turn_off +              {% endif %} +            target: +              entity_id: !input switch diff --git a/blueprints/automation/lights/light_switch_combo.yaml b/blueprints/automation/lights/light_switch_combo.yaml new file mode 100644 index 0000000..9ea8655 --- /dev/null +++ b/blueprints/automation/lights/light_switch_combo.yaml @@ -0,0 +1,92 @@ +blueprint: +  name: Light Switch Combo +  description: Switch to control another switch, light bulb, or power plug (no sync) and allow another action on double click +  domain: automation +  input: +    switch: +      name: switch +      description: controller +      selector: +        entity: +          domain: switch +    master: +      name: master +      description: another switch, smart bulb, or power socket +      selector: +        entity: +    dblclick: +      name: dblclick +      description: Actions to perform on double click +      default: [] +      selector: +        action: +    on_click: +      name: on_click +      description: Additional actions to perform while turning on master switch +      default: [] +      selector: +        action: +    off_click: +      name: off_click +      description: Additional actions to perform while turning off master switch +      default: [] +      selector: +        action: + +#variables: +#  switch_entity: !input switch +#  master_entity: !input master + +trigger: +  - platform: state +    entity_id: !input "switch" + +# Can't do 'restart' since it will break wait_for_trigger +mode: single +action: +  - wait_for_trigger: +    - platform: state +      entity_id: !input switch +    timeout: '1' +    continue_on_timeout: true + +  - if: +      - condition: template +        value_template: '{{ wait.trigger == None }}' +    then: +      - if: +          - condition: state +            entity_id: !input switch +            state: 'on' +        then: +          - if: +              - condition: state +                entity_id: !input master +                state: 'on' +            then: +              - parallel: +                - service: homeassistant.toggle +                  target: +                    entity_id: !input master +                - choose: [] +                  default: !input "off_click" +            else: +              - parallel: +                - service: homeassistant.toggle +                  target: +                    entity_id: !input master +                - choose: [] +                  default: !input "on_click" +    else: +      - choose: [] +        default: !input "dblclick" +#      - service: switch.turn_off +#        target: +#          entity_id: switch.all_lights +#      - service: input_button.press +#        target: +#          entity_id: input_button.button_confirm + +  - service: switch.turn_off +    target: +      entity_id: !input switch diff --git a/blueprints/automation/lights/light_sync.yaml b/blueprints/automation/lights/light_sync.yaml new file mode 100644 index 0000000..44161ae --- /dev/null +++ b/blueprints/automation/lights/light_sync.yaml @@ -0,0 +1,55 @@ +blueprint: +  name: Light Sync +  description: Allows to switch both parts of lustre with single click +  domain: automation + +  input: +    master: +      name: Master +      description: Master Switch +      selector: +        entity: +          domain: switch +    slave: +      name: Slave +      description: Slave Switch +      selector: +        entity: +          domain: switch +    on_click: +      name: on_click +      description: Additional actions to perform while turning on master switch +      default: [] +      selector: +        action: +    off_click: +      name: off_click +      description: Additional actions to perform while turning off master switch +      default: [] +      selector: +        action: + + +trigger: +  - platform: state +    entity_id: !input "master" + +mode: single +action: +  - if: +      - condition: template +        value_template: '{{trigger.to_state.state == "on" }}' +    then: +      - parallel: +          - choose: [] +            default: !input "on_click" +          - service: homeassistant.turn_on +            target: +              entity_id: !input slave +    else: +      - parallel: +          - choose: [] +            default: !input "off_click" +          - service: homeassistant.turn_off +            target: +              entity_id: !input slave diff --git a/blueprints/automation/motion/motion_switch.yaml b/blueprints/automation/motion/motion_switch.yaml new file mode 100644 index 0000000..c78e31f --- /dev/null +++ b/blueprints/automation/motion/motion_switch.yaml @@ -0,0 +1,163 @@ +blueprint: +  name: Motion-activated Switch +  description: Turn on a light when motion is detected and surroundings are dark +  domain: automation +  input: +    motion_entity: +      name: Motion Sensor +      selector: +        entity: +          domain: binary_sensor +          device_class: motion + +    illumination_test: +      name: Illumination Test +      description: Select how to check if existing illumination is sufficient +      default: sun +      selector: +        select: +          options: +            - label: Illuminance Sensor +              value: sensor +            - label: Sun Elevation +              value: sun +            - label: Always turn on lights +              value: none +    illuminance_entity: +      name: Illuminance Sensor +      description: Sensor providing information about illumination in the room (keep empty to rely on sun position) +      selector: +        entity: +          domain: sensor +          device_class: illuminance +    lux_threshold: +      name: LUX threshold +      description: Threshold bellow which we consider that lighting is needed +      default: 40 +      selector: +        number: +          min: 10 +          max: 1000 +          unit_of_measurement: lux +    sun_elevation: +      name: Sun Elevation +      description: Sun elevation (suggested between 0 and -6) when dusks settles and we need to turn on lights) +      default: 0 +      selector: +        number: +          min: -30 +          max: 30 +          unit_of_measurement: ° + + +    light_target: +      name: Light Target +      default: [] +      selector: +        entity: +          multiple: true +          domain: [switch, light] +    no_motion_wait: +      name: Wait time +      description: Time to leave the light on after last motion is detected. +      default: 120 +      selector: +        number: +          min: 0 +          max: 3600 +          unit_of_measurement: seconds + +    on_click: +      name: on_click +      description: Additional actions to perform while turning on master light +      default: [] +      selector: +        action: +    off_click: +      name: off_click +      description: Additional actions to perform while turning off master light +      default: [] +      selector: +        action: + + + +variables: +  lux_threshold: !input lux_threshold +  illuminance_entity: !input illuminance_entity +  test: !input illumination_test + +  current_lux: '{{ (states(illuminance_entity) | float) }}' + +# If motion is detected within the delay, +# we restart the script. +mode: restart +max_exceeded: silent + +trigger: +  - platform: state +    id: "turn_on" +    entity_id: !input motion_entity +    from: "off" +    to: "on" +  - platform: state +    id: "turn_off" +    entity_id: !input motion_entity +    from: "on" +    to: "off" +    for: +      seconds: !input no_motion_wait + +action: +  - choose: +      - conditions: +          - condition: trigger +            id: "turn_on" +        sequence: +          - choose: +              - conditions:  +                  - condition: template +                    value_template: '{{ test == "sensor" }}' +                sequence: +                  - if: +                      - condition: template +                        value_template: '{{ (states(illuminance_entity) | float) < lux_threshold }}' +                    then: +                      - choose: [] +                        default: !input "on_click" +                      - service: switch.turn_on +                        target:  +                          entity_id: !input light_target + +              - conditions:  +                  - condition: template +                    value_template: '{{ test == "sun" }}' +                sequence: +                  - if: +                      - condition: numeric_state +                        entity_id: sun.sun +                        attribute: elevation +                        below: !input sun_elevation +                    then: +                      - choose: [] +                        default: !input "on_click" +                      - service: switch.turn_on +                        target: +                          entity_id: !input light_target +            default: +              - choose: [] +                default: !input "on_click" +              - service: switch.turn_on +                target:  +                   entity_id: !input light_target + +      - conditions: +          - condition: trigger +            id: "turn_off" +        sequence: +          - choose: [] +            default: !input "off_click" +          - service: switch.turn_off +            target:  +              entity_id: !input light_target +    default: [] diff --git a/blueprints/script/camera/security_camera.yaml b/blueprints/script/camera/security_camera.yaml new file mode 100644 index 0000000..0430266 --- /dev/null +++ b/blueprints/script/camera/security_camera.yaml @@ -0,0 +1,142 @@ +blueprint: +  name: Security Camera Streamer +  description: Stream photos from security camera +  domain: script +  input: +    camera: +      name: Camera +      description: Camera +      default: camera.192_168_50_51 +      selector: +        entity: +          domain: camera +    motion_sensor: +      name: Motion Sensor +      description: Sensor detecting if there are motions to trigger the camera +      selector: +        entity: +          domain: binary_sensor +          device_class: motion +    host: +      name: Host +      description: Host running camera server +      default: http://127.0.0.1:8123 +    caption:  +      name: Caption +      description: Caption to send in telegram message +      default: 'Intusion Alert: ' +    lights_on: +      name: Lights On +      description: List of lights to turn on +      default: [] +      selector: +        entity: +          multiple: true +          domain: [light, switch] +    lights_off: +      name: Lights Off +      description: List of lights to turn off +      default: [] +      selector: +        entity: +          multiple: true +          domain: [light, switch] +    prepare: +      name: prepare +      description: Actions to perform before shooting photos +      default: [] +      selector: +        action: +    delay: +      name: Delay +      description: Delay between shots (seconds) +      default: 5 +      selector: +        number: +          min: 1 +          max: 3600 +          unit_of_measurement: s +    fast_shots: +      name: Fast Shots +      description: Number of initial shots with short delay +      default: 10 +      selector: +        number: +          min: 0 +          max: 50 +    fast_delay: +      name: Fast Delay +      description: Delay between fast shots (milliseconds) +      default: 1000 +      selector: +        number: +          min: 100 +          max: 10000 +          unit_of_measurement: ms + +variables: +  camera: !input camera +  smartpi: !input host +  caption: !input caption +  delay: !input delay +  fast_shots: !input fast_shots +  fast_delay: !input fast_delay + +mode: restart +sequence: + - parallel: +    - service: homeassistant.turn_on +      target: +        entity_id: !input lights_on +    - service: homeassistant.turn_off +      target: +        entity_id: !input lights_off +    - choose: [] +      default: !input "prepare" +    - sequence: +      - service: telegram_bot.send_photo +        data: +          disable_notification: false +          caption: '{{ caption }} at {{ states("sensor.date_time_iso") +            }}' +          url: '{{ smartpi + state_attr(camera, "entity_picture") }}' +      - repeat: +          while: +          - condition: template +            value_template: '{{ repeat.index < fast_shots }}' +          sequence: +          - service: telegram_bot.send_photo +            data: +              disable_notification: true +              caption: '{{ caption }} {{ repeat.index }} (fast)' +              url: '{{ smartpi + state_attr(camera, "entity_picture") }}' +          - delay: +              hours: 0 +              minutes: 0 +              seconds: 0 +              milliseconds: '{{ fast_delay }}' +      - repeat: +# About 30 seconds delay before occupancy clears (both ways via state or device) +          until: +          - condition: state +            entity_id: !input motion_sensor +            state: 'off' +#            for:  +#              seconds: 2 +#          - type: is_no_motion +#            condition: device +#            device_id: 6deb0a6fb7a4a849ba22afc166cf9919 +#            device_id: '{{ device_id("binary_sensor.0x00158d0004485e0b_occupancy") }}' +#            entity_id: binary_sensor.0x00158d0004485e0b_occupancy +#            domain: binary_sensor +          sequence: +          - service: telegram_bot.send_photo +            data: +              disable_notification: true +              caption: '{{ caption }} {{ repeat.index + fast_shots - 1 }}' +              url: '{{ smartpi + state_attr(camera, "entity_picture") }}' +          - delay: +              hours: 0 +              minutes: 0 +              seconds: '{{ delay }}' +              milliseconds: 0 diff --git a/blueprints/script/camera/send_photo.yaml b/blueprints/script/camera/send_photo.yaml new file mode 100644 index 0000000..2b14639 --- /dev/null +++ b/blueprints/script/camera/send_photo.yaml @@ -0,0 +1,37 @@ +blueprint: +  name: Send Photo +  description: Send a single photo from the camera +  domain: script +  input: +    camera: +      name: Camera +      description: Camera +      default: camera.192_168_50_51 +      selector: +        entity: +          domain: camera +    host: +      name: Host +      description: Host running camera server +      default: http://127.0.0.1:8123 +    caption:  +      name: Caption +      description: Caption to send in telegram message +      default: '' + +variables: +  camera: !input camera +  smartpi: !input host +  caption: !input caption +#  caption: AubergineView +#  delay: 5 +#  fast_shots: 15 +#  fast_delay: 1000 + +mode: single +sequence: +  - service: telegram_bot.send_photo +    data: +      disable_notification: false +      caption: '{{ caption }} at {{ states("sensor.date_time_iso") }}' +      url: '{{ smartpi + state_attr(camera, "entity_picture") }}' diff --git a/blueprints/script/devices/aircon.yaml b/blueprints/script/devices/aircon.yaml new file mode 100644 index 0000000..b2641be --- /dev/null +++ b/blueprints/script/devices/aircon.yaml @@ -0,0 +1,135 @@ +blueprint: +  name: AirCon +  description: Stream photos from security camera +  domain: script +  input: +    power: +      name: Power +      description: Aircon Smart Power Plug +      selector: +        entity: +          domain: switch +    temperature: +      name: Temperature +      description: Temperature sensor +      selector: +        entity: +          domain: sensor +          device_class: temperature +    cold_temp: +      name: Cold Temp +      description: Temperature threshold to turn on heating +      default: 16 +      selector: +        number: +          min: 8 +          max: 20 +          unit_of_measurement: C +    hot_temp: +      name: Hot Temp +      description: Temperature threshold to turn on cooling +      default: 20 +      selector: +        number: +          min: 20 +          max: 36 +          unit_of_measurement: C +    cool_scene: +      name: Cool Scene +      description: Cooling scene of Aircon +      selector: +        entity: +          domain: scene +    heat_scene: +      name: Heat Scene +      description: Warming scene of Aircon +      selector: +        entity: +          domain: scene +    off_scene: +      name: Off Scene +      description: Off scene of Aircon +      selector: +        entity: +          domain: scene +    confirm: +      name: Confirm +      description: Confirmation script +      default: [] +      selector: +        action: + +variables: +  temp: !input temperature +  cold: !input cold_temp +  hot: !input hot_temp + +alias: AirCon +sequence: +  - if: +      - condition: state +        entity_id: !input power +        state: 'on' +    then: +      - service: scene.turn_on +        target: +          entity_id: !input off_scene +      - delay: +          hours: 0 +          minutes: 0 +          seconds: 5 +          milliseconds: 0 +      - service: switch.turn_off +        target: +          entity_id: !input power +    else: +      - service: switch.turn_on +        target: +          entity_id: !input power +      - delay: +          hours: 0 +          minutes: 0 +          seconds: 5 +          milliseconds: 0 +      - choose: +          - conditions:  +              - "{{ states('sensor.bedroom_temp_temperature') | float < cold }}" +            sequence: +              - service: scene.turn_on +                target: +                  entity_id: !input heat_scene +          - conditions:  +              - "{{ states('sensor.bedroom_temp_temperature') | float > hot }}" +            sequence: +              - service: scene.turn_on +                target: +                  entity_id: !input cool_scene +        default: +          - service: switch.turn_off +            target: +              entity_id: !input power +      - service: switch.turn_on +        target: +          entity_id: !input power +      - choose: [] +        default: !input "confirm" + +#  - if: +#      - condition: state +#        entity_id: switch.bedroom_aircon +#        state: 'off' +#    then: +#      - service: switch.turn_on +#        data: {} +#        target: +#          entity_id: switch.bedroom_aircon +#      - delay: +#          hours: 0 +#          minutes: 0 +#          seconds: 5 +#          milliseconds: 0 +  - service: scene.turn_on +    target: +      entity_id: scene.hyundai_aircon_cool_18 +    metadata: {} +mode: single diff --git a/blueprints/script/devices/kodi-alarm.yaml b/blueprints/script/devices/kodi-alarm.yaml new file mode 100644 index 0000000..48ecd1c --- /dev/null +++ b/blueprints/script/devices/kodi-alarm.yaml @@ -0,0 +1,29 @@ +blueprint: +  name: Kodi - Play Alarm +  description: Stream photos from security camera +  domain: script +  input: +    player: +      name: Player +      description: KoDi Media Player +      selector: +        entity: +          domain: media_player +    song: +      name: Player +      description: KoDi Media Player +      selector: +        media: {} + +mode: restart +sequence: +  - service: media_player.volume_set +    data: +      volume_level: 1 +    target: +      entity_id: !input player +  - service: media_player.play_media +    target: +      entity_id: !input player +    data: +      !input song diff --git a/blueprints/script/homeassistant/confirmable_notification.yaml b/blueprints/script/homeassistant/confirmable_notification.yaml new file mode 100644 index 0000000..d52e5a6 --- /dev/null +++ b/blueprints/script/homeassistant/confirmable_notification.yaml @@ -0,0 +1,84 @@ +blueprint: +  name: Confirmable Notification +  description: >- +    A script that sends an actionable notification with a confirmation before +    running the specified action. +  domain: script +  source_url: https://github.com/home-assistant/core/blob/master/homeassistant/components/script/blueprints/confirmable_notification.yaml +  input: +    notify_device: +      name: Device to notify +      description: Device needs to run the official Home Assistant app to receive notifications. +      selector: +        device: +          integration: mobile_app +    title: +      name: "Title" +      description: "The title of the button shown in the notification." +      default: "" +      selector: +        text: +    message: +      name: "Message" +      description: "The message body" +      selector: +        text: +    confirm_text: +      name: "Confirmation Text" +      description: "Text to show on the confirmation button" +      default: "Confirm" +      selector: +        text: +    confirm_action: +      name: "Confirmation Action" +      description: "Action to run when notification is confirmed" +      default: [] +      selector: +        action: +    dismiss_text: +      name: "Dismiss Text" +      description: "Text to show on the dismiss button" +      default: "Dismiss" +      selector: +        text: +    dismiss_action: +      name: "Dismiss Action" +      description: "Action to run when notification is dismissed" +      default: [] +      selector: +        action: + +mode: restart + +sequence: +  - alias: "Set up variables" +    variables: +      action_confirm: "{{ 'CONFIRM_' ~ context.id }}" +      action_dismiss: "{{ 'DISMISS_' ~ context.id }}" +  - alias: "Send notification" +    domain: mobile_app +    type: notify +    device_id: !input notify_device +    title: !input title +    message: !input message +    data: +      actions: +        - action: "{{ action_confirm }}" +          title: !input confirm_text +        - action: "{{ action_dismiss }}" +          title: !input dismiss_text +  - alias: "Awaiting response" +    wait_for_trigger: +      - platform: event +        event_type: mobile_app_notification_action +        event_data: +          action: "{{ action_confirm }}" +      - platform: event +        event_type: mobile_app_notification_action +        event_data: +          action: "{{ action_dismiss }}" +  - choose: +      - conditions: "{{ wait.trigger.event.data.action == action_confirm }}" +        sequence: !input confirm_action +      - conditions: "{{ wait.trigger.event.data.action == action_dismiss }}" +        sequence: !input dismiss_action diff --git a/blueprints/script/lights/turn_off_lights.yaml b/blueprints/script/lights/turn_off_lights.yaml new file mode 100644 index 0000000..e5538b7 --- /dev/null +++ b/blueprints/script/lights/turn_off_lights.yaml @@ -0,0 +1,32 @@ +blueprint: +  name: turn_off_lights +  description: Turns off a group of lights +  domain: script +  input: +    lights: +      name: Affected class of lights +      description: "Which class of lights to turn off: all, bedroom, living, hall" +      default: "all" + +variables: +  name: !input lights +  std: "switch.lights_{{ name }}" +  manual: "switch.lights_{{ name }}_manual" + + +mode: single + +sequence: +  - service: switch.turn_off +    target: +      entity_id: "{{ std, manual }}" + +  - delay: +      hours: 0 +      minutes: 0 +      seconds: 3 +      milliseconds: 0 + +  - service: switch.turn_on +    target: +      entity_id: "{{ [ manual ] }}" | 
