Max min temp issues after updating to 3.0

Hi every one

I have a problem getting min max temperature to work after I have updated to 3.0 I have used this rules in 2.0

import java.text.SimpleDateFormat
import org.eclipse.smarthome.core.library.types.DecimalType
import org.joda.datetime.DateTime.*
rule “Temperatur Min-og Max values Carportnord”
when
Item Temperatur_Udebygninger_Carportnord received update
then
var Number Min
var Number Max
var String tmp
var SimpleDateFormat df = new SimpleDateFormat( “HH:mm” )
if (Temperatur_Udebygninger_Carportnord.state instanceof DecimalType) {
Min = (Temperatur_Udebygninger_Carportnord.minimumSince(now.toDateMidnight, “rrd4j”).state as DecimalType)
tmp = (Math::round(Min.floatValue10.0)/10.0) + " °C (" + df.format(Temperatur_Udebygninger_Carportnord.minimumSince(now.toDateMidnight, “rrd4j”).timestamp) + " )"
postUpdate(Temperatur_Udebygninger_Carportnord_Min, tmp)
Max = Temperatur_Udebygninger_Carportnord.maximumSince(now.toDateMidnight, “rrd4j”).state as DecimalType
df = new SimpleDateFormat( “HH:mm” )
tmp = (Math::round(Max.floatValue
10.0)/10.0) + " °C (" + df.format(Temperatur_Udebygninger_Carportnord.maximumSince(now.toDateMidnight, “rrd4j”).timestamp) + “)”
postUpdate(Temperatur_Udebygninger_Carportnord_Max, tmp)
}
end
rule “Temperatur Min-og Max values Terrasse”
when
Item Temperature_Terrasse received update
then
var Number Min
var Number Max
var String tmp
var SimpleDateFormat df = new SimpleDateFormat( “HH:mm” )
if (Temperature_Terrasse.state instanceof DecimalType) {
Min = (Temperature_Terrasse.minimumSince(now.toDateMidnight, “rrd4j”).state as DecimalType)
tmp = (Math::round(Min.floatValue10.0)/10.0) + " °C (" + df.format(Temperature_Terrasse.minimumSince(now.toDateMidnight, “rrd4j”).timestamp) + " )"
postUpdate(Temperature_Terrasse_Min, tmp)
Max = Temperature_Terrasse.maximumSince(now.toDateMidnight, “rrd4j”).state as DecimalType
df = new SimpleDateFormat( “HH:mm” )
tmp = (Math::round(Max.floatValue
10.0)/10.0) + " °C (" + df.format(Temperature_Terrasse.maximumSince(now.toDateMidnight, “rrd4j”).timestamp) + “)”
postUpdate(Temperature_Terrasse_Max, tmp)
}
end

is there anything I may have forgotten to install or set up when I switched to 3.0

can somebody help

Yes, you need to replace now.toDateMidnight with now.with(LocalTime.MIN)

like this

rule “Temperatur Min-og Max values Carportnord”
when
Item Temperatur_Udebygninger_Carportnord received update
then
var Number Min
var Number Max
var String tmp
var SimpleDateFormat df = new SimpleDateFormat( “HH:mm” )
if (Temperatur_Udebygninger_Carportnord.state instanceof DecimalType) {
Min = (Temperatur_Udebygninger_Carportnord.minimumSince(now.with(LocalTime.MIN), “rrd4j”).state as DecimalType)
tmp = (Math::round(Min.floatValue10.0)/10.0) + " °C (" + df.format(Temperatur_Udebygninger_Carportnord.minimumSince(now.with(LocalTime.MIN, “rrd4j”).timestamp) + " )"
postUpdate(Temperatur_Udebygninger_Carportnord_Min, tmp)
Max = Temperatur_Udebygninger_Carportnord.maximumSince(now.with(LocalTime.MAX, “rrd4j”).state as DecimalType
df = new SimpleDateFormat( “HH:mm” )
tmp = (Math::round(Max.floatValue
10.0)/10.0) + " °C (" + df.format(Temperatur_Udebygninger_Carportnord.maximumSince(now.with(LocalTime.MAX), “rrd4j”).timestamp) + “)”
postUpdate(Temperatur_Udebygninger_Carportnord_Max, tmp)
}
end

does it work?

Unfortunately not

Have you still got all those imports at top? They’re not appropriate for OH3 - except maybe the simple date format.

I have now tried to remove them but without success, it still does not work, I may have forgotten to install something to make it work

Maybe it is a totally different problem but I also have a problem with a temperature rule.

rule "Heater Tuinschuur"
when
    Item ZWaveNode010FGBS001UniversalBinarySensor_Temperature2 changed
then 
if (ZWaveNode010FGBS001UniversalBinarySensor_Temperature2.state < 9 ) 
{ ZWaveNode007ZMNHYDSmartPlug_Switch.sendCommand(ON)
}
if (ZWaveNode010FGBS001UniversalBinarySensor_Temperature2.state > 11 ) 
{ ZWaveNode007ZMNHYDSmartPlug_Switch.sendCommand(OFF)
}
end 

I feel a bit stupid asking the question here but within OH 2.5 it worked.
When I delete ‘then’ and ‘if’ parts the plug switch turn on.

@Koensk You probably need this advice

1 Like

Thank you so much, that did the trick

I still can not make this work, does anyone have an idea of what is missing or what I may have forgotten when I updated from 2.0 to 3.0, because it worked fine in 2.0

Give us some help here. What happens or doesn’t happen? Have you looked in your openhab.log for clues?

The big change in OH3 that’s relevant for time handling rules is that the Java time functions have all changed. For example, “now” still exists, but it’s a different kind of object with different functions.

This looks relevant

For self help, add some logInfo() lines to your rule so that you can see how far it gets and important values along the way e.g.

if (Temperatur_Udebygninger_Carportnord.state instanceof DecimalType) {
   logInfo("test", "TempUC " + Temperatur_Udebygninger_Carportnord.state.toString)
   Min = (Temperatur_Udebygninger_Carportnord.minimumSince(now.with(LocalTime.MIN), “rrd4j”).state as DecimalType)
   logInfo("test", "Min " + Min.toString)

I dont have any logs from aften i swicht to OH 3.0

That will make it hard for you to sort out this and any other issues later. I’d make fixing that your priority for now.

Now i got the log fil running and i get this in the log file

2021-01-25 06:25:36.690 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::store: No connection to database. Cannot persist item ‘Temperatur_Udebygninger_Carportnord (Type=NumberItem, State=0, Label=Temeratur udenfor, Category=temperature, Groups=[gHistory])’! Will retry connecting to database when error count:0 equals errReconnectThreshold:0
2021-01-25 06:26:03.546 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 06:26:03.548 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!

1 Like

That looks fairly fundamental.
You may have to look back in your log to see what the persistence service has to say at start up time.

Hi
I have made a restart and this is the log from startup

So could indicate I am missing some setup however I am in doubt about where and what

2021-01-25 12:16:36.526 [ERROR] [ence.jdbc.internal.JdbcConfiguration] - Mandatory url parameter is missing in configuration!
2021-01-25 12:16:49.127 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:16:49.128 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:16:49.129 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::store: No connection to database. Cannot persist item ‘Humidity_Vaerksted (Type=NumberItem, State=73.60, Label=Humidity, Category=climate)’! Will retry connecting to database when error count:0 equals errReconnectThreshold:0
2021-01-25 12:17:14.314 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:14.316 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:14.318 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::store: No connection to database. Cannot persist item ‘Temperatur_Udebygninger_Carport (Type=NumberItem, State=1.37, Label=Temeratur Carport, Category=temperature, Groups=[gHistory])’! Will retry connecting to database when error count:0 equals errReconnectThreshold:0
2021-01-25 12:17:14.431 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:14.432 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:14.432 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::store: No connection to database. Cannot persist item ‘Temperatur_Udebygninger_Carportnord (Type=NumberItem, State=0.87, Label=Temeratur udenfor, Category=temperature, Groups=[gHistory])’! Will retry connecting to database when error count:0 equals errReconnectThreshold:0
2021-01-25 12:17:29.043 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:29.052 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:29.054 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::store: No connection to database. Cannot persist item ‘Date (Type=DateTimeItem, State=2021-01-25T12:17:29.037+0100, Label=Date, Category=null)’! Will retry connecting to database when error count:0 equals errReconnectThreshold:0
2021-01-25 12:17:30.094 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:30.094 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:30.095 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::store: No connection to database. Cannot persist item ‘Temperature_Vaerksted (Type=NumberItem, State=7.00, Label=Temperatur værksted, Category=null)’! Will retry connecting to database when error count:0 equals errReconnectThreshold:0
2021-01-25 12:17:30.213 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:30.213 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:30.213 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::store: No connection to database. Cannot persist item ‘Humidity_Vaerksted (Type=NumberItem, State=73.50, Label=Humidity, Category=climate)’! Will retry connecting to database when error count:0 equals errReconnectThreshold:0
2021-01-25 12:17:51.081 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:51.081 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:51.082 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::store: No connection to database. Cannot persist item ‘Temperature_Vaerksted (Type=NumberItem, State=7.10, Label=Temperatur værksted, Category=null)’! Will retry connecting to database when error count:0 equals errReconnectThreshold:0
2021-01-25 12:17:51.199 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:51.199 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: no driver available!
2021-01-25 12:17:51.200 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::store: No connection to database. Cannot persist item ‘Humidity_Vaerksted (Type=NumberItem, State=73.60, Label=Humidity, Category=climate)’! Will retry connecting to database when error count:0 equals errReconnectThreshold:0

Again, this looks pretty fundamental.
It’s talking about jdbc.cfg
Have you got that file? Is it in the right folder? What are the contents?

I don’t know any more about this than it says in JDBC docs.

is i got the file

############################ JDBC Persistence Service >##################################

I N S T A L L J D B C P E R S I S T E N C E S E R V I C E

https://github.com/openhab/openhab/wiki/JDBC-Persistence

Tested databases/url-prefix: jdbc:derby, jdbc:h2, jdbc:hsqldb, jdbc:mariadb, jdbc:mysql, >jdbc:postgresql, jdbc:sqlite

derby, h2, hsqldb, sqlite can be embedded,

If no database is available it will be created, for example the url ‘jdbc:h2:./testH2’ creates a new DB >in OpenHab Folder.

Create new database, for example on a MySQL-Server use:

CREATE DATABASE ‘yourDB’ CHARACTER SET utf8 COLLATE utf8_general_ci;

D A T A B A S E C O N F I G

Some URL-Examples, ‘service’ identifies and activates internally the correct jdbc driver.

required database url like ‘jdbc::[:;]’

url=jdbc:derby:./testDerby;create=true

url=jdbc:h2:./testH2

url=jdbc:hsqldb:./testHsqlDb

url=jdbc:mariadb://192.168.0.1:3306/testMariadb

url=jdbc:mysql://192.168.0.1:3306/testMysql

url=jdbc:postgresql://192.168.0.1:5432/testPostgresql

url=jdbc:sqlite:./testSqlite.db

url=

required database user

#user=

required database password

#password=

E R R O R H A N D L I N G

optional when Service is deactivated (optional, default: 0 -> ignore)

#errReconnectThreshold=

I T E M O P E R A T I O N S

optional tweaking SQL datatypes

see: https://mybatis.github.io/mybatis-3/apidocs/reference/org/apache/ibatis/type/JdbcType.html

see: Data Types

see: http://www.postgresql.org/docs/9.3/static/datatype.html

defaults:

#sqltype.CALL = VARCHAR(200)
#sqltype.COLOR = VARCHAR(70)
#sqltype.CONTACT = VARCHAR(6)
#sqltype.DATETIME = DATETIME
#sqltype.DIMMER = TINYINT
#sqltype.LOCATION = VARCHAR(30)
#sqltype.NUMBER = DOUBLE
#sqltype.ROLLERSHUTTER = TINYINT
#sqltype.STRING = VARCHAR(65500)
#sqltype.SWITCH = VARCHAR(6)

For Itemtype “Number” default decimal digit count (optional, default: 3)

#numberDecimalcount=

T A B L E O P E R A T I O N S

Tablename Prefix String (optional, default: “item”)

for Migration from MYSQL-Bundle set to ‘Item’.

#tableNamePrefix=Item

Tablename Prefix generation, using Item real names or “item” (optional, default: false -> “item”)

If true, ‘tableNamePrefix’ is ignored.

#tableUseRealItemNames=

Tablename Suffix length (optional, default: 4 -> 0001-9999)

for Migration from MYSQL-Bundle set to 0.

#tableIdDigitCount=

Rename existing Tables using tableUseRealItemNames and tableIdDigitCount (optional, default: >false)

USE WITH CARE! Deactivate after Renaming is done!

#rebuildTableNames=true

D A T A B A S E C O N N E C T I O N S

Some embeded Databases can handle only one Connection (optional, default: configured per >database in packet org.openhab.persistence.jdbc.db.* )

see: Hikari connection pool grows to maximum size at start · Issue #256 · brettwooldridge/HikariCP · GitHub

jdbc.maximumPoolSize = 1

jdbc.minimumIdle = 1

T I M E K E E P I N G

(optional, default: false)

#enableLogTime=true