Zigbee Switch state different after power outage

Hi,
I have some zigbee switch that i connect with HA through ZHA…
For on/off no problem, everything great as i expected.
But in the last 2 days, i found a problem when my house had power outage…
Before power lost i have some switch that is on…
After the power back, all my switch become on and after that become all off, include the previous switch that is “on”
but in HA the state still “on”…
to make the HA correct the state i have to turn it off and then turn it back on.

I assume it was because my switch doesn’t have a “last power state”
like in left picture

I try to scan my switch and in has this parameter

{
  "ieee": "d4:c1:38:50:f6:b6:96:a4",
  "nwk": "0xdb4c",
  "model": "TS0012",
  "manufacturer": "_TZ3000_zmlunnhy",
  "manufacturer_id": "0x4417",
  "endpoints": [
    {
      "id": 1,
      "device_type": "0x0100",
      "profile": "0x0104",
      "in_clusters": {
        "0x0000": {
          "cluster_id": "0x0000",
          "title": "Basic",
          "name": "basic",
          "attributes": {
            "0x0000": {
              "attribute_id": "0x0000",
              "attribute_name": "zcl_version",
              "value_type": [
                "0x20",
                "uint8_t",
                "Analog"
              ],
              "access": "5",
              "access_acl": 5,
              "attribute_value": 3
            },
            "0x0001": {
              "attribute_id": "0x0001",
              "attribute_name": "app_version",
              "value_type": [
                "0x20",
                "uint8_t",
                "Analog"
              ],
              "access": "5",
              "access_acl": 5,
              "attribute_value": 80
            },
            "0x0002": {
              "attribute_id": "0x0002",
              "attribute_name": "stack_version",
              "value_type": [
                "0x20",
                "uint8_t",
                "Analog"
              ],
              "access": "5",
              "access_acl": 5,
              "attribute_value": 0
            },
            "0x0003": {
              "attribute_id": "0x0003",
              "attribute_name": "hw_version",
              "value_type": [
                "0x20",
                "uint8_t",

my friend use the same switch and connect it to tuya zigbee gateway, and he can see that the switch has some kind of “last power state” as shown in the right picture

i prefer to not use tuya zigbee gateway to keep my switch in local network…

Can my switch and HA can have some state after power outage?
What should i do to make the switch remember their last power state?

I found this article,

https://community.home-assistant.io/t/change-power-on-state-ts0121-tz3000-rdtixbnuvia-clusters-in-zha/434434

Now i have to simulate power outage scenario to test the new config…
I hope it fix my problem…

Looking at your screenshot, HA thinks that device is a light, not a smart plug. You could indeed use the clusters (as per the link) to control the power on state, but I’d be tempted to find a local ZHA quirk so you can change these things more easily.

I have several Tuya based smart plugs, connected directly to HA via ZHA and use a quirk to expose their full features.

with cluster, the problem solved…
but as you @Rofo said i have to manually do it for all my switch…
Nice if you have and wanna share local quirk for TS0012 that work with my switch so i can control it in UI.

My smart plugs are TS011Fs not TS0012s which are switches, so the quirk I use won’t work for you.

A quick google and I found this thread that might help you