Hi, I’m struggeling with a Number<->int<->joda conversion for days and can’t figure out why.
I have a Number type set up
Number PresenceSimulation_DaysAway “Dauer (Tage) der Abwesenheit” (Home)
This Number type is having a value, according to the logs
2019-07-05 14:03:10.002 [INFO ] [del.script.presence_simulation.rules] - object supplied PresenceSimulation_DaysAway (Type=NumberItem, State=2, Label=Dauer (Tage) der Abwesenheit, Category=null, Groups=[Home])
I can convert this Number to an int
var int days = PresenceSimulation_DaysAway.state
As expected, this works according to the log
2019-07-05 14:04:00.116 [INFO ] [del.script.presence_simulation.rules] - days supplied 2
However, when running
var date = now.minusDays(days)
(or any permutation of this) I receive an error in this rule
2019-07-05 14:13:10.111 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘PresenceSimulation’: An error occurred during the script execution: Could not invoke method: org.joda.time.DateTime.minusDays(int) on instance: 2019-07-05T14:13:10.110+02:00
Why is that? When calling
var date = now.minusDays(2)
this works without any issue.
I have a programming background and I favor strongly typed languages, hence I expected
2
to be the same as
var int days = PresenceSimulation_DaysAway.state
What’s the difference between 2, my var int days and Number.state?