mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add state to RFXtrx covers (#30935)
* Add state to rfxtrx cover * Add state to rfxtrx cover (cover.py)
This commit is contained in:
parent
19a0a7029f
commit
5617e6913b
@ -131,7 +131,7 @@ def setup(hass, config):
|
|||||||
|
|
||||||
if dummy_connection:
|
if dummy_connection:
|
||||||
rfx_object = rfxtrxmod.Connect(
|
rfx_object = rfxtrxmod.Connect(
|
||||||
device, None, debug=debug, transport_protocol=rfxtrxmod.DummyTransport2
|
device, None, debug=debug, transport_protocol=rfxtrxmod.DummyTransport2,
|
||||||
)
|
)
|
||||||
elif port is not None:
|
elif port is not None:
|
||||||
# If port is set then we create a TCP connection
|
# If port is set then we create a TCP connection
|
||||||
@ -215,7 +215,7 @@ def get_pt2262_device(device_id):
|
|||||||
and device.masked_id == get_pt2262_deviceid(device_id, device.data_bits)
|
and device.masked_id == get_pt2262_deviceid(device_id, device.data_bits)
|
||||||
):
|
):
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"rfxtrx: found matching device %s for %s", device_id, device.masked_id
|
"rfxtrx: found matching device %s for %s", device_id, device.masked_id,
|
||||||
)
|
)
|
||||||
return device
|
return device
|
||||||
return None
|
return None
|
||||||
@ -307,13 +307,32 @@ def apply_received_command(event):
|
|||||||
return
|
return
|
||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Device_id: %s device_update. Command: %s", device_id, event.values["Command"]
|
"Device_id: %s device_update. Command: %s", device_id, event.values["Command"],
|
||||||
)
|
)
|
||||||
|
|
||||||
if event.values["Command"] == "On" or event.values["Command"] == "Off":
|
if event.values["Command"] in [
|
||||||
|
"On",
|
||||||
|
"Off",
|
||||||
|
"Up",
|
||||||
|
"Down",
|
||||||
|
"Stop",
|
||||||
|
"Open (inline relay)",
|
||||||
|
"Close (inline relay)",
|
||||||
|
"Stop (inline relay)",
|
||||||
|
]:
|
||||||
|
|
||||||
# Update the rfxtrx device state
|
# Update the rfxtrx device state
|
||||||
is_on = event.values["Command"] == "On"
|
command = event.values["Command"]
|
||||||
|
if command in [
|
||||||
|
"On",
|
||||||
|
"Up",
|
||||||
|
"Stop",
|
||||||
|
"Open (inline relay)",
|
||||||
|
"Stop (inline relay)",
|
||||||
|
]:
|
||||||
|
is_on = True
|
||||||
|
elif command in ["Off", "Down", "Close (inline relay)"]:
|
||||||
|
is_on = False
|
||||||
RFX_DEVICES[device_id].update_state(is_on)
|
RFX_DEVICES[device_id].update_state(is_on)
|
||||||
|
|
||||||
elif (
|
elif (
|
||||||
@ -425,14 +444,17 @@ class RfxtrxDevice(Entity):
|
|||||||
elif command == "roll_up":
|
elif command == "roll_up":
|
||||||
for _ in range(self.signal_repetitions):
|
for _ in range(self.signal_repetitions):
|
||||||
self._event.device.send_open(rfx_object.transport)
|
self._event.device.send_open(rfx_object.transport)
|
||||||
|
self._state = True
|
||||||
|
|
||||||
elif command == "roll_down":
|
elif command == "roll_down":
|
||||||
for _ in range(self.signal_repetitions):
|
for _ in range(self.signal_repetitions):
|
||||||
self._event.device.send_close(rfx_object.transport)
|
self._event.device.send_close(rfx_object.transport)
|
||||||
|
self._state = False
|
||||||
|
|
||||||
elif command == "stop_roll":
|
elif command == "stop_roll":
|
||||||
for _ in range(self.signal_repetitions):
|
for _ in range(self.signal_repetitions):
|
||||||
self._event.device.send_stop(rfx_object.transport)
|
self._event.device.send_stop(rfx_object.transport)
|
||||||
|
self._state = True
|
||||||
|
|
||||||
if self.added_to_hass:
|
if self.added_to_hass:
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
@ -82,7 +82,7 @@ class RfxtrxCover(RfxtrxDevice, CoverDevice, RestoreEntity):
|
|||||||
@property
|
@property
|
||||||
def is_closed(self):
|
def is_closed(self):
|
||||||
"""Return if the cover is closed."""
|
"""Return if the cover is closed."""
|
||||||
return None
|
return not self._state
|
||||||
|
|
||||||
def open_cover(self, **kwargs):
|
def open_cover(self, **kwargs):
|
||||||
"""Move the cover up."""
|
"""Move the cover up."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user