domoticz / domoticz-android

Domoticz Client Application for Android Devices
104 stars 69 forks source link

Domoticz API changes in beta 15326 (1-jun-2023) and stable 2023.2 #692

Closed waltervl closed 2 months ago

waltervl commented 1 year ago

A warning for your app as Domoticz API has changed in latest beta 15326 (1-jun-2023) https://www.domoticz.com/wiki/Domoticz_ ... d_newer.29

For users using API calls from outside Domoticz there has been some changes in API calls. They now always should be of the form /json.htm?type=command&param=command

For example

/json.htm?type=graph will be /json.htm?type=command&param=graph

/json.htm?type=devices will be /json.htm?type=command&param=getdevices

More info in Forum topic https://www.domoticz.com/forum/viewtopic.php?p=303581#p303581

This wiki page will be updated with the new API format

galadril commented 1 year ago

Mm oke a breaking change. any idea when it will go out of beta? Thanks for the heads up

waltervl commented 1 year ago

There is still some discussion which old API calls will be supported by a deprecation warning (see the forum discussion) untill one or 2 stable versions. Perhaps add the api calls you are using in the forum topic.

waltervl commented 1 year ago

In latest beta build the list of backwards compatible API commands is extended https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s#Warning_Beta_Build_15326.2C_1-jun-2023_.28and_newer.29

kiddigital commented 1 year ago

Hi @waltervl , thx for updating the wiki.

One change, 'events' is not backwards compatible as in the old situation it used the 'param' parameter (which conflicts with type=command) and now it used the 'evparam' parameter.

waltervl commented 1 year ago

Hi @waltervl , thx for updating the wiki.

One change, 'events' is not backwards compatible as in the old situation it used the 'param' parameter (which conflicts with type=command) and now it used the 'evparam' parameter.

So what should it be? Something like /json.htm?type=command&param=events&evparam=list

galadril commented 1 year ago

these are all the urls the apps currently use:


    public interface Url {
        @SuppressWarnings("unused")
        interface Action {
            String ON = "On";
            String OFF = "Off";
            String UP = "Up";
            String STOP = "Stop";
            String DOWN = "Down";
            String PLUS = "Plus";
            String MIN = "Min";
            String CLOSE = "Close";
            String OPEN = "Open";
        }

        interface ModalAction {
            String AUTO = "Auto";
            String ECONOMY = "AutoWithEco";
            String AWAY = "Away";
            String DAY_OFF = "DayOff";
            String CUSTOM = "Custom";
            String HEATING_OFF = "HeatingOff";
        }

        @SuppressWarnings("SpellCheckingInspection")
        interface Category {
            String ALLDEVICES = "/json.htm?type=devices";
            String DEVICES = "/json.htm?type=devices&filter=all&used=true";
            String FAVORITES = "/json.htm?type=devices&filter=all&used=true&favorite=1";
            String VERSION = "/json.htm?type=command&param=getversion";
            String DASHBOARD = ALLDEVICES + "&filter=all";
            String SCENES = "/json.htm?type=scenes";
            String SWITCHES = "/json.htm?type=command&param=getlightswitches";
            String WEATHER = ALLDEVICES + "&filter=weather&used=true";
            String CAMERAS = "/json.htm?type=cameras";
            String CAMERA = "/camsnapshot.jpg?idx=";
            String UTILITIES = ALLDEVICES + "&filter=utility&used=true";
            String PLANS = "/json.htm?type=plans";
            String TEMPERATURE = ALLDEVICES + "&filter=temp&used=true";
            String SWITCHLOG = "/json.htm?type=lightlog&idx=";
            String TEXTLOG = "/json.htm?type=textlog&idx=";
            String SCENELOG = "/json.htm?type=scenelog&idx=";
            String SWITCHTIMER = "/json.htm?type=timers&idx=";
            String SCENETIMER = "/json.htm?type=scenetimers&idx=";
        }

        @SuppressWarnings({"SpellCheckingInspection", "unused"})
        interface Switch {
            String DIM_LEVEL = "Set%20Level&level=";
            String COLOR = "&hue=%hue%&brightness=%bright%&iswhite=false";
            String KELVIN = "&kelvin=";
            String WWCOLOR = "&brightness=%bright%&color={\"m\":2,\"t\":%ww%,\"r\":0,\"g\":0,\"b\":0,\"cw\":%cw%,\"ww\":%ww%}";
            String GET = "/json.htm?type=command&param=switchlight&idx=";
            String CMD = "&switchcmd=";
            String LEVEL = "&level=";
        }

        @SuppressWarnings("SpellCheckingInspection")
        interface ModalSwitch {
            String GET = "/json.htm?type=command&param=switchmodal&idx=";
            String STATUS = "&status=";
        }

        @SuppressWarnings("SpellCheckingInspection")
        interface Scene {
            String GET = "/json.htm?type=command&param=switchscene&idx=";
        }

        @SuppressWarnings("SpellCheckingInspection")
        interface Temp {
            String GET = "/json.htm?type=command&param=udevice&idx=";
            String VALUE = "&nvalue=0&svalue=";
            String GRAPH = "/json.htm?type=graph&sensor=temp&idx=";
        }

        @SuppressWarnings("SpellCheckingInspection")
        interface Favorite {
            String GET = "/json.htm?type=command&param=makefavorite&idx=";
            String SCENE = "/json.htm?type=command&param=makescenefavorite&idx=";
            String VALUE = "&isfavorite=";
        }

        interface Protocol {
            String HTTP = "http://";
            String HTTPS = "https://";
        }

        @SuppressWarnings("SpellCheckingInspection")
        interface Device {
            String STATUS = "/json.htm?type=devices&rid=";
            String SET_USED = "/json.htm?type=setused&idx=";
        }

        @SuppressWarnings("unused")
        interface Sunrise {
            String GET = "/json.htm?type=command&param=getSunRiseSet";
        }

        @SuppressWarnings({"unused", "SpellCheckingInspection"})
        interface Plan {
            String GET = "/json.htm?type=plans";
            String DEVICES = "/json.htm?type=command&param=getplandevices&idx=";
        }

        @SuppressWarnings({"unused", "SpellCheckingInspection"})
        interface Log {
            String GRAPH = "/json.htm?type=graph&idx=";
            String GRAPH_RANGE = "&range=";
            String GRAPH_TYPE = "&sensor=";

            String GET_LOG = "/json.htm?type=command&param=getlog&loglevel=";
            String GET_FROMLASTLOGTIME = "/json.htm?type=command&param=getlog&lastlogtime=";
        }

        @SuppressWarnings({"unused", "SpellCheckingInspection"})
        interface Notification {
            String NOTIFICATION = "/json.htm?type=notifications&idx=";
        }

        @SuppressWarnings({"unused", "SpellCheckingInspection"})
        interface Security {
            String GET = "/json.htm?type=command&param=getsecstatus";
            String CHECKLOGIN = "/json.htm?type=command&param=logincheck";
            String NEWCHECKLOGIN = "/logincheck";
        }

        @SuppressWarnings({"unused", "SpellCheckingInspection"})
        interface UserVariable {
            String UPDATE = "/json.htm?type=command&param=updateuservariable";
        }

        @SuppressWarnings("SpellCheckingInspection")
        interface System {
            String SUNRISE = "/json.htm?type=command&param=getSunRiseSet";
            String UPDATE = "/json.htm?type=command&param=checkforupdate&forced=true";
            String USERVARIABLES = "/json.htm?type=command&param=getuservariables";
            String EVENTS = "/json.htm?type=events&param=list";
            String EVENTS_UPDATE_STATUS = "/json.htm?type=events&param=updatestatus&eventid=";
            String RGBCOLOR = "/json.htm?type=command&param=setcolbrightnessvalue&idx=";
            String KELVIN = "/json.htm?type=command&param=setkelvinlevel&idx=";
            String FULLLIGHT = "/json.htm?param=fulllight&type=command&idx=";
            String NIGHTLIGHT = "/json.htm?param=nightlight&type=command&idx=";
            String SETTINGS = "/json.htm?type=settings";
            String CONFIG = "/json.htm?type=command&param=getconfig";
            String SETSECURITY = "/json.htm?type=command&param=setsecstatus";
            String UPDATE_DOWNLOAD_UPDATE = "/json.htm?type=command&param=downloadupdate";
            String UPDATE_DOWNLOAD_READY = "/json.htm?type=command&param=downloadready";
            String UPDATE_DOMOTICZ_SERVER = "/json.htm?type=command&param=execute_script&scriptname=update_domoticz&direct=true";
            String ADD_MOBILE_DEVICE = "/json.htm?type=command&param=addmobiledevice";
            String CLEAN_MOBILE_DEVICE = "/json.htm?type=command&param=deletemobiledevice";
            String LANGUAGE_TRANSLATIONS = "/i18n/domoticz-";
            String SEND_NOTIFICATION = "/json.htm?type=command&param=sendnotification";
            String NOTIFICATIONTYPES = "/json.htm?type=notifications";
            String USERS = "/json.htm?type=users";
            String AUTH = "/json.htm?type=command&param=getauth";
            String LOGOFF = "/json.htm?type=command&param=dologout";
            String LOG = "/json.htm?type=command&param=addlogmessage&message=";
        }

        interface Event {
            String ON = "&eventstatus=1";
            String OFF = "&eventstatus=0";
        }
    }

    public interface FavoriteAction {
        String ON = "1";
        String OFF = "0";
    }

https://github.com/domoticz/domoticz-android/blob/master/domoticzapi/src/main/java/nl/hnogames/domoticzapi/DomoticzValues.java

waltervl commented 1 year ago

So you still have some API calls without fallback eg

            String CAMERAS = "/json.htm?type=cameras";
            String SWITCHLOG = "/json.htm?type=lightlog&idx=";
            String TEXTLOG = "/json.htm?type=textlog&idx=";
            String SCENELOG = "/json.htm?type=scenelog&idx=";
            String SWITCHTIMER = "/json.htm?type=timers&idx=";
            String SCENETIMER = "/json.htm?type=scenetimers&idx=";
            String EVENTS = "/json.htm?type=events&param=list";
kiddigital commented 1 year ago

@galadril , I will try to create a PR with the changes for the file mentioned.

Unfortunately I am not able to compile/test, hope that is ok.

waltervl commented 1 year ago

@kiddigital It is better to have more fallback.... eases everybody that uses the Domoticz API.... See also https://www.domoticz.com/forum/viewtopic.php?f=6&t=40415&start=60

waltervl commented 1 year ago

FYI: With PR https://github.com/domoticz/domoticz/pull/5720 more fallbacks were introduced.

nefsolive commented 11 months ago

Hello, im still have API problems on Domoticz Premium App! Menu Events not working. Give error "OPSS..." I'm still looking to wait for an app update as soon as possible, in order to solve this problem! Well, I think the events menu is sorely missed. thanks.

waltervl commented 11 months ago

Modified title as these API changes also have been implemented in the recently released stable 2023.2 version.

galadril commented 8 months ago

ok so im pushing a new beta build which should detect if it should use the new or old api urls.

galadril commented 3 months ago

Going to remove the old v1 urls, so people need to upgrade after x amount of months backwards compatibility. (first on beta to test)