Icon state

Hello,
How to change the icon of an action depending on the state of the sensor.
I actually created a widget to open my garage door and one to close my garage door.
How can I get live feedback on the status of the door?