Visual Crossing Weather as replacement of Darksky (obsolete)

Moderator: leecollings

User avatar
waltervl
Posts: 5397
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Visual Crossing Weather as replacement of Darksky (obsolete)

Post by waltervl »

So in latest beta of today the forecast is also solved. If someone wants to make a separate barometer and TempHum device. There is a script on the wiki that implements this. Link is in the Visual Crossing wiki. Thanks all for your help!
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Toulon7559
Posts: 848
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Visual Crossing Weather as replacement of Darksky (obsolete)

Post by Toulon7559 »

@waltervi

;-) Perhaps a bit too optimistic?

Today installed that beta by means of Domoticz-update build15192, but it resulted in all VC-widgets/devices 'locking' at 2023-04-19, 14:16:34
Not remedied by screen refresh, nor Domoticz' restart, nor reboot, etc.
Finally removed VC in tab 'Hardware', and refitted under tab 'Hardware', but no VC-devices showing at tab 'Devices'.
In Domoticz no change to API-key and to geolocation, which are exactly same as applied for my Python-script which happily continues reading VC.

Headscratching:
some aspect mistaken/forgotten for the update for Domoticz?
Last edited by Toulon7559 on Thursday 20 April 2023 13:33, edited 1 time in total.
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.
Kedi
Posts: 564
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Visual Crossing Weather as replacement of Darksky (obsolete)

Post by Kedi »

waltervl wrote: Wednesday 19 April 2023 18:55 So in latest beta of today the forecast is also solved. If someone wants to make a separate barometer and TempHum device. There is a script on the wiki that implements this. Link is in the Visual Crossing wiki. Thanks all for your help!
Sorry, but that script has bugs. "sWeatherPressForcast" is not initialized. I changed the script so that it might work.
But for the same reason the "constMapping" is NOT the same for the THB and B device the outcome is different on the devices.
B.t.w. Pressure should be Barometer, first is in Bar, the second in hPa

The Forecast page in Domoticz is just a page from Visual Crossing with all the links etc. in it, not a nice solution.
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Visual Crossing Weather as replacement of Darksky (obsolete)

Post by EdwinK »

Tried creating an account, but nothing is clickable in that site.

(seems to be a problem with Brave browser, with FF it works.)
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
Toulon7559
Posts: 848
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Visual Crossing Weather as replacement of Darksky (obsolete)

Post by Toulon7559 »

1. As basis running the calls to VisualCrossing on one machine via a Python-script controlling the related virtual devices:
running under control of a cronjob with interval of 5 minutes.
2. On another machine testingly via 'Hardware' for Domoticz for the virtual devices.
Using same API-key for the combination.

The latter setup 2. for VisualCrossing for Domoticz shows the virtual devices 'locking' after approx. 14:10 each day.
Almost looks like effect of a quotum of calls/day per API, confirmed by a notice in Domoticz' log that quotum has been exceeded.
Considering VC's price plan,
that would mean that > 1000 calls/day would apply ~40/hour, which seems unlikely with only 2 clients.

Explanation possible?
Last edited by Toulon7559 on Tuesday 20 June 2023 7:23, edited 3 times in total.
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.
rmayne
Posts: 6
Joined: Wednesday 15 May 2019 11:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Visual Crossing Weather as replacement of Darksky (obsolete)

Post by rmayne »

Merci pour le script, j'ai cependant un soucis avec la temperature qui s'affiche en fahrenheit alors que json le donne bien en C°
Michel13
Posts: 53
Joined: Thursday 07 January 2016 19:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: France
Contact:

Re: Visual Crossing Weather as replacement of Darksky (obsolete)

Post by Michel13 »

Hello,
I just created an account at visual crossing to retrieve weather information in domoticz. I created the hardware and I have the data that was added to the devices. Fine.
However, I am mainly looking to get the forecasts and in particular the maximum temperature forecast for the day and possibly that of the next day.
They do exist in the visual crossing forecast page but not in the devices created by the hardware. Is it possible to retrieve this information? additional devices? other method?
Thank you for your help.
Michel13
Posts: 53
Joined: Thursday 07 January 2016 19:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: France
Contact:

Re: Visual Crossing Weather as replacement of Darksky (obsolete)

Post by Michel13 »

Hello,
I answer myself:
The data is not directly accessible by sensors.

My aim was to retrieve the minimum and maximum forecast temperatures but the same following process can be applied to other data delivered via the API.

I created two virtual devices for temperature readings and added the following dzVents script in the events:

Code: Select all

return {
	active = true,
	on = {
		timer = { 'every 1 hours' }, -- Trigger every hour
		httpResponses = { 'weatherDataReceived' } -- Associated HTTP response
	},
	execute = function(domoticz, item)
		-- If the timer triggers, send an HTTP request
		if item.isTimer then
			local apiKey = 'MyAPI'
			local latitude = 'MyLat'
			local longitude = 'MyLong'
			local url = 'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/'
			.. latitude .. ',' .. longitude
			.. '/today/?unitGroup=metric&key=' .. apiKey
			.. '&contentType=json&elements=tempmax,tempmin'

			domoticz.log('Sending HTTP request to: ' .. url, domoticz.LOG_INFO)

			-- Sending HTTP request
			domoticz.openURL({
				url = url,
				method = 'GET',
				callback = 'weatherDataReceived' -- Associate the response with this callback
			})
		end

		-- If HTTP response is received
		if item.isHTTPResponse and item.ok then
			local json = domoticz.utils.fromJSON(item.data) -- Convert JSON to Lua table
			domoticz.log('Raw JSON response: ' .. item.data, domoticz.LOG_DEBUG)

			-- Retrieve tempmax and tempmin values
			if json and json.days and json.days[1] then
				local tempmax = json.days[1].tempmax
				local tempmin = json.days[1].tempmin

				-- Check if values ​​exist
				if tempmax and tempmin then
					domoticz.log('Max temperature: ' .. tempmax .. ', Min temperature: ' .. tempmin, domoticz.LOG_INFO)

					-- Update virtual devices (replace IDX with your own values)
					local idxMax = 150 -- My device IDX for max temperature
					local idxMin = 151 -- My device IDX for min temperature

					domoticz.devices(idxMax).updateTemperature(tempmax) -- Update device for tempmax
					domoticz.devices(idxMin).updateTemperature(tempmin) -- Update device for tempmin
				else
					domoticz.log('Error: Max/min temperatures not found in response.', domoticz.LOG_ERROR)
				end
			else
				domoticz.log('Error: Incorrect or non-compliant JSON data.', domoticz.LOG_ERROR)
			end
		elseif item.isHTTPResponse and not item.ok then
			domoticz.log('Error: HTTP request failed with code: ' .. item.statusCode, domoticz.LOG_ERROR)
		end
	end
}
I realize that this may not be the best way to proceed and also that this script can surely be improved. If anyone has a better suggestion, I'm interested.

Note that retrieving the complete JSON by itself directly in the script with the url
https://weather.visualcrossing.com/Visu ... tType=json' (hence, without &elements=tempmax,tempmin at the end)
did not work for me because strangely a whole bunch of information is not retrieved, including the famous minimum maximum temperatures, despite they are present in Firefox or via a curl in Raspbian with the same url. I have no clue why.

Also note that the url can be simplified by omitting contentType=json. The result is the same.

Hope this will help others.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests