Skip to content

Commit

Permalink
Merge pull request #50 from Toperko/dev
Browse files Browse the repository at this point in the history
fix momentary actions for PCF
  • Loading branch information
pszafer committed Mar 17, 2024
2 parents 706e5db + 0ff46cc commit a4c8512
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions boneio/relay/pcf.py
Expand Up @@ -4,7 +4,7 @@

from adafruit_pcf8575 import DigitalInOut

from boneio.const import NONE, SWITCH, PCF
from boneio.const import NONE, SWITCH, PCF, ON, OFF
from boneio.helper.events import async_track_point_in_time, utcnow
from boneio.helper.pcf8575 import PCF8575
from boneio.relay.basic import BasicRelay
Expand Down Expand Up @@ -66,18 +66,13 @@ def pin(self) -> str:
def turn_on(self) -> None:
"""Call turn on action."""
self.pin.value = self._active_state
self.execute_momentary_turn_on()
self._execute_momentary_turn(momentary_type=ON)
self._loop.call_soon_threadsafe(self.send_state)
self._loop.call_soon_threadsafe(self._callback)

def turn_off(self) -> None:
"""Call turn off action."""
self.pin.value = not self._active_state
if self._momentary_turn_off:
async_track_point_in_time(
loop=self._loop,
action=lambda x: self._momentary_callback(time=x, action=self.turn_on),
point_in_time=utcnow() + self._momentary_turn_off.as_timedelta,
)
self._execute_momentary_turn(momentary_type=OFF)
self._loop.call_soon_threadsafe(self.send_state)
self._loop.call_soon_threadsafe(self._callback)

0 comments on commit a4c8512

Please sign in to comment.