Shelly 1 PM Gen 4 as detached button - single click event on reboot?

Hi,

I am using some Shelly 1 PM Gen 4 relays in detached mode (cf. screenshot) to control Zigbee lights via HA. Now I noticed that HA seems to detect a single click event when the lights disconnect (or probably rather re-connect). So my lights toggle uncommanded. I first saw this when the WiFi access points updated their firmware and rebooted in the process, but a manual reboot of the Shellies via their web interface has the same effect.

In my opinion this should not happen, but how can I find out if the issue is with the device (does it actually send the command upon re-connect?) or the Shelly integration in HA (does it misinterpret the re-connect as a single click event?)?

Look at the activity log when this happens. It will tell you why the lights were toggled.

If you’re using an automation to toggle the lights, post it here (as correctly formatted code, not pictures).

Chances are it’s triggering when the Shelly goes unknown or unavailable & comes back online. Automations can be set up to avoid triggering on this scenario.

Thank you for the quick reply. The automation looks like this:

alias: Upstairs Corridor Ceiling Light On Off Button Action
description: ""
triggers:
  - trigger: state
    entity_id:
      - event.shelly_1_pm_upstairs_corridor_lights_input_0
    attribute: event_type
    to:
      - single_push
conditions: []
actions:
  - action: light.toggle
    metadata: {}
    data: {}
    target:
      entity_id: light.upstairs_corridor_ceiling_light_group
mode: single

I’m not sure where to find the activity log, but here are the “changed variables” from a trace:

this:
  entity_id: automation.upstairs_corridor_on_off_button_action
  state: 'on'
  attributes:
    id: '1764082601493'
    last_triggered: '2026-01-28T20:37:30.912464+00:00'
    mode: single
    current: 0
    friendly_name: Upstairs Corridor Ceiling Light On Off Button Action
  last_changed: '2026-01-25T16:14:12.268057+00:00'
  last_reported: '2026-01-28T20:37:30.914480+00:00'
  last_updated: '2026-01-28T20:37:30.914480+00:00'
  context:
    id: 01KG356NN0FPDXYBYK4MVCVXGZ
    parent_id: 01KG356NN0KD7MGP40FZ90J7DZ
    user_id: null
trigger:
  id: '0'
  idx: '0'
  alias: null
  platform: state
  entity_id: event.shelly_1_pm_upstairs_corridor_lights_input_0
  from_state:
    entity_id: event.shelly_1_pm_upstairs_corridor_lights_input_0
    state: unavailable
    attributes:
      event_types:
        - long_push
        - double_push
        - btn_up
        - triple_push
        - btn_down
        - single_push
      device_class: button
      friendly_name: 'Upstairs Corridor Shelly 1 PM for Lights Input '
    last_changed: '2026-01-28T21:11:35.881865+00:00'
    last_reported: '2026-01-28T21:11:35.881865+00:00'
    last_updated: '2026-01-28T21:11:35.881865+00:00'
    context:
      id: 01KG3752P9SNXHC24A6S8Q50RB
      parent_id: null
      user_id: null
  to_state:
    entity_id: event.shelly_1_pm_upstairs_corridor_lights_input_0
    state: '2026-01-28T20:37:30.911+00:00'
    attributes:
      event_types:
        - long_push
        - double_push
        - btn_up
        - triple_push
        - btn_down
        - single_push
      event_type: single_push
      device_class: button
      friendly_name: 'Upstairs Corridor Shelly 1 PM for Lights Input '
    last_changed: '2026-01-28T21:11:46.126451+00:00'
    last_reported: '2026-01-28T21:11:46.126451+00:00'
    last_updated: '2026-01-28T21:11:46.126451+00:00'
    context:
      id: 01KG375CPECKHCN3K42SN1AM1V
      parent_id: null
      user_id: null
  for: null
  attribute: event_type
  description: state of event.shelly_1_pm_upstairs_corridor_lights_input_0

From what I understand, the event state changes from undefined (not connected, I guess) to single_push. The latter I don’t understand, because it wasn’t pushed?

The activity log is found in your dashboard on the left, or on the device page on the right

However, given you’re using event_type, I suspect it’s the “Action on power on” setting in the Shelly app which is causing your issue.
Try setting it to “Current state of the switch”. If that doesn’t work, revert your change and replace your conditions section with this:

conditions:
  - condition: template
    value_template: "{{ trigger.from_state.state not in ['unknown', 'unavailable'] }}"

I am using buttons in this case (they trigger on contact, then revert to their normal position), and in that case “Current state of the switch” cannot be selected. I’d have to change to “switch”, which I’m not sure would work.

I added the condition to my automation and that does the trick. Thank you! Still, I am wondering where that unexpected single press event comes from.

Not sure since I don’t use one. Probably from the Shelly firing off a button press event on reconnection. Activity log will tell you what’s exactly going on on reconnect.