- Platform information:
- Hardware: Raspberry Pi 4 / 4GB RAM / 64GB SD card
- OS:
cat /etc/os-release
PRETTY_NAME=“Raspbian GNU/Linux 10 (buster)”
NAME=“Raspbian GNU/Linux”
VERSION_ID=“10”
VERSION=“10 (buster)”
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
- Java Runtime Environment:
java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b01-1+rpi1-b01)
OpenJDK Client VM (build 25.212-b01, mixed mode)
- openHAB version:
dpkg --list | grep openhab
ii openhab2 2.5.5-1 all openhab2
ii openhab2-addons 2.5.5-1 all openhab2-addons
- Issue of the topic:
Actually, I am trying to add dynamic icons in my project. I have built up the interface in HABPanel like the following picture:
However, I tried to make an alarm notification by adding the status on the right side of my current status.
Currently, I construct my system by building up the MQTT Broker and installed it on my Raspberry Pi.
I can confirm that it worked smoothly with actual signals (with MQTT.fx v1.7.1).
I can only make the string of the status to change in OnOffType, but I can not make my icon change in the status.
I am not sure how to change it by the rules. Could you please be kind to help me? Thank you in advance for any suggestion!
Following picture is the configuration of my dummy widgets setting:
(By the way, I had my dynamic icons in the classic file)
- Please post configurations (if applicable):
- Items configuration related to the issue
Number Bed_1_analog "Bed Exit Detector [%d]" <analog> {mqtt="<[mosquitto:Bed_1:state:default]"}
Number Bed_1_percent "Bed Exit Detector [%.1f]" <percent> {mqtt="<[mosquitto:Bed_1:state:default]"}
Number Bed_1_analog_num "Analog" <analog> {mqtt="<[mosquitto:Bed_1:state:default]"}
Number Bed_1_percent_num "Percent" <percent> {mqtt="<[mosquitto:Bed_1:state:default]"}
String Bed_1_status "Status" <light> {mqtt="<[mosquitto:Bed_1:state:default]"}
- No Sitemap configuration
- Rules code related to the issue
First .rules file, I tried to apply in my project
rule "Bed Exit"
when
Item Bed_1_status changed
then
logInfo("Rule", "start to manage the status!")
val status_num = transform("status", "$.status", json)
if(Bed_1_status.state == "ON")
{
Bed_1_status.postUpdate("red")
}
else
{
Bed_1_status.postUpdate("green")
}
end
Second .rules I tried to apply in my project
rule "Wallplug_FF_LR_TV ON"
when
Item Bed_1_status changed from OFF to ON
then
Bed_1_status.postUpdate("red")
end
rule "Wallplug_FF_LR_TV OFF"
when
Item Bed_1_status changed from ON to OFF
then
Bed_1_status.postUpdate("red")
end
- No Services configuration related to the issue
Following is my Things configuration
- If logs where generated please post these here using code fences:
Currently, I am not sure how to fix up the warning but I think there is no problem with current system.
==> /var/log/openhab2/events.log <==
2020-05-31 08:43:54.164 [vent.ItemStateChangedEvent] - mqtt_topic_ba6a06c9_Bed_1_percent changed from 0.0 to 3.1
2020-05-31 08:43:54.179 [vent.ItemStateChangedEvent] - mqtt_topic_ba6a06c9_Bed_1_analog_num changed from 0 to 32
2020-05-31 08:43:54.193 [vent.ItemStateChangedEvent] - mqtt_topic_ba6a06c9_Bed_1_percent_num changed from 0.0 to 3.1
2020-05-31 08:43:54.206 [vent.ItemStateChangedEvent] - mqtt_topic_ba6a06c9_Bed_1_analog changed from 0 to 32
==> /var/log/openhab2/openhab.log <==
2020-05-31 08:43:54.642 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"analog":290,"percent":28.30,"status":0}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"analog":290,"percent":28.30,"status":0}
==> /var/log/openhab2/events.log <==
2020-05-31 08:43:54.650 [vent.ItemStateChangedEvent] - mqtt_topic_736bf7e5_Bed_1_status changed from ON to OFF
2020-05-31 08:43:54.657 [vent.ItemStateChangedEvent] - mqtt_topic_ba6a06c9_Bed_1_percent changed from 3.1 to 28.3
2020-05-31 08:43:54.664 [vent.ItemStateChangedEvent] - mqtt_topic_ba6a06c9_Bed_1_analog_num changed from 32 to 290
2020-05-31 08:43:54.670 [vent.ItemStateChangedEvent] - mqtt_topic_ba6a06c9_Bed_1_percent_num changed from 3.1 to 28.3
2020-05-31 08:43:54.677 [vent.ItemStateChangedEvent] - mqtt_topic_ba6a06c9_Bed_1_analog changed from 32 to 290
==> /var/log/openhab2/openhab.log <==
2020-05-31 08:43:55.149 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"analog":0,"percent":0.00,"status":1}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"analog":0,"percent":0.00,"status":1}
==> /var/log/openhab2/events.log <==
2020-05-31 08:43:55.169 [vent.ItemStateChangedEvent] - mqtt_topic_736bf7e5_Bed_1_status changed from OFF to ON
2020-05-31 08:43:55.183 [vent.ItemStateChangedEvent] - mqtt_topic_ba6a06c9_Bed_1_percent changed from 28.3 to 0.0
2020-05-31 08:43:55.198 [vent.ItemStateChangedEvent] - mqtt_topic_ba6a06c9_Bed_1_analog_num changed from 290 to 0
2020-05-31 08:43:55.211 [vent.ItemStateChangedEvent] - mqtt_topic_ba6a06c9_Bed_1_percent_num changed from 28.3 to 0.0
2020-05-31 08:43:55.225 [vent.ItemStateChangedEvent] - mqtt_topic_ba6a06c9_Bed_1_analog changed from 290 to 0
==> /var/log/openhab2/openhab.log <==
2020-05-31 08:43:55.655 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"analog":0,"percent":0.00,"status":1}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"analog":0,"percent":0.00,"status":1}
2020-05-31 08:43:56.163 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"analog":0,"percent":0.00,"status":1}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"analog":0,"percent":0.00,"status":1}
2020-05-31 08:43:56.668 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"analog":0,"percent":0.00,"status":1}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"analog":0,"percent":0.00,"status":1}
2020-05-31 08:43:24.231 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"analog":0,"percent":0.00,"status":1}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"analog":0,"percent":0.00,"status":1}
2020-05-31 08:43:24.739 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"analog":0,"percent":0.00,"status":1}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"analog":0,"percent":0.00,"status":1}
2020-05-31 08:43:25.244 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"analog":0,"percent":0.00,"status":1}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"analog":0,"percent":0.00,"status":1}
Thank you for any suggestion again!!!
In addition, I have used Javascript Transformation and Map Transformation.
Here is my transformation .js files
(function(i) {
try {
data = JSON.parse(i);
analog = Number(data.analog.toFixed(0), 10).toFixed(0);
return analog;
}
catch (err) {
return "-";
}
})(input)
.map file:
1=ON
0=OFF
I have also checked the following articles but I have no idea what’s the problem at all.
Reference: