Retrieve status of specific device using dzVents

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Retrieve status of specific device using dzVents

Post by Number8 »

Hello
I'm wondering whether there is an equivalent in dzVents to this API. I searched the Wiki without success so far

Code: Select all

/json.htm?type=devices&rid=IDX
that returns among other things current

"AstrTwilightEnd": "19:39",
"AstrTwilightStart": "06:06",
"CivTwilightEnd": "18:20",
"CivTwilightStart": "07:24",
"DayLength": "09:46",
"NautTwilightEnd": "19:00",
"NautTwilightStart": "06:45",
"SunAtSouth": "12:52",
"Sunrise": "08:00",
"Sunset": "17:45"

Thank you
Debian buster on NUC and three RPi with buster.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Retrieve status of specific device using dzVents

Post by waaren »

Number8 wrote: Saturday 06 March 2021 9:19 I'm wondering whether there is an equivalent in dzVents to this API. I searched the Wiki without success so far

Code: Select all

/json.htm?type=devices&rid=IDX
these values are stored in Lua table _G.timeofday

To show them use something like

Code: Select all

return
{
    on =
    {
        timer =
        {
            'every minute',
        },
    },

    execute = function(dz)

        for timeOfDay, value in pairs(_G.timeofday) do
            dz.log(timeOfDay .. ': ' .. tostring(value) )
        end

    end
}
To get all attributes of a specific device use

Code: Select all

dz.devices(idx).dump()
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: Retrieve status of specific device using dzVents

Post by Number8 »

Hum, I tried both. I don't think it gives the same kind of output; JSON API returns

Code: Select all

{
	"ActTime" : 1615017135,
	"AstrTwilightEnd" : "20:26",
	"AstrTwilightStart" : "05:41",
	"CivTwilightEnd" : "19:15",
	"CivTwilightStart" : "06:52",
	"DayLength" : "11:23",
	"NautTwilightEnd" : "19:50",
	"NautTwilightStart" : "06:16",
	"ServerTime" : "2021-03-06 08:52:15",
	"SunAtSouth" : "13:03",
	"Sunrise" : "07:22",
	"Sunset" : "18:45",
	"app_version" : "2020.2 (build 12485)",
	"status" : "OK",
	"title" : "Devices"
}
Thanks
Debian buster on NUC and three RPi with buster.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Retrieve status of specific device using dzVents

Post by waaren »

Number8 wrote: Saturday 06 March 2021 14:03 Hum, I tried both. I don't think it gives the same kind of output; JSON API returns
Thanks
I consider hh:mm the "same kind' as time in minutes since midnight but if you think differently you have to do some calculation yourself.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest