self.add_event('speak', self.yourHandler) # this will call the function/method yourHandler everytime a speak-event is triggered
def yourHandler(self, message):
response = message.data.get("utterance") # this extracts the utterance from the event
print(response) # prints the utterance part from the Event in CLI
I have a couple of what are probably very stupid questions.
Does this have to run on the Mark I itself? I tried running the code that @pcwii provided, and it seems to work, but fails in the end. A quick nmap shows that port 8181 (from @KathyReid) isn’t open. Only port 22.
On the Mark I, doing a straight up pip install of the websocket library fails because it doesn’t think pip is installed. pip is there, but in the Mycroft core virtual environment. If I just do an apt-get install python-pip, it’s wanting me to install a host of things, and I’m trying not to hose up my Mark I. Is it safe to do an apt-get install pip on these things?
I apologize in advance for these questions. I admit that I’m mucking around in things that are outside of my comfort zone and over my head for the most part. I appreciate your patience.
Sure, but the errors are pretty uninteresting. I’m using the code @pcwii posted last week exactly other than updating IP information to actually point to my Mark I. That’s here:
When I execute that code, I get this output after quite some time:
Traceback (most recent call last):
File “test.py”, line 22, in
send_message(‘speak, hello’)
File “test.py”, line 17, in send_message
ws = create_connection(url)
File “/usr/local/lib/python2.7/dist-packages/websocket/_core.py”, line 494, in create_connection
websock.connect(url, **options)
File “/usr/local/lib/python2.7/dist-packages/websocket/_core.py”, line 217, in connect
options.pop(‘socket’, None))
File “/usr/local/lib/python2.7/dist-packages/websocket/_http.py”, line 120, in connect
sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
File “/usr/local/lib/python2.7/dist-packages/websocket/_http.py”, line 186, in _open_socket
raise error
socket.error: [Errno 110] Connection timed out
I don’t think it’s anything to do with the code, which seems pretty straight forward. I did do an nmap of the system, and the only open port is showing as 22, and if the MessageBus operates on 8181 I’m not sure how it would establish a connection from outside of the Mark I.
It’s on my main computer, which is running Mint 19. It is running under Python 2.7, but the results are the same if I run it with Python 3.6, which I also have installed.
Traceback (most recent call last):
File "test.py", line 22, in <module>
send_message('speak, hello')
File "test.py", line 17, in send_message
ws = create_connection(url)
File "/home/mike/.local/lib/python3.6/site-packages/websocket/_core.py", line 494, in create_connection
websock.connect(url, **options)
File "/home/mike/.local/lib/python3.6/site-packages/websocket/_core.py", line 217, in connect
options.pop('socket', None))
File "/home/mike/.local/lib/python3.6/site-packages/websocket/_http.py", line 120, in connect
sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
File "/home/mike/.local/lib/python3.6/site-packages/websocket/_http.py", line 186, in _open_socket
raise error
File "/home/mike/.local/lib/python3.6/site-packages/websocket/_http.py", line 170, in _open_socket
sock.connect(address)
TimeoutError: [Errno 110] Connection timed out
I’m trying to connect to a Mark I unit, but port 8181 doesn’t seem open.
Silly question, is ssh enabled on the Device - ie have you used the button on the top to enable ssh - it seems like a silly question but I often forget to do it after a reimage.
Nope, my laptop and the Mark I are on the same internal network. No firewall between them. The only slight variation (and this sounds weird) is that my laptop is wired to the network, and the Mark I is wireless. They’re connected to the exact same router though.
OK, check to see whether your router has something called “wireless isolation” turned on. It’s kinda like a firewall between wired and wireless devices.
As far as I can tell, my router doesn’t have anything called that on or off. I wasn’t able to locate any settings in my router configuration like that.
@linuxrants, @KathyReid
Thought I would chime in on this. if you used my code as is I had the IP address for my device hardcoded.
This should be changed to the IP address of your Mark1.
No problem, thought I would be sure. Just an FYI my route has a setting called AP isolation I think that is the same thing. Are you able to execute the code on a device that is also on wifi and not hardwired?
No. I tried from my work computer and that didn’t work, but it’s Windows and who knows what the heck is going on there. I also tried it on another Linux workstation I have in the house, with the same results. I thought this might be relevant.
nmap -Pn TheCorrectIPAddressIsHere -p 8181
Starting Nmap 7.60 ( https://nmap.org ) at 2018-07-11 13:46 MST
Nmap scan report for mark_1 (TheCorrectIPAddressIsHere)
Host is up.
PORT STATE SERVICE
8181/tcp filtered intermapper
Nmap done: 1 IP address (1 host up) scanned in 2.11 seconds
I get this from both Linux workstations I try to use.
Not sure, your troubleshooting tools are not familiar to me. A simple thing that I did here was enter the ip_address:8181 in my browser on my remote linux computer and returned the following.
Traceback (most recent call last):
File “/opt/venvs/mycroft-core/lib/python3.4/site-packages/tornado/web.py”, line 1390, in _execute
result = self.prepare()
File “/opt/venvs/mycroft-core/lib/python3.4/site-packages/tornado/web.py”, line 2103, in prepare
raise HTTPError(self._status_code)
tornado.web.HTTPError: HTTP 404: Not Found
For the record I have a debian machine hardwired to my network and a picroft on wireless.
I have a working version now. I felt we were getting a little too far into the weeds troubleshooting my local network, so I moved the code onto my Mark I and used the virtual environment that Mycroft itself uses. After one very stupid mistake this morning, it’s working. I appreciate your time and patience, and that of @KathyReid.