diff --git a/.hass_dev/views/chips-view.yaml b/.hass_dev/views/chips-view.yaml index 85f466d2..89ad18a3 100644 --- a/.hass_dev/views/chips-view.yaml +++ b/.hass_dev/views/chips-view.yaml @@ -124,9 +124,9 @@ cards: - type: action icon: mdi:bell tap_action: - action: call-service - service: notify.persistent_notification - service_data: + action: perform-action + perform_action: notify.persistent_notification + data: message: This is notification from mushroom dashboard - type: action icon: mdi:github @@ -158,8 +158,8 @@ cards: grey {% endif %} tap_action: - action: call-service - service: light.toggle + action: perform-action + peform_action: light.toggle target: entity_id: light.bed_light - type: template diff --git a/.hass_dev/views/person-view.yaml b/.hass_dev/views/person-view.yaml index 36a8bfd3..08fa043d 100644 --- a/.hass_dev/views/person-view.yaml +++ b/.hass_dev/views/person-view.yaml @@ -65,45 +65,45 @@ cards: name: Home icon: mdi:home tap_action: - action: call-service - service: device_tracker.see - service_data: + action: perform-action + perform_action: device_tracker.see + data: dev_id: demo_anne_therese location_name: home - type: button name: Not Home icon: mdi:home-export-outline tap_action: - action: call-service - service: device_tracker.see - service_data: + action: perform-action + perform_action: device_tracker.see + data: dev_id: demo_anne_therese location_name: not_home - type: button name: Unknown icon: mdi:help tap_action: - action: call-service - service: device_tracker.see - service_data: + action: perform-action + perform_action: device_tracker.see + data: dev_id: demo_anne_therese location_name: unknown - type: button name: Living Room icon: mdi:sofa tap_action: - action: call-service - service: device_tracker.see - service_data: + action: perform-action + perform_action: device_tracker.see + data: dev_id: demo_anne_therese location_name: Living Room - type: button name: Office icon: mdi:office-building tap_action: - action: call-service - service: device_tracker.see - service_data: + action: perform-action + perform_action: device_tracker.see + data: dev_id: demo_anne_therese gps: [52.37451608362128, 4.888106097860146] columns: 3 diff --git a/docs/cards/chips.md b/docs/cards/chips.md index a6b194e5..0eaae09f 100644 --- a/docs/cards/chips.md +++ b/docs/cards/chips.md @@ -18,7 +18,7 @@ All the options are available in the lovelace editor but you can use `yaml` if y ![Chip action light](../images/chip-action-light.png) ![Chip action dark](../images/chip-action-dark.png) -An action chip allows you to perform a Home Assistant action (navigate, call-service, etc...). +An action chip allows you to perform a Home Assistant action (navigate, perform-action, etc...). ### Alarm control panel chip @@ -84,17 +84,17 @@ A weather chip allows you to display the weather. \* You can render weather svg icons using [weather state](https://developers.home-assistant.io/docs/core/entity/weather/#recommended-values-for-state-and-condition) as icon : -- weather-clear-night -- weather-cloudy -- weather-fog -- weather-lightning -- weather-lightning-rainy -- weather-partlycloudy -- weather-pouring -- weather-rainy -- weather-hail -- weather-snowy -- weather-snowy-rainy -- weather-sunny -- weather-windy -- weather-windy-variant +- weather-clear-night +- weather-cloudy +- weather-fog +- weather-lightning +- weather-lightning-rainy +- weather-partlycloudy +- weather-pouring +- weather-rainy +- weather-hail +- weather-snowy +- weather-snowy-rainy +- weather-sunny +- weather-windy +- weather-windy-variant diff --git a/hacs.json b/hacs.json index 1b6bca90..77b4297e 100644 --- a/hacs.json +++ b/hacs.json @@ -1,6 +1,6 @@ { - "name": "Mushroom", - "filename": "mushroom.js", - "homeassistant": "2024.7.0b0", - "render_readme": true + "name": "Mushroom", + "filename": "mushroom.js", + "homeassistant": "2024.8.0b0", + "render_readme": true } diff --git a/src/cards/alarm-control-panel-card/alarm-control-panel-card-editor.ts b/src/cards/alarm-control-panel-card/alarm-control-panel-card-editor.ts index 0ef5f088..1f52cd59 100644 --- a/src/cards/alarm-control-panel-card/alarm-control-panel-card-editor.ts +++ b/src/cards/alarm-control-panel-card/alarm-control-panel-card-editor.ts @@ -24,7 +24,7 @@ const actions: UiAction[] = [ "more-info", "navigate", "url", - "call-service", + "perform-action", "assist", "none", ]; diff --git a/src/cards/chips-card/chips/action-chip-editor.ts b/src/cards/chips-card/chips/action-chip-editor.ts index 1634251d..7ba2a3d9 100644 --- a/src/cards/chips-card/chips/action-chip-editor.ts +++ b/src/cards/chips-card/chips/action-chip-editor.ts @@ -14,7 +14,7 @@ import { DEFAULT_ACTION_ICON } from "./action-chip"; const actions: UiAction[] = [ "navigate", "url", - "call-service", + "perform-action", "assist", "none", ]; diff --git a/src/cards/chips-card/chips/alarm-control-panel-chip-editor.ts b/src/cards/chips-card/chips/alarm-control-panel-chip-editor.ts index f3c155ee..df5ee9fe 100644 --- a/src/cards/chips-card/chips/alarm-control-panel-chip-editor.ts +++ b/src/cards/chips-card/chips/alarm-control-panel-chip-editor.ts @@ -15,7 +15,7 @@ const actions: UiAction[] = [ "more-info", "navigate", "url", - "call-service", + "perform-action", "assist", "none", ]; diff --git a/src/cards/chips-card/chips/weather-chip-editor.ts b/src/cards/chips-card/chips/weather-chip-editor.ts index f8f1a7c6..4f8afe96 100644 --- a/src/cards/chips-card/chips/weather-chip-editor.ts +++ b/src/cards/chips-card/chips/weather-chip-editor.ts @@ -17,7 +17,7 @@ const actions: UiAction[] = [ "more-info", "navigate", "url", - "call-service", + "perform-action", "assist", "none", ]; diff --git a/src/cards/person-card/person-card-editor.ts b/src/cards/person-card/person-card-editor.ts index 2f4efa97..6c9447d7 100644 --- a/src/cards/person-card/person-card-editor.ts +++ b/src/cards/person-card/person-card-editor.ts @@ -17,7 +17,7 @@ const actions: UiAction[] = [ "more-info", "navigate", "url", - "call-service", + "perform-action", "assist", "none", ]; diff --git a/src/cards/select-card/select-card-editor.ts b/src/cards/select-card/select-card-editor.ts index 3f2a7ee3..51416fa2 100644 --- a/src/cards/select-card/select-card-editor.ts +++ b/src/cards/select-card/select-card-editor.ts @@ -17,7 +17,7 @@ const actions: UiAction[] = [ "more-info", "navigate", "url", - "call-service", + "perform-action", "assist", "none", ]; diff --git a/src/cards/title-card/title-card-editor.ts b/src/cards/title-card/title-card-editor.ts index 30329a33..357367e3 100644 --- a/src/cards/title-card/title-card-editor.ts +++ b/src/cards/title-card/title-card-editor.ts @@ -10,7 +10,7 @@ import { loadHaComponents } from "../../utils/loader"; import { TITLE_CARD_EDITOR_NAME } from "./const"; import { TitleCardConfig, titleCardConfigStruct } from "./title-card-config"; -const actions: UiAction[] = ["navigate", "url", "call-service", "none"]; +const actions: UiAction[] = ["navigate", "url", "perform-action", "none"]; const TITLE_LABELS = [ "title", "subtitle", diff --git a/src/cards/update-card/update-card-editor.ts b/src/cards/update-card/update-card-editor.ts index f1ddaf7a..1abd8ec6 100644 --- a/src/cards/update-card/update-card-editor.ts +++ b/src/cards/update-card/update-card-editor.ts @@ -19,7 +19,7 @@ const actions: UiAction[] = [ "more-info", "navigate", "url", - "call-service", + "perform-action", "assist", "none", ]; diff --git a/src/ha/data/lovelace.ts b/src/ha/data/lovelace.ts index 1db60edf..cb77cf9a 100644 --- a/src/ha/data/lovelace.ts +++ b/src/ha/data/lovelace.ts @@ -126,10 +126,12 @@ export interface ToggleActionConfig extends BaseActionConfig { } export interface CallServiceActionConfig extends BaseActionConfig { - action: "call-service"; - service: string; + action: "call-service" | "perform-action"; + /** @deprecated "service" is kept for backwards compatibility. Replaced by "perform_action". */ + service?: string; + perform_action: string; target?: HassServiceTarget; - // "service_data" is kept for backwards compatibility. Replaced by "data". + /** @deprecated "service_data" is kept for backwards compatibility. Replaced by "data". */ service_data?: Record; data?: Record; } diff --git a/src/ha/panels/lovelace/editor/structs/action-struct.ts b/src/ha/panels/lovelace/editor/structs/action-struct.ts index 512e45aa..463f4fb9 100644 --- a/src/ha/panels/lovelace/editor/structs/action-struct.ts +++ b/src/ha/panels/lovelace/editor/structs/action-struct.ts @@ -31,8 +31,9 @@ const actionConfigStructUrl = object({ }); const actionConfigStructService = object({ - action: literal("call-service"), - service: string(), + action: enums(["call-service", "perform-action"]), + service: optional(string()), + perform_action: optional(string()), service_data: optional(object()), data: optional(object()), target: optional( @@ -67,6 +68,7 @@ export const actionConfigStructType = object({ "toggle", "more-info", "call-service", + "perform-action", "url", "navigate", "assist", @@ -80,6 +82,9 @@ export const actionConfigStruct = dynamic((value) => { case "call-service": { return actionConfigStructService; } + case "perform-action": { + return actionConfigStructService; + } case "fire-dom-event": { return actionConfigStructCustom; } diff --git a/src/utils/base-element.ts b/src/utils/base-element.ts index 139adc8d..2b469a14 100644 --- a/src/utils/base-element.ts +++ b/src/utils/base-element.ts @@ -1,6 +1,6 @@ import { css, CSSResultGroup, LitElement, PropertyValues } from "lit"; import { property } from "lit/decorators.js"; -import { atLeastHaVersion, HomeAssistant } from "../ha"; +import { HomeAssistant } from "../ha"; import "../shared/badge-icon"; import "../shared/card"; import "../shared/shape-avatar"; @@ -18,13 +18,6 @@ export function computeDarkMode(hass?: HomeAssistant): boolean { export class MushroomBaseElement extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; - protected firstUpdated(_changedProperties: PropertyValues): void { - this.toggleAttribute( - "pre-2024-8", - !atLeastHaVersion(this.hass.config.version, 2024, 8) - ); - } - protected updated(changedProps: PropertyValues): void { super.updated(changedProps); if (changedProps.has("hass") && this.hass) { @@ -50,12 +43,6 @@ export class MushroomBaseElement extends LitElement { ${themeColorCss} ${themeVariables} } - :host([pre-2024-8]) { - --spacing: var(--mush-spacing, 12px); - --control-height: var(--mush-control-height, 40px); - --control-spacing: var(--mush-spacing, 12px); - --icon-size: var(--mush-icon-size, 40px); - } `, ]; }