Gpio skills not recognize


#1

-I am new to mycroft and working on rasp-berry pi 3 B+. I am doing btech final year project to control gpio using voice. I installed picroft unstable version 2018-09-12.
I installed picroft 8 switch relay skil gpio using command
msm install https://github.com/smolino/picroft_skill_gpio8s.git
It says sucessfully installed but when i use voice to access that it says sorry i cant understand.
I typed “skills” command in mycroft-cli-client then that shows the skill in red colour.
i tried example skill also same error.


i typed commands
sudo useradd -G gpio mycroft
sudo apt-get install rpi.gpio
sudo pip install GPIO
sudo apt-get install python-rpi.gpio && sudo apt-get install python3-rpi.gpio
please help me


#2

@vijay678,
Not sure if this helps but I have a working skill that I developed for a friend. It can be found here.


#3

It could be that you need to add the user to the gpio group. That is done with the command
On Mark_1 the user is mycroft, on Picroft the user is pi

sudo usermod -g gpio mycroft

#4

Check the logs, should have a message about why it failed to load.


#5

i tried
sudo usermod -g gpio pi
but it didnt solved


#6

In the virtual environment type sudo adduser mycroft gpio


#7

After the ˋadduserˋ you should log out and log in again (or perform a reboot) to see the effect.


#8

Welcome @vijay678, great to have you here.

There are a few things to try here.

  • The Skill is shown in the red colour because it could not load. This is usually because of a Python error. Around the middle of this year we switched from Python 2.7 to Python 3.4 read more about our change here. Some older Skills, written in Python 2.7, won’t work with newer versions of mycroft-core (18.8 and higher).

  • To find the errors that the Skill is showing, please provide your skills.log. This is at /var/log/mycroft/skills.log. You can find more information on Mycroft logs here. If I’m developing a Skill, I always do a tail -f on the skills.log to see if the Skill is throwing any errors.

Until we know more about what errors are occurring, it’s difficult to provide further assistance.


#9

these are the errors
15:14:11.771 - VolumeSkill - ERROR - Couldn’t allocate mixer, ALSAAudioError(‘Unable to find mixer control Master,0 [default]’,)
15:16:19.415 - msm.mycroft_skills_manager - ERROR - Error running install_or_update on mycroft-support-helper: GitException(Git command failed: GitCommandError([‘git’, ‘fetch’], 128, b"fatal: unable to access 'https://github.com/mycr~~~~

15:32:10.237 - mycroft.skills.core:load_skill:159 - ERROR - Failed to load skill: picroft_skill_gpio8s.smolino
Traceback (most recent call last):
File “/home/pi/mycroft-core/mycroft/skills/core.py”, line 126, in load_skill
imp.PY_SOURCE))
File “/usr/lib/python3.5/imp.py”, line 234, in load_module
return load_source(name, filename, file)
File “/usr/lib/python3.5/imp.py”, line 172, in load_source
module = _load(spec)
File “”, line 693, in _load
File “”, line 673, in _load_unlocked
File “”, line 673, in exec_module
File “”, line 222, in _call_with_frames_removed
File “/opt/mycroft/skills/picroft_skill_gpio8s.smolino/init.py”, line 46, in
import GPIO
File “/opt/mycroft/skills/picroft_skill_gpio8s.smolino/GPIO.py”, line 32
“GPIO4”:05,
^
SyntaxError: invalid token

15:32:31.930 - mycroft.skills.core:load_skill:159 - ERROR - Failed to load skill: rpi-gpio-skill.pcwii
Traceback (most recent call last):
File “/home/pi/mycroft-core/mycroft/skills/core.py”, line 126, in load_skill
imp.PY_SOURCE))
File “/usr/lib/python3.5/imp.py”, line 234, in load_module
return load_source(name, filename, file)
File “/usr/lib/python3.5/imp.py”, line 172, in load_source
module = _load(spec)
File “”, line 693, in _load
File “”, line 673, in _load_unlocked
File “”, line 673, in exec_module
File “”, line 222, in _call_with_frames_removed
File “/opt/mycroft/skills/rpi-gpio-skill.pcwii/init.py”, line 21, in
class GPIOSkill(MycroftSkill):
File “/opt/mycroft/skills/rpi-gpio-skill.pcwii/init.py”, line 67, in GPIOSkill
@intent_handler(IntentBuilder(‘TestCustomIntent’).require(self.myKeywords)
NameError: name ‘intent_handler’ is not defined

15:33:10.751 - mycroft.skills.core:load_skill:159 - ERROR - Failed to load skill: picroft_example_skill_gpio.mycroftai
Traceback (most recent call last):
File “/home/pi/mycroft-core/mycroft/skills/core.py”, line 126, in load_skill
imp.PY_SOURCE))
File “/usr/lib/python3.5/imp.py”, line 234, in load_module
return load_source(name, filename, file)
File “/usr/lib/python3.5/imp.py”, line 172, in load_source
module = _load(spec)
File “”, line 693, in _load
File “”, line 673, in _load_unlocked
File “”, line 673, in exec_module
File “”, line 222, in _call_with_frames_removed
File “/opt/mycroft/skills/picroft_example_skill_gpio.mycroftai/init.py”, line 56, in
import GPIO
File “/opt/mycroft/skills/picroft_skill_gpio8s.smolino/GPIO.py”, line 32
“GPIO4”:05,
^
SyntaxError: invalid token


#10

i did “sudo reboot” several times


#11

OK, there are several issues here;

15:32:10.237 - mycroft.skills.core:load_skill:159 - ERROR - Failed to load skill: picroft_skill_gpio8s.smolino
Traceback (most recent call last):
File “/home/pi/mycroft-core/mycroft/skills/core.py”, line 126, in load_skill
imp.PY_SOURCE))
File “/usr/lib/python3.5/imp.py”, line 234, in load_module
return load_source(name, filename, file)
File “/usr/lib/python3.5/imp.py”, line 172, in load_source
module = _load(spec)
File “”, line 693, in _load
File “”, line 673, in _load_unlocked
File “”, line 673, in exec_module
File “”, line 222, in _call_with_frames_removed
File “/opt/mycroft/skills/picroft_skill_gpio8s.smolino/init.py”, line 46, in 
import GPIO
File “/opt/mycroft/skills/picroft_skill_gpio8s.smolino/GPIO.py”, line 32
“GPIO4”:05,
^
SyntaxError: invalid token

This error is caused because both GPIO 04 and 05 have leading zeroes assigned. This is not allowed in Python 3. I suspect this Skill has been written for Python 2, not for Python 3.

See this Stack Overflow error for more information. You may need to remove the leading zeroes to get the Skill to work under Python 3.

15:32:31.930 - mycroft.skills.core:load_skill:159 - ERROR - Failed to load skill: rpi-gpio-skill.pcwii
Traceback (most recent call last):
File “/home/pi/mycroft-core/mycroft/skills/core.py”, line 126, in load_skill
imp.PY_SOURCE))
File “/usr/lib/python3.5/imp.py”, line 234, in load_module
return load_source(name, filename, file)
File “/usr/lib/python3.5/imp.py”, line 172, in load_source
module = _load(spec)
File “”, line 693, in _load
File “”, line 673, in _load_unlocked
File “”, line 673, in exec_module
File “”, line 222, in _call_with_frames_removed
File “/opt/mycroft/skills/rpi-gpio-skill.pcwii/init.py”, line 21, in 
class GPIOSkill(MycroftSkill):
File “/opt/mycroft/skills/rpi-gpio-skill.pcwii/init.py”, line 67, in GPIOSkill
@intent_handler(IntentBuilder(‘TestCustomIntent’).require(self.myKeywords)
NameError: name ‘intent_handler’ is not defined

This usually indicates a function or variable scope issue. I actually think this code block is in the wrong spot, but I’m not sure.

15:33:10.751 - mycroft.skills.core:load_skill:159 - ERROR - Failed to load skill: picroft_example_skill_gpio.mycroftai
Traceback (most recent call last):
File “/home/pi/mycroft-core/mycroft/skills/core.py”, line 126, in load_skill
imp.PY_SOURCE))
File “/usr/lib/python3.5/imp.py”, line 234, in load_module
return load_source(name, filename, file)
File “/usr/lib/python3.5/imp.py”, line 172, in load_source
module = _load(spec)
File “”, line 693, in _load
File “”, line 673, in _load_unlocked
File “”, line 673, in exec_module
File “”, line 222, in _call_with_frames_removed
File “/opt/mycroft/skills/picroft_example_skill_gpio.mycroftai/init.py”, line 56, in 
import GPIO
File “/opt/mycroft/skills/picroft_skill_gpio8s.smolino/GPIO.py”, line 32
“GPIO4”:05,
^
SyntaxError: invalid token

This is again the “leading zeroes” problem.


#12

skills.log errors

16:27:17.685 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
16:27:20.190 - SKILLS - DEBUG - {“type”: “mycroft-date-time.mycroftai:TimeSkillupdate_display”, “data”: {}, “context”: null}
16:27:21.193 - SKILLS - DEBUG - {“type”: “mycroft-reminder.mycroftai:reminder”, “data”: {}, “context”: null}
16:27:29.041 - mycroft.skills.settings:_poll_skill_settings:389 - ERROR - Failed to fetch skill settings: ReadTimeout(ReadTimeoutError(“HTTPSConnectionPool(host=‘api.mycroft.ai’, port=443): Read timed out. (read timeout=3.05)”,),)
Traceback (most recent call last):
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 343, in _make_request
self._validate_conn(conn)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 849, in validate_conn
conn.connect()
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connection.py”, line 356, in connect
ssl_context=context)
File "/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/util/ssl
.py", line 359, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File “/usr/lib/python3.5/ssl.py”, line 385, in wrap_socket
_context=self)
File “/usr/lib/python3.5/ssl.py”, line 760, in init
self.do_handshake()
File “/usr/lib/python3.5/ssl.py”, line 996, in do_handshake
self._sslobj.do_handshake()
File “/usr/lib/python3.5/ssl.py”, line 641, in do_handshake
self._sslobj.do_handshake()
socket.timeout: _ssl.c:704: The handshake operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/requests/adapters.py”, line 449, in send
timeout=timeout
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/util/retry.py”, line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/packages/six.py”, line 686, in reraise
raise value
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 600, in urlopen
chunked=chunked)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 346, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 306, in _raise_timeout
raise ReadTimeoutError(self, url, “Read timed out. (read timeout=%s)” % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘api.mycroft.ai’, port=443): Read timed out. (read timeout=3.05)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/pi/mycroft-core/mycroft/skills/settings.py”, line 386, in _poll_skill_settings
self.update_remote()
File “/home/pi/mycroft-core/mycroft/skills/settings.py”, line 364, in update_remote
skills_settings = self._request_my_settings(hashed_meta)
File “/home/pi/mycroft-core/mycroft/skills/settings.py”, line 481, in _request_my_settings
settings = self._request_settings()
File “/home/pi/mycroft-core/mycroft/skills/settings.py”, line 499, in _request_settings
“path”: self._api_path
File “/home/pi/mycroft-core/mycroft/api/init.py”, line 65, in request
return self.send(params)
File “/home/pi/mycroft-core/mycroft/api/init.py”, line 136, in send
data=data, json=json_body, timeout=(3.05, 15)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/requests/api.py”, line 60, in request
return session.request(method=method, url=url, **kwargs)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/requests/sessions.py”, line 524, in request
resp = self.send(prep, **send_kwargs)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/requests/sessions.py”, line 637, in send
r = adapter.send(request, **kwargs)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/requests/adapters.py”, line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host=‘api.mycroft.ai’, port=443): Read timed out. (read timeout=3.05)
16:27:30.210 - SKILLS - DEBUG - {“type”: “mycroft-date-time.mycroftai:TimeSkillupdate_display”, “data”: {}, “context”: null}
16:27:38.225 - SKILLS - DEBUG - {“type”: “mycroft-configuration.mycroftai:ConfigurationSkillupdate_remote”, “data”: “UpdateRemote”, “context”: null}
16:27:38.244 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
16:27:39.764 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
16:27:40.230 - SKILLS - DEBUG - {“type”: “mycroft-date-time.mycroftai:TimeSkillupdate_display”, “data”: {}, “context”: null}
16:27:43.672 - ConfigurationSkill - WARNING - Failed to update settings, will retry later
16:27:48.800 - mycroft.skills.settings:_poll_skill_settings:389 - ERROR - Failed to fetch skill settings: ReadTimeout(ReadTimeoutError(“HTTPSConnectionPool(host=‘api.mycroft.ai’, port=443): Read timed out. (read timeout=3.05)”,),)
Traceback (most recent call last):
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 343, in _make_request
self._validate_conn(conn)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 849, in validate_conn
conn.connect()
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connection.py”, line 356, in connect
ssl_context=context)
File "/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/util/ssl
.py", line 359, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File “/usr/lib/python3.5/ssl.py”, line 385, in wrap_socket
_context=self)
File “/usr/lib/python3.5/ssl.py”, line 760, in init
self.do_handshake()
File “/usr/lib/python3.5/ssl.py”, line 996, in do_handshake
self._sslobj.do_handshake()
File “/usr/lib/python3.5/ssl.py”, line 641, in do_handshake
self._sslobj.do_handshake()
socket.timeout: _ssl.c:704: The handshake operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/requests/adapters.py”, line 449, in send
timeout=timeout
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/util/retry.py”, line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/packages/six.py”, line 686, in reraise
raise value
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 600, in urlopen
chunked=chunked)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 346, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 306, in _raise_timeout
raise ReadTimeoutError(self, url, “Read timed out. (read timeout=%s)” % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘api.mycroft.ai’, port=443): Read timed out. (read timeout=3.05)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/pi/mycroft-core/mycroft/skills/settings.py”, line 386, in _poll_skill_settings
self.update_remote()
File “/home/pi/mycroft-core/mycroft/skills/settings.py”, line 364, in update_remote
skills_settings = self._request_my_settings(hashed_meta)
File “/home/pi/mycroft-core/mycroft/skills/settings.py”, line 481, in _request_my_settings
settings = self._request_settings()
File “/home/pi/mycroft-core/mycroft/skills/settings.py”, line 499, in _request_settings
“path”: self._api_path
File “/home/pi/mycroft-core/mycroft/api/init.py”, line 65, in request
return self.send(params)
File “/home/pi/mycroft-core/mycroft/api/init.py”, line 136, in send
data=data, json=json_body, timeout=(3.05, 15)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/requests/api.py”, line 60, in request
return session.request(method=method, url=url, **kwargs)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/requests/sessions.py”, line 524, in request
resp = self.send(prep, **send_kwargs)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/requests/sessions.py”, line 637, in send
r = adapter.send(request, **kwargs)
File “/home/pi/mycroft-core/.venv/lib/python3.5/site-packages/requests/adapters.py”, line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host=‘api.mycroft.ai’, port=443): Read timed out. (read timeout=3.05)


#13

That whole block of errors is basically saying that your device couldn’t contact home.mycroft.ai; it shouldn’t have a bearing on the functionality of your Skill.


#14

ok thank you @KathyReid
but I am new to mycroft i dont know how to modify those skills


#15

As a starting point, try removing the leading zeroes from the GPIO pins that have 05 and 06 assigned, and see if that loads the Skill.


#16

sorry for using your time more
please give me commands to access and modify that GPIO pins


#17

hi @vijay678

If you are not familar with commands to edit files on your raspberrypi, I wouldnt recoment you to try to install and use skills that Arent in the mycroft market.

But when that said, there is lots of guides and instructions n how to edit files, navigate around in the shell and all that Linux stuff.
After this, there is mycroft documentation.

And then do ask questions and reach out for help but be specifik on your questions. Then you eventualy will get the knoledege to make your GPIO skill work :slight_smile:

In short - Navigate to the skills directory bu using the cd command. Edtit the file using the nano editor. Like this

cd /opt/mycroft/skills/picroft_skill_gpio8s 
nano __init__.py

When you exit the nano editor remember to save the file. When that is done mycroft automactly reloads the skill, and then you can look for if there is other problems in the log and try fix that the same way.

When everything is done and it works for you, you could go further and fork the original GitHub repo, add your changes and make a pull request back to the original repo.
Then the next one wants to do what you did, dosnt have to go throu same problems.


#18

Thank you @andlo
Definitely I will try it.


#19

@KathyReid, @vijay678, The gpio skill i wrote was very crude and not really ready for community consumption, just demonstrated skill development wuth a new mycroft convert, with that said it was written for Python 3 so don’t think that is the issue. Might be something else going on with some legacy code i was playing with. Will try to have a look in next 24 hours.


#20

I removed some incomplete code that I was playing with and accidentally pushed to the repo, I am pretty sure it was the source of your issues. msm update should get the gpio skill working again. There is no implied warranty :yum: