Max77
(Max)
January 16, 2021, 11:36pm
1
Hi all
I am adding my homemade air sensors into OH3 (stable release). The battery voltage is an item linked to an mqtt channel with Voltage property - it seems to work properly as the “V” unit is added.
I use a JS transformation to get the battery level
(function(voltage) {
var batt_level = (voltage - 3.5)/0.7;
return batt_level;
})(input)
and I define a dimensionless item
Question - why does the value still have the “V” unit as the parallel item linked to the same channel?
I cannot use use the %% label formatter, of course (it returns 1%).
Any explanation for this behavior?
Thanks
Max
rossko57
(Rossko57)
January 17, 2021, 2:44pm
2
I think you have a variation of this problem
I don’t think it makes any difference how you create your target String type Item.
Your problem does look the same as @Cybso , although you’ve not shown us the crucial part - the profile you selected for your channel link.
@Cybso did not find a fix for this problem,but a circumvention (doing the transformation elsewhere)
The nature of the problem appears to be that the transform profile framework attempts to use a binding supplied default state presentation format on the output of a transfo…
The OH framework is applying the default channel formatting suggested by the binding to the output of your transform profile, in this case adding " V".
It’s not yet clear if/how they’ll fix this bug.
You should be able to circumvent by removing the units from the channel, and have MQTT deal with number only.
Max77
(Max)
January 17, 2021, 9:44pm
3
@rossko57
thanks - I will try it and post the results here.
Has the issue (bug?) already filed?
Max
rossko57
(Rossko57)
January 18, 2021, 10:54am
4
Yes, as referenced in the other thread that you read
opened 09:36PM - 30 Dec 20 UTC
bug
I'm using openHAB 3.0 with docker on a linux host system.
My use case is an a… larm indicating that the humidity in my bathroom is over a certain upper value. When this happens the bathroom fan is turned on to bring the humidity down. The fan should stay on until the humidity drops below a certain lower value.
For this I configured a switch item carrying the alarm value and linked it to the humidity sensor with a channel configured for the hysteresis profile.
The expected outcome should be a switch item handling the alarm value with the hysteresis in place. The current outcome is that the item goes into an error state.
The item configuration is:
![image](https://user-images.githubusercontent.com/4890418/103382284-c3a56380-4aee-11eb-85e4-2275a2a95f19.png)
The channel link configuration is:
![image](https://user-images.githubusercontent.com/4890418/103382325-ef284e00-4aee-11eb-9825-12a0d80d3404.png)
As you can see in the screen shots, the state is "Err". The probable cause might be the following log entry:
```
2020-12-30 00:41:22.012 [WARN ] [e.internal.SseItemStatesEventBuilder] - Exception while formatting value 'OFF' of item Badezimmer_Sicherheit_Feuchtigkeitsalarm with format '%.0f': f != java.lang.String
```
Max77
(Max)
January 19, 2021, 9:36pm
5
Almost there!
I have now reprogrammed my (ESP-based) sensor by deleting the battery voltage unit in the source code.
I also had to clean mosquitto DB according to this tutorial
In mosquitto, I read
openhabian@openhabHost:~ $ mosquitto_sub -v -t homie/esp_gateway/kidsBedroomTH/battery/#
homie/esp_gateway/kidsBedroomTH/battery/$name Battery
homie/esp_gateway/kidsBedroomTH/battery/$datatype float
homie/esp_gateway/kidsBedroomTH/battery 4.08
I am now able to link this channel to the existing equipment and getting voltage (w/o unit) and battery level (in %) right.
Thanks!
Max