Skip to content

Commit

Permalink
- PLC_StatelessProgrammableSwitch and PLC_Doorbell corrected conf…
Browse files Browse the repository at this point in the history
…ig schema for get_ProgrammableSwitchEvent and fixed poll issue
  • Loading branch information
Feilner committed Dec 13, 2024
1 parent 67eef0f commit 051f160
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
- Version 2.0.x has changed the name of some configurations.
- Please stay on version 1.0.x if you do not want to adapt your configuration.

## [2.0.5] 2024-12-13

### Fixed
- `PLC_StatelessProgrammableSwitch` and `PLC_Doorbell` corrected config schema for get_ProgrammableSwitchEvent and fixed poll issue

## [2.0.4] 2024-08-17

### Fixed
Expand Down
7 changes: 6 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,13 @@
"type": "number",
"description": "offset and bit that is polled by homebridge-plc. <br><b>NOTE:</b>PLC has to set to `true`. When polled with value `true` the actual event is read from `get_ProgrammableSwitchEvent` and this flas is set to `false` by homebirdge-plc to confirm that the event is handled. S7 type `Bool` e.g. `55.1` for `DB4DBX55.1` <b>(polling only, not used for push)</b>"
},
"get_ProgrammableSwitchEvent": {
"title": "get_ProgrammableSwitchEvent <b>(push support)</b> <b>(control support)</b>",
"type": "number",
"description": "offset to read current event of the switch. This is reported towards home app S7 type `Byte` e.g. `3` for `DB4DBB3`<br> - `0`: single press<br> - `1`: double press<br> - `2`: long press<br> - `3`: unknown"
},
"get_LockCurrentState": {
"title": "get_LockCurrentState <b>(push support)</b> <b>(push support)</b>",
"title": "get_LockCurrentState <b>(push support)</b>",
"type": "number",
"description": "offset to read current state current state S7 type `Bool` .g. `3.1` for `DB4DBB3`<br> - `false`: secured<br> - `true`: unsecured"
},
Expand Down
35 changes: 19 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3041,26 +3041,29 @@ GenericPLCAccessory.prototype = {
// StatelessProgrammableSwitch, Doorbell
////////////////////////////////////////////////////////////////
else if (this.config.accessory == 'PLC_StatelessProgrammableSwitch' || this.config.accessory == 'PLC_Doorbell'){
this.getBit(function(err,value){
if(!err && value)
{
this.getByte(function(err, event) {
if (!err) {
this.service.getCharacteristic(Characteristic.ProgrammableSwitchEvent).updateValue(event);
this.log.info( "[" + this.name + "] Stateless switch event :" + event);
this.setBit(0,function(err){},
// poll isEvent bit and evaluate in callback
this.getBit(
function(err, isEvent) {
if(!err && isEvent) {
// isEvent is set get get ProgrammableSwitchEvent value
this.getByte(
function(err, value) {
if (!err) {
this.log.info( "[" + this.name + "] Stateless switch event :" + value);
this.service.getCharacteristic(Characteristic.ProgrammableSwitchEvent).updateValue(value);
// clear isEvent after sucessful reading ProgrammableSwitchEvent
this.setBit( 0 ,function(err){},
this.config.db,
Math.floor(this.config.isEvent), Math.floor((this.config.isEvent*10)%10),
'clear IsEvent');
}
}.bind(this),
this.config.db,
this.config.get_ProgrammableSwitchEvent,
'read Event'
),
this.service.getCharacteristic(Characteristic.ProgrammableSwitchEvent).getValue();
}
}.bind(this),
this.config.db,
this.config.get_ProgrammableSwitchEvent,
'read Event'
);
}
}.bind(this),
}.bind(this),
this.config.db,
Math.floor(this.config.isEvent), Math.floor((this.config.isEvent*10)%10),
'poll isEvent'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-plc",
"version": "2.0.4",
"version": "2.0.5",
"description": "Homebridge plugin for Siemens Step7 and compatible PLCs. (https://github.com/homebridge)",
"license": "MIT",
"keywords": [
Expand Down

0 comments on commit 051f160

Please sign in to comment.