Items-Quantitytype

Hi,
I have vollowing setup:
A Netatmo temperature Sensor, and a Eurotronics ZWave Heating-Regulator.

I will use the Netatmo Temperature as the input parameter for the heating Regulator.
It is still running under OH3, but it is an old DSL Rule.

My intention is to transfer it to the new Javascript rules.
My Old Rule:
var String formattedString
var String CmdString

logInfo("Heating_AZ", "temp has changed")
formattedString = String.format("AZN_Temperature: %1$.1f", (AZNA_Temperatur.state as 
    QuantityType<Number>).doubleValue)
logInfo("Heating_AZ", formattedString )
CmdString = String.format("%1$.1f", (AZNA_Temperatur.state as QuantityType<Number>).doubleValue)
logInfo("Heating_AZ", CmdString )
AZTH_Externaltemperature.sendCommand(CmdString)

The new setup (new Javascript Rule):

events.sendCommand("AZTH_Externaltemperature", itemRegistry.getItem("AZNA_Temperatur").getState());

From the logging it looks that it is working. But it looks that the Eurotronics has problems receiving the temperature with quantities.
What I actually did not find how to translate the itemRegistry.getItem(“AZNA_Temperatur”).getState() into a number without a unit (Quantity).

Has someone an idea?

Best regads

I don’t know Eurotronics, so I don’t know, if you could somehow configure the binding or your devices to use UoM-items.

AFAIK there’s no built-in function for that. You could regex the hell out of it with a function to strip the unit(s), you could just replace the temperature unit (items["ITEMNAME"].toString().replace(" °C", "")), or you could just leave the DSL as is, as it is working 100%.
Why do you want to recreate the function in JavaScript? OH3 won’t deprecate DSL for the foreseeable future and possibly OH4 still has options for DSL-based rules…?

It is just a personal interest to translate all rules to Javascript. I know that the old DSL rules are running. Otherwise it will be cold in my house during the winter :rofl:.

That’s why I would never use openHAB as the sole logic. In my setup I use KNX actuators for the heating regulation, which are completly reliant - what I do via KNX-binding is to tell the room thermostats, which temperature they should use or based on our calendars, whether it’s homeoffice-day (usually these days!) or vacation days (=house empty) and when to heat the house up, fire up warm water, … a few hours before our return.

what you could also do - either use a proxy item (in OH3 simply connect both items via the “follow” option) without UoM and use that for updating your Eurotronics or strip the UoM from AZNA_Temperatur

That with the follow is also a good idea. Just read it yesterday evening. But actually I’m not shure.
I have two items. One from the netatmo, that shows me the Temperatur, and the second from the heating regulator. That is the input Temperatur to regulate.
How is the setup then?
The input on then heating regulator needs to follow the temperature on the netatmo thing.
So do I need to create a second item in the regulator temperature and set that to follow?

You could just try that, perhaps the “follow”-function doesn’t care about UoM.

That was my thought: create a second temperature-item, which has no UoM and follows your AZNA_Temperatur. and AZTH_Externaltemperature follows that proxy item… untested, but could work.

Please don’t post “How do I …” problems in the Tutorials and Examples forum section, it makes it harder for people to find the tutorials and examples with solutions.

Sry for the wrong place

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.