Page 1 of 1

Add new virtual switch using JSON

Posted: Saturday 14 May 2016 19:16
by korniza
Hello guys,
I like to create a number of virtual switches using JSON so to have IDX of switch selected by me. I search forum but no post found. Also wiki describes on the way to create virtual sensors but not virtual switches.
Is there any way to perform it even using a console script? Please help!

Re: Add new virtual switch using JSON

Posted: Saturday 14 May 2016 21:11
by Egregius
Use developer mode of your browser while adding a switch.
Don't think you can choose the idx.

Re: Add new virtual switch using JSON

Posted: Sunday 15 May 2016 3:14
by Egregius

Code: Select all

json.htm?type=createvirtualsensor&idx=2&sensorname=test&sensortype=6
idx is the idx of the dummy hardware.

Re: Add new virtual switch using JSON

Posted: Sunday 15 May 2016 3:42
by korniza
Egregius wrote:

Code: Select all

json.htm?type=createvirtualsensor&idx=2&sensorname=test&sensortype=6
idx is the idx of the dummy hardware.
Thank you for! It does work! :)
New device was created is not assigned to any hardware (it appeared on devices as ? unknown hardware). Can I "move" it to an exist hardware or build via JSON a hardware and assign this orphan device? :?
The reason I ask them is that I like to create a script to replicate some of my hardware to another (backup) domoticz. It is a painfull situation performing by hand and always have the same IDX for particular sensors.

Re: Add new virtual switch using JSON

Posted: Sunday 15 May 2016 3:46
by Egregius
I assume you have the dummy hardware installed and used that idx in your url?
If it's only for backup I would create a script that copies the records directly from/to the database.

Re: Add new virtual switch using JSON

Posted: Sunday 15 May 2016 10:01
by korniza
If it was for the settings, I use the database backup/restore process. BUT is it for specific devices/sensors.