Hey guys,
I think the ui_template is my final boss
I would like to create a template like this:
It works quite well so far, but as soon as I send "msg.payload.LWL" or "msg.payload" to the template, it disappears. The icon alone works.
The icon function is based on
On/off button for dashboard 2.0 in ui_template (updates and improvements)
<template>
<div class="container">
<div class="title">Garagem</div>
<v-icon
class="icon"
ref="icon"
@click="alternar"
:style="iconStyle"
>
{{ iconName }}
</v-icon>
<p class="textstyle">
<span class="hostname-label">Hostname: </span>
<a :href="`http://${msg.payload.StatusNET.IPAddress}`" class="hostname" target="_blank" rel="noopener noreferrer">
{{ msg.payload.StatusNET.Hostname }}
</a>
<br />
<span>IP: {{ msg.payload.StatusNET.IPAddress }}</span>
<br />
<span :class="{'online': msg.payload.LWT === 'Online', 'offline': msg.payload.LWT === 'Offline'}">
Status: {{ msg.payload.LWT }}
</span>
<br />
<span>Restart Grund: {{ msg.payload.StatusPRM.RestartReason }}</span>
<br />
<span>Firmware: {{ msg.payload.StatusFWR.Version }}</span>
</p>
</div>
</template>
<script>
export default {
data() {
return {
value: '',
iconName: 'mdi-television-ambient-light'
};
},
computed: {
iconStyle() {
return {
color: this.value === 'ON' '#BD9608' : '#A9A9A9',
textShadow: this.value === 'ON' '0px 0px 10px #BD9608' : '0px 0px 0px'
};
}
},
methods: {
alternar() {
if (this.value === 'ON') {
this.off_alternar();
} else {
this.on_alternar();
}
},
on_alternar() {
this.value = "ON";
this.send({ payload: "ON" });
},
off_alternar() {
this.value = "OFF";
this.send({ payload: "OFF" });
},
on() {
this.value = "ON";
},
off() {
this.value = "OFF";
}
},
watch: {
msg(newVal) {
if (newVal.payload === "ON") {
this.on();
} else {
this.off();
}
}
},
mounted() {
this.off();
}
}
</script>
<style>
.container {
display: flex;
flex-direction: column;
margin: auto;
height: auto;
width: 100%;
background-color: #4F4F4F;
color: #000000;
border: 1px solid #000000;
font-size: 14px;
border-radius: 18px;
align-items: flex-start;
padding: 10px;
}
.title {
margin: 5px auto auto auto;
font-size: 85%;
text-align: center;
}
.icon {
width: 50%;
margin: -7px auto auto auto;
font-size: 300%;
transition: color 0.3s, text-shadow 0.3s;
}
.textstyle {
margin-top: 5px;
text-align: left;
color: #FFFFFF;
}
.hostname-label {
font-weight: bold;
}
.hostname {
color: #800080;
text-decoration: underline;
}
.hostname:visited {
color: #800080;
}
.online {
color: green;
font-weight: bold;
}
.offline {
color: red;
font-weight: bold;
}
</style>
Does anyone have an idea what I'm doing wrong?
Thanks in advance again