Skip to content

Commit

Permalink
Implement polling of garage door status
Browse files Browse the repository at this point in the history
  • Loading branch information
braindead1 committed Jan 3, 2021
1 parent 6e49247 commit 90b7d65
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 1 deletion.
8 changes: 8 additions & 0 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@
</select>
<label for="wlanPollType" class="translate">WLAN</label>
</div>
<div class="input-field col s12 m6 l4">
<select id="doorPollType" class="value">
<option value="NoPoll" class="translate">No poll</option>
<option value="Status">Status</option>
<option value="Info">Info</option>
</select>
<label for="doorPollType" class="translate">Garage door</label>
</div>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions admin/words.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
"restPeriod2Start": "",
"restPeriod2End": "",
"batteryPollType": "Info",
"doorPollType": "Info",
"errorsPollType": "Info",
"extensionPollType": "Info",
"gpsPollType": "Info",
Expand Down
80 changes: 80 additions & 0 deletions lib/objects_door.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"door.enabled": {
"type": "state",
"common": {
"name": "Enabled",
"type": "boolean",
"role": "state",
"read": true,
"write": false,
"desc": ""
},
"native": {},
"value": "door.enabled"
},
"door.state.open": {
"type": "state",
"common": {
"name": "Open",
"type": "boolean",
"role": "state",
"read": true,
"write": false,
"desc": ""
},
"native": {},
"value": "door.state.open"
},
"door.state.close": {
"type": "state",
"common": {
"name": "Closed",
"type": "boolean",
"role": "state",
"read": true,
"write": false,
"desc": ""
},
"native": {},
"value": "door.state.close"
},
"door.pending.open": {
"type": "state",
"common": {
"name": "Open",
"type": "boolean",
"role": "state",
"read": true,
"write": false,
"desc": ""
},
"native": {},
"value": "door.pending.open"
},
"door.pending.close": {
"type": "state",
"common": {
"name": "Closed",
"type": "boolean",
"role": "state",
"read": true,
"write": false,
"desc": ""
},
"native": {},
"value": "door.pending.close"
},
"door.arrested": {
"type": "state",
"common": {
"name": "Arrested",
"type": "boolean",
"role": "state",
"read": true,
"write": false,
"desc": ""
},
"native": {},
"value": "door.arrested"
}
}
13 changes: 13 additions & 0 deletions lib/objects_status.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@
"native": {},
"value": "status.stopped"
},
"status.dooropen": {
"type": "state",
"common": {
"name": "Door open",
"type": "boolean",
"role": "state",
"read": true,
"write": false,
"desc": ""
},
"native": {},
"value": "status.dooropen"
},
"status.duration": {
"type": "state",
"common": {
Expand Down
8 changes: 7 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Robonect extends utils.Adapter {
this.currentStatus;

this.batteryPollType;
this.doorPollType;
this.errorsPollType;
this.extensionPollType;
this.gpsPollType;
Expand Down Expand Up @@ -85,6 +86,7 @@ class Robonect extends utils.Adapter {
this.restPeriod2End = this.config.restPeriod2End;

this.batteryPollType = this.config.batteryPollType;
this.doorPollType = this.config.doorPollType;
this.errorsPollType = this.config.errorsPollType;
this.extensionPollType = this.config.extensionPollType;
this.gpsPollType = this.config.gpsPollType;
Expand Down Expand Up @@ -214,6 +216,7 @@ class Robonect extends utils.Adapter {
*/
async initializeObjects() {
const objects_battery = require('./lib/objects_battery.json');
const objects_door = require('./lib/objects_door.json');
const objects_error = require('./lib/objects_error.json');
const objects_ext = require('./lib/objects_ext.json');
const objects_gps = require('./lib/objects_gps.json');
Expand All @@ -229,6 +232,7 @@ class Robonect extends utils.Adapter {

const objects = {
...objects_battery,
...objects_door,
...objects_error,
...objects_ext,
...objects_gps,
Expand All @@ -240,7 +244,7 @@ class Robonect extends utils.Adapter {
...objects_timer,
...objects_version,
...objects_weather,
...objects_wlan
...objects_wlan,
};

for (const id in objects) {
Expand Down Expand Up @@ -291,6 +295,8 @@ class Robonect extends utils.Adapter {

if (this.batteryPollType !== 'NoPoll' && (pollType === 'Initial' || (this.batteryPollType === pollType && doRegularPoll)))
await this.pollApi('battery');
if (this.doorPollType !== 'NoPoll' && (pollType === 'Initial' || (this.doorPollType === pollType && doRegularPoll)))
await this.pollApi('door');
if (this.errorsPollType !== 'NoPoll' && (pollType === 'Initial' || (this.errorsPollType === pollType && doRegularPoll)))
await this.pollApi('error');
if (this.extensionPollType !== 'NoPoll' && (pollType === 'Initial' || (this.extensionPollType === pollType && doRegularPoll)))
Expand Down

0 comments on commit 90b7d65

Please sign in to comment.