IotaWatt and EmonCMS Data Posting

Something I have noticed since using IotaWatt with EmonCMS is sometimes when EmonCMS gets rebooted. I find that IotaWatt will start from the historical data update point that was set likely a year ago rather than the last posted upload. In talking with Overeasy at IotaWatt he brought up how EmonCMS posts data is done in a very low write way and that the cache it holds gets lost upon a reboot or power failure sometimes. In my case I run EmonCMS on my server in a container with spin drive in RAID 6 setup. So, more writes doesn’t bother me. I was wondering if there is a setting that might be changed to allow the database to write maybe every 15, 30 minutes or even every posting.

The default cache time is 300 seconds, not 30 minutes! You are right though, this was primarily designed to reduce the wear on SD Cards.

You can disable the cache, but I really cannot remember the right way to do it. @glyn.hudson or @TrystanLea can help with that. It will simply write the data immediately. Personally I run it at 30s.

I’m not sure how the start point is determined by IotaWatt. Certainly, Emoncms hasn’t cached a year’s worth of data!

My only guess is somehow due to the cache not being written it gets corrupted somehow and IotaWatt just goes back to the historical default I set way back when I set it up. Figure more writes might prevent that. Worth a try, just need to know how to set it.

Much more likely it doesn’t compute/retrieve the last date correctly. If there was any data corruption, I think folk would notice. There is nothing special about what emoncms does with IotaWatt data.

That’s also a possibility, bad transmit over wifi maybe. My new setup will have improved wifi for it and obviously a Ryzen 5 should have more than enough horsepower for it.

Unless I’m reading it wrong, isn’t the OP asking if it can be changed to 15 minutes, etc?

Pretty sure he thinks emoncms caches it for a long time and that is why IotaWatt starts sending from the beginning again if there is a reboot.

This is almost certainly a setting in the IotaWatt, It’s an issue I’ve had in the past.
In the Iotawatt menu go to /Setup/DataUploaders select emoncms and you should find a field called upload history from. that field has to be manually changed to start the history upload from a more recent date.

1 Like

That is correct. I have also asked to have that date in the field auto change to move it up to where instead it would only go back, say, two weeks for example instead.

You can get it from emoncms using http://hostname/feed/timevalue.json?id=1 where ID is the feed ID.