Can't switch virtual device

Moderator: leecollings

Post Reply
Alain
Posts: 171
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Can't switch virtual device

Post 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?
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | TP-Link | Node-Red | Grafana |
ferrosk
Posts: 44
Joined: Saturday 26 August 2017 20:13
Target OS: Linux
Domoticz version: 2023.2
Contact:

Re: Can't switch virtual device

Post 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
Domoticz 2023.2 on Odroid M1 and Armbian
MySensors (RFM69 Serial GW): bunch of DIY sensors/devices
Zwave (Z-Wave.me RaZberry board): Danfoss devices
Zigbee (Sonoff Dongle Plus): IKEA, Tesla devices
Alain
Posts: 171
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Can't switch virtual device

Post 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.
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | TP-Link | Node-Red | Grafana |
Alain
Posts: 171
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Can't switch virtual device

Post by Alain »

ufw is inactive
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | TP-Link | Node-Red | Grafana |
Alain
Posts: 171
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Can't switch virtual device

Post 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.
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | TP-Link | Node-Red | Grafana |
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest