Hey guys,
I am having some issues with the changedSince() function and could use your help. I have read other threads where people have also had issues with this function but haven’t seen a resolution to it.
In short, when I use the changedSince() function, it doesn’t pull the most recent change but instead pulls the second to most recent change.
Let me describe my setup. I have mapdb configured as my default persistence but I also have influxdb and Graphana installed and connected. This is how I check if influxdb is actually storing the item states.
my rule for testing:
rule “rule name”
when
Item Tester received update
then
var time = 6
if(JMHomekit.changedSince(now.minusHours(time), “influxdb”)) {
logInfo(“home.rules”, “true” + time) }
else {logInfo(“home.rules”, “false” + time)}
end
the item changed 5.5 hours ago and then again 10 minutes ago.
Running time = 6 yields: true6
Running time = 5 yields: false5
If I update the item again and run the same experiment by picking a point before the last change but after the second to last one, ill get the same results. I am having this issue with 2 separate items.
I should also note that the changes are all showing up on Graphana and when I run lastUpdate on an item, it provides the time of the last change.
I also can confirm that the items are in fact changing as opposed to just updating. This can also be seen on Graphana as well as in the below logs as these are simple ON/OFF switch items.
The 2 items in question are switched by Homekit automatically when myself or my wife gets home.
Lastly, I pulled the logs and I can confirm all changes to an item are present though I did see a few times where it changed from NULL to ON/OFF. Not sure what thats about.
2021-01-21 09:17:37.633 [vent.ItemStateChangedEvent] - JMHomekit changed from ON to OFF
2021-01-21 09:45:39.403 [vent.ItemStateChangedEvent] - JMHomekit changed from NULL to OFF
2021-01-21 10:02:44.455 [vent.ItemStateChangedEvent] - JMHomekit changed from NULL to OFF
2021-01-21 10:45:45.004 [vent.ItemStateChangedEvent] - JMHomekit changed from NULL to OFF
2021-01-21 12:35:08.721 [ome.event.ItemCommandEvent] - Item ‘JMHomekit’ received command ON
2021-01-21 12:35:08.722 [vent.ItemStateChangedEvent] - JMHomekit changed from OFF to ON
2021-01-21 13:15:42.758 [vent.ItemStateChangedEvent] - JMHomekit changed from NULL to ON
2021-01-21 13:35:06.924 [ome.event.ItemCommandEvent] - Item ‘JMHomekit’ received command OFF
2021-01-21 13:35:06.926 [vent.ItemStateChangedEvent] - JMHomekit changed from ON to OFF
2021-01-21 14:09:36.878 [vent.ItemStateChangedEvent] - JMHomekit changed from NULL to OFF
2021-01-21 14:43:33.157 [vent.ItemStateChangedEvent] - JMHomekit changed from NULL to OFF
2021-01-21 18:42:13.703 [ome.event.ItemCommandEvent] - Item ‘JMHomekit’ received command ON
2021-01-21 18:42:13.704 [vent.ItemStateChangedEvent] - JMHomekit changed from OFF to ON
I could get around this like others have by creating a couple dummy items to hold the DateTime of the last change but wanted to post it here to see if I was doing anything wrong and or if this is a bug, then hopefully it’ll get squashed.