Tips for creating first own skill

Hey guys,

I have installed MyCroft on my Raspberry Pi and did the initial setup already. Paired my device etc.
Everything is working fine.

My main goal is to practice my Python skills. For that I want to create a new skills and play around a bit.
I’m looking for some tips or guidelines for beginners. Like what I should keep in mind when creating a skill.
I read the documentation and created a first new skill with mycroft-msk create. The skill is connected with my github account.

Now I want to add some more logic to the __init__.py .

What is the best way to develop?

I’m working on a windows machine and have my repository cloned on my PC. I work with PyCharm.
So whenever I do changes, I commit and push it to my repository.
And on my PiCroft I go to the /opt/mycroft/skills/my-skill folder and do a git pull.

Not sure if this is the way to go though.
Sometimes I just uninstall the skill and install it again.
My question is if there is some kind of workflow or things I have to be aware of when developing a new skill?

1 Like

Hi Zerato - welcome to the Forums!

Great to hear you’re looking at your first Mycroft Skill too.

I’ve seen many different workflows. A few of the more common ones:

  • Some people like to develop and test on their main machine, then push it to their dedicated Mycroft device. If you’re not running Linux on your primary machine this can be done in a VM.
  • Committing your changes to Github and pulling from there means you keep a comprehensive history of your changes. However others prefer to copy files directly to the device using scp or rsync and then push to github when they’ve verified it’s working.
  • I haven’t used it in a while but this Skill from Andlo runs a VS Code instance directly on your device letting you develop directly on the Pi meaning you can write code in a browser and every save will immediately be available on your Picroft.

Where ever you do your development, I’d also suggest writing some integration tests for your expected behaviour. This means you can quickly test any changes you make by running a single command:

mycroft-start vktest -t my-skill

This saves you the hassle of manually speaking or typing a range of utterances and then needing to listen/watch the individual output of each.

Particularly if you have a lot of tests, I like to add a tag for the functionality that I’m currently working on. You can see an example of that here:

Where one of the tests has been tagged with @wip (work in progress). Then you can run only those tests with:

mycroft-start vktest -t my-skill --tags=@wip

Alternatively you can tag tests you don’t want to run then exclude them using a ~ tilde:

mycroft-start vktest -t my-skill --tags=~@donotrun

Hope that helps and interested to hear from others if you have a particular workflow that works for you?

2 Likes

Hey,

thank you!

  • Some people like to develop and test on their main machine, then push it to their dedicated Mycroft device. If you’re not running Linux on your primary machine this can be done in a VM.

I’m not so familar with Linux but I want to try this out. For example if I work on my Windows PC on a VM, how can I push it directly to the Mycroft device?

Thanks for your help

with atom i used some sort of ssh-copy module, but lately using pycharm with mycroft running parallel or mycroft running in pycharm :slight_smile:

I’m going to add another question related to this topic for @gez-mycroft or anyone else. I usually learn by reading some basic docs, fiddling a little, dig into more docs about what I don’t understand, etc. So part of what I need to do this is to be able to put a print statement in the python code of a skill. I’ve done that and I know it works because I (dumbly) messed up the syntax and I got a syntax error in the cli skill log. But I rather expected the print output to go into the skill log as well. But nope–nothing. Where does print output go? Or is there a better way just to get some simple stuff like the values or types of variables? Or json structures? Or whatever?

Ok, I just found “log.info()” which does essentially what I want. Still curious where print goes, but not that important anymore.

FWIW, my eventual goal is to support the “Hubitat” home automation hub. I know there are other skills like HomeAssistant that I might be able to extend, but right now, just the basics :slight_smile:

1 Like

And finally to answer my own question, print DOES appear in the skills log (I just found the video!). I don’t know why I did not see it before. @gez-mycroft I hope you see this and do not waste your time answering my question.