-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Support for pi4ioe5v9xxxx I2C IO expanders #28847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 47fcf38
Added support for the Pi4ioe5v9xxxx binary IO expanders.
antonverburg d13c85d
Merge branch 'dev' of https://github.com/antonverburg/home-assistant …
antonverburg ef3aed8
Merge pull request #2 from home-assistant/dev
antonverburg b9ac5b0
Correction for black failure
antonverburg a4ee95c
Correction for black failure
antonverburg ef29a50
Fix for manifest.json
antonverburg e6d17a1
Fix for flake8 fault missing a period
antonverburg 133e698
Some modifications I made during tests seem to be disapeared, fixed f…
antonverburg 1e72ab4
WIP virtual thermostat
DB-CL 868ff1e
WIP virtual thermostat
DB-CL 3269021
WIP
DB-CL a30ef9e
100% tests coverage
DB-CL 05f7f47
Manifest, codeowners, typo fix
DB-CL 639589b
Lint problem
DB-CL 3ca5dc6
Test file blacked
DB-CL 96f8188
Add a test case for b4dpxl's question
DB-CL a8ca158
Update CODEOWNERS
DB-CL 4844179
Replacement of generic thermostat
DB-CL 0927a84
Cleaning
DB-CL 74f5519
Lint
DB-CL c73263a
More lint
DB-CL dd387ce
Using external PyPI package, removed get()
antonverburg ed1b6b1
Fix flake8 checks
antonverburg dda333e
Merge pull request #7 from home-assistant/dev
antonverburg ca0e73e
removed virtual thermostat
antonverburg 4eab30d
Re-fix black & isort
antonverburg 1d0948b
Re-fix isort 2
antonverburg b04a527
Merge branch 'virtual_thermostat' of https://github.com/DB-CL/home-as…
antonverburg a1647e2
Update homeassistant/components/pi4ioe5v9xxxx/binary_sensor.py
antonverburg 79db9d7
Update homeassistant/components/pi4ioe5v9xxxx/binary_sensor.py
antonverburg 8a6f8f1
Update homeassistant/components/pi4ioe5v9xxxx/switch.py
antonverburg 347a1ad
Update homeassistant/components/pi4ioe5v9xxxx/switch.py
antonverburg 26dffbe
Update homeassistant/components/pi4ioe5v9xxxx/switch.py
antonverburg 8ab4f54
Update homeassistant/components/pi4ioe5v9xxxx/switch.py
antonverburg acaa66b
Merge branch 'dev' of https://github.com/antonverburg/home-assistant …
antonverburg 2472ebc
black for switch
antonverburg e1c93d2
update to latest version manual merge
antonverburg 319508b
Merge pull request #15 from home-assistant/dev
antonverburg 4b11e62
Delete test_generic_thermostat.py
antonverburg a7ab2f3
Delete .gitignore
antonverburg 7769f40
Delete climate.py
antonverburg c952966
Delete manifest.json
antonverburg 1435e0e
Delete test_climate.py
antonverburg f4c2292
Delete test_climate.py
antonverburg 1b0ef00
fix thermostat interference
antonverburg d400d61
fix thermostat interference 1
antonverburg 2c098d7
fix thermostat interference 2
antonverburg 48c9125
Fix pylint
antonverburg 306feca
Merge pull request #16 from home-assistant/dev
antonverburg 4da14b4
Update .pre-commit-config.yaml
antonverburg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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).""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
|
|
||
| @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) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): | ||
|
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): | ||
|
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() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.