You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can I just start listening for incoming data using Shelly.addEventHandler()?
Why not create a typical "publisher/subscriber" example, combined with a HTTPServer? The publisher sends an event over the websocket to the subscriber, and the subscriber sets the received value in KVS. That way, there's no dependency on external components and it'd provide a great starting point to connect other devices.
Thanks for considering! 😊
The text was updated successfully, but these errors were encountered:
wimleers
changed the title
Example script with outbound websocket relaying information
Outbound websocket example: publisher/subscriber to provide a working starting point?
Oct 6, 2023
Maybe the example is misleading a bit. In a Shelly the transport is not related to the notification mechanism. One may have MQTT and oubound WebSocket channels open and publish notifications over them. Or receive RPC requests. One can communicate directly with a script by calling the Script.Eval method if he knows which script id the script has.
To directly communicate with the device you can add an http endpoint handler in a script or subscribe for an MQTT topic:
https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Ws shows it's possible to create outbound websockets from scripts. Cool.
But all it provides in terms of showing how to communicate is this:
There's only one very vague example in this repo:
shelly-script-examples/ble-ruuvi.js
Line 117 in 5a7ab80
Can I just start listening for incoming data using
Shelly.addEventHandler()
?Why not create a typical "publisher/subscriber" example, combined with a
HTTPServer
? The publisher sends an event over the websocket to the subscriber, and the subscriber sets the received value in KVS. That way, there's no dependency on external components and it'd provide a great starting point to connect other devices.Thanks for considering! 😊
The text was updated successfully, but these errors were encountered: