Custom buttons input and output

Hi all,

Pleae could somebody help me out.

I need to make a custom button, the button needs to change colour on a state of an input but when i press it, it needs to trigger an output.

i have an esp32 monitoring the outputs of an plc, those are my inputs and i have outputs from my esp32 to trigger the outputs on the plc.

example: input lounge light status
output lounge light switch

if the light is on the button must change green but i can press the button to turn off the light.

i’ve tried a few things, nothing has worked, this is my first time making a custom button.

if somebody could please help me out with a sample code, i would appreciated it.

thanks.

What custom button cards did you try, and why did they not fit your purpose?