I am trying to figure out why dynamic icons do not work with a Switch, using MQTT binding.
I want to have a switch which would have a dynamic icon displaying the status of my device (which is received via a separate MQTT channel). I believe the following code is written correctly, but it doesn’t work (the icon doesn’t change when the status received via MQTT changes):
//sitemap:
Switch item=Clear_case mappings=[ON="Clear case"]
//items:
Switch Clear_case "" <casestatus> {mqtt="<[broker:3d_printer/clear_case/status:state:default],>[broker:3d_printer/clear_case/switch:command:ON:1]"}
I did create casestatus.png, casestatus-0.png, and casestatus-1.png inside icons folder. The MQTT incoming message is either “0” or “1”.
What is interesting that exactly the same setup (mqtt, icons) works perfectly fine when I separate my code into two items - a switch and a number:
//sitemap:
Switch item=Clear_case mappings=[ON="Clear case"]
Text item=Clear_case_status label="[]"
//items:
Number Clear_case_status "[%d]" <casestatus> {mqtt="<[broker:3d_printer/clear_case/status:state:default]"}
Switch Clear_case "" <empty> {mqtt=">[broker:3d_printer/clear_case/switch:command:ON:1]"}
Which proves that I got the MQTT and dynamic icons stuff right. But I am puzzled why the same doesn’t work for the case of a dynamic icon with a single Switch item (my first example).
BTW I am using Basic UI, OpenHab2.
Can anyone tell me what I am doing wrong here?
Thanks!