Skip to content

Commit ec2d91e

Browse files
committed
Properly handle unavailable port value writes
1 parent 13d9786 commit ec2d91e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

qtoggleserver/raspigpio/raspigpio.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
from typing import Optional
44

5-
from qtoggleserver.core import ports
5+
from qtoggleserver.core import ports as core_ports
66
from qtoggleserver.utils import json as json_utils
77

88

9-
class GPIO(ports.Port):
10-
TYPE = ports.TYPE_BOOLEAN
9+
class GPIO(core_ports.Port):
10+
TYPE = core_ports.TYPE_BOOLEAN
1111

1212
ADDITIONAL_ATTRDEFS = {
1313
'output': {
@@ -67,6 +67,7 @@ async def handle_enable(self) -> None:
6767
async def read_value(self) -> bool:
6868
return 'level=1' in self._exec_raspi_gpio(f'get {self._no}')
6969

70+
@core_ports.skip_write_unavailable
7071
async def write_value(self, value: bool) -> None:
7172
self.debug('writing output value %s', json_utils.dumps(value))
7273
self._exec_raspi_gpio(f'set {self._no} d{self._OUTPUT_LEVEL_MAPPING[value]}')

0 commit comments

Comments
 (0)