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

mqtt_subscriber signal crashes if used with another signal on the same synapse #573

Open vinpav opened 4 years ago

vinpav commented 4 years ago

Hi ! First of all notice that I've been using Kalliope for more than a year now and my version isn't up to date (must be the 5.1 release).

I recently tested the "mqtt_subscriber" signal and it looks like this signal is not working when used with an "order" signal in the same synapse.

For example :

  - name: "hello"
    signals:
      - mqtt_subscriber:
          broker_ip: "192.168.xx.xx"
          topic: "hello-topic"
    neurons:
      - say:
          message: "Hey there !"

Works as intended.

Whereas :

  - name: "hello"
    signals:
      - order: "salut"
      - mqtt_subscriber:
          broker_ip: "192.168.xx.xx"
          topic: "hello-topic"
    neurons:
      - say:
          message: "Hey there !"

Raises a python error (I don't have the stack trace unfortunately) when the mqtt_subscriber signal is triggered.

Did you experienced this error already ? Is this a bug ?

Thanks !

Sispheor commented 4 years ago

If you can provide the stack trace. Thanks for the synapse example, it's a good start for us.

vinpav commented 4 years ago

Here's the stack trace :

Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.1-py2.7.egg/kalliope/signals/mqtt_subscriber/mqtt_subscriber.py", line 33, in run list_broker_to_instantiate = self.get_list_broker_to_instantiate(self.list_synapses_with_mqtt) File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.1-py2.7.egg/kalliope/signals/mqtt_subscriber/mqtt_subscriber.py", line 65, in get_list_broker_to_instantiate if not any(x.broker_ip == signal.parameters["broker_ip"] for x in returned_list_of_broker): File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.1-py2.7.egg/kalliope/signals/mqtt_subscriber/mqtt_subscriber.py", line 65, in <genexpr> if not any(x.broker_ip == signal.parameters["broker_ip"] for x in returned_list_of_broker): TypeError: string indices must be integers, not str

I'm not sure but it seems that the synapse crashes only when there's an "order" signal after the "mqtt_subscriber" signal. The correct example to reproduce the error might be :

- name: "hello"
    signals:
      - mqtt_subscriber:
          broker_ip: "192.168.xx.xx"
          topic: "hello-topic"
      - order: "hello"
    neurons:
      - say:
          message: "Hey there !"
Sispheor commented 4 years ago

Thanks. I'll take a look.