I have a problem depending a notification in a rule. Every morning I will receive a message with the actual measures outdoor temperature from one of my temperature sensors (WEATHER1Aussen_Temperature.state).
The item (WEATHER1Aussen_Temperature; number) is configured with paper ui. My problem is, that the measured temperatures from the sensors are in the following format, e.g.: 12.9000000000000003552713678800500929355621337890625. Exactly with this format I receive my notification. Is it possible to configure the output format for the item value in the sendNotification command?
rule "Aktuelle Temperatur 7 Uhr"
when
Time cron "0 0 7 1/1 * ? *"
then
logInfo("rules", "Die aktuelle Außentemperatur beträgt " +WEATHER1Aussen_Temperature.state+ " °C")
sendNotification("xxx@xxx.de","Die aktuelle Außentemperatur beträgt " +WEATHER1Aussen_Temperature.state+ " °C")
end
thank you for your help. I have tried your proposal without success. I get an error message:
[ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule Aktuelle Temperatur 7 Uhr: f != org.eclipse.smarthome.core.library.types.DecimalType
So the idea is first to say to openHAB that the state object we have is of DecimalType (and not e.g. a DateTimeType,OnOffType and so on). Next we have to convert that Eclipse Smart Home Object (!) to something Java understands. And that is then done by the method .floatValue() which is a method of DecimalType and which returns a float value, which can then used to do everthing you can do with a float value
Fair point . For pure formatting of the value for a string this is the leaner approach. For those who a interested the method “format” of the public interface “Type” it is described here:
I have used as you suggested.
it works.as expected.
thanks a lot
My rule file is as below
rule "Trial for Notificaiton"
when
Item Socket1 changed
then
sendBroadcastNotification("Socket1 is Switched "+ String.format(Socket1.state.toString), "light" ,"high")
end