Understanding the UV value from Weather

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
paul402
Posts: 105
Joined: Monday 23 May 2016 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Understanding the UV value from Weather

Post 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.
User avatar
waltervl
Posts: 6690
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Understanding the UV value from Weather

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 6690
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Understanding the UV value from Weather

Post 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
Last edited by waltervl on Friday 15 September 2023 23:51, edited 1 time in total.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
paul402
Posts: 105
Joined: Monday 23 May 2016 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Understanding the UV value from Weather

Post by paul402 »

That's brilliant. Thanks for the help. Much appreciated. I guess I got stressed and didn't read thoroughly enough!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest