...
based off the original code from https://github.com/BongoEADGC6/mycroft-home-assistant, spun off my own version since they seem to be inactive.
See https://geekedoutsolutions.com/using-home-assistant-with-mycroft-ai-for-home-automation for a general overview of Mycroft AI and Home Assistant
Now confirmed working for mycroft 18.8.1.
Now using the new Long-Lived Access Tokens instead of legacy api password.
Make sure you have your home assistant settings filled out on home.mycroft.ai.
This is a skill to add Home Assistant support to
Mycroft. Currently is supports turning on and off several
entity types (light
, switch
, scene
, climate
, groups
and input_boolean
).
You can always find me in the mycroft mattermost channel here, https://chat.mycroft.ai
If you want to join my official discord where I will have a chatbot helper and more you can join via https://discord.gg/Xnn89dB
If you like this and want to say thanks check out my Patreon I also include special posts here for my Patrons.
If you liked this project, you can donate to support it and new features and also help me justify spending more time on this project.
You can donate directly via my Blog or any of the other options listed below.
Or become a Patreon - I offer special posts and tutorials to my Patreons that aren't public.
Should be able to install this now via just saying Hey Mycroft, install skill home assistant
it will then confirm if you want to install it and say yes and you are good to go.
Can also be installed via msm install https://github.com/btotharye/mycroft-homeassistant.git
This skill utilizes the skillsettings.json file which allows you to configure this skill via home.mycroft.ai after a few minutes of having the skill installed you should see something like below in the https://home.mycroft.ai/#/skill location:
Fill this out with your appropriate home assistant information and hit save.
You create the Long-Lived Access Token on the user profile page
Home-Assistant supports basic speech based communication.
When enabling the setting Enable conversation component as fallback
on home.mycroft.ai, sentences that were not parsed
by any skill before (based on matching keywords) will be passed to this conversation component at the local Home-Assistant server.
Like this, Mycroft will answer default and custom sentences specified in Home-Assistant.
Say something like "Hey Mycroft, turn on living room lights". Currently available commands
are "turn on" and "turn off". Matching to Home Assistant entity names is done by scanning
the HA API and looking for the closest matching friendly name. The matching is fuzzy (thanks
to the fuzzywuzzy
module) so it should find the right entity most of the time, even if Mycroft
didn't quite get what you said. I have further expanded this to also look at groups as well as lights. This way if you say turn on the office light, it will do the group and not just 1 light, this can easily be modified to your preference by just removing group's from the fuzzy logic in the code.
Example Code: So in the code in this section you can just remove group, etc to your liking for the lighting. I will eventually set this up as variables you set in your config file soon.
def handle_lighting_intent(self, message):
entity = message.data["Entity"]
action = message.data["Action"]
LOGGER.debug("Entity: %s" % entity)
LOGGER.debug("Action: %s" % action)
ha_entity = self.ha.find_entity(entity, ['group','light', 'switch', 'scene', 'input_boolean'])
if ha_entity is None:
#self.speak("Sorry, I can't find the Home Assistant entity %s" % entity)
self.speak_dialog('homeassistant.device.unknown', data={"dev_name": ha_entity['dev_name']})
return
ha_data = {'entity_id': ha_entity['id']}
Currently the phrases are:
- Hey Mycroft, turn on office (turn on the group office)
- Hey Mycroft, turn on office light (to turn on the light named office)
- Hey Mycroft, activate Bedtime (Bedtime is an automation)
- Hey Mycroft, turn on Movietime (Movietime is a scene)
- Hey Mycroft, status of thermostat (For sensors in homeassistant)
- Hey Mycroft, locate/where brian (Brian is a device tracker object)
- Hey Mycroft, what is the current living room temp
- Hey Mycroft, what is the current season
- Hey Mycroft, tell me the current (status|state|value|sensor) of the living room thermostat temperature
- Hey Mycroft, set the hallway thermostat to 75 degrees
- Hey Mycroft, set the hallway thermostat temperature to 75 degrees
- Hey Mycroft, change the hallway thermostat temperature to 75 degrees
- Script intents processing
- New intent for opening/closing cover entities
- New intent for locking/unlocking lock entities (with added security?)
- New intent for thermostat values, raising, etc.
- New intent to handle multimedia/kodi
- Increasing and Decreasing Climate controls
All contributions welcome:
- Fork
- Write code
- Submit merge request
See LICENCE
.