MQTT triggered automation keeps trigering forever

Hello,

Using Mosquito MQTT and Shelly 2.5 via MQTT. Trying to implement button long push action. My automation simple automation for testing :

alias: 1 2aukstas long press
description: ''
trigger:
  - platform: mqtt
    topic: shellies/shellyswitch25-40F5202A29E1/input_event/0
  - platform: mqtt
    topic: shellies/shellyswitch25-40F5202A29E1/input_event/1
condition:
  - condition: template
    value_template: '{{ trigger.payload_json.event == ''L'' }}'
action:
  - service: notify.mobile_app_andriaus_iphone_pro
    data:
      message: mygtukas long push
  - service: light.turn_off
    data: {}
    entity_id: light.2nd_floor_foyer_light
mode: single

The problem is: First long push is working,but after this automation goes to infinite look trigering action every 30 seconds

Please edit your post and format your pasted automation confg correctly. See point 11 here: Help us help you

This will trigger when input_event is 1 or 0 is that the desired behavior? Each entry in trigger can fire the automation. If yes, I guess not pushing the button sets the trigger.payload_json.event to ‘L’ what makes kind of sense, as you haven’t pushed the button for long.

/input_event/ 0 or 1 defines the relay/button on the wall. if i manually long press - it works. The problem is that MQTT trigger somehow keeps triggeding every 30 seconds.

Watch the topics with something like MQTT Explorer (free) to see what is being published to them.

Actually it will trigger when anything is published to either of the topics:

topic: shellies/shellyswitch25-40F5202A29E1/input_event/0
topic: shellies/shellyswitch25-40F5202A29E1/input_event/1

But should be prevented from executing the actions unless the payload condition '{{ trigger.payload_json.event == ''L'' }}' evaluates as true.

Ah, i just subscibed to topic via Mosquito plugin configuration and see that the same is published every 30 seconds. Why ?

According to the Shelly API I think you should be monitoring this insted:

Input events can be monitored on:

  • shellies/shellyswitch25-<deviceid>/longpush/<i> for each SW input <i> ; reports a value indicating longpush state as 0 (shortpush) or 1 (longpush)

See Welcome to Shelly Technical Documentation | Shelly Technical Documentation

you are perfectly right, my bad.

Yes, thanks. it works with shellies/shellyswitch25-40F5202A29E1/longpush/1

1 Like