Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make state enforcement configurable when coordinator data is stale #2805

Open
KBurbank opened this issue Jan 23, 2025 · 1 comment
Open

Make state enforcement configurable when coordinator data is stale #2805

KBurbank opened this issue Jan 23, 2025 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@KBurbank
Copy link

Current Behavior

When the DataUpdateCoordinator returns stale data (logging "Coordinator data for [entity_id] is too old to be returned"), the component attempts to enforce its last known state by sending commands to the device approximately every 90 seconds.

This results in:

  1. Repeated set_light_state commands being sent to Alexa
  2. Lights being turned back on after manual off commands directly to Alexa
  3. Unnecessary API calls to Amazon's servers

In my case, the entity is a light that only connects to Alexa. I turn the light manually and a minute later, it pops back on.

Example log pattern:

DEBUG [custom_components.alexa_media.alexa_entity] Coordinator data for [entity_id] is too old to be returned
DEBUG [alexapy.alexaapi] set_light_state response: {'controlResponses': [{'code': 'SUCCESS' ...}]} for data: {"controlRequests": [{"entityId": "[entity_id]", "parameters": {"action": "turnOn"}}, {"entityId": "[entity_id]", "parameters": {"action": "setColorTemperature", "colorTemperatureName": "warm_white"}}]}

Desired Behavior

Add a configuration option to control how the component handles stale coordinator data. For example:

alexa_media:
      stale_data_behavior: "unknown"  # Options: "enforce" (current behavior) or "unknown"

When set to "unknown", instead of trying to enforce the last known state, the component would simply mark the entity state as unknown until fresh data is available.

Use Case

This would be particularly useful for:

  1. Users who control devices through multiple interfaces (Alexa app, voice commands, etc.)
  2. Reducing unnecessary API calls
  3. Preventing devices from being turned back on when manually turned off

Current Workaround

Currently using a helper boolean that Alexa updates directly and a separate automation to maintain state, but this shouldn't be necessary.

Copy link

@KBurbank this issue was automatically closed because it did not follow the issue template and this warning: IMPORTANT: Please search the issues, including closed issues, and the FAQ before opening a new issue. The template is mandatory; failure to use it will result in issue closure.

@danielbrunt57 danielbrunt57 added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jan 24, 2025
@danielbrunt57 danielbrunt57 reopened this Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants