Script / Automation issue

Once again I am stuck with an automation that just does not seem to want to run, I am trying to setup an automation, that whenever my “Garage Door” switch is toggled, that it sends me a notification via Push Bullet.
Now if I setup the automation and test the automation it works, however on my front end, when I toggle the switch, the switch activates activated, but the automation does not run.

setup is as follows:

WEMOS D1 mini setup with ESP Home:

switch:
- platform: gpio
  id: relay_1
  pin:
    number: GPIO5
    inverted: False
  restore_mode: ALWAYS_OFF
- platform: template
  name: "Garage Door"
  icon: "mdi:garage"
  turn_on_action:
  - switch.turn_on: relay_1
  - delay: 1s
  - switch.turn_off: relay_1

- platform: gpio
  id: relay_2
  pin:
    number: GPIO4
    inverted: False
  restore_mode: ALWAYS_OFF
- platform: template
  name: "Car Port"
  icon: "mdi:garage"
  turn_on_action:
  - switch.turn_on: relay_2
  - delay: 1s
  - switch.turn_off: relay_2

- platform: restart
  name: 'Garage Door REBOOT'

Entities Card on HASSIO Front end:

entities:
  - entity: switch.garage_door
  - entity: switch.car_port
  - entity: switch.garage_door_reboot
show_header_toggle: false
title: Garage
type: entities

Automation:

device_id: ad490433ae6f40f2a2e05173c7448960
domain: switch
entity_id: switch.garage_door
platform: device
type: turned_on
data:
  message: test
service: notify.phone

am I missing something?

I believe your automation formatting is off.
YAML is sensitive to it and yours is not valid.

I understand that, however, I’m using the Automation Editor, which does all the formatting for me, I merely just converted it to YAML to post it here.

I suspect Automation Editor is not always right… :\

Was thinking maybe creating a script, and then setting up a toggle switch to call up that script?

Unfortunately, I’m not familiar with this type of automations.
What is it doing?
Does this work?

- alias: msg_test
  trigger:
    platform: state
    entity_id: switch.garage_door
    to: 'on'
  action:
    service: notify.phone
    data:
      message: test
1 Like

Will give it a try and let you know :slight_smile:

Are you sure this automation worked in testing? There’s no action and trigger part, somehow I can’t believe this worked. Any errors in the logs?

2 Likes

Well when I ran the automation manually I got the push notification, but I do suspect that there were a few flaws in my switch setup as well as my automation, so instead of wasting time troubleshooting, I reconfigured the switch and re did the automation completely and now it works like a charm.
Thanks for everyone’s input here :smiley:
Will post the details of the switch and automation a bit later today just in case somebody else runs into the same issue down the line :slight_smile:

1 Like

So as promised, a little late I know, but better late than never :smiley:

Switch:

binary_sensor:
  - platform: gpio
    pin: D3
    name: "Garage Reed"
    id: garage_reed
  - platform: gpio
    pin: D4
    name: "Carport Reed"
    id: carport_reed

switch:
  - platform: gpio
    pin: D5
    name: "Garage Door Switch"
    id: garage_switch
  - platform: gpio
    pin: D6
    name: "Carport Switch"
    id: carport_switch

cover:
  - platform: template
    device_class: garage
    name: "Garage Door"
    lambda: !lambda |-
      if (id(garage_reed).state) {
        return COVER_OPEN;
      } else {
        return COVER_CLOSED;
      }    
    open_action:
      # Turn the OPEN switch on briefly 
      - switch.turn_on: garage_switch
      - delay: 0.1s
      - switch.turn_off: garage_switch
    close_action:
      - switch.turn_on: garage_switch
      - delay: 0.1s
      - switch.turn_off: garage_switch
    stop_action:
      - switch.turn_on: garage_switch
      - delay: 0.1s
      - switch.turn_off: garage_switch
    optimistic: true
    assumed_state: true
    
  - platform: template
    device_class: garage
    name: "Carport Door"
    lambda: !lambda |-
      if (id(carport_reed).state) {
        return COVER_OPEN;
      } else {
        return COVER_CLOSED;
      } 
    open_action:
      # Turn the OPEN switch on briefly
      - switch.turn_on: carport_switch
      - delay: 0.1s
      - switch.turn_off: carport_switch
    close_action:
      - switch.turn_on: carport_switch
      - delay: 0.1s
      - switch.turn_off: carport_switch
    stop_action:
      - switch.turn_on: carport_switch
      - delay: 0.1s
      - switch.turn_off: carport_switch
    optimistic: true
    assumed_state: true

Automation:
Carport Closed:
“trigger”

entity_id: binary_sensor.carport_reed
from: 'on'
platform: state
to: 'off'

“Action”

data:
  message: Car Port Closed
service: notify.phone

repeat the automation in reverse for the open signal and then rinse and repeat for the garage part.
The code for the switch I got somewhere here and modified it to to my specification, so credits to whoever came up with it.