Update dimmer from outside of domoticz without triggering

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
jslettengren
Posts: 9
Joined: Thursday 19 October 2017 19:11
Target OS: Linux
Domoticz version:
Contact:

Update dimmer from outside of domoticz without triggering

Post by jslettengren »

Long story short: I have a number of Velux motorized windows and blinds that I try to get integrated into Domoticz. The problem I have has to do with updating the values in Domoticz from "outside" using curl.

In Domoticz, I have the Windows and Blinds set up as dimmers, dummy HW. (I did try the "Blinds percentage", but then the sliders did not work.)

When changing dimmer value -> dzvents-script is triggered and calls setposition.js and position is set to desired value. This works perfectly.

When changing blinds or windows using the velux remotes (not integrated into Domoticz), I want to update the values in Domoticz without triggering the aforementioned dzvents script. How can this be done?

Currently, I have a bash-script that runs on a timer (independant of Domoticz). But every time it updates the values in Domoticz, the dzvents-script is triggered, and the windows and blinds move slightly (rounding errors will inevitably make this happen).

Code for updating the values in Domoticz (reduced to one device for readability):

Code: Select all

#!/bin/bash

# Script that updates the devices in Domoticz

data=$(node /home/user/velux/getAllPositions.js)

# Sort it
bulPos=$(echo "$data" | grep -P -o '(?<=Blind up left:\s)[0-9.]*')

# Pipe through calculator and awk to transform to integer 0-16 instead of float 0-1:
bulPos=$(echo "scale=4; $bulPos*16" | bc)
bulPos=$(echo $bulPos | awk '{print int($1+0.5)}')

curl -s "http://127.0.0.1:<portnr>/json.htm?type=command&param=switchlight&idx=478&switchcmd=Set%20Level&level=${bulPos}"
I have tried &param=udevice

Code: Select all

 
curl -s "http://127.0.0.1:<portnr>/json.htm?type=command&param=udevice&idx=478&switchcmd=Set%20Level&level=${bulPos}"

but that gives an error.

So how can I update the device values without triggering the dzvents-script? Can I do something from within the dzvents script? Maybe find out the source of the value change?

dzvents-script that sets levels:

Code: Select all

return {
	on = {
		devices = {
			'Blind up left',
			'Blind up center',
			'Blind up right',
			'Blind down left',
			'Blind down center',
			'Blind down right',
			'Window left',
			'Window right'
		}
	},
	execute = function(domoticz, device)
	    if (device.changed) then
	        -- Here, I would like to check if value change came from GUI or from curl/json
           	os.execute('node /home/user/velux/setPosition.js "' .. device.name .. '" ' .. device.level*0.01);
           end	
	end
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Update dimmer from outside of domoticz without triggering

Post by waaren »

jslettengren wrote: Friday 24 April 2020 16:53 Long story short: I have a number of Velux motorized windows and blinds that I try to get integrated into Domoticz. The problem I have has to do with updating the values in Domoticz from "outside" using curl.

So how can I update the device values without triggering the dzvents-script?[/b] Can I do something from within the dzvents script? Maybe find out the source of the value change?
What is your dzVents level ?
If >= 3.0.0 I can help using the new customEvent Trigger.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jslettengren
Posts: 9
Joined: Thursday 19 October 2017 19:11
Target OS: Linux
Domoticz version:
Contact:

Re: Update dimmer from outside of domoticz without triggering

Post by jslettengren »

waaren wrote: Friday 24 April 2020 17:26
jslettengren wrote: Friday 24 April 2020 16:53 Long story short: I have a number of Velux motorized windows and blinds that I try to get integrated into Domoticz. The problem I have has to do with updating the values in Domoticz from "outside" using curl.

So how can I update the device values without triggering the dzvents-script?[/b] Can I do something from within the dzvents script? Maybe find out the source of the value change?
What is your dzVents level ?
If >= 3.0.0 I can help using the new customEvent Trigger.
Thank you. I'm on Domoticz 4.10717, dzVents Version: 2.4.19, unfortunately. This may be the thing that pushes me to the next stable release.

How could the customEvent trigger be of help?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Update dimmer from outside of domoticz without triggering

Post by waaren »

jslettengren wrote: Saturday 25 April 2020 16:15 How could the customEvent trigger be of help?
You can trigger a script by sending the customEvent via curl

so not send

Code: Select all

curl -s "http://127.0.0.1:<portnr>/json.htm?type=command&param=switchlight&idx=478&switchcmd=Set%20Level&level=${bulPos}"
but

Code: Select all

curl -s 'http://127.0.0.1:<portnr>/json.htm?type=command&param=customevent&event=MyEvent&data=jsonString
this will trigger a dzVents script listening to the customEvent "MyEvent" passing whatever you put in the jsonString. The dzVents script can for example set the virtual blind to a certain level with the option silent()
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jslettengren
Posts: 9
Joined: Thursday 19 October 2017 19:11
Target OS: Linux
Domoticz version:
Contact:

Re: Update dimmer from outside of domoticz without triggering

Post by jslettengren »

waaren wrote: Saturday 25 April 2020 17:31
jslettengren wrote: Saturday 25 April 2020 16:15 How could the customEvent trigger be of help?
You can trigger a script by sending the customEvent via curl

so not send

Code: Select all

curl -s "http://127.0.0.1:<portnr>/json.htm?type=command&param=switchlight&idx=478&switchcmd=Set%20Level&level=${bulPos}"
but

Code: Select all

curl -s 'http://127.0.0.1:<portnr>/json.htm?type=command&param=customevent&event=MyEvent&data=jsonString
this will trigger a dzVents script listening to the customEvent "MyEvent" passing whatever you put in the jsonString. The dzVents script can for example set the virtual blind to a certain level with the option silent()
Thanks a lot. It seems like that will do the trick! I'll give it a try when I have updated Domoticz.
Post Reply

Who is online

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