Mycroft - OpenHab2 Skill

Been following and playing around with Mycroft and OpenHab2, A post by Tommy who worked on an integration of mycroft and openhab2 via rest api

If no one had seen it before here it is.


repositroy moved here:


Hi Mortommy,

When trying to install this skill I get the following error message.

Can you assist?

the error is related to one of the dependence. Could you verify if you have installed build-essential package?

dpkg -l build-essential

Hi Mortommy,

below is the output of a vanilla picroft setup:
root@picroft:/home/pi# dpkg -l build-essential Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-=====================================================-===============================-===============================-=============================================================================================================== ii build-essential 11.7 armhf Informational list of build-essential packages
The path seems to be a bit off:
python2.7 is in /usr/local/lib/python2.7 and in /usr/local/local/lib/python2.7 rather than in /usr/lib/ directly

Hi @mortommy,

I’m pleased to say my Mycroft 1 is now able to control my OpenHAB2 system (yay!), and am impressed with my new ability to control devices by voice! :smiley: :sparkler:

The best part is openhab-skill connects directly to OpenHAB2 via the local REST API, without the need to go via an external MyOpenHAB portal - this architecture feels a lot more secure to me.

I’d like to report two skill bugs which I had to patch locally to get the skill working - both are likely part of recent commits to add internationalisation.

My software engineering skills are rusty, so a github pull-request is beyond me - at least for the moment! :slight_smile:

Bug 1 - “it-it” test causes SyntaxError
After finding via msm, that the openhab-mycroft skill would not start, I started debugging by looking for issues in the skill log file:

$ apt list --installed |grep mycroft-core
mycroft-core/unknown,now 0.9.13 armhf [installed]

$ vim /var/log/mycroft-skills.log

18:24:02.226 - mycroft.skills.core:load_skill:163 - ERROR - Failed to load skill: openhab-mycroft
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/mycroft_core-0.9.13-py2.7.egg/mycroft/skills/", line 131, in load_skill
    skill_descriptor["name"] + MainModule, *skill_descriptor["info"])
  File "/opt/mycroft/skills/openhab-mycroft/", line 257
    if self.lang == "it-it"
SyntaxError: invalid syntax

My Mark 1 is set to default “en-us” (although I’m British). Adding brackets around the logical test didn’t fix the comparison, so I commented out the Italian language tests completely in
I added hash comments to lines 257-259 and 268-270.
This got further, but not quite success.

Bug 2 - SyntaxError: Non-ASCII character
The skill still threw an error:

vim /var/log/mycroft-skills.log

19:16:41.580 - mycroft.skills.core:load_skill:163 - ERROR - Failed to load skill: openhab-mycroft
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/mycroft_core-0.9.13-py2.7.egg/mycroft/skills/", line 131, in load_skill
    skill_descriptor["name"] + MainModule, *skill_descriptor["info"])
  File "/opt/mycroft/skills/openhab-mycroft/", line 265
SyntaxError: Non-ASCII character '\xc3' in file /opt/mycroft/skills/openhab-mycroft/ on line 265, but no encoding declared; see for details

Line 265 includes a non-ASCII unicode character (requestType == "l'umidità").

Based on Python PEP0263, I added a line at the top of define a source code encoding at the top of](

> # Copyright (c) 2010-2017 by the respective copyright holders.
> # -*- coding: iso-8859-15 -*-

With the work around (commenting out “it-it”) and fix (adding encoding), the skill started, connected first time and started working. It took 10 mins and many ON / OFF tests for the novelty of speech control to wear off! :slight_smile:

Initial tests (Hey Mycroft, list openhab items) suggest openhab-skill is using the OpenHAB item file Item Name, rather than the Item Label which is not ideal as my item names are camel-case variables not designed for human-use, and especially hard to speak.

Experimentation continues… thanks for developing the binding, and hope the reports above help.

Thanks so much for reporting this in detail @FloatingBoater.
I’m going to ping my colleague @forslund on this one, who may have more information to assist.

Again, thanks for providing so much detail - hugely appreciated.

Kind regards,


Thanks for the encouragement - I’m still hacking away, although working on Xtend, Java, and Python at the same time is not to be recommended!

I now have fixes for both issues, which might get the Italian support working as originally intended. I’m not quite ready to attempt a GitHub pull request so apologies for the attempt at a manual patch.

Edit and …

Bug 1 - “it-it” test causes SyntaxError
After some reading, this is a simple Python syntax error.
Change line 257 to add brackets and a colon:

if (self.lang == "it-it"):

Change line 268 to add brackets and a colon:

if (self.lang == "it-it"):

Bug 2 - SyntaxError: Non-ASCII character
Add a new line at the top to specify encoding:

# Copyright (c) 2010-2017 by the respective copyright holders.
# -*- coding: iso-8859-15 -*-

I’ve also added a log line for the current language settings at line 57:

LOGGER.debug("self.lang :" + self.lang + ":")
supported_languages = ["en-us", "it-it"]

Seems I’m too late to the party and all is figured out :slight_smile:

I’d like to recommend using

# -*- coding: utf-8 -*-

since it’ll be more future-proof and can handle practically any language.

1 Like

Hi @FloatingBoater , thank you for your post. If you won’t add a PR, could you please open a new issue in the official repo?
thank you.

Changed applied, thank you again for your contribution.

Hi @mortommy,

Thanks for applying the changes - unfortunately, I’m not (yet) up to creating a branch and a PR myself.

Would you mind checking the change to line 269 again please?

The first bracket is in the wrong place:

(if self.lang == "it-it"): 

My code has:

if (self.lang == "it-it"):

The githib code gives an error:

File "/opt/mycroft/skills/openhab-mycroft/", line 269
(if self.lang == "it-it"):
SyntaxError: invalid syntax

Fix applied. Thank your for your contribution.
About the list of items and your request of having listed the labels instead of the items name, could you crate a new issue?
Thank you.

1 Like

I’m struggeling with the usage of the openhab2 skill. Installation went fine on my picroft but I cant figure out how to correctly define items in openhab. I used the item definitions from the skill example but mycroft always replies that the openhab items are unknown.
An help much appreciated

Thank you

Could you post an example of your items definition in openHAB?

I have defined these two items (besides others).

Switch GoodNight “Good Night” [ “Switchable” ]
Switch Sonos “Sonos” [ “Switchable” ]


I suggest we take this one step at a time.

Can you switch these Items on/off in a SiteMap with default config?

# Your install may have a slightly different path to conf/
# /opt/openhab/conf/sitemaps/ohtest.sitemap

sitemap ohtest label="OpenHAB Test" {
    Frame label="OpenHAB Mycroft Test" {
        Switch item=GoodNight
        Switch item=Sonos

The items you show are missing the binding configuration which would only work if these are dummy items designed to trigger a state change in a rule:

Switch GoodNight “Good Night” [ “Switchable” ] {channel="details of binding"}

If that works, as the Mycroft binding is similar to Homekit / Alexa, I followed those instructions:

From the three main tag types, I have Lighting and Switchable working:

  • Lighting - Switch, Dimmer, Color
  • Switchable - Switch, Dimmer, Color
  • CurrentTemperature - RO Number

I would then ssh into Mycroft and use the debug console to look what is happening - you can also type in speech commands:

python -m mycroft.client.text.main --quiet

One suggestion is to define multiple Items bound to the same Channel/ Thing, each with different label text to make it easier to speak a command.

With this item, I can say ‘switch on bedside radio’:

Switch Bed_Radio "Bedside Radio" <radio> ["Switchable"] {channel="zwave:detail removed"}

I’m going to add some debug code to my local copy of the skill to understand if the intent is parsed from the Item Name (e.g. Bed_Radio) or the Item Label (e.g. Bedside Radio) as the speech Hey Mycroft, list openhab items lists the non-human-readable Item Names.

Hi @mortommy,

After some testing, I’ve confirmed that the binding uses the OpenHAB Item Label, and not the OpenHAB Item Name for speech/ intent recognition.

The test to prove this is pretty simple - add a test Item to the OpenHAB *.items file with a very different Name and Label text:

Switch fish "bicycle" ["Switchable"] {channel="binding detail removed"}

Then, fire up the Mycroft test console, refresh the Items from OpenHAB and try turning on fish and bicycle:

python -m mycroft.client.text.main --quiet

At the prompt, simulate saying text whilst watching the logs (same as saying Hey Mycroft…):

refresh openhab items

The skill pulls the list of items with tags and reads the out the Names.
The Name is a variable name so often non-human readable - useful for debug, but not very ‘speakable’!
This is what made me suspect the skill was using Name rather than Label!

Say the Name - fish

Mycroft recognises the intent, parrots back the command, but NOTHING HAPPENS. This is slightly misleading, but could well be the Mycroft intent parser, rather than the OpenHAB binding.

turn on fish
>> turn on fish

Say the Label - bicycle

turn on bicycle
>> switch on bicycle

Mycroft recognises the intent from the Label, fires a call to the OpenHAB REST API to turn on the Item named ‘fish’ correctly:

requests.packages.urllib3.connectionpool - DEBUG - http://openhab.home:8080 "POST /rest/items/fish HTTP/1.1" 200 0

So, that seems to work well, and as expected.

My testing so far works for ["Switchable"] and ["Lighting"], but I’ve not managed to ask for the temperature of a ["CurrentTemperature"] sensor. When I ask, what is radiator temperature, the Weather skill gives me a forecast!

So, the issue is more of an improvement request…

Thanks again!

First: Thank you very much for your detailed response!
I think the skill is somehow not correctly installed.
When i ask: "Hey Mycroft, refresh openhab items"
The reply is : "All right. I found 0 items. "
Which is not true, because i have plenty of items.

Maybe you can confirm that my configuration is (in)correct (which I added manually)
in mycroft.conf /usr/local/lib/python2.7/site-packages/mycroft_core-0.9.14-py2.7.egg/mycroft/configuration/

// =================================================================
// All of the follow are specific to particular skills and will soon
// be removed from this file.
// =================================================================

“wifi”: {
“setup”: false
“openHABSkill”: {
“host”: “”,
“port”: “8080”
“ConfigurationSkill”: {
“max_delay”: 60

Thanks again for your support


My experience of many years of integrating complex systems is that breaking tasks down into individual steps, each checked with testing of some sort, is the best approach. Finding where a log file is, and looking to see what it contains tests your understanding.

More often than not, logs have shown a component didn’t work the way I thought, and I learned something. It’s also motivating to see a part of a complex system work - even if it’s a small part.

With that in mind, here’s a step-by-step…

Configure and test OpenHAB

Before working with Mycroft, I’d suggest checking that…

  • Does your OpenHAB install work?
  • Can you switch your desired Items on or off via an OpenHAB SiteMap?
  • Can you see status changes on an OpenHAB web interface, and see the changes on the ESH console?

I say that particularly as the Item definitions you gave earlier don’t include any binding information, and the Sonos binding has many Channels to control (i.e. not just on/ off, like a simple switch). Start simple - confirm you understand and have tested on /off of one device in OpenHAB.

In case you’ve not seen then, there are quite good confg docs here:

I access the OpenHAB console by SSH’ing into my server, and then SSH’ing a second time locally into OpenHAB. If you use OpenHABian, this may be simpler with a web-based log viewer.

Before moving to Mycroft, you can also manually test the interface Mycroft will use - REST.

  • test the openHAB REST interface by manually opening a web browser and going to: http://your OpenHAB server:8080/rest/items
  • This should show a JSON formatted list of all your items which is not easy to read, but very useful.
  • Do the same as Mycroft will do, and use CONTROL-F in the browser to search for Switchable or Lighting tags.
    You should see Items with :

Your last post suggests you should be able to browse to:

If you don’t get a list of items, check the OpenHAB console, any firewalls (none on a RPi, but you might be using a PC/ Mac), if the software is running, and your IP addresses.

Configure and test Mycroft OH2 binding - based on a Mark 1

Once you have tested OpenHAB (and only after you’ve tested… :slight_smile: ), you can start on Mycroft.

  • Update, install and test Mycroft and the OH2 binding by SSH’ing into Mycroft:
sudo msm update
msm search openhab
msm info openhab-skill
msm install openhab-skill
msn list

I didn’t see msm list the openhab-skill as installed, but it was there and worked.

  • Mycroft skill config seems to be in two places:
cat /etc/mycroft/mycroft.conf
cat /home/mycroft/.mycroft/mycroft.conf
  • I found adding openHABSkill params into /home/mycroft/.mycroft/mycroft.conf worked for me.
cat /home/mycroft/.mycroft/mycroft.conf
  "tts": {
    "mimic": {
  "SkillInstallerSkill": {
    "path": "/usr/local/bin/msm"
  },   <<<<<<======= N.B. this extra comma!
  "openHABSkill": {
    "host": "youropenhabservername",
    "port": "8080"

N.B - note the extra comma before the new openHABSkill block.

  • Restart the skills and watch the logs:
sudo service mycroft-skills restart

tail -f /var/log/mycroft-skills.log
python -m mycroft.client.text.main --quiet
  • You should see lots of scrolling debug information, either by tailing the log file directly, or by using python to open the Mycroft console. The console allows you to type in a spoken command - ideal for testing.
  • Speak (or type into the console) refresh openhab items
  • You should see a connectionpool line connecting from Mycroft into OpenHAB and hear All right. I found nn items
  • If you don’t - check the OH2 REST interface via a browser again, and look for errors in both OH2 and Mycroft logs.
  • Speak (or type into the console) list openhab items
  • You should hear Found the following items: .... and a list of the Item names.
  • If the list isn’t what you’ve tagged in the OH2 config, check the OH2 *.items config - again, use the manual browser test above to look for the tags Mycroft is looking for (Switchable, Lighting).

You should now be able to say something like… turn on mydevice light, and see Mycroft connect to OpenHAB and the Item turn on.

I hope this helps you (and hopefully others…) get Mycroft turning your home automation on and off via OpenHAB.

1 Like