Skip to content

Commit

Permalink
fix for port ranges, back to int
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeneef committed Jul 2, 2024
1 parent d641701 commit 75861e7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This HACS integration is used to address GPIO (especially and only tested for Ra

**This is working in my homeassistant environment, that's it. Shared for testing and usage at your own risk!**

This is a rewrite of [ha-rpi_gpio](https://github.com/thecode/ha-rpi_gpio) adapted in [ha-gpio](https://codeberg.org/raboof/ha-gpio) and rewritten by me ..
`ha_gpiod` is based on [ha-rpi_gpio](https://github.com/thecode/ha-rpi_gpio), which was already adapted for `gpiod` in [ha-gpio](https://codeberg.org/raboof/ha-gpio) and rewritten from scratch by me ..

# Installation
Via HACS: add as custom repository from github using this github https://github.com/jdeneef/ha_gpiod/ (HACS => integrations => 3-dots menu => custom repositories, go back to hacs, install gpiod component, reboot, add config, reboot)
Expand Down Expand Up @@ -83,9 +83,9 @@ Key | Required | Default | Type | Description
`unique_id` | no | generated | string | An ID that uniquely identifies the sensor. Set this to a unique value to allow customization through the UI, auto generated when not set manually in config
`debounce` | no | `50` | integer | The time in milliseconds for port debouncing
`active_low` | no | `false` | boolean | If `true`, input of `gpio` is inverted, `active_low` results in `on`
`invert_logic` | *retrofit* | | boolean | see `active_low`, might be removed in the future
`invert_logic` | *backwards compatibility* | | boolean | see `active_low`, might be removed in the future
`bias` | no | `PULL_UP` | string | control bias setting of GPIO, used to define the electrical state of a GPIO line when not actively driven; `PULL_UP` set weak pull-up resistor on the line, ensuring that the line is pulled to a high level (3.3V or 5V) when not actively driven; `PULL_DOWN` sets weak pull-down resistor to pull to low level (0V), `DISABLED` remains floating, `AS_IS` not changed
`pull_mode` | *retrofit* | | string | see `bias`, might be removed in the future
`pull_mode` | *backwards compatibility* | | string | see `bias`, might be removed in the future


## Switch
Expand All @@ -102,9 +102,9 @@ Key | Required | Default | Type | Description
`port` | yes | | integer | the GPIO port to be used
`unique_id` | no | generated | string | An ID that uniquely identifies the switch. Set this to a unique value to allow customization through the UI, auto generated when not set manually in config
`active_low` | no | `false` | boolean | If `true`, output of `gpio` is inverted, `active_low` switches `on`
`invert_logic` | *retrofit* | | boolean | see `active_low`, might be removed in the future
`invert_logic` | *backwards compatibility* | | boolean | see `active_low`, might be removed in the future
`bias` | no | `AS_IS` | string | Type of internal pull resistor to use: `PULL_UP` - pull-up resistor, `PULL_DOWN` - pull-down resistor, `AS-IS` no change
`pull_mode`|*retrofit*| |string|see `bias`, might be removed in the future
`pull_mode`|*backwards compatibility*| |string|see `bias`, might be removed in the future
`drive`|no| `PUSH_PULL`|string | control drive configuration of the GPIO, determines how the line behaves when it is set to output mode; `PUSH_PULL`, GPIO line can both source and sink current, can actively drive the line to both high and low states. `OPEN-DRAIN`, GPPIO can only sink current (drive the line to low) and is otherwise left floating, and `OPEN-SOURCE` the reverse.

## Cover
Expand All @@ -117,18 +117,18 @@ Key | Required | Default | Type | Description
--- | --- | --- | --- | ---
`name` | yes | | string | The name for the cover entity
`relay_port`|yes| |integer|Relay switch gpio switching cover motor
`relay_pin`|*retrofit*| |integer|see `relay_port`, might be removed in the future
`relay_pin`|*backwards compatibility*| |integer|see `relay_port`, might be removed in the future
`relay_time`|no|`200` |integer|Time in milliseconds relay switch will be switched to open/close cover
`relay_active_low`|no | `false`| boolean| invert input for `relay_port`
`invert_relay`|*retrofit*| | boolean|see `relay_active_low`, might be removed in the future
`invert_relay`|*backwards compatibility*| | boolean|see `relay_active_low`, might be removed in the future
`relay_bias` | no | `AS_IS` | string | Type of internal pull resistor to use: `PULL_UP` - pull-up resistor, `PULL_DOWN` - pull-down resistor
`relay_drive`|no|`PUSH_PULL`|string|set `relay_pin` `drive_mode`, options: `OPEN_DRAIN`, `OPEN_SOURCE`, `PUSH_PULL`
`state_port`|yes| | integer|State port for opened/closed status of cover
`state_pin`|*retrofit*| | integer|see `state_port`, might be removed in the future
`state_pin`|*backwards compatibility*| | integer|see `state_port`, might be removed in the future
`state_bias` | no | `PULL_UP` | string | Type of internal pull resistor to use: `PULL_UP` - pull-up resistor, `PULL_DOWN` - pull-down resistor
`state_pull_mode`|*retrofit*| |string|see `state_bias`, might be removed in the future
`state_pull_mode`|*backwards compatibility*| |string|see `state_bias`, might be removed in the future
`state_active_low`|no | `false`| boolean| invert output for state pin
`invert_state`|*retrofit*| |boolean|see `state_active_low`, might be removed in the future
`invert_state`|*backwards compatibility*| |boolean|see `state_active_low`, might be removed in the future
`unique_id` | no | generated | string | An ID that uniquely identifies the switch. Set this to a unique value to allow customization through the UI, auto generated when not set manually in config

## Add Debug info and issue reporting
Expand Down
2 changes: 1 addition & 1 deletion custom_components/gpiod/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
vol.Exclusive(CONF_SENSORS, CONF_SENSORS): vol.All(
cv.ensure_list, [{
vol.Required(CONF_NAME): cv.string,
vol.Required(CONF_PORT): vol.In(list(range(1,40))),
vol.Required(CONF_PORT): cv.positive_int,
vol.Optional(CONF_UNIQUE_ID): cv.string,
vol.Optional(CONF_ACTIVE_LOW): cv.boolean,
vol.Optional("invert_logic"): cv.boolean, # backwards compatibility for now
Expand Down
8 changes: 4 additions & 4 deletions custom_components/gpiod/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
vol.Exclusive(CONF_COVERS, CONF_COVERS): vol.All(
cv.ensure_list, [{
vol.Required(CONF_NAME): cv.string,
vol.Optional(CONF_RELAY_PORT): vol.In(list(range(1,40))),
vol.Optional("relay_pin"): vol.In(list(range(1,40))), # backwards compatibility for now
vol.Optional(CONF_RELAY_PORT): cv.positive_int,
vol.Optional("relay_pin"): cv.positive_int, # backwards compatibility for now
vol.Optional(CONF_RELAY_TIME, default=DEFAULT_RELAY_TIME): cv.positive_int,
vol.Optional(CONF_RELAY_ACTIVE_LOW): cv.boolean,
vol.Optional("invert_relay"): cv.boolean, # backwards compatibility for now
vol.Optional(CONF_RELAY_BIAS, default=DEFAULT_RELAY_BIAS): vol.In(BIAS.keys()),
vol.Optional(CONF_RELAY_DRIVE, default=DEFAULT_RELAY_DRIVE): vol.In(DRIVE.keys()),
vol.Optional(CONF_STATE_PORT): vol.In(list(range(1,40))),
vol.Optional("state_pin"): vol.In(list(range(1,40))), # backwards compatibility for now
vol.Optional(CONF_STATE_PORT): cv.positive_int,
vol.Optional("state_pin"): cv.positive_int, # backwards compatibility for now
vol.Optional(CONF_STATE_BIAS): vol.In(BIAS.keys()),
vol.Optional("state_pull_mode"): vol.In(BIAS.keys()), # backwards compatibility for now
vol.Optional(CONF_STATE_ACTIVE_LOW): cv.boolean,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/gpiod/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
vol.Exclusive(CONF_SWITCHES, CONF_SWITCHES): vol.All(
cv.ensure_list, [{
vol.Required(CONF_NAME): cv.string,
vol.Required(CONF_PORT): vol.In(list(range(1,40))),
vol.Required(CONF_PORT): cv.positive_int,
vol.Optional(CONF_UNIQUE_ID): cv.string,
vol.Optional(CONF_ACTIVE_LOW): cv.boolean,
vol.Optional("invert_logic"): cv.boolean, # backwards compatibility for now
Expand Down

0 comments on commit 75861e7

Please sign in to comment.