Just get me the last value!

There are instances where a graph might not be appropriate. I might simply want to display the current temperature outside. I don’t want any fancy formatting I simply want to embed the value in one of my posts. Which value though? The temperature is only meaningful if you know the date and time at which the reading was taken.

Last known temperature reading is 17.5C  taken at 2019-09-20 15:07:55

It is possible to display both using the [ mqttcogs_get ] shortcode. In it’s most basic form it will return the most recent datetime or payload field. Here’s the code to display the text above:

Last known temperature reading is [ mqttcogs_get topic='mysensors_out/99/2/1/0/0' field='payload']C  
taken at [ mqttcogs_get topic='mysensors_out/99/2/1/0/0' field='datetime' dateformat='Y-m-d H:i:s' local='false']

What about other days?

It’s also possible to specify a ‘from’ and ‘to’ attribute and a sort attribute. This would allow you to get the start and end temperature for a given date range. I’m not sure why you might want to do this!




No Comments


You can leave the first : )



Leave a Reply

Your email address will not be published. Required fields are marked *