Skip to content

Commit

Permalink
correct interpretation of outlow/outhigh
Browse files Browse the repository at this point in the history
was just start value.. hm.
  • Loading branch information
Garfonso committed Dec 19, 2024
1 parent c6caeb9 commit 1ce87e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ Connect such a sensor to a GPIO pin as described on the [node-dht-sensor](https:
PLACEHOLDER for the next version:
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
* (Garfonso) correct interpretation of start value setting.

### 2.2.2 (2024-11-02)
* (simatec) responsive design for settings page added

Expand Down
17 changes: 9 additions & 8 deletions lib/gpioControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,14 @@ class GpioControl {
*/
async writeGpio(port, value) {
if (value === undefined) {
value = (await this.adapter.getStateAsync('gpio.' + port + '.state'))?.val;
// set the value based on configuration or state.
if (this.gpioPorts[port].configuration === 'outhigh') {
value = true;
} else if (this.gpioPorts[port].configuration === 'outlow') {
value = false;
} else {
value = (await this.adapter.getStateAsync('gpio.' + port + '.state'))?.val;
}
}

if (typeof port === 'string') {
Expand All @@ -228,13 +235,7 @@ class GpioControl {
try {
if (this.gpioPorts[port]) {
try {
let invert = false;
if (this.gpioSettings[port].configuration === 'outhigh') {
this.log.debug(`Inverting value from ${value} to ${!value} for port ${port} because set to ${this.gpioSettings[port].configuration}`);
invert = true;
}

this.gpioPorts[port].value = invert ? !value : value;
this.gpioPorts[port].value = value;
this.log.debug('Written ' + value + ' into port ' + port);
await this.adapter.setStateAsync('gpio.' + port + '.state', value, true);
} catch (err) {
Expand Down

0 comments on commit 1ce87e3

Please sign in to comment.