Skip to content

Commit

Permalink
Fix for opsdroid 0.20+ compatibility (#21)
Browse files Browse the repository at this point in the history
* Fix for opsdroid 0.20+ compatibility

* Fix unit tests for opsdroid 0.20+ compatibility

* Run black

* Opsdroid 0.20 dropped support for Python 3.6
  • Loading branch information
davdr authored Jun 1, 2021
1 parent 1a0ee19 commit 26bbab5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ after_success: codecov
jobs:
fast_finish: true
include:
- python: "3.6"
- python: "3.7"
- python: "3.8"
- stage: deploy
Expand Down
17 changes: 12 additions & 5 deletions opsdroid_homeassistant/skill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,18 @@ async def lights_on_at_sunset(self, event):

def __init__(self, opsdroid, config, *args, **kwargs):
super().__init__(opsdroid, config, *args, **kwargs)
[self.hass] = [
connector
for connector in self.opsdroid.connectors
if connector.name == "homeassistant"
]
self._hass = None

@property
def hass(self):
if self._hass is None:
# create lazily (opsdroid.connectors not yet known when __init__ called)
[self._hass] = [
connector
for connector in self.opsdroid.connectors
if connector.name == "homeassistant"
]
return self._hass

async def call_service(self, domain: str, service: str, *args, **kwargs):
"""Send a service call to Home Assistant.
Expand Down
2 changes: 2 additions & 0 deletions opsdroid_homeassistant/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ async def opsdroid(connector_config, mock_skill_path):
configure_lang({})
with OpsDroid(config) as opsdroid:
await opsdroid.load()
await opsdroid.start_connectors()
await sleep(0.1) # Give the startup tasks some room to breathe
yield opsdroid
await opsdroid.stop()
await opsdroid.unload()


Expand Down

0 comments on commit 26bbab5

Please sign in to comment.