A Prototype Kodi Skill

Hello,

Over the weekend I got Mycroft up and running on my desktop machine and then decided to start trying to write skills. After teaching Mycroft to tell me how many GitHub notifications I have, I thought I would start working on a Kodi skill, seeing how I couldn’t find anyone else who had started.

So far, I have only made it do a search for Films in the database and play them, so you can say things like:

“Mycroft, play the film The Matrix”

or if you ask it:

“Mycroft, find films containing Star Trek”

it will list out all the films with the query string in the title.

You can see what I have got so far here: https://github.com/Cadair/mycroft-kodi, you will need to change the hard-coded IP address to make it connect to your Kodi instance.

If anyone has any ideas for improving the code, especially the Mycroft side, please let me know, and if anyone else is already working on this we should combine efforts.

Stuart

4 Likes

Hi @Cadair,

I had planned to work on a Kodi Skill just after finishing my esp8266 Skill. It’s a good thing that you started the dev of the Kodi Skill because I don’t have experience in Kody API :smiley:

I’ll gladly help you to improve the Kodi Skill. :wink:

Nice work by the way !

What does your esp8266 skill do? I have been meaning to make my esp actually do something for ages…

I had no experience with the JSON-RPC API till Saturday either! :smiley:

Pull requests, issues etc very welcome.

This is awesome @Cadair - we’ve been talking about installing Kodi on the actual unit itself, which would make the IP (localhost). Is there a library for finding Kodi instances on the local network? Anyway, I love this, I’ll try it out this week. Thanks man! Great work!

There is a way to do network detection, I have seen the functionality on android remote apps etc. (Not that it always works perfectly).

One of the things I do have in mind for later on is selection and control of multiple instances of Kodi, I have quite a few around the house. Also I need to look into the skills preferences system for a better way of specifying kodi hosts, maybe with a nickname. Then you could do something like “Mycroft, in the lounge play film the matrix”.

My more immediate plans are to make, play/pause and stop work, then TV searching and playback work.

Currently, it’s extremely basic. I can turn on/off a led by voice : https://github.com/Dark5ide/mycroft-core/tree/feature/esp8266/mycroft/skills/esp8266 (I branched all the repo ^^).
I didn’t yet push the Arduino code of my esp8266 on GitHub.

My goal is to use some command keyword and module keyword and make understand to Mycroft to which module sends the command.
Exemple :

Mycroft, turn the mood light on”, then Mycroft send “light = on” to the correct esp8266 connected to the switch of my mood light.

I plan to add some parameters in the configuration file ( ~/.mycroft/mycroft.ini) like :
[Esp8266Skill] esp8266 = ['192.168.1.x', '192.168.1.y', ...] # or ['esp8266_1.local', 'esp8266_2.local', ...] with mDNS module = ['mood_light', 'bedside_lamp', 'TV', 'fan', 'led0', 'led1', ...] commands = ['turn on', 'turn off', 'increase volume', 'next channel', ...]

Currently, the commands are based on a http request but I would like to implement a websockets client in the esp8266 code.

I had no experience with the JSON-RPC API till Saturday either! :smiley:

Haha, nice :stuck_out_tongue:, so let us work together to master this Kodi part for an awesome Kodi Skill :wink:

@ryanleesipes I am trying to write some tests for my skill, I am currently running it in ~/.mycroft/third_party_skills and your test runner doesn’t seem to be detecting them. Do you have any suggestions?

Has anyone played with storing persistent data on a mycroft instance? Maybe a simple key-value store? Could be useful in the case of a script that scans the network and finds Kodi Instances, allowing a user setting up a mycroft instance the ability to select which Kodi instances you want to set up access to. Might also be nice for situations where you want to send a quick command and Mycroft should know which instance you want to use, say the kodi system in the room, versus muting your roommate’s instance after 1 AM. Setting and remembering a default Kodi installation would be key in a mult-installation home.

How about using the config file (~/.mycroft/mycroft.ini) ?

Is that safe? I know I typically avoid flat file persistent storage like that because of the risk of multiple threads accessing the file at the same time, losing one set of changes. What about reloading of that file? Is that something currently supported, and if so, would a reload affect all other skills or target just the skill calling for a reload?

I guess that this is a bigger/broader question then. Maybe there is a preferred way to add “services” for skills to use, and we could use that to do something like a RethinkDB installation with some basic exposed mutator methods for skills to utilize.

Still having problems running the skill in the third party directory @Cadair?

@Cadair I started working on a Kodi Skill. It has an autodiscover mechanism and some functionality to play movies by name. I want to adjust the autodiscover to use async requests and add the notion of multiple instances of kodi. It’s been a little bit since I’ve worked on it, but I plan on picking it back up now that I have a little more free time.

Here is a link to my repository if you want to check it out:

1 Like

hey @undefined

We should combine forces!

I will go over your repo when I get a bit of time, if you have a good look over mine we should be able to work out what features each one has and which way is better to graft one on to the other.

I see that you are doing the http requests directly where as I use https://github.com/haikuginger/kodipydent, yours removes the dependency but adds more code. Which approach do you think is better?

1 Like

@Cadair That sounds great! I’ve just recently got my NAS back up and running and can’t wait to get a solid kodi skill going for Mycroft.

This was the first time I’ve worked with python. I decided to create the API client myself just for fun and to get a better handle on the language. I wrote a similar skill for Amazon Alexa using NodeJS, so I was mostly just adjusting the code I already had. It would probably make more sense to use a vetted library. The one you linked looks good. I’ll try it out tomorrow. Here was a library I came across that we could also consider using:
https://github.com/Arn-O/py-kodi-remote-controller

I saw that one, but unless I am mistaken it only works on the audio library.

Hi Cadair,

Please forgive me but I am a noob when it comes to mycroft ai and linux. I have been trying for sometime to get your kodi skill to work and that of undefined’s both without any luck.

I was able to run the test.py in undefined’s skill with success so i know i can talk to my kodi instance but I cannot get either of them to work in mycroft. I believe there should be a KodiSkill folder created under the ~/.mycroft/skills folder but this isn’t working.

I am running mycroft on Ubuntu 16.04 LTS.

Can you please provide any assistance also some guidance as to where I can find the log files for the kodi skill?

Thanks

Where did you get mycroft to run your desktop?