Parsing TASMOTA timestamp in json_v2 payload

Hello All,

according to the documentation, the type of the time stamp (’ timestamp_format’) may be unix, unix_ms, unix_us, unix_ns, or the Go “reference time” (with the latter I do not understand what is meant).

From my TASMOTA device I get a timestamp in the JSON payload in the form “2023-10-20T12:34:56”. That’s the content of the ‘%timestamp%’ variable.

What do I have to do so that this time stamp is interpreted correctly by Telegraf?

Thanks!
conne914

Hello @conne914,
Thanks for your question. Please see the following resource:

Essentially you can use that as your format.

Hi Anaisdg,

thanks for the link! I haven’t had time to test it in full context yet, but at least I now understand the previously mysterious concept of the “go reference time format”.

At least I was able to successfully test “my own” timestamp format on the “playground”.

package main

import (
	"fmt"
	"time"
)

func parse(date string) {
	t, err := time.Parse("2006-01-02T15:04:05", date)
	if err != nil {
		panic(err)
	}
	fmt.Println(t)
}

func main() {
	parse("2023-10-24T13:49:55")
}

Best,
conne914