Skip to content

Commit

Permalink
Add the ability to reload rpi_gpio platforms from yaml (home-assistan…
Browse files Browse the repository at this point in the history
…t#39548)

* add reload service

* test for reload service

* missing file

* Revert "missing file"

This reverts commit 24391fe.

* Revert "test for reload service"

This reverts commit 5bda48d.
  • Loading branch information
Misiu authored Sep 2, 2020
1 parent cb1cf22 commit 2d2efeb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions homeassistant/components/rpi_gpio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
_LOGGER = logging.getLogger(__name__)

DOMAIN = "rpi_gpio"
PLATFORMS = ["binary_sensor", "cover", "switch"]


def setup(hass, config):
Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/rpi_gpio/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
from homeassistant.const import DEVICE_DEFAULT_NAME
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.reload import setup_reload_service

from . import DOMAIN, PLATFORMS

_LOGGER = logging.getLogger(__name__)

Expand All @@ -33,6 +36,9 @@

def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Raspberry PI GPIO devices."""

setup_reload_service(hass, DOMAIN, PLATFORMS)

pull_mode = config.get(CONF_PULL_MODE)
bouncetime = config.get(CONF_BOUNCETIME)
invert_logic = config.get(CONF_INVERT_LOGIC)
Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/rpi_gpio/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from homeassistant.components.cover import PLATFORM_SCHEMA, CoverEntity
from homeassistant.const import CONF_NAME
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.reload import setup_reload_service

from . import DOMAIN, PLATFORMS

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -49,6 +52,9 @@

def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the RPi cover platform."""

setup_reload_service(hass, DOMAIN, PLATFORMS)

relay_time = config.get(CONF_RELAY_TIME)
state_pull_mode = config.get(CONF_STATE_PULL_MODE)
invert_state = config.get(CONF_INVERT_STATE)
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/rpi_gpio/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
reload:
description: Reload all rpi_gpio entities.
6 changes: 6 additions & 0 deletions homeassistant/components/rpi_gpio/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from homeassistant.const import DEVICE_DEFAULT_NAME
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.reload import setup_reload_service

from . import DOMAIN, PLATFORMS

_LOGGER = logging.getLogger(__name__)

Expand All @@ -29,6 +32,9 @@

def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Raspberry PI GPIO devices."""

setup_reload_service(hass, DOMAIN, PLATFORMS)

invert_logic = config.get(CONF_INVERT_LOGIC)

switches = []
Expand Down

0 comments on commit 2d2efeb

Please sign in to comment.