Skip to content

Add support for home assistant's STATE_OFF#1041

Merged
SteveMicroNova merged 1 commit into
mainfrom
SupportZoneOff
Apr 21, 2025
Merged

Add support for home assistant's STATE_OFF#1041
SteveMicroNova merged 1 commit into
mainfrom
SupportZoneOff

Conversation

@SteveMicroNova
Copy link
Copy Markdown
Contributor

@SteveMicroNova SteveMicroNova commented Apr 1, 2025

What does this change intend to accomplish?

Support STATE_OFF for use with home assistant media_player entities

Checklist

  • Have you tested your changes and ensured they work?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • If applicable, have you updated the documentation/manual?
  • If applicable, have you updated the CHANGELOG?
  • Does your submission pass linting & tests? You can test on localhost using ./scripts/test
  • Have you written new tests for your core features/changes, as applicable?

@SteveMicroNova SteveMicroNova requested a review from linknum23 April 3, 2025 21:32
@SteveMicroNova
Copy link
Copy Markdown
Contributor Author

I forget if this needed new tests to be made for it since we only talked about this verbally a few days ago and I have since fed my brain into a taffy puller with the various things I've been touching lately

Let me know what changes this needs, if any, and I'll make a rapid release so it can be used with the upcoming hacs_amplipi update

@SteveMicroNova SteveMicroNova marked this pull request as ready for review April 3, 2025 21:34
Comment thread amplipi/models.py Outdated
""" Indicate no source connection, simulated in SW by muting zone for now """

ZONE_OFF = -2
""" Indicate that a zone is set to STATE_OFF within home assistant """
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
""" Indicate that a zone is set to STATE_OFF within home assistant """
""" Indicate that a zone is set to STATE_OFF used for tracking a power off state for external interfaces that treat a zone as a media player with an on/off button. Used for integrations such as home assistant. Use the following mapping to use as an on/off indicator:
- ON: source_id != ZONE_OFF
- OFF: source_id == ZONE_OFF
To turn off: set to ZONE_OFF.
To turn back on: set to SOURCE_DISCONNECTED (to wait for the user to change an input) or set to any valid source id to start playing something.
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That probably needs a touch of rework but gets the general concept past.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a less verbose version in my recent commit, see here:

"""
Indicate that a zone is considered off for the purpose of external interfaces such as home assistant

ON = source_id != ZONE_OFF
OFF = source_id == ZONE_OFF

To turn off: set to ZONE_OFF
To turn on: set to SOURCE_DISCONNECTED or any valid source_id
"""

Copy link
Copy Markdown
Contributor

@linknum23 linknum23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed this looks good!

@SteveMicroNova SteveMicroNova merged commit 7f4c552 into main Apr 21, 2025
3 checks passed
@SteveMicroNova SteveMicroNova deleted the SupportZoneOff branch April 21, 2025 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants