Skip to content

Commit

Permalink
v1.0.25 (#26)
Browse files Browse the repository at this point in the history
### Added
- `PLC_Thermostat`: add push support for `get_CurrentHeatingCoolingState`
- `PLC_Thermostat`: add support for `get_TargetHeatingCoolingState` and `set_TargetHeatingCoolingState` including `mapGetTarget` and `mapSetTarget`

### Fixed
- `PLC_Thermostat` fixed documentation of `get_CurrentHeatingCoolingState`
- `PLC_Thermostat` remove warning when using `get_StatusTampered` or `get_StatusLowBattery` see homebridge/homebridge#2768
  • Loading branch information
Feilner authored Jan 19, 2021
1 parent 6501ffc commit 6d91d36
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 19 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# Changelog


## [1.0.25] 2021-01.19

### Added
- `PLC_Thermostat`: add push support for `get_CurrentHeatingCoolingState`
- `PLC_Thermostat`: add support for `get_TargetHeatingCoolingState` and `set_TargetHeatingCoolingState` including `mapGetTarget` and `mapSetTarget`

### Fixed
- `PLC_Thermostat` fixed documentation of `get_CurrentHeatingCoolingState`
- `PLC_Thermostat` remove warning when using `get_StatusTampered` or `get_StatusLowBattery` see https://github.com/homebridge/homebridge/issues/2768

## [1.0.24] - 2021-01-05

### Added
Expand Down
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ normal temperature sensor
- `minValue` default value: -50
- `maxValue` default value: 50
- `minStep` default value: 0.5
- `get_StatusTampered`: **(optional)** **(push support)** offset and bit to tamper detection. (Home app shows this only within the options) S7 type `Bool` e.g. `55.2` for `DB4DBX55.2` **Note:** Homebridge 1.2.5 generates a warning when using this.
- `get_StatusTampered`: **(optional)** **(push support)** offset and bit to tamper detection. (Home app shows this only within the options) S7 type `Bool` e.g. `55.2` for `DB4DBX55.2`
- `false`: ok
- `true`: tampered
- `get_StatusLowBattery`: **(optional)** **(push support)** offset and bit to battery low detection. (Home app does not inform with push notification) S7 type `Bool` e.g. `55.3` for `DB4DBX55.3` **Note:** Homebridge 1.2.5 generates a warning when using this.
- `get_StatusLowBattery`: **(optional)** **(push support)** offset and bit to battery low detection. (Home app does not inform with push notification) S7 type `Bool` e.g. `55.3` for `DB4DBX55.3`
- `false`: ok
- `true`: battery low

Expand Down Expand Up @@ -196,17 +196,22 @@ temperature sensor and temperature regulation
- `minHumidityValue` default value: 0
- `maxHumidityValue` default value: 100
- `minHumidityStep` default value: 1
- `get_CurrentHeatingCoolingState`: **(optional)** current heating/cooling state when not present fixed `1` is used S7 type `Byte` e.g. `8` for `DB4DBB58`
- `0`: inactive
- `1`: idle
- `2`: heating
- `3`: cooling
- `get_TargetHeatingCoolingState` not yet supported returns fixed `3`
- `get_CurrentHeatingCoolingState`: **(optional)** **(push support)** offset to get current heating/cooling state S7 type `Byte` e.g. `8` for `DB4DBB8`. When not defined fixed `1`: heating is used.
- `0`: inactive (shown as green in home app)
- `1`: heating (shown as orange in home app)
- `2`: cooling (shown as blue in home app)
- `get_TargetHeatingCoolingState` **(optional)** **(push support)** offset to get target heating/cooling state. S7 type `Byte` e.g. `9` for `DB4DBB9`. When not defined fixed `3`: automatic is used.
- `0`: off
- `1`: heat
- `2`: cool
- `3`: automatic
- `set_TargetHeatingCoolingState` **(optional)** **(control support)** offset to set target heating/cooling state. Can be identical with `get_TargetHeatingCoolingState`. Has to be defined when `get_TargetHeatingCoolingState` is defined. When not defined writes changes are ignored. S7 type `Byte` e.g. `9` for `DB4DBB9`.
- `0`: off
- `1`: heat
- `2`: cool
- `3`: automatic
- `set_TargetHeatingCoolingState` not yet supported writes are ignored
- `mapGetTarget`: **(optional)** define mapping array for get target heating cooling state. The PLC value is used as index into the table. e.g. `[0, 3]` which maps the PLC value `0->0 1->3` when the PLC supports only two states with `0:off` and and `1:automatic`.
- `mapSetTarget`: **(optional)** define mapping array for set target heating cooling state. The home app value is used as index into the table. e.g. `[0, 1, 0, 3]` which maps the PLC value `0->0 1->1 2->0, 3->3` when the PLC supports only two states with `0:off` and `1:heat` and `3:automatic`. The state cool is mapped to off.
- `get_StatusTampered`: **(optional)** **(push support)** offset and bit to tamper detection. (Home app shows this only within the options) S7 type `Bool` e.g. `55.2` for `DB4DBX55.2`
- `false`: ok
- `true`: tampered
Expand Down Expand Up @@ -581,6 +586,12 @@ Note: The example is just an example it contains also some optional settings. Fo
"get_TargetTemperature": 16,
"set_TargetTemperature": 16,
"get_CurrentHeatingCoolingState": 20
"mapSetTarget": [
0,
1,
0,
3
],
},
{
"accessory": "PLC_WindowCovering",
Expand Down
83 changes: 73 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,29 @@ function GenericPLCAccessory(platform, config, accessoryNumber) {
this.service = new Service.Thermostat(this.name);
this.accessory.addService(this.service);

informFunction = function(notUsed){
// update target state and current state value.
this.service.getCharacteristic(Characteristic.TargetHeatingCoolingState).getValue(function(err, value) {
if (!err) {
this.service.getCharacteristic(Characteristic.TargetHeatingCoolingState).updateValue(value);
}
}.bind(this));

this.service.getCharacteristic(Characteristic.CurrentHeatingCoolingState).getValue(function(err, value) {
if (!err) {
this.service.getCharacteristic(Characteristic.CurrentHeatingCoolingState).updateValue(value);
}
}.bind(this));
}.bind(this);

if ('mapSetTarget' in config && config.mapSet) {
this.modFunctionSet = function(value){return this.mapFunction(value, config.mapSetTarget);}.bind(this);
}

if ('mapGetTarget' in config && config.mapGet) {
this.modFunctionGet = function(value){return this.mapFunction(value, config.mapGetTarget);}.bind(this);
}

if ('get_CurrentHeatingCoolingState' in config) {
this.service.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
.on('get', function(callback) {this.getByte(callback,
Expand All @@ -378,16 +401,34 @@ function GenericPLCAccessory(platform, config, accessoryNumber) {
);}.bind(this));
}

this.service.getCharacteristic(Characteristic.TargetHeatingCoolingState)
.on('get', function(callback) {this.getDummy(callback,
3, // currently return fixed value off=0, heat=1, cool=2, automatic=3
'get TargetHeatingCoolingState'
);}.bind(this))
.on('set', function(value, callback) {this.setDummy(value, callback,
'set TargetHeatingCoolingState',
// stick to fixed value
function(value){ this.service.getCharacteristic(Characteristic.TargetHeatingCoolingState).updateValue(3); }.bind(this)
);}.bind(this));
if ('get_TargetHeatingCoolingState' in config) {
this.service.getCharacteristic(Characteristic.TargetHeatingCoolingState)
.on('get', function(callback) {this.getByte(callback,
config.db,
config.get_TargetHeatingCoolingState,
'get TargetHeatingCoolingState',
this.modFunctionGet
);}.bind(this))
.on('set', function(value, callback) {this.setByte(value, callback,
config.db,
config.set_TargetHeatingCoolingState,
'set TargetHeatingCoolingState',
informFunction,
this.modFunctionSet
);}.bind(this));
}
else {
this.service.getCharacteristic(Characteristic.TargetHeatingCoolingState)
.on('get', function(callback) {this.getDummy(callback,
3, // currently return fixed value off=0, heat=1, cool=2, automatic=3
'get TargetHeatingCoolingState'
);}.bind(this))
.on('set', function(value, callback) {this.setDummy(value, callback,
'set TargetHeatingCoolingState',
// ignore set and return current fixed values
informFunction
);}.bind(this));
}

this.service.getCharacteristic(Characteristic.TemperatureDisplayUnits)
.on('get', function(callback) {this.getDummy(callback,
Expand Down Expand Up @@ -450,6 +491,8 @@ function GenericPLCAccessory(platform, config, accessoryNumber) {
}

if ('get_StatusTampered' in config) {
//Silence warning that the characteristic is not supported.
this.service.addCharacteristic(Characteristic.StatusTampered);
this.service.getCharacteristic(Characteristic.StatusTampered)
.on('get', function(callback) {this.getBit(callback,
config.db,
Expand All @@ -459,6 +502,8 @@ function GenericPLCAccessory(platform, config, accessoryNumber) {
}

if ('get_StatusLowBattery' in config) {
//Silence warning that the characteristic is not supported.
this.service.addCharacteristic(Characteristic.StatusLowBattery);
this.service.getCharacteristic(Characteristic.StatusLowBattery)
.on('get', function(callback) {this.getBit(callback,
config.db,
Expand Down Expand Up @@ -1204,6 +1249,18 @@ GenericPLCAccessory.prototype = {
this.service.getCharacteristic(Characteristic.TargetRelativeHumidity).updateValue(value);
rv = true;
}
if (this.config.get_CurrentHeatingCoolingState == offset)
{
this.log.debug( "[" + this.name + "] Push CurrentHeatingCoolingState:" + value);
this.service.getCharacteristic(Characteristic.CurrentHeatingCoolingState).updateValue(value);
rv = true;
}
if (this.config.get_TargetHeatingCoolingState == offset)
{
this.log.debug( "[" + this.name + "] Push TargetHeatingCoolingState:" + value);
this.service.getCharacteristic(Characteristic.TargetHeatingCoolingState).updateValue(value);
rv = true;
}
if (this.config.get_StatusTampered == offset)
{
this.log.debug( "[" + this.name + "] Push StatusTampered:" + value);
Expand Down Expand Up @@ -1493,6 +1550,12 @@ GenericPLCAccessory.prototype = {
this.service.getCharacteristic(Characteristic.TargetRelativeHumidity).setValue(value);
rv = true;
}
if (this.config.set_TargetHeatingCoolingState == offset)
{
this.log.debug( "[" + this.name + "] Control TargetHeatingCoolingState:" + value);
this.service.getCharacteristic(Characteristic.TargetHeatingCoolingState).setValue(value);
rv = true;
}
}
// CONTROL handling ////////////////////////////////////////////
// Window, WindowCovering and Door
Expand Down

0 comments on commit 6d91d36

Please sign in to comment.