Home Automation with Android app - Need some idea !

Hi all !

I did a home automation project using the arduino mega and an android app that I did it myself, and it's working very well, but today I found out a problem.

The problem is that when only one user is connected with android the system works, it displays the device status on the fly, but when another guy connects with android app and toggles some device status, the status is only updated on its screen, but not on the screen of the first guy too. In other words, the server only updates the status on the screen of who changes the status of the devices, but I need that when someone changes something, the changes be updated on all android screens that the app is open.

I'm using ethernet shield and http post requests, and my sketch disconnects the user after each request, I was thinking about doing the android requests the devices's status every second, but I think that it will not be viable and it could cause some delay on server's side.

What do you think guys ? Is there any better solution to do that ? Any idea ?

my sketch disconnects the user after each request

This is the problem.

I was thinking about doing the android requests the devices's status every second,

In my view

1)Whenever user run the app and SignIn it will update the status of device by generating the android request.

2) Put the button(GUI) in your app and whenever User press the button it will generate android request for the devices's status.

This is the problem.

No. That is what a server is SUPPOSED to do. Service a client and then forget that the client exists.

I was thinking about doing the android requests the devices's status every second, but I think that it will not be viable and it could cause some delay on server's side.

That is what you need to do. The client(s) need to make additional requests, if they want to know that something changed on the server. It is NOT the servers responsibility to push data.

I was thinking about doing the android requests the devices's status every second, but I think that it will not be viable and it could cause some delay on server's side. That is what you need to do. The client(s) need to make additional requests, if they want to know that something changed on the server. It is NOT the servers responsibility to push data.

I will give it a try, and see if it slows down the server's speed.

Anybody know how it works in commercials home automation apps ?

Thanks for replying guys.

PaulS:

This is the problem.

No. That is what a server is SUPPOSED to do. Service a client and then forget that the client exists.

Yes i know, "That is what a server" In my view if it will be clent and server is place some where on CLOUDS 8) "A Broker" sharing point for all client app.

kbssa:
Anybody know how it works in commercials home automation apps ?

Yes, If the Application support the long range controlling IoT.
Device → Online Cloud(Broker)<- Client Application