Page 1 of 1

Can't switch virtual device

Posted: Sunday 09 October 2022 20:54
by Alain
I am trying to push a remote switch command from one pc to another via a script. This is giving me errors, so I decided to look at it locally on the pc that is giving me the error.

What I have: 1 dummy hardware for virtual sensors. There, I created a virtual on/off switch. I go to the devices tab and it is there and I can switch it on and off. No problem.

When I try to switch it with a JSON command, it gives me an error. The command I'm using is:

Code: Select all

http://192.168.0.38:8080/json.htm?type=command&param=switchlight&idx=13&switchcmd=on
It reports

Code: Select all

	
message	"Error sending switch command, check device/hardware (idx=13) !"
status	"ERROR"
title	"SwitchLight"
When I use the same command with idx=2 for a switch that was created automatically as a Zigbee switch, it works fine. Isn't it possible to switch a virtual device through a JSON command?

Re: Can't switch virtual device

Posted: Sunday 09 October 2022 21:46
by ferrosk
Hi,

Valid commands are: switchcmd=<On|Off|Toggle|Stop> so try with:

Code: Select all

http://192.168.0.38:8080/json.htm?type=command&param=switchlight&idx=13&switchcmd=On
see wiki

Re: Can't switch virtual device

Posted: Sunday 09 October 2022 22:28
by Alain
Now the next problem has risen. I can send a JSON command from the remote computer to another remote computer, but not the other way around. I get a 401 unauthorized message. I have compared the Ubuntu settings in both machines, but they look the same.

Re: Can't switch virtual device

Posted: Sunday 09 October 2022 22:39
by Alain
ufw is inactive

Re: Can't switch virtual device

Posted: Monday 10 October 2022 14:07
by Alain
I found the problem to be that I forgot to add 127.0.*, 192.168.0.* to the local networks (no username and password) under settings. It beats me how I looked over that. Anyway, a simple fix.