Skip to content
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

Add hass object to state badge #314

Merged
merged 4 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{% if installed %}

### Features
{% if version_installed.replace("v", "").replace(".","") | int < 10803 %}
- Fixed `State badges updating again thanks to @elupus`
{% endif %}

{% if version_installed.replace("v", "").replace(".","") | int < 10802 %}
- Fixed `Entity icons not updating on state change`
{% endif %}
Expand Down
176 changes: 171 additions & 5 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "room-card",
"version": "1.08.02",
"version": "1.08.03",
"description": "Show entities in Home Assistant's Lovelace UI",
"keywords": [
"home-assistant",
Expand All @@ -19,6 +19,7 @@
"jest-environment-jsdom": "^29.5.0",
"jest-ts-auto-mock": "^2.1.0",
"lit": "^3.1.0",
"minify-html-literals-loader": "^1.1.1",
"ts-auto-mock": "3.5.0",
"ttypescript": "^1.5.13",
"yarn": "^1.22.18"
Expand Down
128 changes: 1 addition & 127 deletions room-card.js

Large diffs are not rendered by default.

Binary file modified room-card.js.gz
Binary file not shown.
1 change: 1 addition & 0 deletions src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const renderIcon = (stateObj: HomeAssistantEntity, config: RoomCardEntity

return html`<state-badge
class="icon-small ${classes}"
.hass=${hass}
.stateObj="${stateObj}"
.overrideIcon="${isObject(customIcon) ? (customIcon as EntityCondition).icon : customIcon as string}"
.stateColor="${config.state_color}"
Expand Down
4 changes: 2 additions & 2 deletions tests/entity/renderEntitiesRow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Testing entity file function renderEntitiesRow', () => {
const result = renderEntitiesRow(config, entities, hass, element);
const htmlResult = getRenderString(result);

expect(htmlResult).toMatch('<div class="entities-row content-left"><div class="entity" style="" @action=_handleAction .actionHandler=> <span>Test Entity</span> <div><state-badge class="icon-small " .stateObj="" .overrideIcon="mdi:light" .stateColor="" style="" ></state-badge></div> </div></div>');
expect(htmlResult).toMatch('<div class="entities-row content-left"><div class="entity" style="" @action=_handleAction .actionHandler=> <span>Test Entity</span> <div><state-badge class="icon-small " .hass= .stateObj="" .overrideIcon="mdi:light" .stateColor="" style="" ></state-badge></div> </div></div>');
}),
test('Passing entities and classes should return entities-row with one child element', () => {

Expand All @@ -64,6 +64,6 @@ describe('Testing entity file function renderEntitiesRow', () => {
const result = renderEntitiesRow(config, entities, hass, element, 'test-class');
const htmlResult = getRenderString(result);

expect(htmlResult).toMatch('<div class="entities-row content-left test-class"><div class="entity" style="" @action=_handleAction .actionHandler=> <span>Test Entity</span> <div><state-badge class="icon-small " .stateObj="" .overrideIcon="mdi:light" .stateColor="" style="" ></state-badge></div> </div></div>');
expect(htmlResult).toMatch('<div class="entities-row content-left test-class"><div class="entity" style="" @action=_handleAction .actionHandler=> <span>Test Entity</span> <div><state-badge class="icon-small " .hass= .stateObj="" .overrideIcon="mdi:light" .stateColor="" style="" ></state-badge></div> </div></div>');
})
})
Loading
Loading