WiFi momentary light switch

I’m looking for suggestions for setting up a somewhat unique (from what I’ve seen, anyway) light switch to trigger a single color light linked to HA. The light itself is integrated via Tasmota. The button will be a very basic D1-Mini.

The button will trigger one of two things:
If “untouched” prior, it will turn the light on and set the brightness to 100%. Prior to this, it needs to store the previous on/off state & brightness.
If the switch is previously “touched”, it will reset the light to the previously stored state & brightness, and reset the switch to “untouched”.

The thing I’m having a problem with is the HA dashboard. What I want to happen is that as soon as anything for that lights state or brightness changes via the dashboard itself, the switch reverts to the “untouched” state.

I’m new to ALL of this except for the actual device construction. So, any and all help would be appreciated.

Personally, i think node red is the easiest way to solve this problem, for a specific reason.

You can store things in flow variables, or global variables, that exist outside of the context of flow execution. There is no way to do that in HA short of using input text or input number, which IMO is clunky.

Specifically for your dashboard problem, you may need to build a template switch to display, rather than the button itself, as buttons are momentary by design – ie they are “on” when clicked and revert back to “off” straight away.

A simpler way might be to integrate your D1 mini as a normal switch. On == touched, Off = untouched. Dont implement it as a momentary switch in HA, but a standard switch.

HTH!