Create a device

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

Moderator: leecollings

Post Reply
DanM
Posts: 79
Joined: Thursday 23 October 2014 22:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Create a device

Post by DanM »

Hi,

If there any way to check if a device exists and create it if not?

Best,

Dan
SweetPants

Re: Create a device

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Create a device

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest