Add support for Nanoleaf Aurora Light Panels#13456
Add support for Nanoleaf Aurora Light Panels#13456emlove merged 6 commits intohome-assistant:devfrom
Conversation
|
seems like there was a recent change to RGB_COLOR and xy colors instead of rgb; I'll need to dig in to that to check (see #11288 ) |
emlove
left a comment
There was a problem hiding this comment.
Really great work! I've just added a few comments here for best practices.
| host = config.get(CONF_HOST) | ||
| name = config.get(CONF_NAME) | ||
| token = config.get(CONF_TOKEN) | ||
| aurora_light = aurora().Aurora(host, token) |
There was a problem hiding this comment.
You can just import nanoleaf in setup_platform. The wrapper isn't necessary.
|
|
||
| def __init__(self, light): | ||
| """Initialize an Aurora.""" | ||
| self._brightness = light.brightness |
There was a problem hiding this comment.
Instead of duplicating the update logic here, just assign self._light ans self._name, and then pass True as the second argument (update_before_add) of add_devices. Hass will then call update before adding the entity to the state machine.
| @property | ||
| def icon(self): | ||
| """Return the icon to use in the frontend, if any.""" | ||
| return "mdi:triangle-outline" |
There was a problem hiding this comment.
Not sure about overriding the icon for a light, but no strong feelings myself if it's aligned with the actual device. Could you add some screenshots of what this looks like in a card?
There was a problem hiding this comment.
I kinda like it since the device itself is a triangle, however this is more of a special snowflake kind of situation, so if you'd like to keep this as a regular light bulb I'll happily oblige.
It looks like this (I hope it's okay to attach it here, I don't think it fits into the documentation itself):

|
@armills Thanks for the review and the comments!
I'd simply |
|
Ah yeah, that's my mistake. They should be initialized to |
|
This is working great for me on .66 thanks for all you do. I was just wondering if it's possible to get the motion sensor exposed to use with automations! |
|
@Norien glad it works! |
|
Thanks for the contribution! 🌟 |
MartinHjelmare
left a comment
There was a problem hiding this comment.
Commenting for possible improvement in a future PR.
| https://github.com/software-2/nanoleaf | ||
|
|
||
| For more details about this platform, please refer to the documentation at | ||
| https://home-assistant.io/components/light.nanoleaf_aurora/ |
There was a problem hiding this comment.
The url is wrong. It should end with the platform name.
There was a problem hiding this comment.
I don't think I get it. There is no platform for the nanoleaf aurora lights, there is however a aurora sensor which has nothing to do with those lights (which is why I named the documentation light.nanoleaf_aurora) - did I misunderstand something/do something incorrectly?
There was a problem hiding this comment.
The name of the platform module is aurora.py. Then you have to name the docs page https://home-assistant.io/components/light.aurora/ eg.
There was a problem hiding this comment.
I get it now, thanks - If I rename it to aurora the component page will display a link to the binary sensor, thinking they are related, is there a way to overwrite that behaviour or do you recon that this is OK? - if not, I will probably have to rename the component itself
There was a problem hiding this comment.
Yes, we shouldn't have two platforms with the same name that are not connected. Please rename this platform. nanoleaf_aurora.py is ok.
There was a problem hiding this comment.
Thanks, I've renamed it in #13831 , for the others I'll create separate PRs as well, if possible it would be great if this could get in 0.67 so that nobody has to update their config in the version following afterwards
| if aurora_light.on is None: | ||
| _LOGGER.error("Could not connect to \ | ||
| Nanoleaf Aurora: %s on %s", name, host) | ||
| add_devices([AuroraLight(aurora_light)], True) |
There was a problem hiding this comment.
Do we still want to add devices if the above error happens?
There was a problem hiding this comment.
Probably not, my mistake - I'll send a PR hopefully this weekend
| name = config.get(CONF_NAME) | ||
| token = config.get(CONF_TOKEN) | ||
| aurora_light = nanoleaf.Aurora(host, token) | ||
| aurora_light.hass_name = name |
There was a problem hiding this comment.
Why put the name on the aurora light instance? You can pass the name separately when instantiating the entity.
There was a problem hiding this comment.
That is a very good question, probably not needed. I'll have a look at it this weekend, thank you for the comments!

Description:
Added support for Nanoleaf Aurora lights
Related issue (if applicable): None, discussion at https://community.home-assistant.io/t/nanoleaf-aurora-component/21054/
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5018
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.