Trigger state node to block messages?

I have a very simple setup with a physical toggle switch on/off via ESPhome, when we have a power cut for example and the switch is left in the “on” position the device state goes “unavailable” then when it reconnects it triggers to “on” again. I’m looking for a way to filter this out and block it when this scenario occures but still want the regular on/off to be allowed.

I have looked at the trigger: state node and tried a couple of options but can’t get it to work. Is this the right solution?

Thanks

I had a similar situation, and this helped.

If you use an event: state node for the trigger the bottom has a set of check boxes for these situations.

Thanks for looking at my post, this would have been perfect to fix at the source but unfortunatly doesnt work as the relay is on another device not all in one.

Thanks for looking also, this appears to have fixed my issue. Was right under my nose !

Then you can use the solution suggested by @Mikefila, or this if you want to use a trigger: state node.