kalliope-project / kalliope

Kalliope is a framework that will help you to create your own personal assistant.
https://kalliope-project.github.io/
GNU General Public License v3.0
1.71k stars 230 forks source link

Neuron mqtt subscriber #467

Open Sispheor opened 6 years ago

Sispheor commented 6 years ago

Connect to a broker, read a value and quit. Because the existing signal mqtt will trigger an action on each received message. With a neuron, we could have a message on demand.

ghost commented 6 years ago

I still did not had installed Kalliope due to the fact I want fist to stabilize the pairing between my RPi 3 and a bluetooth speaker.

My next requirement will be to install a MQTT broker on the same RPi. For that I found a lightweight broker called Moquette.

As Sispheor said it should then be interresting to get MQTT feedback on demand (Example : "Which day are we ?") but it should also interesting that Kalliope give information when a MQTT has been triggered (Example : ."I detected movement around your car" - message said when I am sleeping "There is water on the ground at ..." - by supposing the wash machine is loosing water).

I have to recognize I still did not had study how MQTT return work but by considering they could be trigger by generating a structured JSON/text file that Kalliope could then use (and archive when the user confirmed he take care about this last information) then I presume it should be easy for Kalliope to react (trigger) when a MQTT result has just be send to the broker. It "just need" to be filter like : will be said on demand, have to been send now (due to security reason), will be said following calendar/time (like when I wake up or come back at home), ...

Then I propose to : 1) test if Kalliope could work on the same RPi 3 with Moquette and a lightweight Dashboard named Crouton 2) check how Moquette could generate a file (JSON or text) and 3) how this "external" file should be structured to allow Kalliope to filter it (on demand, direct, timing, delete or archive (default) when confirmed, ...) then 4) test Kalliope to extract file content (command line) to say the file content based on the structure used 5) the archived events could then be asked to Kalliope to remember us (on demand or if new events become reccurent) when something happend.

Sispheor commented 6 years ago

What you are looking for is almost covered in the mqtt signal.

Sispheor commented 6 years ago

And BTW you should at first try kalliope :)

I keep this issue opened because I still want to create a neuron to get one shot info from a broker that save state.

The example is: A device push the current temperature every minute in the broker. If we use the mqtt signal, we would make kalliope speaking every minute. Or we want to have the temperature only on demand. For this we need a dedicated mqtt neuron.

ghost commented 6 years ago

You right. I want first to get Kalliope available then I will test cling it to another SD card to see if they both Kallipe and Moquette work together. Then with Crouton.

But I still have to stabilize the pairing with the bluetooth speaker before installing Kalliope.

You also right with the answer Kalliope must return on demand from a last MQTT value the broker received.

As you want to take this neuron in one shot this is why I first gave my opinion and then recommand to take care about those aspects : 1) MQTT events known by the broker does not have to only be announced on demand but well 2) also at desired moment time/date/calendar (example : I come back home I want Kalliope could tell me what I want to know at this moment and 3) also at desired events (example : even if I am sleeping (time zone) I want Kalliope could advise me some security alert)

What I means is the fact, for a one shot, your neuron has to foreseen some further aspects than only saying last each MQTT triggered events received on the broker.

As I still does not know how to use neuron and MQTT (I will use as far as possible) I sincerely appreciate your approach I will certainly use. Thanks for your work on this one.

Sispheor commented 6 years ago

The "desired moment" is handled by a signal called "event" . Please read the doc, play with kalliope and then we'll talk about enhancement. Thanks.