Skip to content

Commit

Permalink
Initial commit of new service
Browse files Browse the repository at this point in the history
Signed-off-by: Mick Vleeshouwer <[email protected]>
  • Loading branch information
iMicknl committed Sep 2, 2020
1 parent cae20b7 commit 30b6ed3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
21 changes: 20 additions & 1 deletion custom_components/tahoma/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
from homeassistant import config_entries
from homeassistant.components.scene import DOMAIN as SCENE
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_EXCLUDE, CONF_PASSWORD, CONF_USERNAME
from homeassistant.const import (
CONF_EXCLUDE,
CONF_PASSWORD,
CONF_USERNAME,
EVENT_HOMEASSISTANT_START,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import aiohttp_client, config_validation as cv

Expand Down Expand Up @@ -45,6 +50,8 @@
extra=vol.ALLOW_EXTRA,
)

SERVICE_REFRESH_STATES = "refresh_states"


async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the TaHoma component."""
Expand Down Expand Up @@ -137,6 +144,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
hass.config_entries.async_forward_entry_setup(entry, platform)
)

async def handle_service_refresh_states(call):
"""Handle the service call."""
await client.refresh_states()

def _register_services(event):
"""Register the domain services."""
hass.services.register(
DOMAIN, SERVICE_REFRESH_STATES, handle_service_refresh_states
)

hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, _register_services)

return True


Expand Down
2 changes: 1 addition & 1 deletion custom_components/tahoma/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/tahoma",
"requirements": [
"pyhoma==0.4.0"
"pyhoma==0.4.1"
],
"codeowners": ["@philklei", "@imicknl", "@vlebourl", "@tetienne"],
"issue_tracker": "https://github.com/imicknl/ha-tahoma/issues"
Expand Down
5 changes: 4 additions & 1 deletion custom_components/tahoma/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ set_cover_position_low_speed:
example: "cover.living_room"
position:
description: Position of the cover (0 to 100).
example: 30
example: 30

refresh_states:
description: Ask the box to refresh all devices states for protocols supporting that operation.
2 changes: 1 addition & 1 deletion requirements.test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ pytest-cov<3.0.0
pytest-homeassistant

# from our manifest.json for our Custom Component
pyhoma==0.4.0
pyhoma==0.4.1

0 comments on commit 30b6ed3

Please sign in to comment.