Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
01bdaab
Merge pull request #1 from home-assistant/dev
antonverburg Nov 15, 2019
47fcf38
Added support for the Pi4ioe5v9xxxx binary IO expanders.
antonverburg Nov 16, 2019
d13c85d
Merge branch 'dev' of https://github.com/antonverburg/home-assistant …
antonverburg Nov 16, 2019
ef3aed8
Merge pull request #2 from home-assistant/dev
antonverburg Nov 18, 2019
b9ac5b0
Correction for black failure
antonverburg Nov 18, 2019
a4ee95c
Correction for black failure
antonverburg Nov 18, 2019
ef29a50
Fix for manifest.json
antonverburg Nov 18, 2019
e6d17a1
Fix for flake8 fault missing a period
antonverburg Nov 18, 2019
133e698
Some modifications I made during tests seem to be disapeared, fixed f…
antonverburg Nov 18, 2019
1e72ab4
WIP virtual thermostat
DB-CL Sep 11, 2019
868ff1e
WIP virtual thermostat
DB-CL Sep 11, 2019
3269021
WIP
DB-CL Oct 6, 2019
a30ef9e
100% tests coverage
DB-CL Oct 14, 2019
05f7f47
Manifest, codeowners, typo fix
DB-CL Oct 16, 2019
639589b
Lint problem
DB-CL Oct 17, 2019
3ca5dc6
Test file blacked
DB-CL Oct 18, 2019
96f8188
Add a test case for b4dpxl's question
DB-CL Oct 21, 2019
a8ca158
Update CODEOWNERS
DB-CL Oct 21, 2019
4844179
Replacement of generic thermostat
DB-CL Jan 11, 2020
0927a84
Cleaning
DB-CL Jan 11, 2020
74f5519
Lint
DB-CL Jan 11, 2020
c73263a
More lint
DB-CL Jan 11, 2020
dd387ce
Using external PyPI package, removed get()
antonverburg Jan 29, 2020
ed1b6b1
Fix flake8 checks
antonverburg Jan 30, 2020
dda333e
Merge pull request #7 from home-assistant/dev
antonverburg Jan 31, 2020
ca0e73e
removed virtual thermostat
antonverburg Jan 31, 2020
4eab30d
Re-fix black & isort
antonverburg Jan 31, 2020
1d0948b
Re-fix isort 2
antonverburg Jan 31, 2020
b04a527
Merge branch 'virtual_thermostat' of https://github.com/DB-CL/home-as…
antonverburg Jan 31, 2020
a1647e2
Update homeassistant/components/pi4ioe5v9xxxx/binary_sensor.py
antonverburg Mar 30, 2020
79db9d7
Update homeassistant/components/pi4ioe5v9xxxx/binary_sensor.py
antonverburg Mar 30, 2020
8a6f8f1
Update homeassistant/components/pi4ioe5v9xxxx/switch.py
antonverburg Mar 30, 2020
347a1ad
Update homeassistant/components/pi4ioe5v9xxxx/switch.py
antonverburg Mar 30, 2020
26dffbe
Update homeassistant/components/pi4ioe5v9xxxx/switch.py
antonverburg Mar 30, 2020
8ab4f54
Update homeassistant/components/pi4ioe5v9xxxx/switch.py
antonverburg Mar 30, 2020
acaa66b
Merge branch 'dev' of https://github.com/antonverburg/home-assistant …
antonverburg Mar 30, 2020
2472ebc
black for switch
antonverburg Mar 31, 2020
e1c93d2
update to latest version manual merge
antonverburg Mar 31, 2020
319508b
Merge pull request #15 from home-assistant/dev
antonverburg Mar 31, 2020
4b11e62
Delete test_generic_thermostat.py
antonverburg Mar 31, 2020
a7ab2f3
Delete .gitignore
antonverburg Mar 31, 2020
7769f40
Delete climate.py
antonverburg Mar 31, 2020
c952966
Delete manifest.json
antonverburg Mar 31, 2020
1435e0e
Delete test_climate.py
antonverburg Mar 31, 2020
f4c2292
Delete test_climate.py
antonverburg Mar 31, 2020
1b0ef00
fix thermostat interference
antonverburg Mar 31, 2020
d400d61
fix thermostat interference 1
antonverburg Mar 31, 2020
2c098d7
fix thermostat interference 2
antonverburg Mar 31, 2020
48c9125
Fix pylint
antonverburg Apr 1, 2020
306feca
Merge pull request #16 from home-assistant/dev
antonverburg Apr 1, 2020
4da14b4
Update .pre-commit-config.yaml
antonverburg Apr 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ omit =
homeassistant/components/pencom/switch.py
homeassistant/components/philips_js/media_player.py
homeassistant/components/pi_hole/sensor.py
homeassistant/components/pi4ioe5v9xxxx/binary_sensor.py
homeassistant/components/pi4ioe5v9xxxx/switch.py
homeassistant/components/picotts/tts.py
homeassistant/components/piglow/light.py
homeassistant/components/pilight/*
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ homeassistant/components/panel_iframe/* @home-assistant/frontend
homeassistant/components/pcal9535a/* @Shulyaka
homeassistant/components/persistent_notification/* @home-assistant/core
homeassistant/components/philips_js/* @elupus
homeassistant/components/pi4ioe5v9xxxx/* @antonverburg
homeassistant/components/pi_hole/* @fabaff @johnluetke
homeassistant/components/pilight/* @trekky12
homeassistant/components/plaato/* @JohNan
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/pi4ioe5v9xxxx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Support for controlling IO expanders from Digital.com (PI4IOE5V9570, PI4IOE5V9674, PI4IOE5V9673, PI4IOE5V96224, PI4IOE5V96248)."""
80 changes: 80 additions & 0 deletions homeassistant/components/pi4ioe5v9xxxx/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
"""Support for binary sensor using RPi GPIO."""
import logging

from pi4ioe5v9xxxx import pi4ioe5v9xxxx # pylint: disable=import-error
import voluptuous as vol

from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
from homeassistant.const import DEVICE_DEFAULT_NAME
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

CONF_INVERT_LOGIC = "invert_logic"
CONF_PINS = "pins"
CONF_I2CBUS = "i2c_bus"
CONF_I2CADDR = "i2c_address"
CONF_BITS = "bits"

DEFAULT_INVERT_LOGIC = False
DEFAULT_BITS = 24
DEFAULT_BUS = 1
DEFAULT_ADDR = 0x20


_SENSORS_SCHEMA = vol.Schema({cv.positive_int: cv.string})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_PINS): _SENSORS_SCHEMA,
vol.Optional(CONF_I2CBUS, default=DEFAULT_BUS): cv.positive_int,
vol.Optional(CONF_I2CADDR, default=DEFAULT_ADDR): cv.positive_int,
vol.Optional(CONF_BITS, default=DEFAULT_BITS): cv.positive_int,
vol.Optional(CONF_INVERT_LOGIC, default=DEFAULT_INVERT_LOGIC): cv.boolean,
}
)


def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the IO expander devices."""
pins = config[CONF_PINS]
binary_sensors = []

pi4ioe5v9xxxx.setup(
i2c_bus=config[CONF_I2CBUS],
i2c_addr=config[CONF_I2CADDR],
bits=config[CONF_BITS],
read_mode=True,
invert=False,
)
for pin_num, pin_name in pins.items():
binary_sensors.append(
Pi4ioe5v9BinarySensor(pin_name, pin_num, config[CONF_INVERT_LOGIC])
)
add_entities(binary_sensors, True)


class Pi4ioe5v9BinarySensor(BinarySensorDevice):
"""Represent a binary sensor that uses pi4ioe5v9xxxx IO expander in read mode."""

def __init__(self, name, pin, invert_logic):
"""Initialize the pi4ioe5v9xxxx sensor."""
self._name = name or DEVICE_DEFAULT_NAME
self._pin = pin
self._invert_logic = invert_logic
self._state = pi4ioe5v9xxxx.pin_from_memory(self._pin)
Comment thread
antonverburg marked this conversation as resolved.

@property
def name(self):
"""Return the name of the sensor."""
return self._name

@property
def is_on(self):
"""Return the state of the entity."""
return self._state != self._invert_logic

def update(self):
"""Update the IO state."""
pi4ioe5v9xxxx.hw_to_memory()
self._state = pi4ioe5v9xxxx.pin_from_memory(self._pin)
8 changes: 8 additions & 0 deletions homeassistant/components/pi4ioe5v9xxxx/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"domain": "pi4ioe5v9xxxx",
"name": "pi4ioe5v9xxxx IO Expander",
"documentation": "https://www.home-assistant.io/integrations/pi4ioe5v9xxxx",
"requirements": ["pi4ioe5v9xxxx==0.0.2"],
"dependencies": [],
"codeowners": ["@antonverburg"]
}
92 changes: 92 additions & 0 deletions homeassistant/components/pi4ioe5v9xxxx/switch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
"""Allows to configure a switch using RPi GPIO."""
import logging

from pi4ioe5v9xxxx import pi4ioe5v9xxxx # pylint: disable=import-error
import voluptuous as vol

from homeassistant.components.switch import PLATFORM_SCHEMA
from homeassistant.const import DEVICE_DEFAULT_NAME
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import ToggleEntity

_LOGGER = logging.getLogger(__name__)

CONF_PINS = "pins"
CONF_INVERT_LOGIC = "invert_logic"
CONF_I2CBUS = "i2c_bus"
CONF_I2CADDR = "i2c_address"
CONF_BITS = "bits"

DEFAULT_INVERT_LOGIC = False
DEFAULT_BITS = 24
DEFAULT_BUS = 1
DEFAULT_ADDR = 0x20

_SWITCHES_SCHEMA = vol.Schema({cv.positive_int: cv.string})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_PINS): _SWITCHES_SCHEMA,
vol.Optional(CONF_I2CBUS, default=DEFAULT_BUS): cv.positive_int,
vol.Optional(CONF_I2CADDR, default=DEFAULT_ADDR): cv.positive_int,
vol.Optional(CONF_BITS, default=DEFAULT_BITS): cv.positive_int,
vol.Optional(CONF_INVERT_LOGIC, default=DEFAULT_INVERT_LOGIC): cv.boolean,
}
)


def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the swiches devices."""
pins = config.get(CONF_PINS)
switches = []

pi4ioe5v9xxxx.setup(
i2c_bus=config[CONF_I2CBUS],
i2c_addr=config[CONF_I2CADDR],
bits=config[CONF_BITS],
read_mode=False,
invert=False,
)
for pin, name in pins.items():
switches.append(Pi4ioe5v9Switch(name, pin, config[CONF_INVERT_LOGIC]))
add_entities(switches)


class Pi4ioe5v9Switch(ToggleEntity):
Comment thread
antonverburg marked this conversation as resolved.
"""Representation of a pi4ioe5v9 IO expansion IO."""

def __init__(self, name, pin, invert_logic):
"""Initialize the pin."""
self._name = name or DEVICE_DEFAULT_NAME
self._pin = pin
self._invert_logic = invert_logic
self._state = False

@property
def name(self):
"""Return the name of the switch."""
return self._name

@property
def should_poll(self):
Comment thread
antonverburg marked this conversation as resolved.
"""No polling needed."""
return False

@property
def is_on(self):
"""Return true if device is on."""
return self._state

def turn_on(self, **kwargs):
"""Turn the device on."""
pi4ioe5v9xxxx.pin_to_memory(self._pin, not self._invert_logic)
pi4ioe5v9xxxx.memory_to_hw()
self._state = True
self.schedule_update_ha_state()

def turn_off(self, **kwargs):
"""Turn the device off."""
pi4ioe5v9xxxx.pin_to_memory(self._pin, self._invert_logic)
pi4ioe5v9xxxx.memory_to_hw()
self._state = False
self.schedule_update_ha_state()
3 changes: 3 additions & 0 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,9 @@ pencompy==0.0.3
# homeassistant.components.unifi_direct
pexpect==4.6.0

# homeassistant.components.pi4ioe5v9xxxx
pi4ioe5v9xxxx==0.0.2

# homeassistant.components.rpi_pfio
pifacecommon==4.2.2

Expand Down