Skip to content

Commit

Permalink
Add view device link
Browse files Browse the repository at this point in the history
  • Loading branch information
christiaanderidder committed Jan 11, 2025
1 parent 841eb50 commit d949a3c
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions src/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import {
mdiMoleculeCo2,
mdiValve,
mdiValveOpen,
mdiValveClosed
mdiValveClosed,
mdiGauge
} from "@mdi/js";
import { customElement, state } from 'lit/decorators';
import { styles } from "./styles";
import { HassEntity } from "home-assistant-js-websocket";
import { HomeAssistant, LovelaceCardConfig, MoreInfoActionConfig, handleAction } from "custom-card-helpers";
import { HomeAssistant, LovelaceCardConfig, MoreInfoActionConfig, NavigateActionConfig, handleAction } from "custom-card-helpers";

declare global {
interface Window {
Expand Down Expand Up @@ -62,6 +63,8 @@ export class BrinkRenoventHruCard extends LitElement {

@state() private config: Config;

@state() private deviceId : string

@state() private fanModeRead: HassEntity;
@state() private fanModeWrite: HassEntity;
@state() private outdoorAirTemperature: HassEntity;
Expand Down Expand Up @@ -90,6 +93,7 @@ export class BrinkRenoventHruCard extends LitElement {

public static getStubConfig() {
return {
deviceId: "",
fanModeReadEntity: "sensor.ebusd_excellent400_fanmode",
fanModeWriteEntity: "select.ebusd_excellent400_fanmode",
indoorAirTemperatureEntity: "sensor.ebusd_excellent400_insidetemperature",
Expand All @@ -111,6 +115,9 @@ export class BrinkRenoventHruCard extends LitElement {

public set hass(hass: HomeAssistant) {
this.ha = hass;

this.deviceId = this.config.deviceId;

this.fanModeRead = hass.states[this.config.fanModeReadEntity];
this.fanModeWrite = hass.states[this.config.fanModeWriteEntity];
this.outdoorAirTemperature = hass.states[this.config.outdoorAirTemperatureEntity];
Expand Down Expand Up @@ -188,6 +195,7 @@ export class BrinkRenoventHruCard extends LitElement {
${this.renderCO2Level(this.co2Level2)}
${this.renderCO2Level(this.co2Level3)}
${this.renderCO2Level(this.co2Level4)}
${this.renderDetails(this.deviceId)}
</div>
`;
}
Expand Down Expand Up @@ -217,7 +225,7 @@ export class BrinkRenoventHruCard extends LitElement {

return html`
<div class="hru-zone-line" .entity=${entity} @click=${this.moreInfo}>
<ha-svg-icon .path=${mdiWeatherWindy} class=${this.bypassValveStateClass()}></ha-svg-icon> ${entity.state}
<ha-svg-icon .path=${this.bypassValveIcon()} class=${this.bypassValveStateClass()}></ha-svg-icon> ${entity.state}
</div>
`;
}
Expand All @@ -242,6 +250,16 @@ export class BrinkRenoventHruCard extends LitElement {
`;
}

private renderDetails(deviceId: string) {
if (!deviceId) return;

return html`
<div class="hru-zone-line" @click=${() => this.navigate(`/config/devices/device/${deviceId}`)}>
<ha-svg-icon .path=${mdiGauge}></ha-svg-icon> View device
</div>
`;
}

private renderFanModes() {
if (!this.fanModeRead || !this.fanModeWrite) return;

Expand Down Expand Up @@ -308,4 +326,15 @@ export class BrinkRenoventHruCard extends LitElement {
}
handleAction(this, this.ha, config, "tap");
}

private navigate(path: string) {
console.log(path);
var config = {
tap_action: {
navigation_path: path,
action: "navigate"
} as NavigateActionConfig
}
handleAction(this, this.ha, config, "tap");
}
}

0 comments on commit d949a3c

Please sign in to comment.