Dinamically change picture/icon inside the map card

Dear all, how can I use “templating” to change picture/icon inside the map card??
I’m referring to device_tracker picture/icon.
For example, if state == home > picture1; if state == not_home > picture2

Thanks a lot.