klausmeyer / fritzbox-smarthome

🏡 💡 Ruby client for AVM Home Automation Interface
MIT License
6 stars 5 forks source link

Use generic Actor class for unrecognised device #30

Closed carpodaster closed 2 years ago

carpodaster commented 2 years ago

Prevents calling new_from_api on nil in Actor.all when the Actor subclasses's match? predicates don't find a suitable class.

Specifically, I have a Fritz!DECT 500 (the lightbulb¹) and it swam belly up when getting all actors. I deliberately didn't add a proper XML for the 500 as I wanted this to work with all unrecognised devices.

I sneaked in a change to attempt to assign an actor instance's name from the product name XML attribute as well, just so that I could see what devices are being returned. Happy to change it back.

NoMethodError: undefined method `new_from_api' for nil

¹) I might add a real actor subclass for it in the near future

klausmeyer commented 2 years ago

😎 Cool thank you! Looks very good on the first glance.

I'll have a closer look and do a quick smoke test before merging & pushing a new version.

klausmeyer commented 2 years ago

https://rubygems.org/gems/fritzbox-smarthome/versions/0.3.0