Clean up commands generation for rfxtrx (#38236)
This commit is contained in:
1 parent
c3966a5ef2
commit
c93fc8af4a
4 files changed
+34
-53
No files matched your search
@@ -487,38 +487,7 @@ class RfxtrxCommandEntity(RfxtrxEntity):
|
||||
self.signal_repetitions = signal_repetitions
|
||||
self._state = None
|
||||
|
||||
def _send_command(self, command, brightness=0):
|
||||
async def _async_send(self, fun, *args):
|
||||
rfx_object = self.hass.data[DOMAIN][DATA_RFXOBJECT]
|
||||
|
||||
if command == "turn_on":
|
||||
for _ in range(self.signal_repetitions):
|
||||
self._device.send_on(rfx_object.transport)
|
||||
self._state = True
|
||||
|
||||
elif command == "dim":
|
||||
for _ in range(self.signal_repetitions):
|
||||
self._device.send_dim(rfx_object.transport, brightness)
|
||||
self._state = True
|
||||
|
||||
elif command == "turn_off":
|
||||
for _ in range(self.signal_repetitions):
|
||||
self._device.send_off(rfx_object.transport)
|
||||
self._state = False
|
||||
|
||||
elif command == "roll_up":
|
||||
for _ in range(self.signal_repetitions):
|
||||
self._device.send_open(rfx_object.transport)
|
||||
self._state = True
|
||||
|
||||
elif command == "roll_down":
|
||||
for _ in range(self.signal_repetitions):
|
||||
self._device.send_close(rfx_object.transport)
|
||||
self._state = False
|
||||
|
||||
elif command == "stop_roll":
|
||||
for _ in range(self.signal_repetitions):
|
||||
self._device.send_stop(rfx_object.transport)
|
||||
self._state = True
|
||||
|
||||
if self.hass:
|
||||
self.schedule_update_ha_state()
|
||||
for _ in range(self.signal_repetitions):
|
||||
await self.hass.async_add_executor_job(fun, rfx_object.transport, *args)
|
||||
Reference in new issue
Block a user