-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proof of Concept: MQTT database/provider #548
base: master
Are you sure you want to change the base?
Conversation
Move (de)serialization to separate functions, remove unneccesary console.log
To allow differentiating from #outgoing
From public MQTT of hackerspace Bitraf, http://iot.bitraf.no
i = range[from: 1 to: 3] | ||
|
||
commit @mqtt | ||
[#message #outgoing topic: "eve/test/" + i, payload: i] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't know that we overloaded + in this way? pretty sure the preferred syntax here would
be 'interpolation', as in "eve/test/{{i}}". this inherits implicit string conversion from JS, but
i think there is an ongoing discussion about how much implicit string conversion makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just what I instincivally reached for as a first-day Eve programmer, and it worked, so I didn't change it. :D Agreed that string interpolation is preferred, it is easier to understand the code, and it is less magical than implicit string conversions (which I don't think are very nice at all).
sensor = [#bitraf #temperature name topic] | ||
search @mqtt | ||
message = [#message #incoming topic: topic, payload] | ||
sort[value: payload, per: topic] = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the intent here? does the payload for each topic contain historical samples that you
want to throw away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each message (on that topic) contains a payload with a temperature value. The sensors send such messages at a fixed messages intervals (every minute in our case, I think). And since the search is for messages, without a sort/filter I get all these messages, including things which are long in the past.
i just looked briefly at the MQTT spec, but since its a pub sub model, don't you think it would be its kind of sad, because the analyze phase can actually look at the eve listeners and
|
@convolvatron Not sure I don't understand what you mean by "i just looked briefly at the MQTT spec, but since its a pub sub model, don't you think it would be best if this state were modeled explicitly in the mqtt database?". Which state are you referring to? The latest value from a topic? (as in the example) |
@convolvatron Re 3, is "current eve time" associated with a real-world time/date, so I can based on that query for things from November 14? If so, then I think that would be enough. |
Agreed on 5) error handling, putting in records seems like the natural way to go. |
re: "current eve time" - yes, this isn't 100% cooked, but its either the real time to the best of our ability, or eventually it may be a virtual time, which is is strongly correlated to wall clock time but may also indicate a global serialization order wrt pub sub model - again, i don't know, but the protocol spec looks like you explicitly contact the broker to subscribe to topics (and presumably the broker works with other brokers to build a distribution tree). so the state i'm referring to is 'which topics i care about'. is that a thing :) ? |
Yes, client must ask the broker to be subscribed to a set of topics. This is often a topic name like The code now does a hacky subscribe to everything ( It may make sense to then require Afaik, there is no broker-to-broker communication specified in the MQTT protocol. But a broker like Mosquitto allows to "overlay" a set of topics from another broker into a certain prefix. So sending on 'temperature/sensor1' on broker A, may then appear on broker B under |
It's sounding like this integration should now be possible using the newly |
Absolutely, this has been one of my motivating examples behind the new API. It still needs a polish pass, but @cmontella is working on a survival guide to the new DSL and watcher interface. If you have time to try this out, please let us know any thoughts you have on what works and what doesn't about it, and if you have questions feel free to ping me here or on the mailing list. |
NOTE: This is a quick hack, from playing with Eve and trying to apply it to embedded devices and the physical world. The code is not intended to be merged as-is, just using a PR to have the code available for the discussion.
Background
MQTT is a message broker protocol, commonly for connected embedded devices / IoT / "Internet of Things".
MQTT can be supported on client-side using a WebSocket bridge. Mosquitto, one of the most common brokers, supports this out-of-the-box (behind a configuration option). Only Node.js support is implemented here, so far.
Open questions
[#message #incoming broker: mqtt.bitraf.no topic: 'foo/somename' ]
. I'm inclined to say yes, as this makes it a generic transport, usable with 0, 1 or many brokers, with the decisions being done by the Eve programs (not the runtime).myorganization/temperature/office/value
adds tagsmyorganization
temperature
office
value
. Might be nifty, but a bit automagical. Better if done via a separate Eve block, which splits the MQTT topic path, and "enriches" the records with tags?