Fix warnings raised when migrating incomplete automation configuration (#25898)

This commit is contained in:
Franck Nijhof 2025-06-24 18:02:45 +02:00 committed by GitHub
parent edcca81acc
commit caa60e4e8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -415,7 +415,7 @@ export const migrateAutomationAction = (
return action.map(migrateAutomationAction) as Action[]; return action.map(migrateAutomationAction) as Action[];
} }
if ("service" in action) { if (typeof action === "object" && action !== null && "service" in action) {
if (!("action" in action)) { if (!("action" in action)) {
action.action = action.service; action.action = action.service;
} }
@ -423,7 +423,7 @@ export const migrateAutomationAction = (
} }
// legacy scene (scene: scene_name) // legacy scene (scene: scene_name)
if ("scene" in action) { if (typeof action === "object" && action !== null && "scene" in action) {
action.action = "scene.turn_on"; action.action = "scene.turn_on";
action.target = { action.target = {
entity_id: action.scene, entity_id: action.scene,
@ -431,7 +431,7 @@ export const migrateAutomationAction = (
delete action.scene; delete action.scene;
} }
if ("sequence" in action) { if (typeof action === "object" && action !== null && "sequence" in action) {
for (const sequenceAction of (action as SequenceAction).sequence) { for (const sequenceAction of (action as SequenceAction).sequence) {
migrateAutomationAction(sequenceAction); migrateAutomationAction(sequenceAction);
} }