Simple Door Status Widget

@mediatech15
Thanks for this widget. Love it so far.

But I always get a warning in the logs if the page is shown and the widget gets displayed:

2023-02-28 19:42:49.541 [WARN ] [e.internal.SseItemStatesEventBuilder] - Attempting to send a state update of an item which doesn't exist: undefined
2023-02-28 19:42:49.739 [WARN ] [e.internal.SseItemStatesEventBuilder] - Attempting to send a state update of an item which doesn't exist: undefined

My code of the widget (I have made the props.update as optional, because I donā€™t have this):

uid: door_lock_status
tags:
  - marketplace:136160
props:
  parameters:
    - description: Label for Door
      name: label
      required: false
      type: TEXT
    - context: item
      description: Door Lock Item
      label: Item
      name: lock
      required: false
      type: TEXT
    - context: item
      description: Door Battery Item
      label: Item
      name: battery
      required: false
      type: TEXT
    - context: item
      description: Door Sensor Item
      label: Item
      name: sensor
      required: false
      type: TEXT
    - context: item
      description: Door Update Time Item
      label: Item
      name: updated
      required: false
      type: TEXT
  parameterGroups: []
timestamp: Feb 26, 2023, 10:39:00 PM
component: oh-label-cell
config:
  color: '= (items[props.sensor].state === "1") ? "lightblue" : (items[props.lock].state === "3") ? "yellow" : "white"'
  expandable: false
  footer: '= (props.updated) ? "Last Updated @ " + dayjs(items[props.updated].state).format("M/D/YY h:m:ss A") + " & Battery level is " + items[props.battery].displayState : "Batterie " + items[props.battery].displayState'
  header: = props.label
  icon: '= (items[props.sensor].state === "OPEN") ? "iconify:ri:door-open-line" : (items[props.lock].state === "ON") ? "iconify:bxs:lock" : "bxs:lock-open"'
  label: = items[props.lock].displayState
  on: true
  subtitle: '= (props.sensor) ? "TĆ¼r ist " + (items[props.sensor].displayState) : ""'

Making the props not required will not make the resulting code below not take them into account. There is light checks for things but some things may need to be edited/removed if you donā€™t have them. Example if you donā€™t use a sensor you will need to modify the logic to not need the sensor item to make updates. (thatā€™s my guess to the part your not using) The warnings just mean that a state is attempting to be retrieved for an unknown item, which makes sense if you arenā€™t using all the same items I configured it for.

1 Like

hello,

first, my programming skill in yaml is very fundamental, Iā€™ve tried to implement a visibility rule for the Battery level.
I would like, that the font is displayed at under 3.4V.

for this, I tried the following code

visibility: '= items[props.battery].state <= 3.4 '

of course, it doesnā€™t work :slight_smile: Iā€™ve googled a lot, but didnā€™t find a solution for me or code that I can use and modify.
Maybe someone can help me :slight_smile: I would appreciate it! =)

Here is how I did my solar stuff so you can get the idea:

component: oh-cell
config:
  action: navigate
  actionPage: page:Solar_Overview
  color: =((Number.parseFloat(items.FroniusSymoInverter_GridPower.state))>=0)?('red'):('green')
  footer: =(Math.round((Number.parseFloat(items.FroniusSymoInverter_LoadPower.state))))+"
    Consumption/Self " +
    (Math.round(Number.parseFloat(items.FroniusSymoInverter_SelfConsumption.state)))
    + "%"
  header: "=((Number.parseFloat(items.FroniusSymoInverter_GridPower.state))<=0)?(\
    'Currently on Solar'):('Currently on Grid') "
  icon: =((Number.parseFloat(items.FroniusSymoInverter_GridPower.state))<=0)?('f7:sun_max_fill'):('if:mdi:transmission-tower-import')
  iconColor: =((Number.parseFloat(items.FroniusSymoInverter_GridPower.state))>=0)?('red'):('yellow')
  on: =((Number.parseFloat(items.FroniusSymoInverter_GridPower.state))!=0)
  subtitle: =(Math.round(Number.parseFloat(items.FroniusSymoInverter_CurrentSolarYield.state)))+"
    Solar updated " + (items.FroniusSymoInverter_GridPower_updated.displayState)
  title: '=(Math.round(Number.parseFloat(items.FroniusSymoInverter_GridPower.state)))+"
    Grid " '

Which looks like this:
image