Page 1 of 1

Update & create devices with LUA --> List of types & subtypes?

Posted: Sunday 13 November 2016 15:09
by mvzut
I am creating a lua script that updates a number of virtual devices/sensors. If the devices don't exist, they should first be created. I am currently using the following command for this:

Code: Select all

commandArray['OpenURL'] = 'http://127.0.0.1:8080/json.htm?type=command&param=udevice&hid='..DUMMY_HW_ID..'&did='..DID..'&dunit=1&dtype=242&dsubtype=1&nvalue=0&svalue=20'
This creates a dummy device with a specific type & subtype (in the above case a thermostat setpoint) and gives it a value. It must be given a unique device ID (DID, not to be confused with IDX). If the device already exists, it justs updates it. This is a very convenient way to update devices without having to worry about their IDX or name, or whether they exist at all.

This seems to be an undocumented JSON command. I'm very happy I found out about it, but there is one problem: I don't have the full list of possible types & subtypes anymore. There used to be an extensive overview in a forum thread (viewtopic.php?t=4501), but this was removed for some reason. Unfortunately I forgot to make a copy of the info... I only know a few types & subtypes that I looked up a few months ago, which I used in several test scripts:

Code: Select all

DTYPE1 = 80   --Temperature sensor
DSUBTYPE1 = 5 --LaCrosse TX3
DTYPE2 = 243  --General sensor
DSUBTYPE2 = 6 --Percentage
DTYPE3 = 242  --Thermostat
DSUBTYPE3 = 1 --Setpoint
DTYPE4 = 17   --Switch
DSUBTYPE4 = 0 --On/Off switch
All other forum posts which seem to be discussing this method (which you can still find using Google search) also appear to be removed.

Does anybody still have the full list? And why are all posts related to this topic removed?

Thanks!
Martijn

UPDATE:
I think I found the info in the source code: https://github.com/domoticz/domoticz/bl ... aretypes.h
However, if somebody still has an easier-to-read list, or knows where this method is described, please reply! And maybe there are other undocumented features of the JSON interface?

Re: Update & create devices with LUA --> List of types & subtypes?

Posted: Monday 14 November 2016 11:15
by dynasticorpheus
Also wondering why this is the case? Currently using httpry to see what urls are used for device creation when doing this from the user interface.

Update & create devices with LUA --> List of types & subtypes?

Posted: Monday 14 November 2016 13:26
by mvzut
dynasticorpheus wrote:Also wondering why this is the case? Currently using httpry to see what urls are used for device creation when doing this from the user interface.
Interesting! Never thought of it that way, but the web interface can probably also only communicate with the core application using some kind of JSON interface. Although we should be able to see how that works by looking at the source code, just "sniffing" the communication is probably easier, especially if you're not a (C) programmer. What would be even easier is if one of the developers can explain how it works, and how we could maybe do more with the JSON interface than is documented...