maxinminax / node-mihome

Control Mi Home devices, such as Mi Robot Vacuums, Mi Air Purifiers, Mi Smart Home Gateway (Aqara) and more
MIT License
121 stars 34 forks source link

Add conditional chaining to prevent for each fail on undefined #49

Open ChristopherGier opened 2 years ago

ChristopherGier commented 2 years ago

https://github.com/maxinminax/node-mihome/blob/e60c287d9bb2d9ba9123543d92ec481be5a62b5e/lib/device-miio.js#L192

Changing the line to

properties?.forEach(property => {

should prevent the script from failing if the attribute is undefined. The issue occured using Smart Fan 2 as the attribute was not defined there