Ich habe mich mal an einem Tür-Fenster Widget mit Batterie-Status versucht da ich nicht zwei "Zellen" für ein Gerät in die UI bringen möchte.
Leider erhalte ich als Rückgabeparameter immer 'NULL' für den Sensor und finde dafür keine Lösung. Beim direkten Einbinden des Items zeigt es korrekt an (siehe Screen)
Ich denke, die Abfrage des Status sollte dafür korrekt sein... Oder irre ich mich?
Oder hat jemand schon ein schönes Widget dafür erstellt?
Hier mal der Code dazu...
Code
uid: cell_tuer_fenster_offen
tags: []
props:
parameters:
- description: Small title on top of the card
label: Title
name: title
required: false
type: TEXT
- description: Icon on top of the card (only f7 icons (without f7:))
label: Icon
name: icon
required: false
type: TEXT
- context: item
label: Fenster Sensor
name: window_item
required: false
type: TEXT
- context: item
description: on/off item
label: Sensor Batterie
name: battery_item
required: false
type: TEXT
parameterGroups: []
timestamp: Jan 24, 2023, 9:44:50 AM
component: f7-card
config:
style:
noShadow: false
padding: 0px
border-radius: var(--f7-card-expandable-border-radius)
box-shadow: 5px 5px 10px 1px rgba(0,0,0,0.1)
background-color: "=props.bgcolor ? props.bgcolor : ''"
height: 120px
margin-left: 5px
margin-right: 5px
slots:
content:
- component: f7-block
config:
style:
position: absolute
top: -5px
left: 16px
flex-direction: row
display: flex
slots:
default:
- component: f7-icon
config:
f7: =props.icon
size: 25
style:
margin-right: 10px
visible: "=props.icon ? true : false"
- component: Label
config:
text: "=props.title ? props.title : ''"
style:
font-size: 20px
margin-top: 0px
- component: f7-block
config:
style:
position: absolute
bottom: -20px
left: 12px
flex-direction: row
display: flex
slots:
default:
- component: f7-icon
config:
f7: house
size: 25
- component: Label
config:
text: '=items[props.window_item].state == "OPEN" ? "Geöffnet" : "Geschlossen" '
style:
font-size: 20px
margin-left: 5px
margin-top: 0px
color: '=items[props.window_item].state == "OPEN" ? "red" : "green" '
- component: f7-block
config:
style:
position: absolute
bottom: -55px
left: 12px
flex-direction: row
display: flex
slots:
default:
- component: f7-icon
config:
f7: battery_25
size: 25
- component: Label
config:
text: =items[props.battery_item].state
style:
font-size: 20px
margin-left: 5px
margin-top: 0px
color: '=items[props.battery_item].state == "ON" ? "red" : "green" '
Display More