Page 2 of 2
Re: Visual Crossing Weather as replacement of Darksky (obsolete)
Posted: Wednesday 19 April 2023 18:55
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!
Re: Visual Crossing Weather as replacement of Darksky (obsolete)
Posted: Wednesday 19 April 2023 23:50
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?
Re: Visual Crossing Weather as replacement of Darksky (obsolete)
Posted: Thursday 20 April 2023 9:58
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.
Re: Visual Crossing Weather as replacement of Darksky (obsolete)
Posted: Thursday 20 April 2023 11:18
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.)
Re: Visual Crossing Weather as replacement of Darksky (obsolete)
Posted: Sunday 04 June 2023 18:45
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?
Re: Visual Crossing Weather as replacement of Darksky (obsolete)
Posted: Thursday 15 June 2023 9:38
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°
Re: Visual Crossing Weather as replacement of Darksky (obsolete)
Posted: Wednesday 22 January 2025 15:16
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.
Re: Visual Crossing Weather as replacement of Darksky (obsolete)
Posted: Tuesday 28 January 2025 15:20
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.