Help! Tuya wireless switch publishes heartbeat messages as presses

Not sure if this is the right category…
Hi all. I posted this an a issue on the core Github repo and got the suggestion to filter out state changes from unavailable/unknown in the automation. I did that, and it hasn’t helped. No reply since. Wondering if you have any ideas?

The problem

I have a Tuya Wireless 2 Gang Smart Scene Switch (aka Tuya Wireless Switch). ID eb404e0ebdc96783a7ptu7, category wxkg. It consistently sends press events even though I haven’t pressed it. I’ve been logging these events for a few days now and the comparison of the Home Assistant press logs and the Tuya Developer Portal logs are interesting.

Tuya Logs

Home Assistant ‘Logs’
21-03-2026-08-36-15, 22-03-2026-00-36-44, 22-03-2026-16-37-04, 23-03-2026-08-41-52, 24-03-2026-03-23-25, 24-03-2026-19-23-29, 25-03-2026-11-23-33, 26-03-2026-03-23-54, 26-03-2026-19-24-10, 27-03-2026-11-24-17, 28-03-2026-11-25-17, 29-03-2026-03-25-46‎

The core Tuya integration appears to be using heartbeat messages as press/click events.
My automation only captures press/click events, so it’s definitely not using a different event_type for heartbeats.
{{ trigger.event.data.new_state.attributes.event_type in ['click','press'] }}

Event from a real press

event_type: state_changed
data:
  entity_id: event.wireless_switch_button_1
  old_state:
    entity_id: event.wireless_switch_button_1
    state: "2026-03-28T19:49:57.429+00:00"
    attributes:
      event_types:
        - click
        - press
      event_type: click
      device_class: button
      friendly_name: Strip Lights
    last_changed: "2026-03-28T19:49:57.429607+00:00"
    last_reported: "2026-03-28T19:49:57.429607+00:00"
    last_updated: "2026-03-28T19:49:57.429607+00:00"
    context:
      id: 01KMTZY01N5N5WR6A7MRXAAWMW
      parent_id: null
      user_id: null
  new_state:
    entity_id: event.wireless_switch_button_1
    state: "2026-03-28T19:50:23.502+00:00"
    attributes:
      event_types:
        - click
        - press
      event_type: click
      device_class: button
      friendly_name: Strip Lights
    last_changed: "2026-03-28T19:50:23.502795+00:00"
    last_reported: "2026-03-28T19:50:23.502795+00:00"
    last_updated: "2026-03-28T19:50:23.502795+00:00"
    context:
      id: 01KMTZYSGEK69FEYK82JKBPRBK
      parent_id: null
      user_id: null
origin: LOCAL
time_fired: "2026-03-28T19:50:23.502795+00:00"
context:
  id: 01KMTZYSGEK69FEYK82JKBPRBK
  parent_id: null
  user_id: null

What version of Home Assistant Core has the issue?

core-2026.2.3

What type of installation are you running?

Home Assistant Container

Diagnostics information

  "integration_manifest": {
    "domain": "tuya",
    "name": "Tuya",
    "codeowners": [
      "Tuya",
      "zlinoliver"
    ],
    "config_flow": true,
    "dependencies": [
      "ffmpeg"
    ],
    "dhcp": [
      {
        "macaddress": "105A17*"
      },
      {
        "macaddress": "10D561*"
      },
      {
        "macaddress": "1869D8*"
      },
      {
        "macaddress": "381F8D*"
      },
      {
        "macaddress": "508A06*"
      },
      {
        "macaddress": "68572D*"
      },
      {
        "macaddress": "708976*"
      },
      {
        "macaddress": "7CF666*"
      },
      {
        "macaddress": "84E342*"
      },
      {
        "macaddress": "D4A651*"
      },
      {
        "macaddress": "D81F12*"
      }
    ],
    "documentation": "https://www.home-assistant.io/integrations/tuya",
    "integration_type": "hub",
    "iot_class": "cloud_push",
    "loggers": [
      "tuya_sharing"
    ],
    "requirements": [
      "tuya-device-sharing-sdk==0.2.8"
    ],
    "is_built_in": true,
    "overwrites_built_in": false
  },
  "setup_times": {
    "null": {
      "setup": 1.6332021914422512e-05
    },
    "01JHYNDEFS0VH7NVZ31Z830C1A": {
      "wait_import_platforms": -0.12865515297744423,
      "wait_base_component": -0.0010877089807763696,
      "config_entry_setup": 29.738058179966174
    }
  },
  "data": {
    "endpoint": "https://apigw.tuyaus.com",
    "terminal_id": "17715620694558ejxVT",
    "mqtt_connected": true,
    "disabled_by": null,
    "disabled_polling": false,
    "id": "eb404e0ebdc96783a7ptu7",
    "name": "Buttons",
    "category": "wxkg",
    "product_id": "l8yaz4um5b3pwyvf",
    "product_name": "Wireless Switch",
    "online": true,
    "sub": false,
    "time_zone": "+13:00",
    "active_time": "2025-12-24T18:05:23+00:00",
    "create_time": "2025-12-24T18:05:23+00:00",
    "update_time": "2025-12-24T18:05:23+00:00",
    "function": {},
    "status_range": {
      "switch_mode1": {
        "type": "Enum",
        "value": "{\"range\":[\"click\",\"press\"]}",
        "report_type": null
      },
      "switch_mode2": {
        "type": "Enum",
        "value": "{\"range\":[\"click\",\"press\"]}",
        "report_type": null
      },
      "battery_percentage": {
        "type": "Integer",
        "value": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}",
        "report_type": null
      }
    },
    "status": {
      "switch_mode1": "click",
      "switch_mode2": "click",
      "battery_percentage": 33
    },
    "home_assistant": {
      "name": "Buttons",
      "name_by_user": null,
      "disabled": false,
      "disabled_by": null,
      "entities": [
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "button",
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "event.wireless_switch_button_1",
            "state": "2026-03-28T14:25:46.958+00:00",
            "attributes": {
              "event_types": [
                "click",
                "press"
              ],
              "event_type": "click",
              "device_class": "button",
              "friendly_name": "Strip Lights"
            },
            "last_changed": "2026-03-28T17:18:02.473186+00:00",
            "last_reported": "2026-03-28T17:18:02.473186+00:00",
            "last_updated": "2026-03-28T17:18:02.473186+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "button",
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "event.wireless_switch_button_2",
            "state": "2026-03-28T14:25:46.958+00:00",
            "attributes": {
              "event_types": [
                "click",
                "press"
              ],
              "event_type": "click",
              "device_class": "button",
              "friendly_name": "Main Light"
            },
            "last_changed": "2026-03-28T17:18:02.473408+00:00",
            "last_reported": "2026-03-28T17:18:02.473408+00:00",
            "last_updated": "2026-03-28T17:18:02.473408+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": "battery",
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": "%",
          "state": {
            "entity_id": "sensor.wireless_switch_battery",
            "state": "33.0",
            "attributes": {
              "state_class": "measurement",
              "unit_of_measurement": "%",
              "device_class": "battery",
              "friendly_name": "Buttons Battery"
            },
            "last_changed": "2026-03-28T17:18:02.486801+00:00",
            "last_reported": "2026-03-28T17:18:02.486801+00:00",
            "last_updated": "2026-03-28T17:18:02.486801+00:00"
          }
        }
      ]
    },
    "set_up": true,
    "support_local": true,
    "local_strategy": {
      "1": {
        "value_convert": "enum",
        "status_code": "switch_mode1",
        "config_item": {
          "statusFormat": "{\"switch_mode1\":\"$\"}",
          "valueDesc": "{\"range\":[\"click\",\"press\"]}",
          "valueType": "Enum",
          "enumMappingMap": {
            "double_click": {
              "code": "switch_mode1",
              "value": "double_click"
            },
            "long_press": {
              "code": "switch_mode1",
              "value": "press"
            },
            "single_click": {
              "code": "switch_mode1",
              "value": "click"
            }
          },
          "pid": "l8yaz4um5b3pwyvf"
        }
      },
      "2": {
        "value_convert": "enum",
        "status_code": "switch_mode2",
        "config_item": {
          "statusFormat": "{\"switch_mode2\":\"$\"}",
          "valueDesc": "{\"range\":[\"click\",\"press\"]}",
          "valueType": "Enum",
          "enumMappingMap": {
            "double_click": {
              "code": "switch_mode2",
              "value": "double_click"
            },
            "long_press": {
              "code": "switch_mode2",
              "value": "press"
            },
            "single_click": {
              "code": "switch_mode2",
              "value": "click"
            }
          },
          "pid": "l8yaz4um5b3pwyvf"
        }
      },
      "10": {
        "value_convert": "default",
        "status_code": "battery_percentage",
        "config_item": {
          "statusFormat": "{\"battery_percentage\":\"$\"}",
          "valueDesc": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}",
          "valueType": "Integer",
          "enumMappingMap": {},
          "pid": "l8yaz4um5b3pwyvf"
        }
      }
    },
    "warnings": null
  },
  "issues": []

Additional information

Each event is also duplicated.
I’ve filtered this out of my automation by checking how recent the last log was.

{% set current = states('input_text.front_door_message_times') %} {% if current in ['unknown','unavailable',''] %}
  true
{% else %}
  {% set last = current.split(',')[-1].strip() %}
  {% set last_dt = strptime(last, '%d-%m-%Y-%H-%M-%S') %}
  {{ (as_timestamp(now()) - as_timestamp(last_dt)) > 5 }}
{% endif %}`

Though officially this would classify as a bug in the integration creating the event entities, my opinion is that this is also in part caused by a very badly designed event entity.

But it is the integration you should report the bug to, as they should not trigger a state change for anything other than presses or changes in availability.

It’s the core Tuya integration, yeah. In the issue I linked to the integration & it’s documentation as the template instructed.

Yeah, this looks like a Tuya issue, not your setup. The switch is basically sending heartbeat updates, and Home Assistant is treating them like button presses. Since there’s no separate event type, it can’t really tell the difference. Best workaround is to filter by timing, gnore events that happen in a pattern or too far apart from a real press. Otherwise, you’d need a fix in the Tuya integration or switch to something local like Zigbee if possible.

I do have some new Zigbee switches but it seems a shame to have to throw away/not use two perfectly good sets of buttons. Any ideas on how to get some attention to the issue? Or do I just wait and hope.

Would it be considered rude to follow up/bump the issue or ping one of the people who work on the Tuya intergration?