Skip to content
DewGew edited this page Feb 8, 2024 · 4 revisions

API

DZGA has an REST API using POST. This allows users to run their own scripts.

System:
Sync devices:
/api?custom=sync

Set enable/disable googla assistant:
/api?custom=user_settings&googleassistant=true/false

Sets roomplan:
/api?custom=user_settings&roomplan=IDX

Sets domoticz url:
/api?custom=user_settings&domourl=URL

Restart server (requires admin):
/api?custom=restart

Remove a user (requires admin):
/api?custom=removeuser&user=USER

Device config:
Hide a device:
/api?custom=device_config&id=ID&hide=true/false

Turn on/off check state message:
/api?custom=device_config&id=ID&checkstate=true/false

Set room:
/api?custom=device_config&id=ID&room=ROOMNAME

Set device ack:
/api?custom=device_config&id=ID&ack=true/false

Set device type:
/api?custom=device_config&id=ID&devicetype=TYPE

Set nicknames:
/api?custom=device_config&id=ID&nicknames=NAME1,NAME2,NAME3

This lua example script enables/disables google assistant:

local idx = 123
local url = '192.168.1.123:8181'
local token = 'myCoolToken'
local state

return {
	on = {
		devices = {idx}
	},
	execute = function(domoticz, item)
	    
        domoticz.log(dev, domoticz.LOG_INFO)
        
        if (item.state == 'Off') then
            state = 'false'
        else
            state = 'true'
        end

        domoticz.openURL({
			url = 'http://'..url..'/api?custom=user_settings&googleassistant=' .. state,
			method = 'POST',
			headers = {
			    Authorization = 'Bearer '..token
			    },
		})
		domoticz.log('Google Assistant is ' .. item.state, domoticz.LOG_FORCE)

	end
}

Domoticz API

By default POST requests to the API can be passed to the Domoticz backend. This means that DZGA accepts the same API calls as Domoticz. Just replace /json.htm with /api

Example to get details of all lights/switches from domoticz:
/api?type=command&param=getdevices&filter=light&used=true&order=Name

You can find all domoticz api:s here.

Clone this wiki locally