Skip to content

Commit

Permalink
Merge pull request #316 from klein0r/master
Browse files Browse the repository at this point in the history
Added LaMetric and WLED
  • Loading branch information
Apollon77 authored Feb 23, 2024
2 parents 4d40264 + 6962c39 commit 2c04602
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mocha": true
},
"parserOptions": {
"ecmaVersion": 6
"ecmaVersion": 2021
},
"extends": "eslint:recommended",
"rules": {
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG_OLD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Older changes
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ For more details and for information how to disable the error reporting see [Sen
- KNX (disabled actually)
- Keba KeContact P30
- Kodi
- LaMetric
- Landroid
- LGTV
- Lightify
Expand Down Expand Up @@ -101,6 +102,7 @@ For more details and for information how to disable the error reporting see [Sen
- UPnP
- ValloxMV
- Wifilight
- WLED
- Yamaha
- Yeelight
- Z-wave USB (Tested with Aeon Labs)
Expand Down Expand Up @@ -148,6 +150,10 @@ You can execute `sudo setcap cap_net_raw+p /bin/ping` to add missing capabilitie
### **WORK IN PROGRESS**
-->
## Changelog
### **WORK IN PROGRESS**
* (klein0r) Added WLED
* (klein0r) Added LaMetric

### 4.3.0 (2024-02-21)
* (bluefox) Replaced vis with vis-2

Expand Down
1 change: 0 additions & 1 deletion lib/adapters/chromecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ function addChromecast(ip, device, options) {
// just check if IP exists
function detect(ip, device, options, callback) {
let foundInstance = false;
options.log.debug('Chromecast UPnp data: ' + JSON.stringify(device));

device._upnp.forEach(upnp => {
if (!foundInstance && upnp.ST && upnp.ST === 'urn:dial-multiscreen-org:service:dial:1') {
Expand Down
45 changes: 45 additions & 0 deletions lib/adapters/lametric.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';

const tools = require('../tools.js');

function addInstance(ip, device, options) {
let instance = tools.findInstance(options, 'lametric', obj => obj.native.lametricIp === ip);

if (!instance) {
instance = {
_id: tools.getNextInstanceID('lametric', options),
common: {
name: 'lametric'
},
native: {
lametricIp: ip,
},
comment: {
add: 'LaMetric device'
}
};
options.newInstances.push(instance);
return true;
} else {
return false;
}
}

function detect(ip, device, options, callback) {
let foundInstance = false;

device._upnp.forEach(upnp => {
if (!foundInstance && upnp._location && upnp._location.includes('LaMetric Time')) {
options.log.debug('LaMetric device detected at: ' + ip);
if (addInstance(ip, device, options)) {
foundInstance = true;
}
}
});

callback(null, foundInstance, ip);
}

exports.detect = detect;
exports.type = ['upnp'];
exports.timeout = 100;
42 changes: 42 additions & 0 deletions lib/adapters/wled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

const tools = require('../tools.js');

function addInstance(ip, options) {
let instance = tools.findInstance(options, 'wled', obj => obj.native.devices.filter(device => device.ip === ip));

if (!instance) {
instance = {
_id: tools.getNextInstanceID('wled', options),
common: {
name: 'wled',
},
native: {
devices: {
wled: {
ip
}
}
},
comment: {
add: ['WLED', ip]
}
};
options.newInstances.push(instance);
return true;
} else {
return false;
}
}

function detect(ip, device, options, callback) {
if (device?._mdns?.PTR && device._mdns.PTR.datax.includes('_wled._tcp.local')) {
callback(null, addInstance(ip, options), ip);
} else {
callback(null, false, ip);
}
}

exports.detect = detect;
exports.type = ['mdns'];
exports.timeout = 1500;

0 comments on commit 2c04602

Please sign in to comment.