How to invoke a function on edge device without connecting to the cloud


#1

Hello,

is it possible to call a function exposed by a device without connecting to the cloud ?
Let’s imagine a switch that needs to turn on a light. How can the switch call the “turn-on” function of the light without internet connection and so without calling the Cloud API ?
I think this is a very common scenario where edge devices need to communicate together even with unstable internet connection.
I imagine the new mesh devices will do the trick, but is this possible with Photons?

Thanks a lot for your inputs.


#2

Sure. You can control when the photon connects by using SEMI-AUTOMATIC or MANUAL connecting modes. If you don’t connect to the cloud then you have to use TCP or UDP to call your others device to turn on. Or hook them up to a GPIO pin or something. You cant call the cloud function directly but you should be able to work in another function that listens for a TCP packet and invokes the same underlying code. What are you trying to do specifically if you want more detail?


#3

Thanks a lot for your answer.
What I’m trying to do is a configurable “scene” controller. Let me explain:

  • Some photons act as “actuators”, they control RGB lights, linear actuators, servo motors etc…
  • One photon is the “scene controller”. The controller has some trigger inputs (ex: buttons, presence sensors, etc,) and can controll all the other photons.

This way the controller can be configured, for example, to turn on a light, play a sound, move something etc…
The hard part is the “configurability” of the controller. My idea is to let the the final user configure the controller uploading a file with rules and sequences of commands. In a second phase a web ui can be created to generate such file.
The file would contain a list of command; something like:
WHEN INPUT 1 TRIGGERED DO {LIGHT1/ON, LIGHT2/OFF, LIGHT3/OFF, MOTOR1/ON, PLAYER1/PLAY/TRACK1}.
The problem is resolving LIGHT1, LIGHT2, LIGHT3, MOTOR1, PLAYER1, which in my idea re the names of the photons which act like actuators.
If I could use the cloud that would not be a problem, but I’m trying to get indipendent from the internet connection.
In the configuration phase I can assume that the photons are connected to internet, and I will create a web app to configure them, but at runtime the controller must be able to control the Others calling them by name (or id) without relying on the Cloud.
If there were an mqtt server running on the photon I could use that. But I don’t think it exists.
Hope I could illustrate my idea.
If you have any suggestions I would really be glad to hear.


#4

That would be a textbook example for the upcoming mesh devices.

For the time being you could use UDP broadcast/multicast to do that without a MQTT broker, but you’d need a common WiFi network all devices can connect to.
You could also add a RPi to the setup which could act as MQTT broker.