MCPcopy
hub / github.com/aholstenson/miio / _updateDeviceList

Method _updateDeviceList

lib/devices/gateway.js:135–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133 }
134
135 _updateDeviceList() {
136 function stripLumiFromId(id) {
137 if(id.indexOf('lumi.') === 0) {
138 return id.substring(5);
139 }
140 return id;
141 }
142
143 return this.call('get_device_prop', [ 'lumi.0', 'device_list' ])
144 .then(list => {
145 const defs = [ ...this.extraChildren ];
146 for(let i=0; i<list.length; i+=5) {
147 const id = stripLumiFromId(list[i]);
148 const type = list[i+1];
149 const online = list[i+2] === 1;
150
151 // Sanity check, skip gateway if found
152 if(id === '0') continue;
153
154 defs.push({
155 id: 'miio:' + id,
156 type: type,
157 online: online
158 });
159 }
160
161 return this.syncer.update(defs);
162 });
163 }
164
165 /**
166 * Either resolve the developer key or setup a new one.

Callers 1

initCallbackMethod · 0.95

Calls 2

updateMethod · 0.80
callMethod · 0.45

Tested by

no test coverage detected