Getting Started


pip install opsdroid-homeassistant

Example Skill

To create our first skill we need to create a Python file. You can either create a standalone file or a module that can be imported.

Let’s create a new file called /home/user/opsdroid-skills/ This can be anywhere you like but keep note of the path as we will need it in our config later.

from asyncio import sleep
from opsdroid_homeassistant import HassSkill, match_hass_state_changed

class MotionLights(HassSkill):

    @match_hass_state_changed("", state="on")
    async def motion_lights(self, event):
        """Turn the outside light on with motion if after sunset."""
        if await self.sun_down():
            await self.turn_on("")
            await sleep(60)
            await self.turn_off("")

Example configuration

Next we need to edit our Opsdroid configuration to tell it about Home Assistant and our new skill.

You can open your config in an editor by running

$ opsdroid config edit


You can set the EDITOR environment variable to your preferred editor and opsdroid will automatically open your config in that.

## Set the logging level
  level: info

## Show welcome message
welcome-message: true

## Connector modules
    url: http://localhost:8123/
    token: mytoken

## Skill modules
    path: /home/user/opsdroid-skills/

In the above configuration we are enabling the Home Assistant connector. We need to give it the URL of our Home Assistant and a Long Lived Access Token.

We also configure our skill with the path to the Python file we created.

Running Opsdroid

Now we can start Opsdroid with:

$ opsdroid start

For more information on installing and configuring Opsdroid see the documentation.