Hi, I have a MQTT broker set up in different machine on my network than the one running OpenHAB. I have OpenHAB to communicating to said broker and have been able to define THINGS for the parameters/fields I want to use. There is one particular field that comes in JSON format, and it is a pump speed. The speed is stored as OFF, LOW or HIGH.
{"Time":"23.12.2022, 09:53:39","Pump 1":"OFF","Pump 2":"OFF","Circulating Pump":"ON"}
I can map an ITEM to it and get a STRING type to get the state of the pump speed, no issues there. But I will like have either a SWITCH type of ITEM (ON or OFF that is), or in a best case, a NUMBER type of item where 0=OFF, 1=LOW and 2=HIGH.
In trying to get the ITEMS as a SWITCH OpenHAB interprets the OFF value with no issues, and it always interprets the LOW value as ON sets the switch to ON (so far so good!), but it does not recognizes the HIGH value and it throws an error complaining that HIGH is not defined as in the SWITCH library.
I tried to define the state as: on=“HI”, on=“LOW”, off=“OFF” on the THING configuration after the transformationPattern, but again, it recognizes OFF and LOW, but it complains about HIGH.
I even tried to use the MAP transformation after ingesting the JSON data on the THING config, but that was not successful.
At this point, I am not certain if what I want to do is possible, but I figured I could ask for help. If I could transform the data into a SWITCH type as it comes in, that would be good… it would be best if I could convert it into a NUMBER (e.g 1, 2 3 3 per my comment above) so that I can graph it over time on my INFLUX/GRAFANA stack and get a meaningful trending (graphing strings is not as intuitive)
Here is my THING set up:
Type string : pumps_pump1 "Pump 1" [stateTopic="spa/pumps/state", transformationPattern="JSONPATH:$.['Pump 1']" ]
Type string : pumps_pump2 "Pump 2" [stateTopic="spa/pumps/state", transformationPattern="JSONPATH:$.['Pump 2']" ]
Here in my ITEM set up:
String HotTub_Pump_State_1 "Hot Tub Pump #1" (HotTub_Pumps) { channel="mqtt:topic:hottub:pumps_pump1" }
String HotTub_Pump_State_2 "Hot Tub Pump #2" (HotTub_Pumps) { channel="mqtt:topic:hottub:pumps_pump2" }
Thanks in advance for any help that can be provided.