Created
January 8, 2020 08:25
-
-
Save jacobtomlinson/bbcfa79f1d293becbe7557b135c0335a to your computer and use it in GitHub Desktop.
Opsdroid Home Assistant example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from asyncio import sleep | |
from opsdroid_homeassistant import HassSkill, match_hass_state_changed | |
class MotionLights(HassSkill): | |
@match_hass_state_changed("binary_sensor.drive", 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("light.drive") | |
await sleep(60) | |
await self.turn_off("light.drive") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment