Fetching min/max values for weather sensors

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
norrland
Posts: 8
Joined: Monday 28 November 2016 22:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Fetching min/max values for weather sensors

Post by norrland »

It would have been great if there was a way to fetch at least daily min/max values for weather sensors like temperature, wind, barometric pressure and humidity through the API. Even better if we could fetch daily, weekly, monthly and yearly min/max values. It is an important feature when using Domoticz as a weather station.

Using a request like this returns current values
/json.htm?type=devices&rid=99

The history request returns all values for a period
/json.htm?type=graph&sensor=temp&idx=99&range=day

For both cases it is up the the front-end or other caller to calculate min/max. Or is there another option that I've not been able to find?

Right now, I'm using virtual sensors that are set by a LUA script that invokes a bash-script that uses SQL to fetch max/min values in the Domoticz DB. A somewhat lengthy solution.
stlaha2007
Posts: 370
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: Fetching min/max values for weather sensors

Post by stlaha2007 »

Sorry, but have you looked further at the json-wiki??

Month and Year reports include min-avg-max temp.
Try the following /json.htm?type=graph&sensor=temp&idx=IDX&range=month

Add it to your domoticz url and replace IDX with the temp-device you want...
Still need to seperate them.

[Edit: typo in sentence]
norrland
Posts: 8
Joined: Monday 28 November 2016 22:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Fetching min/max values for weather sensors

Post by norrland »

Thanks for your fast reply!

Yes, i understand that the monthly and yearly range gives min (tm), max (te) and average (ta) for days included. It is however only daily values. To get weekly or monthly you still need to calc, right?

If this is the json-wiki you are referring to, then yes, I've read it.
https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's

As far as I can see it does not mention anything about min/max but it is not so hard to figure out with some testing. Or is there another wiki-page I've missed?
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Fetching min/max values for weather sensors

Post by mvzut »

I'm also interested in a more convenient way to fetch min/max values of temperature sensors. In other home automation systems it's often a built-in function. Maybe an idea to show this in the UI for each sensor, and report the values in the JSON output (or even in the otherdevices_svalues)?

By the way, you don't have to go via bash scripting to fetch daily min/max values, you can simply run a LUA script every minute that directly updates a virtual Domoticz device. I did it like this:

Code: Select all

min_max_buiten = otherdevices['Min/max buiten']
min_buiten = tonumber(string.match(min_max_buiten,'(.*)\194\176C /')) or 0
max_buiten = tonumber(string.match(min_max_buiten,'/ (.*)\194\176C')) or 0
temp_buiten = tonumber(otherdevices_svalues['Buiten achter']:match("([^;]+)"))
if temp_buiten > max_buiten then max_buiten = temp_buiten end
if temp_buiten < min_buiten then min_buiten = temp_buiten end
new_min_max_buiten = min_buiten .. '\194\176C / ' .. max_buiten..'\194\176C'
if new_min_max_buiten ~= min_max_buiten then
  table.insert(commandArray, {['UpdateDevice'] = otherdevices_idx['Min/max buiten'] .. '|0|' .. new_min_max_buiten})
end
You could also store the min/max values in individual dummy temperature devices, but I solved it with a text device.
Downside of this solution is that I have to do this for every temperature sensor that I want to know min/max values for. This creates a lot of overhead and extra devices.Image
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
stlaha2007
Posts: 370
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: Fetching min/max values for weather sensors

Post by stlaha2007 »

Both are correct conclusions or solutions.

I agree there's no weekly graph for temp, and also not a min/max on de daily.
A weekly graph incl. min/max might be handy.
Also the less quick methode is temp tab button custom graph with long term gives you more to your liking.

Just curious... why do you guys want min/max of the current day/24hours? As i can see it directly (not by .05 exactly :-) ) ehat min and max are.
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Fetching min/max values for weather sensors

Post by Nautilus »

mvzut wrote:I'm also interested in a more convenient way to fetch min/max values of temperature sensors. In other home automation systems it's often a built-in function. Maybe an idea to show this in the UI for each sensor, and report the values in the JSON output (or even in the otherdevices_svalues)?

By the way, you don't have to go via bash scripting to fetch daily min/max values, you can simply run a LUA script every minute that directly updates a virtual Domoticz device. I did it like this:

You could also store the min/max values in individual dummy temperature devices, but I solved it with a text device.
Downside of this solution is that I have to do this for every temperature sensor that I want to know min/max values for. This creates a lot of overhead and extra devices.
Can I ask how do you manage the time period of the min / max temps with this approach, do you just clear the values at some point or? Otherwise, if there is one really warm or cold day, then the values basically never update after that? Or have I missed something? :)
Last edited by Nautilus on Tuesday 29 November 2016 14:24, edited 2 times in total.
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Fetching min/max values for weather sensors

Post by mvzut »

Nautilus wrote:
mvzut wrote:I'm also interested in a more convenient way to fetch min/max values of temperature sensors. In other home automation systems it's often a built-in function. Maybe an idea to show this in the UI for each sensor, and report the values in the JSON output (or even in the otherdevices_svalues)?

By the way, you don't have to go via bash scripting to fetch daily min/max values, you can simply run a LUA script every minute that directly updates a virtual Domoticz device. I did it like this:

You could also store the min/max values in individual dummy temperature devices, but I solved it with a text device.
Downside of this solution is that I have to do this for every temperature sensor that I want to know min/max values for. This creates a lot of overhead and extra devices.
Can I ask how do you manage the time period of the mio / max temps with this approach? If there is one really warm or cold day, then the values basically never update after that? Or have I missed something? :)
Sorry, I forgot to mention that I set both values (min and max) to the current values at midnight.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Fetching min/max values for weather sensors

Post by Nautilus »

mvzut wrote: Sorry, I forgot to mention that I set both values (min and max) to the current values at midnight.
Ok, I assumed something like that :) Would be nice to have e..g. a rolling 24h min / max but this is probably the simplest way to get started.
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Fetching min/max values for weather sensors

Post by Toulon7559 »

;-) Perhaps a very 'practical & down to earth' reaction, but why don't you apply a website like WeatherUnderground to make the info on min/max per time-period? They already have the database- and calculation-functions to produce the answers to your question, as well as a presentation of results.
If WUnderground is not your favourite, then as alternative AWEKAS or PWSWeather can do the job.

And if you want to keep the job at your computer, perhaps PYWWS is your friend (although it needs 'some' effort to get it running).
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
norrland
Posts: 8
Joined: Monday 28 November 2016 22:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Fetching min/max values for weather sensors

Post by norrland »

Toulon7559 wrote:;-) Perhaps a very 'practical & down to earth' reaction, but why don't you apply a website like WeatherUnderground to make the info on min/max per time-period? They already have the database- and calculation-functions to produce the answers to your question, as well as a presentation of results.
If WUnderground is not your favourite, then as alternative AWEKAS or PWSWeather can do the job.

And if you want to keep the job at your computer, perhaps PYWWS is your friend (although it needs 'some' effort to get it running).
That's how I'm doing today, with a local http://www.wviewweather.com server. It is however not so smooth to have two different sites and having to flip pages on both of them to get a complete overview of both weather, cameras and automation.

Another solution would be to build a new dashboard/frontpage that can incorporate all servers state but it would take more effort than I'm able to put into it. Domoticz is so close to fix all these features, especially with the new front pages and themes available here on the forum.

This small change would get us a bit closer!
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests