Hey there!
I am currently trying to fetch some dates from a web-scraping service I developed for our garbage collection.
I got multiple DateTime items that I would like to update with postUpdate.
However it does not work because I always get an error:
java.lang.IllegalArgumentException: The argument 'state' must not be null.
My script:
// Get Json from the service
var result = JSON.parse(httpGet("http://192.168.178.20:8080/garbage?streetId=60C28030&number=291").body());
// Get dates from the array for the different types of garbage
var yellowDate = result.filter(function(el) { return el.type== "yellow" })[0].dates[0];
var blueDate = result.filter(function(el) { return el.type== "blue" })[0].dates[0];
var greyDate = result.filter(function(el) { return el.type== "grey" })[0].dates[0];
// Update items with the dates
events.postUpdate("GarbageCollectionDate_Yellow", new Date(Date.parse(yellowDate)));
events.postUpdate("GarbageCollectionDate_Blue", new Date(Date.parse(blueDate)));
events.postUpdate("GarbageCollectionDate_Grey", new Date(Date.parse(greyDate)));