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
71.83k stars 30.09k forks source link

Netatmo "selected_schedule" attribute not updated #81752

Closed xabaras75 closed 3 months ago

xabaras75 commented 1 year ago

The problem

the attribute "selected attribute" of the entities relating to the thermo valve is not updated: if I change the schedule type in netatmo app, this schedule does not appear on hassio.

What version of Home Assistant Core has the issue?

Home Assistant 2022.11.1

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

https://www.home-assistant.io/integrations/netatmo/

Diagnostics information

config_entry-netatmo-a5153bac6db88fe85b82ec9cdc42533e.json (2).txt

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 1 year 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` Change the title of 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.

(message by CodeOwnersMention)


netatmo documentation netatmo source (message by IssueLinks)

cgtobi commented 1 year ago

Does it eventually change after time?

xabaras75 commented 1 year ago

Does it eventually change after time?

this is the situation after 1 day of check:

1) if I change the plan on hassio, in netatmo app this change is not received. for ex in the below figure, I have chosen the plan "in viaggio" but in netatmo web site the plan is another one:

Netatmo web app: image

Hassio (entity selection of the schedule generated by the intergation itself): image

2) if I change the plan in netatmo app (or web site) again the paln remain the same in hassio (not receiving the change)

mundschenk-at commented 1 year ago

Can we reopen this please?

cgtobi commented 1 year ago

Have you set up your system so that is receives webhook events?

mundschenk-at commented 1 year ago

Have you set up your system so that is receives webhook events?

Sorry, missed the reply notification. Yes, I am receiving webhook updates from Netatmo.

I might have misunderstood the intend of this ticket, but there is an issue where the schedule selection entity in HA appears to switch back to the previous schedule after a few minutes. Except it doesn't really, if you check via the Netatmo Energy app.

CrazyHenk44 commented 1 year ago

Indeed. When changing the schedule, the change is visible in the netatmo site, but after a few seconds the schedule in HA returns to the previous value. In every location (entity select.{homename} and in all radiators climate.{roomname}'s selected_schedule attribute. I've also tried script changing the value at the radiator level as with yaml via select.{homename} and via the default select switch.

deosrc commented 1 year ago

Sorry if this hijacks the thread. I also have this issue where the select will not update for about an hour sometimes after it is updated through HA, however, I don't have the webhook configured. I'm not keen on the idea of exposing HA to the public internet, just to know when my heating schedule is updated from the same application.

Is there a reason it doesn't seem to trigger a new API call after the select is updated? I'm happy to try adding it myself, just want to make sure it's not been done that way by design because of API rate limits or something.

issue-triage-workflows[bot] commented 1 year 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.

mundschenk-at commented 1 year ago

Still an issue.

issue-triage-workflows[bot] commented 1 year 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.

mundschenk-at commented 1 year ago

Still an issue

davidgdlt commented 1 year ago

Due to this issue the plugin is unusable for Netatmo Thermostats.

CrazyHenk44 commented 1 year ago

nobody cares.

deosrc commented 1 year ago

This is obviously far from an ideal solution but I have an automation that reloads the integration when one of the select entities is changed:

alias: Reload Netatmo on change
description: >-
  Workaround for Netatmo changes not retaining value after change if webhook is
  not configured.
trigger:
  - platform: event
    event_type: call_service
    event_data:
      domain: select
      service: select_option
      service_data:
        entity_id:
          - select.heating_schedule
  - platform: event
    event_type: call_service
    event_data:
      domain: climate
      service: set_preset_mode
condition: []
action:
  - service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id: select.heating_schedule
mode: restart

The main issue with this (other than it being a rather ugly workaround), is that the entities will become unavailable briefly while reloading so automations triggered by states become rather tricky.

It does ensure that changing a preset on a dashboard shows the correct value though.

davidgdlt commented 1 year ago

Thanks deosrc. Unfortunately it doesn't work for me, perhaps because the information I want to refresh is the temperature and preset_mode and not the schedule. For that I tried with this service call instead:

service: homeassistant.reload_config_entry
data: {}
target:
  entity_id: climate.mythermostat

But the information is not updated and only will after a while by itself.

issue-triage-workflows[bot] commented 9 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.

mundschenk-at commented 9 months ago

Not stale

deosrc commented 9 months ago

I have managed to get this in a mostly stable state with a workaround. To be clear, I am only saying this is my setup and may work for others.

My setup is:

I realised the setup was working when I had re-registered the webhook. You can test this with the following:

  1. Open two browser windows/tabs
  2. In the first window, go to Developer Tools > Events and start listening for "netatmo_event"
  3. In the second window, go to Developer Tools > Services.
  4. First make a call to netatmo.unregister_webhook. Don't worry if this fails, continue with the next step.
  5. Next make a call to netatmo.register_webhook. This must succeed.
  6. Check your event listener in the other window. If you received an event then the webhook is working. You can also check the push_type is webhook_activation to be certain.

If the above worked for you, this doesn't mean it will keep working. Unfortunately it seems to stop working at some point for me. To ensure the hook is always registered, I have a few components to help out but this should be equivalent as a single automation:

alias: Netatmo - Re-register Webhook when no messages
description: Re-registers the Netatmo Webhook if no messages have been received recently.
trigger:
  - platform: event
    event_type: netatmo_event
  - platform: homeassistant
    event: start
condition: []
action:
  - delay:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
  - service: netatmo.unregister_webhook
    data: {}
  - service: netatmo.register_webhook
    data: {}
mode: restart

The automation relies on mode: restart. It will start on home assistant startup, or when a webhook event is received. It will then wait 5 minutes. If a message is received in this time, the automation is restarted without taking any action. If the 5 minutes elapses without the automation restarting (no message is received), it will re-register the webhook. Re-registering the webhook should result in an event being received, so the automation will start itself up again and begin the 5 minute wait again.

cgtobi commented 9 months ago

@deosrc so actually the selected_schedule attribute is updated but dependant on the functionality of the webhook events?

deosrc commented 9 months ago

@cgtobi I believe so. If I understand the code correctly and how HA works, it will update either from the webhook event or the next time the Netatmo API is polled. The next API update can be up to 10 minutes away for home related entities though as defined here:

https://github.com/home-assistant/core/blob/0614e291c1423afb1a341a0fee5227bb069d8b7c/homeassistant/components/netatmo/data_handler.py#L72-L79

Sorry I might have posted the above thinking it was UI updates in HA rather than from the Netatmo app. I'm following a few of these issues but I believe the same is still true. HA will only persist the change when the integration receives the notification that the state has been updated. For Netatmo, this is either the webhook event or the next API poll. If the state isn't updated, the UI will revert after a few seconds.

cgtobi commented 9 months ago

Yeah, that is correct. Just wanted to double check. Thanks for clarifying.

issue-triage-workflows[bot] commented 6 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.

mundschenk-at commented 6 months ago

Still an issue.

issue-triage-workflows[bot] commented 3 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.