Skip to content

Commit

Permalink
Fixed actions, removed entity alongside more-info (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcokreeft87 committed May 22, 2023
1 parent 05f72e9 commit b596a3d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
5 changes: 5 additions & 0 deletions info.md
@@ -1,6 +1,11 @@
{% if installed %}

### Features
{% if version_installed.replace("v", "").replace(".","") | int < 10723 %}
- Fixed `actions no longer working`
- Removed `entity alongside more-info tap_actions`
{% endif %}

{% if version_installed.replace("v", "").replace(".","") | int < 10722 %}
- Fixed `Navigation header url not working`
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "room-card",
"version": "1.07.22",
"version": "1.07.23",
"description": "Show entities in Home Assistant's Lovelace UI",
"keywords": [
"home-assistant",
Expand Down
6 changes: 3 additions & 3 deletions room-card.js

Large diffs are not rendered by default.

Binary file modified room-card.js.gz
Binary file not shown.
20 changes: 6 additions & 14 deletions src/entity.ts
Expand Up @@ -2,7 +2,7 @@ import { secondsToDuration } from './lib/seconds_to_duration';
import { formatNumber } from './lib/format_number';
import { computeStateDisplay, computeStateDomain } from './lib/compute_state_display';
import { checkConditionalValue, evalTemplate, getValue, isObject, isUnavailable, renderClasses } from './util';
import { ActionConfig, ActionHandlerEvent, handleAction, hasAction, HomeAssistant } from 'custom-card-helpers';
import { ActionHandlerEvent, handleAction, hasAction, HomeAssistant } from 'custom-card-helpers';
import { HomeAssistantEntity, EntityCondition, RoomCardEntity, RoomCardIcon, RoomCardConfig, EntityStyles, RoomCardRow, RoomCardAttributeTemplate } from './types/room-card-types';
import { html, HTMLTemplateResult, LitElement } from 'lit';
import { LAST_CHANGED, LAST_UPDATED, TIMESTAMP_FORMATS } from './lib/constants';
Expand Down Expand Up @@ -183,25 +183,17 @@ export const clickHandler = (element: LitElement, hass: HomeAssistant, entity: R
handleAction(element, hass, entity, ev.detail.action);
}

export const generateActions = (config: RoomCardConfig, entity: RoomCardEntity) => {
return {
tap_action: checkAction(config.tap_action, entity?.tap_action),
double_tap_action: checkAction(config.double_tap_action, entity?.double_tap_action),
hold_action: checkAction(config.hold_action, entity?.hold_action),
} as RoomCardEntity
}

export const checkAction = (action: ActionConfig, entityAction: ActionConfig) => {
return entityAction ?? action;
}

export const renderTitle = (config: RoomCardConfig, hass: HomeAssistant, element: LitElement, entity?: RoomCardEntity) : HTMLTemplateResult => {
if(config.hide_title === true)
return null;

const _handleAction = (ev: ActionHandlerEvent): void => {
if (hass && ev.detail.action) {
clickHandler(element, hass, generateActions(config, entity), ev);
clickHandler(element, hass, entity ?? {
tap_action: config.tap_action,
double_tap_action: config.double_tap_action,
hold_action: config.hold_action
} as RoomCardEntity, ev);
}
}

Expand Down

0 comments on commit b596a3d

Please sign in to comment.