Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 40f00e8

Browse files
committed
worked on initial query #496
1 parent 482a94a commit 40f00e8

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

ChannelServices/HomeMaticHomeKitGarageDoorService.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ HomeMaticHomeKitGarageDoorService.prototype.createDeviceService = function (Serv
166166
// there is a actor for every direction so
167167
if (value === Characteristic.TargetDoorState.OPEN) {
168168
that.currentDoorState.updateValue(that.characteristic.CurrentDoorState.OPENING, null)
169-
170169
that.sendActorMessage(that.address_actor_open, that.message_actor_open['on'])
171170
that.sendActorMessage(that.address_actor_open, that.message_actor_open['off'], that.delay_actor_open)
172171
// reset Command Switch to override target
@@ -197,10 +196,10 @@ HomeMaticHomeKitGarageDoorService.prototype.createDeviceService = function (Serv
197196
this.platform.registerAdressForEventProcessingAtAccessory(this.address_sensor_open, this)
198197
// this is dirty shit .. ¯\_(ツ)_/¯ it works so we do not change that ...
199198
// query sensors at launch delayed by 60 seconds
200-
setTimeout(function () {
199+
this.inittimer = setTimeout(function () {
201200
that.log.debug('garage door inital query ...')
202201
that.querySensors()
203-
}, 60000)
202+
}, 30000)
204203
}
205204

206205
HomeMaticHomeKitGarageDoorService.prototype.sendActorMessage = function (address, message, delay) {
@@ -243,18 +242,19 @@ HomeMaticHomeKitGarageDoorService.prototype.event = function (channel, dp, newVa
243242
let eventAddress = channel + '.' + dp
244243
// Kill requery timer
245244
clearTimeout(this.requeryTimer)
245+
clearTimeout(this.inittimer)
246246

247247
if ((this.address_sensor_close !== undefined) && (this.address_sensor_open !== undefined)) {
248248
// we have two sensors
249249
this.log.debug('Two Sensor Mode')
250-
if ((eventAddress === this.address_sensor_close) && (newValue === this.state_sensor_close)) {
250+
if ((eventAddress === this.address_sensor_close) && (this.didMatch(newValue, this.state_sensor_close))) {
251251
// Sensor Close said its closed
252252
this.log.debug('close sensor is %s set CurrentDoorState to close', newValue)
253253
this.currentDoorState.updateValue(this.characteristic.CurrentDoorState.CLOSED, null)
254254
this.targetCommand = false
255255
}
256256

257-
if ((eventAddress === this.address_sensor_close) && (newValue !== this.state_sensor_close)) {
257+
if ((eventAddress === this.address_sensor_close) && (!(this.didMatch(newValue, this.state_sensor_close)))) {
258258
// Sensor Close just opened so the door is moving to open position
259259
this.log.debug('close sensor is %s set TargetDoorState to open CurrentDoorState to opening', newValue)
260260
if (this.targetCommand) {
@@ -263,14 +263,14 @@ HomeMaticHomeKitGarageDoorService.prototype.event = function (channel, dp, newVa
263263
this.currentDoorState.updateValue(this.characteristic.CurrentDoorState.OPENING, null)
264264
}
265265

266-
if ((eventAddress === this.address_sensor_open) && (newValue === this.state_sensor_open)) {
266+
if ((eventAddress === this.address_sensor_open) && (this.didMatch(newValue, this.state_sensor_open))) {
267267
// Sensor Open said its open
268268
this.log.debug('open sensor is %s set CurrentDoorState to open', newValue)
269269
this.currentDoorState.updateValue(this.characteristic.CurrentDoorState.OPEN, null)
270270
this.targetCommand = false
271271
}
272272

273-
if ((eventAddress === this.address_sensor_open) && (newValue !== this.state_sensor_open)) {
273+
if ((eventAddress === this.address_sensor_open) && (!(this.didMatch(newValue, this.state_sensor_open)))) {
274274
// Sensor open just went to false so the door is moving to close position
275275
this.log.debug('open sensor is %s set TargetDoorState to close CurrentDoorState to closing', newValue)
276276
if (this.targetCommand) {
@@ -284,27 +284,27 @@ HomeMaticHomeKitGarageDoorService.prototype.event = function (channel, dp, newVa
284284
if (eventAddress === this.address_sensor_close) {
285285
// first set a new target state but ony if the target was not set by homekit first
286286
if (this.targetCommand === false) {
287-
let newState = (newValue === that.state_sensor_close) ? this.characteristic.TargetDoorState.CLOSED : this.characteristic.TargetDoorState.OPEN
287+
let newState = (this.didMatch(newValue, that.state_sensor_close)) ? this.characteristic.TargetDoorState.CLOSED : this.characteristic.TargetDoorState.OPEN
288288
this.log.debug('Close sensor is %s set targetDoorState %s', newValue, newState)
289289
this.targetDoorState.updateValue(newState, null)
290290
}
291291
// wait one second cause we have a really fast going garage door
292292
setTimeout(function () {
293-
let newState = (newValue === that.state_sensor_close) ? that.characteristic.CurrentDoorState.CLOSED : that.characteristic.CurrentDoorState.OPEN
293+
let newState = (that.didMatch(newValue, that.state_sensor_close)) ? that.characteristic.CurrentDoorState.CLOSED : that.characteristic.CurrentDoorState.OPEN
294294
that.log.debug('timer fired close sensor is %s set new current state %s', newState, newState)
295295
that.currentDoorState.updateValue(newState, null)
296296
}, 1000)
297297
}
298298

299299
if (eventAddress === this.address_sensor_open) {
300300
if (this.targetCommand === false) {
301-
let newState = (newValue === this.state_sensor_open) ? that.characteristic.TargetDoorState.OPEN : this.characteristic.TargetDoorState.CLOSED
301+
let newState = (this.didMatch(newValue, this.state_sensor_open)) ? that.characteristic.TargetDoorState.OPEN : this.characteristic.TargetDoorState.CLOSED
302302
this.log.debug('open sensor is %s set new target state %s', newValue, newState)
303303
this.targetDoorState.updateValue(newState, null)
304304
}
305305

306306
setTimeout(function () {
307-
let newState = (newValue === that.state_sensor_open) ? that.characteristic.CurrentDoorState.OPEN : that.characteristic.CurrentDoorState.CLOSED
307+
let newState = (that.didMatch(newValue, that.state_sensor_open)) ? that.characteristic.CurrentDoorState.OPEN : that.characteristic.CurrentDoorState.CLOSED
308308
that.log.debug('fired open sensor is %s set new state %s', newValue, newState)
309309
that.currentDoorState.updateValue(newState, null)
310310
}, 1000)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "homebridge-homematic",
3-
"version": "0.0.203",
3+
"version": "0.0.204",
44
"description": "Homematic plugin for homebridge: https://github.com/nfarina/homebridge",
55
"license": "ISC",
66
"keywords": [

0 commit comments

Comments
 (0)