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

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

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

Post 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?
Last edited by mvzut on Sunday 13 November 2016 15:09, edited 5 times in total.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

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

Post 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.
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

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

Post 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...
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest