dzVents and sValue's

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

Moderator: leecollings

Post Reply
Robbie
Posts: 29
Joined: Friday 04 September 2015 1:15
Target OS: NAS (Synology & others)
Domoticz version: 2.2980
Contact:

dzVents and sValue's

Post by Robbie »

dzVents is greatly documented, but I am confused when it comes to sValue's.

item.sValue returns "On" or "Off", but not the sValue as seen in the visual-editor's Devices-current-states page.

By using 'item.dump()' in a script, I found the sValue data with key "1" or "2" etc., so item.rawData[1] gives me the value I'm looking for.

Now my question;

Is there a shortcut to get this value I'm not aware of? In the doc's is explained how to set/update multiple sVal's but not how to 'get' them.
After doing a google-search I noticed this is unclear for not just me, so maybe we can clarify this sVal-quest ;)
User avatar
waltervl
Posts: 6002
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: dzVents and sValue's

Post by waltervl »

The dzVents sValue is based on the Domoticz JSON principle as far as I see ( https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s ). The visual-editor's Devices-current-states page uses another more internal method.

So why can you not work with the given sValue like "On" or "Off"? Why do you need 0 or 1?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Robbie
Posts: 29
Joined: Friday 04 September 2015 1:15
Target OS: NAS (Synology & others)
Domoticz version: 2.2980
Contact:

Re: dzVents and sValue's

Post by Robbie »

The sValue(s) can be any useful string. In my use-case there are motion sensors holding info about what triggered them. See screenshot.
I use these value's in notifications.

I might be wrong, but the "status" (On/Off) is something different than the discussed "sValues" right?
Schermafbeelding 2021-06-21 om 19.02.10.png
Schermafbeelding 2021-06-21 om 19.02.10.png (36.01 KiB) Viewed 638 times
Robbie
Posts: 29
Joined: Friday 04 September 2015 1:15
Target OS: NAS (Synology & others)
Domoticz version: 2.2980
Contact:

Re: dzVents and sValue's

Post by Robbie »

While thinking about this, I wonder why dzVents offers item.status and item.sValue like the way it does. In many cases they hold the same value. Okay, "status" serve's a purpose, but then what's the reason for "sValue"?
The function setValues(nValue,[ sValue1, sValue2, …]) offers to set multiple sValue's, but dzVents is lacking a function to fetch them.

The reason is unclear to me and I feel there perhaps is an opportunity to fill this gap.
User avatar
waltervl
Posts: 6002
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: dzVents and sValue's

Post by waltervl »

I still do not understand your need.
Multiple sValues are there for special devices (like electricity or weather) that accept multiple sValues like temp;humidity;pressure
A motion sensor has only 1 attribute with 1 value On/Off. So for switches there is only 1 value. For switches in dzVents you get that only value with device.state

I also wonder why dzVents support Svalue. I did not see a lot of usage examples. That is why I asked you why you would like to use this for.

I have no knowledge that a motion sensor in Domoticz knows and saves what triggered it. The screenshot you showed is not a Domoticz screenshot. Perhaps zwave?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Robbie
Posts: 29
Joined: Friday 04 September 2015 1:15
Target OS: NAS (Synology & others)
Domoticz version: 2.2980
Contact:

Re: dzVents and sValue's

Post by Robbie »

waltervl wrote: Monday 21 June 2021 21:02 I have no knowledge that a motion sensor in Domoticz knows and saves what triggered it. The screenshot you showed is not a Domoticz screenshot. Perhaps zwave?
Thats a screenshot of the Domoticz visual-editor's Devices-current-states page.

Natively a motion sensor has 1 value On/Off, but any type of device can hold as many sValues as you would like it to have.
In my case the (virtual) device gets updated by MQTT, motion On/Off (nValue) + trigger person/vehicle/animal (sValue). Next I use dzVents to send a notification with the sValue: "Person detected", "Car detected" etc.

In my opinion; if a value can be set, it can be used however you like, and you need to be able to retrieve it.
I'm happy with using item.rawData, so it's not a big deal, but it would be nice to have a quick function for it :)
User avatar
waltervl
Posts: 6002
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: dzVents and sValue's

Post by waltervl »

I think you are using something not much used and also not where it was designed for.
In dzVents you can write helpers. This would be a nice function you can program in a helper yourself.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Robbie
Posts: 29
Joined: Friday 04 September 2015 1:15
Target OS: NAS (Synology & others)
Domoticz version: 2.2980
Contact:

Re: dzVents and sValue's

Post by Robbie »

I hope you don't mind a healthy debate on this, because in my opinion your conclusion might be too conventional.
Perhaps it's not much used because the full functions aren't yet in place. Yes there are multiple ways to achieve any automation-purpose in Domoticz,
But keeping all possible info tightly together in 1 device, along with the possibility to update all that info in 1 single transaction, it seems only logical to 'get' them and use them whenever needed. I see unlimited use-cases for it in this growing home-automation-world.

I wonder, with what idea in mind was it actually specifically designed for? Could sValue's grow into a more rich data-holder/functionality than it currently is? The only thing it needs is a item.getValue(n)

Hahha my speech needs a mic-drop... sValue's will be proud of me :p
User avatar
waltervl
Posts: 6002
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: dzVents and sValue's

Post by waltervl »

I am not one of the developers so I have no idea what the intention of sValue was. I think it is not intended for use on switches but only on devices having need of multiple values. There is also no API call for your use case. That it works is no evidence that it should work.

You can use it of course as long as it works. Until a developer decides to narrow down (could be by accident) the usage. So it is up to you and the maintainer of dzVents to act on it. Or decide to document that there is an intention to store and maintain sValues on light/switches. I think, but not tested, that no UI element other than the event manager current device status list shows these sValues on switches, also an indication that it is unintended.

So coming back on your initial question: No there is no other way and you are fully free to make an Pull Request on github repository to add a get.Value(n) function. You can also make your own function by writing a helper.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest