Mycroft Skill For Hubitat Ready To Try Out

For people looking for integration between Hubitat and Mycroft, I have made a start. In github/burnsfisher/hubitat-integration-skill you will find the code for a Mycroft skill that works with Hubitat's maker app. It works only locally (which was one of my main goals--avoid the cloud!) and at the moment can only work with devices that are controlled by turning them on and off. To make it work, you have to add the devices you want to control to the maker app in Hubitat. In the Mycroft skill, you will need to access "setting" in your on-line Mycroft account to add the Hubitat access token and either the dotted quad address of Hubitat or change it to 'hubitat.local', although the latter seems to be slower.

When you have the skill setup (git clone the repo into /opt/mycroft/skills for Picroft (Mycroft on a Raspberry pi) you can say "hey mycroft, scan for new devices" (or it will do it when it starts up). And the "hey mycroft, turn off/on xxxx" or some variant of that. xxx is the device label you want to control.

WARNING: This is closer to stable now than a few months ago, but I may change anything. In addition, I know there are other Mycroft skills for other devices like Home Automation. I may try to combine this with one of them to take advantage of a lot of other code. I think there are ways to add properties like the access token and address in a better way, but I have not yet tried.

BUT if you want something to start playing around with, you are welcome to grab this code, and if you want to improve it, I'm happy to look at pull requests.

6 Likes

One person was watching my github repository. To them, my apologies. I've deleted that repository and created a new one called hubitat-integration-skill. I was using the first one to test out various methods, and now that I have managed to get a reasonable methodology, I decided to take the "test" part out of it before anyone else started watching or forking.

1 Like

I'm not going to keep updating changes here (as I did the last couple). If you want to see what the current state is, look at the github repository change comments. Feel free to add issues etc.

1 Like

Well, I will update it a bit. It is probably at the point of actually being usable for on/off and set levels. It does work with scene activators too and can do setLevel for dimmers. I'm thinking of a couple other things I'd like it to do like tell me the temp reading on my Stelpro thermostat, but that will require learning more stuff with Mycroft :slight_smile:

2 Likes

Nice feature, I am in the early stage of Hubitat currently.
I am setting up some basic rules, but soon I will start with voice assistant (mycroft). Definitely I will check out your repo and try to support you as much as I can (at least with testing).
Keep going, great to see someone implements an interface between mycroft and hubitat!

1 Like

Ok, reading the thermostat works. "Hey Mycroft! What is the inside temperature". "The temperature is 65.0"

1 Like

Sorry I did not see this earlier. Thanks...any testing you can do is helpful! I've been using it regularly for 3 months now and it works reasonably well!

1 Like

This integration is very interesting to me, so I just forked your repository. When supply chain issues end, I'm planning to setup a PiCroft.

1 Like

Great! Let me know if you have suggestions or bug reports.

1 Like

I will be looking at this as well, probably in another month or so.
Thanks very much for the opportunity to look at your code.

2 Likes

I've changed the title to make it a bit less alpha-y and the text to remove some of the no-longer-relevant comments. I've been using this for 3 months now, and it does what I need. I've also used it with the Mycroft "routines" skill, although you may need some of my changes that the owner of routines has decided not to pull.

2 Likes

@burns_hub give me a few and I'll be joining the fun. Thank you for making this. Will star/watch your repo on github.

Would love to chat with you further on what your PR was that they didn't pull. Does this mean, for full usage, we probably have to compile from source?

@yot I do hope this works ok for you. Feel free to give me feedback either here or in github issues.

Regarding the PR for "routines", I think we just had different opinions about how some things should be done. That's fine. But I believe that you can install my version of routines from my github repo just as well. It is FAR from perfect--some commands it simply does not understand--but it is a useful addition.

Regarding "compile from source" Well, it is all Python so no real compile. And not enough people have reviewed/tested to get it in as an "official" Mycroft skill. But you should be able to install it directly from gitHub. And it works fine without 'routines' too. Routines just gives you a few added abilities (like Mycroft speaking back, or a command that does not match the Hubitat device name).

Hi, My apologies for not seeing this sooner. I don't have a mycroft appliance proper, but do have a mic array setup on an rpi4 with mycroft installed. I've been waiting for an application to test with this. Will be setting up and hopefully testing / contributing in some way as hubitat + mycroft is my main use case. I intended to ditch all amazon devices for local non-cloud based control with mycroft + hubitat. Thank you kindly for your efforts in this regard.

Good luck @lcstyle! Do let me know how it works for you. I also use Mycroft on a Pi. One thing that I find is that Mycroft finds a lot of what it thinks are trigger words in normal conversation. My wife talking to me, zoom meetings, anything. I have not gotten around to upgrade to a later Mycroft or to try to change the trigger word.

@burns_hub it's installed, but I don't see it under skill settings.. weird, any ideas?

I'm getting a "NoneType object has no attribute replace" exception on line 41

I renamed init.py and replaced it with old init, the old init is also breaking.

I've modified the config file to try to get this to load, but no matter what entries i make in the config file, it fails to load. Is it pulling config params from the mycroft ai website, or is it pulling data from the local yaml file?

If it's trying to pull from the mycroft website, it won't work, I don't see the skill in my settings page and the skills manager won't load the skill due to the various exceptions.

Chicken and egg, but I'm guessing I'm misunderstanding something here.

Here's the debug output, there is no settings.json file by the way, i added a debug log statement to try to see if it was getting the attribute but of course the attribute is empty so i just moved the nonetype exception to my new debug line.

2022-09-26 16:12:38.530 | INFO     | 13131 | mycroft.skills.skill_loader:load:185 | ATTEMPTING TO LOAD SKILL: hubitat-integration-skill.burnsfisher
2022-09-26 16:12:38.532 | DEBUG    | 13131 | mycroft.skills.skill_loader:remove_submodule_refs:44 | Skill module: hubitat-integration-skill_burnsfisher
2022-09-26 16:12:38.566 | INFO     | 13131 | mycroft.skills.settings:get_local_settings:83 | /opt/mycroft/skills/hubitat-integration-skill.burnsfisher/settings.json
2022-09-26 16:12:38.569 | DEBUG    | 13131 | mycroft.skills.mycroft_skill.event_container:add:153 | Added event: mycroft.skill.enable_intent
2022-09-26 16:12:38.573 | DEBUG    | 13131 | mycroft.skills.mycroft_skill.event_container:add:153 | Added event: mycroft.skill.disable_intent
2022-09-26 16:12:38.576 | DEBUG    | 13131 | mycroft.skills.mycroft_skill.event_container:add:153 | Added event: mycroft.skill.set_cross_context
2022-09-26 16:12:38.580 | DEBUG    | 13131 | mycroft.skills.mycroft_skill.event_container:add:153 | Added event: mycroft.skill.remove_cross_context
2022-09-26 16:12:38.584 | DEBUG    | 13131 | mycroft.skills.mycroft_skill.event_container:add:153 | Added event: mycroft.skills.settings.changed
2022-09-26 16:12:38.586 | DEBUG    | 13131 | mycroft.skills.mycroft_skill.event_container:add:153 | Added event: hubitat-integration-skill.burnsfisher.set
2022-09-26 16:12:38.596 | DEBUG    | 13131 | mycroft.skills.mycroft_skill.event_container:add:153 | Added event: hubitat-integration-skill.burnsfisher:attr.intent
2022-09-26 16:12:38.600 | DEBUG    | 13131 | mycroft.skills.mycroft_skill.event_container:add:153 | Added event: hubitat-integration-skill.burnsfisher:turn.on.intent
2022-09-26 16:12:38.612 | DEBUG    | 13131 | mycroft.skills.mycroft_skill.event_container:add:153 | Added event: hubitat-integration-skill.burnsfisher:rescan.intent
2022-09-26 16:12:38.617 | DEBUG    | 13131 | mycroft.skills.mycroft_skill.event_container:add:153 | Added event: hubitat-integration-skill.burnsfisher:turn.off.intent
2022-09-26 16:12:38.623 | DEBUG    | 13131 | mycroft.skills.mycroft_skill.event_container:add:153 | Added event: hubitat-integration-skill.burnsfisher:level.intent
2022-09-26 16:12:38.626 | DEBUG    | 13131 | mycroft.skills.mycroft_skill.event_container:add:153 | Added event: hubitat-integration-skill.burnsfisher:list.devices.intent
2022-09-26 16:12:38.632 | ERROR    | 13131 | mycroft.skills.skill_loader:_create_skill_instance:313 | Skill initialization failed with TypeError('can only concatenate str (not "NoneType") to str')
Traceback (most recent call last):
  File "/home/pi/mycroft-core/mycroft/skills/skill_loader.py", line 307, in _create_skill_instance
    self.instance.initialize()
  File "/opt/mycroft/skills/hubitat-integration-skill.burnsfisher/__init__.py", line 23, in initialize
    self.on_settings_changed()
  File "/opt/mycroft/skills/hubitat-integration-skill.burnsfisher/__init__.py", line 35, in on_settings_changed
    self.log.debug('attr_name from settings is:' + self.settings.get('attr_name'))
TypeError: can only concatenate str (not "NoneType") to str
2022-09-26 16:12:38.636 | ERROR    | 13131 | mycroft.skills.skill_loader:_communicate_load_status:351 | Skill hubitat-integration-skill.burnsfisher failed to load

I'm running the picroft image
Download img Picroft Release Candidate 2021-06-04 image

This distribution is very outdated.. my matrix voice module is meant for rpi4, so if there's a way to install picroft on a rpi4 from an updated raspbian OS distribution I'd be all for it, but it doesn't seem like a manual install is available.

So it looks like it is not finding the settings in your Mycroft account. In order to make this work you have to create a Mycroft account. In your Mycroft account, you will get a list of skills that you are using and the ability to set values for some settings. For example, my dev1 setting says:

"temperature","heatingSetpoint","level"
and dev1 says

'thermostat','thermostat','overhead lights'

As I recall, these are to add verbs like "Level" to some devices like
Overhead lights".

To be honest, it's been a while since I have messed with this --- it all has worked fine for many months---so I don't actually remember how how you get your Picroft connected to your Mycroft account. It is certainly easy and important. Alternatively, you could hardcode those values in the code to start out. You'll also need stuff like the URL (hubitat.local) and the token from the hubitat maker app.

yes, i do have a mycroft account and have registered the device, however, the skill would never show up in the settings page. I believe the exception causes the skill to not load, or maybe, the picroft image I was running was just so old it was failing to update the skills list via the mycroft api.

Oh, ok. Sorry if I misunderstood. I think I'd try manually putting values into the code for those settings. Or alternatively take out the call to "on_settings_changed" from "__Initialize". There might be a race problem there the first time a new user shows up. That is, you have to get the skill initialized before the settings show up in your account. I probably added that call from Initialize after I had the settings in my account.

1 Like

that's probably it.

thanks

1 Like

Download the Hubitat app