Tap image to toggle lights and fans

I am using picture-elements for my floorpan. I am using state-icons to toggle the lights and fans. Is it possible to toggle switches by tapping on part of the image?

For example, tapping on the dining table turns on dining room lights, tapping on the kitchen counter turns on the pendant lights above the counter, etc.

For anyone who wants to do the same, I found the solution here. It worked perfectly.