Page 1 of 1

api-call only by idx or by device name as well

Posted: Thursday 23 April 2020 22:59
by Tukker
Hi,
In python I can do an api-call like this:

Code: Select all

SENSOR = "http://192.168.2.1:8080/json.htm?type=devices&rid=1"
In dzVents I can lookup a device by name like

Code: Select all

devices = { 'CV_switch_manual' }
Is it possible to do an api-call in python by name like:

Code: Select all

SENSOR = "http://192.168.2.1:8080/json.htm?type=devices&rid=Oregon"
Or didn't I search enough.

Re: api-call only by idx or by device name as well

Posted: Thursday 23 April 2020 23:43
by waaren
HvdW wrote: Thursday 23 April 2020 22:59 Is it possible to do an api-call in python by name like:

Code: Select all

SENSOR = "http://192.168.2.1:8080/json.htm?type=devices&rid=Oregon"
Not possible in one pass. Not from Python nor from any other language. It is not available as API call in domoticz

What you can do is call

Code: Select all

http://192.168.2.1:8080/json.htm?type=command&param=devices_list

to get a JSON of all deviceNames / idx and
process that list to extract the idx belonging to the name you want.

Or (probably quicker) just get all devices from domoticz using

Code: Select all

http://192.168.2.1:8080/json.htm?type=devices
and walk the list with the devicename as searchkey to find your device

Re: api-call only by idx or by device name as well

Posted: Friday 24 April 2020 0:04
by Tukker
Thanks @waaren