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

Allow inverting switch_as_x cover, lock, valve #19324

Merged
merged 6 commits into from
Jan 24, 2024
Merged

Conversation

emontnemery
Copy link
Collaborator

Proposed change

Allow inverting switch_as_x cover, lock, valve

Core PR: home-assistant/core#107535

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

// Change invert setting
const origEntityId = this.entry.options?.switch_as_x?.entity_id;
// remove current helper
await deleteConfigEntry(this.hass, this.helperConfigEntry.entry_id);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The core PR needs an update to allow setting this via an option flow.
Although entity registry has undelete which preserves UUID and entity_id, user configuration such as icon override is not kept.

bramkragten
bramkragten previously approved these changes Jan 8, 2024
if (!origEntityId) {
// should not happen, guard for types
} else {
const configFlow = await createConfigFlow(this.hass, "switch_as_x");
const configFlowResult = (await handleConfigFlowStep(
const configFlow = await createOptionsFlow(
Copy link
Member

Choose a reason for hiding this comment

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

Can we do the same for changing the switch as type? (Can be a different PR)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would prefer not, because when changing the switch as type we want to delete the entity registry item etc.

invert: this._switchAsInvert,
target_domain: this._switchAsDomain,
}
)) as DataEntryFlowStepCreateEntry;
if (configFlowResult.result?.entry_id) {
Copy link
Member

Choose a reason for hiding this comment

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

We don't have to do this in this case? As the entity id stays the same there is no need to open a different more info dialog?

Comment on lines 1153 to 1155
"invert_switch_as_cover_description": "Show as open when the switch is off",
"invert_switch_as_lock_description": "Show as locked when the switch is off",
"invert_switch_as_valve_description": "[%key:ui::dialogs::entity_registry::editor::invert_switch_as_cover_description%]",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"invert_switch_as_cover_description": "Show as open when the switch is off",
"invert_switch_as_lock_description": "Show as locked when the switch is off",
"invert_switch_as_valve_description": "[%key:ui::dialogs::entity_registry::editor::invert_switch_as_cover_description%]",
"invert" : {
"label": "Invert state",
"descriptions": {
"cover": "Show as open when the switch is off",
"lock": "Show as locked when the switch is off",
"valve": "Show as open when the switch is off",
}
}

bramkragten
bramkragten previously approved these changes Jan 15, 2024
@bramkragten bramkragten merged commit c2d71ac into dev Jan 24, 2024
13 checks passed
@bramkragten bramkragten deleted the switch_as_x_invert branch January 24, 2024 17:32
@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants