home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.06k stars 31.08k forks source link

Netatmo Dimmer values #115634

Closed melobytes closed 4 months ago

melobytes commented 7 months ago

The problem

I've integrated a Legrand k4411c with Home Assistant. The switch functionality for turning the lights on and off works well, but I'm experiencing issues with the dimming feature. Specifically, setting the brightness to 51% in Home Assistant results in the dimmer adjusting to 89%.

To address this, I found that in the netatmo/light.py file, the brightness level was being sent as a raw value. I modified the code to correctly scale the brightness value:

await self._dimmer.async_set_brightness(round(float(kwargs[ATTR_BRIGHTNESS])*100/255))

With this change, the dimming now operates correctly. However, there is a significant delay in the update of the brightness value. When I make a change to the brightness, it takes some time for the correct value to be reflected. I'm currently using a webhook with Nabu Casa for updates.

What version of Home Assistant Core has the issue?

2024.4.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Netatmo

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 7 months ago

Hey there @cgtobi, mind taking a look at this issue as it has been labeled with an integration (netatmo) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `netatmo` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign netatmo` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


netatmo documentation netatmo source (message by IssueLinks)

cgtobi commented 7 months ago

@melobytes Thanks for your investigation

melobytes commented 7 months ago

is it possible that the delay depends on the pooling rate homeassistant is taking to refresh the status of the dimmer? however it seems that the delay is not constant so probably something else is happening

cgtobi commented 7 months ago

Exactly that. Netatmo does not provide webhook events for those devices as far as I am aware of.

melobytes commented 7 months ago

Indeed, I've observed that only a few devices support webhooks, specifically those from Netatmo, not Bticino. I'm curious as to why Alexa and Google/Nest Home updates are so prompt when the developer hasn't made webhooks available. What is Home Assistant missing that these services have? Aren't the same Netatmo development tools available across all platforms? The exposed api should be the same for everyone

cgtobi commented 7 months ago

That is a fair question. To be honest, there might be more undocumented events, but someone with access to the device has to test that. You can do that in the HA developer tools events section once webhook is registered.

melobytes commented 7 months ago

i guess that in order to update the dimmer, HA would fire a /homestatus event, right? if so, where can i find this call? maybe after setting the status of a switch, it is appropriate to call again the /homestatus request in order to get the new value? i think google would poll each second or a couple of seconds while i do not know what is the knob for HA (what is the trigger to get an update?)

cgtobi commented 7 months ago

We already have a force update mechanism but on the other hand we also have a rate limit that we have to work within.

melobytes commented 7 months ago

where is the force update implemented? and what about the limit? could you also please point me out where we are doing the /homestatus request? Thanks for your prompt response and your help

cgtobi commented 7 months ago

The actual calls against /homestatus etc are done in pyatmo the underlying lib. If you want to get deeper into that I'd rather suggest to chat about this on Discord.

issue-triage-workflows[bot] commented 4 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.