mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix remote_rpi_gpio switch inversion (#34390)
This removes the double-inversion of switches on the remote_rpi_gpio platform. Fixes #24571
This commit is contained in:
parent
6273ad85f8
commit
58f1d1754e
@ -26,7 +26,9 @@ def setup_output(address, port, invert_logic):
|
||||
"""Set up a GPIO as output."""
|
||||
|
||||
try:
|
||||
return LED(port, active_high=invert_logic, pin_factory=PiGPIOFactory(address))
|
||||
return LED(
|
||||
port, active_high=not invert_logic, pin_factory=PiGPIOFactory(address)
|
||||
)
|
||||
except (ValueError, IndexError, KeyError):
|
||||
return None
|
||||
|
||||
|
@ -37,7 +37,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
led = remote_rpi_gpio.setup_output(address, port, invert_logic)
|
||||
except (ValueError, IndexError, KeyError, OSError):
|
||||
return
|
||||
new_switch = RemoteRPiGPIOSwitch(name, led, invert_logic)
|
||||
new_switch = RemoteRPiGPIOSwitch(name, led)
|
||||
devices.append(new_switch)
|
||||
|
||||
add_entities(devices)
|
||||
@ -46,11 +46,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
class RemoteRPiGPIOSwitch(SwitchDevice):
|
||||
"""Representation of a Remtoe Raspberry Pi GPIO."""
|
||||
|
||||
def __init__(self, name, led, invert_logic):
|
||||
def __init__(self, name, led):
|
||||
"""Initialize the pin."""
|
||||
self._name = name or DEVICE_DEFAULT_NAME
|
||||
self._state = False
|
||||
self._invert_logic = invert_logic
|
||||
self._switch = led
|
||||
|
||||
@property
|
||||
@ -75,12 +74,12 @@ class RemoteRPiGPIOSwitch(SwitchDevice):
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the device on."""
|
||||
remote_rpi_gpio.write_output(self._switch, 0 if self._invert_logic else 1)
|
||||
remote_rpi_gpio.write_output(self._switch, 1)
|
||||
self._state = True
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn the device off."""
|
||||
remote_rpi_gpio.write_output(self._switch, 1 if self._invert_logic else 0)
|
||||
remote_rpi_gpio.write_output(self._switch, 0)
|
||||
self._state = False
|
||||
self.schedule_update_ha_state()
|
||||
|
Loading…
x
Reference in New Issue
Block a user