Problem sending command to remote server z-wave device  [Solved]

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

Moderator: leecollings

Post Reply
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Problem sending command to remote server z-wave device

Post by ronaldbro »

Hi,

I'm having a problem and don't know what's the best place on the forum to place it. So I'll start here...

Because of z-wave problems I decided to move my z-wave stick to a secondary Pi. It was in a Pi 4, my main domoticz, but every now and then I got a crashed domoticz. Today I couldn't get it working again, after a restart during z-wave initialization I got a segmentation fault every time. On my secondary Pi, a Pi 3 only running for 6 Mi Flora's and 2 Somfy blinds it worked without any problem.
So all my z-wave devices worked and with the Domoticz remote server I got the devices on my main Domoticz again. So far so good, everything works and I can control my z-wave devices on my main domoticz.

But my scripts don't work anymore. When I send a command to a shutter or light switch I get the following error:

Code: Select all

2020-06-13 22:12:40.380 Error: Switch command not send!, Hardware device disabled or not found! 
And yes I did update the idx in the scripts...

For my Somfy blinds using RFXCom this works fine.
As a workaround I tried to send new setpoints to my blinds using json command in dzVents and this works fine. But not the dimTo() command...

So...
1) Controlling z-wave blinds and switches from server to client using the Domoticz widgets works fine.
2) Controlling z-wave blinds and switches from server to client using json commands from dzVents works fine.
3) Contrlling Somfy blinds from server to client using dzVents commands works fine. (.open() and .close())
But...
Controlling z-wave blinds and switches from server to client using DzVents commands does not work (.dimTo(), .switchOn() and .switchOff())

Hopefully someone can help.
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: Problem sending command to remote server z-wave device

Post by ronaldbro »

After some more testing I think this is a problem in dzVents...

When I replace
dev.switchOn()
By
dz.openURL({url = 'http://127.0.0.1:8080' .. '/json.htm?type=command&param=switchlight&idx=' .. dev.idx ..'&switchcmd=On'})

Then my scripts work.

So using the switchOn command on a slave zwave device doesn't work but sending a json to localhost does work...

@waaren, do you think this might be a bug in dzVents?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Problem sending command to remote server z-wave device

Post by waaren »

ronaldbro wrote: Wednesday 17 June 2020 23:33 When I replace
dev.switchOn()
By
dz.openURL({url = 'http://127.0.0.1:8080' .. '/json.htm?type=command&param=switchlight&idx=' .. dev.idx ..'&switchcmd=On'})
Regardless weather a device is a physical, -virtual or slave device, dzVents sends the same commands. The majority of commands to update a device are send to domoticz via the commandArray and EventSystem. That route is a different path then via the webserver (which is used when you use openURL)

I don't know enough of the domoticz internal differences between a physical OpenZwave device and a slave one to explain why the switchOn() fails on the slave. You might want to check if the same command also fail on slaves from other hardware devices.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: Problem sending command to remote server z-wave device

Post by ronaldbro »

Hi waaren,

I already checked if other hardware works and my Somfy blinds through RFXCom work fine as slave. It seems this is only with zwave.
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: Problem sending command to remote server z-wave device

Post by ronaldbro »

Hi @waaren,

I did some more tests and found out that it works fine in Blockly, so it seems to be related to dzVents.

This works:
2020-06-18_10-41-44.png
2020-06-18_10-41-44.png (22.03 KiB) Viewed 1408 times
This does not work:

Code: Select all

return {
	on = {
		devices = {
			1068
			}
		},

	-- custom logging level for this script
	logging = {
        level = domoticz.LOG_DEBUG,
        marker = "Test"
    },

	-- actual event code
	-- the second parameter is depending on the trigger
	-- when it is a device change, the second parameter is the device object
	-- similar for variables, scenes and groups and httpResponses
	-- inspect the type like: triggeredItem.isDevice
	execute = function(dz, triggeredItem, info)
	    if triggeredItem.level == 0 then
	        dz.devices(1051).switchOn()
	   else
	        dz.devices(1051).switchOff()
	   end
	end
}
It results in the following log:
2020-06-18 10:44:39.407 Status: dzVents: Info: Test: ------ Start internal script: Test dzVents switchOn: Device: "Test knop (Zigate beneden)", Index: 1068
2020-06-18 10:44:39.408 Status: dzVents: Debug: Test: Processing device-adapter for Woonkamer: Eettafel: Switch device adapter
2020-06-18 10:44:39.408 Status: dzVents: Debug: Test: Constructed timed-command: On
2020-06-18 10:44:39.408 Status: dzVents: Info: Test: ------ Finished Test dzVents switchOn
2020-06-18 10:44:39.414 Error: Switch command not send!, Hardware device disabled or not found!

This does work:

Code: Select all

return {
	on = {
		devices = {
			1068
			}
		},

	-- custom logging level for this script
	logging = {
        level = domoticz.LOG_DEBUG,
        marker = "Test"
    },

	-- actual event code
	-- the second parameter is depending on the trigger
	-- when it is a device change, the second parameter is the device object
	-- similar for variables, scenes and groups and httpResponses
	-- inspect the type like: triggeredItem.isDevice
	execute = function(dz, triggeredItem, info)
	    if triggeredItem.level == 0 then
            dz.openURL({url = 'http://127.0.0.1:8080' .. '/json.htm?type=command&param=switchlight&idx=1051&switchcmd=On'})
	   else
            dz.openURL({url = 'http://127.0.0.1:8080' .. '/json.htm?type=command&param=switchlight&idx=1051&switchcmd=Off'})
	   end
	end
}
All three tests use the same device.

Please advice what to do? I can make a github issue, but they probably refer me back to you or need more internal info how dzVents switch the device.
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: Problem sending command to remote server z-wave device

Post by ronaldbro »

Forget about it, problem is solved. Just found out the cause.

I moved my zwave stick to another pi and used the master-slave.
I did not remove the zwave hardware from my main device, but disabled the z-wave hardware. I gave the devices I got from the remote server hardware the same name as initially, which mean all my original z-wave devices have the same name as the remote z-wave devices. As I never use the names in scripts, but always the idx I never expected this to be a problem. But after renaming it works.

So basically my conclusion is that even if I use the idx, dzVents converts it to a device name when sending a command.

In my opinion this would be a design flaw of dzVents as the idx is always unique and the name not. But maybe there is a good reason for it. But anyway it is what it is and I can solve my problems by renaming the old devices. (Because this is a stability test I'm not ready to delete the old hardware yet)

Thanks for your help waaren.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Problem sending command to remote server z-wave device

Post by waaren »

ronaldbro wrote: Thursday 18 June 2020 10:48 Please advice what to do? I can make a github issue, but they probably refer me back to you or need more internal info how dzVents switch the device.
Sorry but I cannot add anything here beyond what I already wrote in my previous post. dzVents just sends the switchOn command to domoticz.
You could switch to debug in dzVents and/or start domoticz with logging = debug to see what is actually send / processed.

The error message you see comes from mainWorker (sourcecode line 11351)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Problem sending command to remote server z-wave device

Post by waaren »

Good that you solved it !
ronaldbro wrote: Thursday 18 June 2020 10:57 I can solve my problems by renaming the old devices.
Disabling the devices should also do it.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Problem sending command to remote server z-wave device

Post by waaren »

ronaldbro wrote: Thursday 18 June 2020 10:57 In my opinion this would be a design flaw of dzVents as the idx is always unique and the name not. But maybe there is a good reason for it.
Not 100% sure but I guess the reason is that the Lua engine in domoticz expects a name when switching a device.

from the wiki: One tip before you get started: Make sure that all your devices have unique names
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: Problem sending command to remote server z-wave device  [Solved]

Post by ronaldbro »

That could be a good reason, in that case the design flaw is there ;)

I also know and understand the tip. I also agree with it, because it makes things unclear. From a functional point of view I still have unique names because I disabled the original zwave hardware... But I also think if non-unique names give a technical problem then Domoticz should not allow it and it should not be only a tip.

Anyway, glad I found the root cause of my problems so I can solve it.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest