Page 1 of 1
Create a device
Posted: Tuesday 28 August 2018 11:27
by DanM
Hi,
If there any way to check if a device exists and create it if not?
Best,
Dan
Re: Create a device
Posted: Wednesday 29 August 2018 19:33
by SweetPants
First you need a list with all devices in the system, used or not.
http://<ip>:<port>/json.htm?type=devices&filter=all&order=Name
This returns a JSON with all devices, you can now test if the device exists and create a new one if not
Re: Create a device
Posted: Friday 31 August 2018 19:06
by waaren
DanM wrote: ↑Tuesday 28 August 2018 11:27
Hi,
If there any way to check if a device exists and create it if not?
Best,
Dan
To check if a device exist and is set to active:
Code: Select all
local deviceName = "your device name"
local myDevice = domoticz.devices(deviceName)
if myDevice then
domoticz.log("device " .. myDevice.name .. " exist and is active")
else
domoticz.log("device " .. deviceName .. " does not exist or is set inactive")
end
to create a device you will need to call domoticz via an API
https://www.domoticz.com/wiki/Domoticz_ ... _commands
This can be done using the openURL command in dzVents