Having trouble with message bus

Hi there - I built a mycroft on an orange pi plus. using armbian as the os. it working well and everything, the armbian is a miminal install, so it could be just a lack of prerequisites where my problem is arising. from .

any ways I want to build a spi screen interface. both local and remote ( possibly most probably based on mqtt) but I am having trouble getting the message bus to work for me

i tried your example

#! /usr/bin/env python3

import sys
from websocket import create_connection
uri = 'ws://' + sys.argv[1] + ':8181/core'
ws = create_connection(uri)
print("Sending " + sys.argv[2] + " to " + uri + "...")
if len(sys.argv) >= 4:
 data = sys.argv[3]
else:  
 data = "{}"

message = '{"type": "' + sys.argv[2] + '", "data": ' + data +'}'  
result = ws.send(message)  
print("Receiving..." )
result = ws.recv()  
print("Received '%s'" % result)
ws.close()  

python not my strongest suit i like perl more

but I get this as an error

  Traceback (most recent call last):
  File "./testpy3", line 5, in <module>
  uri = 'ws://' + sys.argv[1] + ':8181/core'
  IndexError: list index out of range

it probably something simple but since it python I not sure where to start

would some be kind enough to point me in the right direction…

I have been using python paho mqtt for ages now. It is rock solid. Just put a mosquitto server on one of you machines.

Speaking of the mqtt thing…we just finished cooking a roast using my custom meat probe based on a Adafruit featherm0 wifi with an lcd. It’s a pretty nice setup. I can select the type of meat using the lcd and let’r rip. It projects the finish time and I can monitor it on my notebook using a simple script that watches the mqtt messages. On my todo list is to create a MyCroft skill that monitors the meat probe.

1 Like

currently it not an issue with mqtt… my current issue is just to get mycroft message bus example to work. connect to the it and display data coming out of it so i can parse it .

I assume that is what the above mycroft example is about

never mind I as able to extract the data from the log files.
such as getting the song names for when I am streaming music
example

tail -f /var/log/mycroft/skills.log | grep -i ICY-META:

produces this every time the a new song change:

ICY-META: StreamTitle='Ava Max - Sweet but Psycho';
ICY-META: StreamTitle='Coldplay - Up&Up';
ICY-META: StreamTitle='NSG;Tion Wayne - Options';

now I can strip it a bit more and push the song title and artist to the Spi screen both locally and remotely

How did you call the python-script? sys.argv is a list of all parameters that are passed to the script when being called (argv[0] is the name of the script itself - “testpy3.py” in your case).

Error message “list index out of range” for sys.argv[1] means most likely that you didn’t pass any parameter at all.

Looking at the code you need to pass at least two parameters: 1) IP of the server running messagebus 2) the message-type to be sent over the bus. 3) optional: message-data

e.g. testpy3.py 127.0.0.1 mycroft.stop

1 Like

There is some simple code here that I use to remotely send an utterance to the message bus.

Might be helpful.

2 Likes