Garage door switch notification

Hi,

Newbie question here… Could not find answer I want…

I put a switch on my garage door to sense open/close. I want to send a notification when it opens and when it closes. Problem is that it keep sending open messages… I cannot include time with ‘for:’, since it can be open a random time. I did include that for close.

Any ideas to send just one notification?

  • alias: garage open
    hide_entity: true
    trigger:
    platform: state
    entity_id: switch.garagepoort
    to: ‘on’
    action:
    service: notify.ios_iphone
    data:
    message: “garagepoort open!”

  • alias: garage dicht
    hide_entity: true
    trigger:
    platform: state
    entity_id: switch.garagepoort
    to: ‘off’
    for:
    minutes: 5
    action:
    service: notify.ios_iphone
    data:
    message: “garagepoort dicht!”

Include a from: off in your “garage open” automation and see if this solves your problem.

Hi Florian,

Thanks for the suggestion, I put it in both but I still get 2 messages at least… It is a RXTRX platform switch.

But you did put from: on in “garage dicht” right?

Yes, this is what I have now. I get two open messages AND a closed when I open the door! And closed + open when I close it… It is a CoCo switch. Should I use fire_event in the switch definition? I don’t understand that parameter.

  • alias: garage open
    hide_entity: true
    trigger:
    platform: state
    entity_id: switch.garagepoort
    from: ‘off’
    to: ‘on’
    action:
    service: notify.ios_iphone
    data:
    message: “garagepoort open!”

  • alias: garage dicht
    hide_entity: true
    trigger:
    platform: state
    entity_id: switch.garagepoort
    from: ‘on’
    to: ‘off’
    action:
    service: notify.ios_iphone
    data:
    message: “garagepoort dicht!”

I’ve never used an RFXtrx switch myself so anything I say is guessing only. You could try to set fire_event: false and check if that works. I’d also try to add for for 2 seconds to “debounce the signal” a little.

If nothing of that helps I’d suggest you reformat your post (see blue box at top about syntax highlighting) so we can make sure there is nothing wrong with the indentation.

Thanks for your suggestions! Putting in 2s for a delay works. Fire_event by itself did not. So here is the code that works:

- alias: garage open
  hide_entity: true
  trigger:
    platform: state
    entity_id: switch.garagepoort
    from: 'off'
    to: 'on'
    for:
      seconds: 2
  action:
    service: notify.ios_iphone
    data:
      message: "garagepoort open!"
      
- alias: garage dicht
  hide_entity: true
  trigger:
    platform: state
    entity_id: switch.garagepoort
    from: 'on'
    to: 'off'
    for:
      seconds: 2
  action:
    service: notify.ios_iphone
    data:
      message: "garagepoort dicht!"
1 Like