2017년 4월 28일 금요일

Domotic API Call


 have made several apps with App-Inventor but now stumbled upon a problem I have not yet found a solution for.

I am trying to get my Domoticz (home automation) system responding to an app.
However I do not get the API call working properly.
Any suggestions.

Here is the link to the API documentation:
https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s#Get_all_lights.2Fswitches

So basically what I am trying to do is this:

http://192.168.1.2:8080//json.htm?type=command&param=switchlight&idx=99&switchcmd=Off When I enter this in a web-browser (using the right IP number and IDX for the switch) my switch nicely turns off. Now what I would like to have is some code that does this when I push a button on my screen. Would also be nice to get the list of devices in my system in a database using this: /json.htm?type=devices&filter=light&used=true&order=Name Anybody any idea ??? --
use the web component together with your URL 
and then call the Web.Get method
use the web.GotText event to receive the result

--
This is what I Tried and only get the error:
Unable to get a response

When I paste this code right into my browser it works.......
So the Ip is ok and the json string also.

Sorry made a mistake in the original post
should be a single "/" before the json part just like above in the blocks.


-- 
sorry, I have overseen, that you are using a local ip and port 8080
this probably does not work? see also: API connect through port 8080


-- 
I changed port 8080 in Domoticz to port 80 and made sure this was working

Then altered my code in Mit App-Inventor and no luck,,,,,

Next step I tried to access from global IP number (not local) and also no success.
Anybody around with Domoticz experience ???

-- 
Thanks for your prompt reply's  anyway......

-- 

Next step I tried to access from global IP number (not local) and also no success.

global ip without port should work...

-- 

Found it !!!

The code should be as the blocks show.

However IP adress should not be the local IP adress. But the IP adress for accessing Domoticz over the internet.
The Username and password need to be invoked in the command as shown and they need to be coded base 64.

The code shown here works !!!!

-- 

댓글 없음:

댓글 쓰기