-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Convert scene action to service call #11705
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ import "../../../../components/ha-card"; | |
| import "../../../../components/ha-alert"; | ||
| import "../../../../components/ha-icon-button"; | ||
| import type { HaYamlEditor } from "../../../../components/ha-yaml-editor"; | ||
| import type { Action } from "../../../../data/script"; | ||
| import type { Action, ServiceSceneAction } from "../../../../data/script"; | ||
| import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box"; | ||
| import { haStyle } from "../../../../resources/styles"; | ||
| import type { HomeAssistant } from "../../../../types"; | ||
|
|
@@ -44,8 +44,28 @@ const OPTIONS = [ | |
| "device_id", | ||
| ]; | ||
|
|
||
| const getType = (action: Action | undefined) => | ||
| action ? OPTIONS.find((option) => option in action) : undefined; | ||
| const getType = (action: Action | undefined) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why can't we re-use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we would have to change all the element names 😅 but yes, I do want to do that, found it a bit late though
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aaah ok . yeah not this pr. |
||
| if (!action) { | ||
| return undefined; | ||
| } | ||
| if ("metadata" in action && action.service) { | ||
| switch (action.service) { | ||
| case "scene.turn_on": | ||
| // we dont support arrays of entities | ||
| if ( | ||
| !Array.isArray( | ||
| (action as unknown as ServiceSceneAction).target?.entity_id | ||
| ) | ||
| ) { | ||
| return "scene"; | ||
| } | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
| return OPTIONS.find((option) => option in action); | ||
| }; | ||
|
|
||
| declare global { | ||
| // for fire event | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.