Is there a way to use a particle cloud variable for this?

I’d like to have alerts on one photon controlled by the status of a pin on another photon. Ideally (for most up to date accuracy and code leanness) wouldn’t it be best to poll for the status of that variable? I guess the alternative would be to publish the status of the switch when its status changes…but isn’t there a chance a publish could get missed? Also seems like a slightly inefficient way of doing it? Maybe not?

(to help this query make sense: basically the use case is: Should alerts sound in the guest room? yes they should UNLESS the toggle switch in the kitchen is ON because we have guests in that room!

@daneboomer, this is a perfect project for Mesh! However, Photons are great also. In your case, a Photon can’t query another Photon’s variables. This leaves one of two choices. You use pub/sub but with a twist. The first Photon sends a pub to which the second Photon subscribes. The second Photon also sends an acknowledgement pub to which the first Photon subscribes to. So if a pub is sent by the first Photon and not acknowledged by the second Photon, the first Photon can retry.

Or, you can use direct TCP or UDP network messages. You can use UDP in a similar way to the pub/sub described. The first Photon sends a UDP message to the second Photon on your LAN. The second Photon then sends back an ACK message to the first. You get the idea.

I prefer the first scenario, since it is elegant and clean, with the caveat that if the Photons lose their Cloud connection, the messages will not work.

1 Like