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 !!!!

-- 

API connect through port 8080


Greetings, I want to connect to an API in PHP but using port 8080 ( or whatever different to 80 ) , and can not ; I returns error 1101 (no response ) and shows me that the URL is correct , for example 192.168.1.55:8080/test/miapi.php . The strange thing is that if I do using port 80 , works properly !. What am i doing wrong?

--
PS if I test in the emulator , it works !! It is not in the smartphone

--
Is your API hosted on your own computer?
Is the 8080 port open? Some old routers need to open it manually in the admin page (192.168.0.1 or  192.168.1.1)
Did you allow that port in your firewall?
If it's working in port 80, why you can't use in that port?

--

Orientation Sensor 160426


Hi, I am using a Lenovo TB3-710 tablet that has an accelerometer sensor. I tried downloading a compass app and kinetics sensor app as per the forum below but it still doesn't work. When I tried to download the compass app it says that the tablet doesn't have a compass sensor, is this the problem?

orientation sensor works on some devices , and doesn't for others

--
Problem as to why my orientation sensor doesn't work I mean. Anything basic that I am trying to do on my app with the orientation sensor doesn't work at all.

--
Did you check your tablet's specs? Does it have the sensor? If your tablet doesn't have the sensor, there's not much we can do here.

-- 

When I tried to download the compass app it says that the tablet doesn't have a compass sensor, is this the problem?


it seems to be, your device does not have an orientation sensor?

what happens, if you try the suggestions from sstephan: orientation sensor works on some devices , and doesn't for others

-- 
Hi Italo, the tablet has a GPS and accelerometer sensor, am confused because other android mobiles that we are using such as the Oppo, Samsung Galaxy Nexus and Xiaomi, don't have orientation sensors in their specs and yet it works. Would it be that for the orientation sensor to work it needs accelerometer and compass sensor? I am reading also that it needs a GPS received.

Hi Taifun, i tried all the suggestions from sstephan and it didn't work :(

Thank you both for replying :)

-- 
Most tablets have an accelerometer, some tablets do not have an orientation sensor and/or a GPS,   GPS receivers are only available on the more expensive versions of tablets.

A GPS is a Global Positioning Sensor receiver.  It is not an orientation sensor.    An accelerometer is not a orientation sensor.   An orientation sensor is built-in hardware 
that interacts with the Earth's magnetic field.

Here is a link to the orientation sensor documentation for App Inventor 

You can check to see if a device has an orientation sensor by using the OrientationSensor.Available property.   If querying results in false; the device does not have an orientation sensor or the sensor is inoperative.

Properties
Available
Indicates whether the orientation sensor is present on the Android device.
Do the check.  Some tablets DO NOT have an orientation sensor...what is needed for a compass app.    If the app you downloaded requires a GPS and your tablet does not have a GPS the app might work under WIFI or NETWORK which will 'fill in' for the GPS in a LocationSensor call.

-- 
thank you this helps.

When i buy an android device though, what should i look out for in specs? As none of the specs these days would say "Orientation sensor". Should it be compass sensor?

-- 
The key words would be either Orientation sensor  or  magnetometer. What hardware is provided is up to the manufacturer.  Often the product documentation is incomplete.

If a device has a GPS, the manufacturer will state it has a GPS, if the maker does not brag about a GPS, then it probably does not have a GPS.  The issue of having an orientation sensor 
probably is more complex.  Almost no manufacturer will say their device does not have an orientation sensor.

If the device is very inexpensive, I guess it will lack certain hardware features.  If unsure you might go to the manufacturer's web page and ask if the device has a magnetometer or orientation sensor..they might tell you.

-- 
ok thank you

-- 

how to get a delay timer


i want my app to show an image for 5 secs then hide again after the timer ends. this will happen when a value of 3 is the answer in a calulator. but i cant seems to do this

--
Create a clock component with 5000 ms. When the value is 3, show the message in a label. After that set the timer to enabled.
Inside the Clock.Timer event, set the message label to " " to delete it and set the timer to false.

-- 
i tried doing this and it didn't work. the image isn't displaying

-- 
Post your blocks.

--
so what i got is. when answer = 3 it will trigger a timer that should display the image for 5 secs. after 5 sec the timer should end and then the image will hide it self again. but i cant get the image to hide after 5 secs of it being up it will just stay  there

-- 
how do i show my blocks

-- 

how do i show my blocks

-- 

how do i show my blocks
search for screen capture here in the forum

--