mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-11 14:23:07 +01:00
scan in switches
This commit is contained in:
@@ -98,15 +98,22 @@ HomeAssistantPlatform.prototype = {
|
|||||||
var that = this;
|
var that = this;
|
||||||
var foundAccessories = [];
|
var foundAccessories = [];
|
||||||
var lightsRE = /^light\./i
|
var lightsRE = /^light\./i
|
||||||
|
var switchRE = /^switch\./i
|
||||||
|
|
||||||
|
|
||||||
this._request('GET', '/states', {}, function(error, response, data){
|
this._request('GET', '/states', {}, function(error, response, data){
|
||||||
|
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
entity = data[i]
|
entity = data[i]
|
||||||
|
var accessory = null
|
||||||
|
|
||||||
if (entity.entity_id.match(lightsRE)) {
|
if (entity.entity_id.match(lightsRE)) {
|
||||||
accessory = new HomeAssistantLight(that.log, entity, that)
|
accessory = new HomeAssistantLight(that.log, entity, that)
|
||||||
|
}else if (entity.entity_id.match(switchRE)){
|
||||||
|
accessory = new HomeAssistantSwitch(that.log, entity, that)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accessory) {
|
||||||
foundAccessories.push(accessory)
|
foundAccessories.push(accessory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user