Hi - Thanks for the tip, I’ve now tried adding “Z” at the end, but I still get the same error.
I’ve now tried with the following formats home/status/moteino_0_update "2018-08-13T15:57:04Z" home/status/moteino_0_update "2018-08-13T14:49:48.474467+00:00" home/status/moteino_0_update "2018-08-13T15:02:22.921355+00:00Z"
Still get the same error …
When comparing to a binding I have installed, I see datetime items being updated in line with the second example above.
Hi - thanks again - I know this page, but I don’t see how this will help in resolving my problem, which is that I am unable to store a date directly into a datetype item via MQTT. Or is it not supported?
Thanks for your help and input - the root cause was the way I was serializing (using json.dumps in Python) and then publishing as key, value … so despite using an apparently valid date, my program was mangling some element (perhaps forcing it to be interpreted as a string?). I’ve now managed to find a more direct way to publish onto mqtt successfully and now Openhab updates the datetype item correctly.
I think my problem was very esoteric, but here goes.
Moteino (small arduinos with radio) devices publish a very simple stream of values based on attached sensors
A python program loads these values into a json message and publishes over MQTT
I was using the json library to load, and then dump the values out … and somehow mangled the formatting of the json fields
The following gist shows the whole program, now successfully delivering the correct values to Openhab.
Instead of using .isoformat() you should use .strftime("%Y-%m-%dT%H:%M:%SZ") I think. For parsing correctly from openHAB to a python datetime object I think you have to use as example parser.parse("2022-04-24T06:20:00.402978-0700").