Hello everyone, I’m reaching out to seek some assistance regarding an issue I’m encountering with my Hue sensors in OpenHAB 4. Previously, in OpenHAB 2, I had a straightforward setup where I could easily utilize the brightness value from my Hue motion and light sensor. A simple rule using a condition like I_OG_Deckensensor_Helligkeit.state < 2 worked seamlessly. However, upon upgrading to OpenHAB 4, I’ve stumbled upon a snag that’s preventing me from achieving the same functionality.
The issue arises because the sensor now returns a value formatted as a string with the unit ‘lx’ appended, such as ‘0 lx’. This change in data format has caused my previous rule to fail, as it’s no longer possible to directly compare this string value with a numerical threshold. My attempts to parse this value into an integer have resulted in errors, as the string contains non-numeric characters which the parser cannot handle.
I’ve tried several approaches to extract the numerical portion of the string, including using Integer::parseInt(), but each attempt has led to exceptions. It seems that the presence of the ‘lx’ suffix is causing the parsing to fail. I’m curious to know if there’s a way to manipulate this string to isolate the numerical value, allowing me to perform the necessary comparisons within my rule.
Additionally, I’m wondering if there’s a more efficient method within OpenHAB 4 to handle such sensor data, perhaps through a built-in function or a transformation that can automatically strip away the unit and convert the remaining part into a usable number. I’ve explored the documentation and community forums, but I haven’t found a clear solution yet.
If anyone has successfully navigated this issue or has insights into best practices for handling sensor data with units in OpenHAB 4, I would greatly appreciate your guidance. Your expertise would be invaluable in helping me resolve this challenge and get my automation rules up and running smoothly again. Thank you in advance for your assistance!