Skip to content
This repository has been archived by the owner on Mar 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #22 from AlCalzone/ampel
Browse files Browse the repository at this point in the history
Ampel erst grün machen, wenn Scan abgeschlossen ist
  • Loading branch information
GermanBluefox committed Sep 22, 2017
2 parents 83499b5 + 4eb40aa commit e0b5f41
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Following global Actions are current supported:
- Danfoss Z Thermostat 014G0013

## Changelog
### 0.7.0 (2017-07-12)
### 0.8.0 (2017-07-12)
* (Apollon77) Update to Openzwave-shared 1.4

### 0.7.0 (2017-07-12)
Expand Down
20 changes: 17 additions & 3 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"version": "0.8.0",
"news": {
"0.7.0": {
"0.8.0": {
"en": "Update to Openzwave-shared 1.4",
"de": "Update zu Openzwave-shared 1.4",
"ru": "Update to Openzwave-shared 1.4"
Expand Down Expand Up @@ -111,7 +111,8 @@
"type": "state",
"common": {
"role": "indicator.connected",
"name": "If connected to ZWave stick",
"name": "ZWave ready to use",
"desc": "If the ZWave driver has finished initializing",
"type": "boolean",
"read": true,
"write": false,
Expand All @@ -131,12 +132,25 @@
},
"native": {}
},
{
"_id": "info.driverReady",
"type": "state",
"common": {
"role": "state",
"name": "If the ZWave driver is loaded and ready",
"type": "boolean",
"read": true,
"write": false,
"def": false
},
"native": {}
},
{
"_id": "info.scanCompleted",
"type": "state",
"common": {
"role": "state",
"name": "Scan fo devices is completed",
"name": "Scan of devices is completed",
"desc": "If scan of devices is completed",
"type": "boolean",
"read": true,
Expand Down
10 changes: 7 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,7 @@ function deleteDevice(nodeID, callback) {
function resetInstanceStatusInfo() {
// resets states with information about adapter status
adapter.setState('info.connection', false, true);
adapter.setState('info.driverReady', false, true);
adapter.setState('info.scanCompleted', false, true);
adapter.setState('info.libraryVersion', '', true);
adapter.setState('info.libraryTypeName', '', true);
Expand Down Expand Up @@ -1001,19 +1002,20 @@ function main() {

// ------------- controller events ---------------------------
zwave.on('connected', function (ozw) {
adapter.setState('info.connection', true, true);
adapter.setState('info.OZW', ozw, true);
adapter.log.info('connected: OZW = ' + ozw);
adapter.log.info('device connected: OZW = ' + ozw);
});

zwave.on('driver ready', function (homeid) {
adapter.log.info('scanning homeid=0x' + homeid.toString(16) + '...');
adapter.setState('info.homeId', homeid.toString(16), true);
adapter.log.info('driver ready: homeid = ' + homeid);
adapter.setState('info.driverReady', true, true);
});

zwave.on('driver failed', function () {
adapter.setState('info.connection', false, true);
adapter.setState('info.driverReady', false, true);
adapter.log.error('failed to start driver');
zwave.disconnect(adapter.config.usb);
process.exit();
Expand All @@ -1023,7 +1025,9 @@ function main() {
adapter.setState('forceInit', false, true);
adapter.log.info('Scan completed');
adapter.setState('info.scanCompleted', true, true);

// set status to green only after the scan is completed
adapter.setState('info.connection', true, true);

adapter.setState('info.libraryVersion', zwave.getLibraryVersion(), true);
adapter.setState('info.libraryTypeName', zwave.getLibraryTypeName(), true);
adapter.setState('info.controllerNodeId', zwave.getControllerNodeId(), true);
Expand Down

0 comments on commit e0b5f41

Please sign in to comment.