Page 1 of 1

Understanding the UV value from Weather

Posted: Friday 15 September 2023 13:04
by paul402
I'm retrieving several values from Domoticz and saving to files for my own Python programs to handle.
However the UV value from Weather seems to be different.
On the devices page the UVI value shows 4.0.
If use the code below

Code: Select all

	    local outside_solar=domoticz.devices(2219)
            domoticz.log('get value for solar device 2219 ')
            local outside_solar=outside_solar
            local file = io.open('/home/pi/Documents/SandeSolar.txt','w') 
            file:write(outside_solar, "\n") 
            file:close()
            os.execute("chmod a+rw /home/pi/Documents/SandeSolar.txt")
I get the error "scripts/dzVents/generated_scripts/Ext_Temp_For_Python.lua:32: bad argument #1 to 'write' (string expected, got table)".

If I use the following line
"local outside_solar=tostring(outside_solar)"
the file created contains "table: 0x696f6a28" rather than the 4 I see on the Domoticz page.
I'm obviously missing something. Can anyone help out please.

Re: Understanding the UV value from Weather

Posted: Friday 15 September 2023 14:46
by waltervl
From dzvents documentation: https://www.domoticz.com/wiki/DzVents:_ ... #UV_sensor
UV sensor
uv: Number. UV index.
Try in the first line (and remove the 3th line as it is useless)

Code: Select all

local outside_solar=domoticz.devices(2219).uv

Re: Understanding the UV value from Weather

Posted: Friday 15 September 2023 14:53
by waltervl
By the way, it is better that your python program polls Domoticz with an api call and use the json outcome to process further.
See https://www.domoticz.com/wiki/Domoticz_ ... fic_device

example:

Code: Select all

http://IP:Port/json.htm?type=command&param=getdevices&rid=2219

Re: Understanding the UV value from Weather

Posted: Friday 15 September 2023 17:38
by paul402
That's brilliant. Thanks for the help. Much appreciated. I guess I got stressed and didn't read thoroughly enough!