Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/components/rflink/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ def __init__(
def _handle_event(self, event):
"""Domain specific event handler."""
command = event["command"]
if command == "on":
if command in ["on", "allon"]:
self._state = True
elif command == "off":
elif command in ["off", "alloff"]:
self._state = False

if self._state and self._off_delay is not None:
Expand Down
16 changes: 14 additions & 2 deletions tests/components/rflink/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,30 @@ async def test_default_setup(hass, monkeypatch):
assert config_sensor.state == STATE_OFF
assert config_sensor.attributes["device_class"] == "door"

# test event for config sensor
# test on event for config sensor
event_callback({"id": "test", "command": "on"})
await hass.async_block_till_done()

assert hass.states.get("binary_sensor.test").state == STATE_ON

# test event for config sensor
# test off event for config sensor
event_callback({"id": "test", "command": "off"})
await hass.async_block_till_done()

assert hass.states.get("binary_sensor.test").state == STATE_OFF

# test allon event for config sensor
event_callback({"id": "test", "command": "allon"})
await hass.async_block_till_done()

assert hass.states.get("binary_sensor.test").state == STATE_ON

# test alloff event for config sensor
event_callback({"id": "test", "command": "alloff"})
await hass.async_block_till_done()

assert hass.states.get("binary_sensor.test").state == STATE_OFF


async def test_entity_availability(hass, monkeypatch):
"""If Rflink device is disconnected, entities should become unavailable."""
Expand Down