[SOLVED] Python rule maximumSince not working


I have a combined Washer and Dryer machine at home. Because I want different notifications for different programms I try to use persistence to figure out which Programm has finished. Washing machine programms always have a power peak which is greater then 800.0. I’ll tried maximumSince start time and look whether there is this peak inside but my condition always is evaluated as true.

Here is the relevant code:

 max_leistung = PersistenceExtensions.maximumSince(itemRegistry.getItem("leistungWaschmaschine"), start).state
 programm = "Waschmaschine ist"

    if max_leistung > 800.0:
         #washing machine code here
         programm = "Trockner ist"
         #dryer code here

    waschmaschine.log.info(u"{} ist fertig: start: {} max_leistung: {}, reingung: {}".format(programm, start, max_leistung, reinigung))

Here is the log output for the last dryer run which was wrong detected as washing machine even though max_leistung is below 800.0:

2020-01-14 22:45:23.978 [INFO ] [jsr223.jython.Waschmaschine ] - Waschmaschine ist ist fertig: start: 2020-01-14T19:51:44.000+01:00 max_leistung: 461.41, reingung: 0

Thanks in advantage

You need to compare apples to apples. Try this…

if max_leistung > DecimalType(800):


Thanks will try this later! I thought python could do this conversion automatically on it’s own.

If I got it right the other way arround would although work?

if float(str(max_leistung)) > 800.0

So I can integrate this into my persistence wrapper class


Either way would work

1 Like