fix: Confirmations should apply to all actions (#1959)

This also refactors how generic HA actions are handled, and improves
typing of actions.


[skip ci]
This commit is contained in:
Dermot Duffy
2025-03-15 14:32:48 -07:00
committed by GitHub
parent a79ffa6edc
commit 75ae7720d3
90 changed files with 1332 additions and 854 deletions
+9 -6
View File
@@ -1,6 +1,5 @@
import { HASS, renderTemplate } from 'ha-nunjucks/dist';
import { ConditionState, ConditionsTriggerData } from '../../conditions/types';
import { ActionType } from '../../config/types';
import { HomeAssistant } from '../../ha/types';
interface TemplateContextInternal {
@@ -24,7 +23,7 @@ export class TemplateRenderer {
conditionState?: ConditionState;
triggerData?: ConditionsTriggerData;
},
): ActionType => {
): unknown => {
return this._renderTemplateRecursively(
hass,
data,
@@ -59,11 +58,15 @@ export class TemplateRenderer {
hass: HomeAssistant,
data: unknown,
templateContext?: TemplateContext,
): ActionType {
): unknown {
if (typeof data === 'string') {
// ha-nunjucks has a more complete model of the Home Assistant object, but
// does not export it as a type.
return renderTemplate(hass as unknown as typeof HASS, data, templateContext);
return renderTemplate(
// ha-nunjucks has a more complete model of the Home Assistant object, but
// does not export it as a type.
hass as unknown as typeof HASS,
data,
templateContext,
);
} else if (Array.isArray(data)) {
return data.map((item) =>
this._renderTemplateRecursively(hass, item, templateContext),