Simple Door Status Widget

Nice! It’s looking good!

Now I need to work out an alternative for the lock status. I just have a door sensor, and no lock…

You could put the item for the open close in where it asks for lock and leave the open close one empty. It will hide the text

1 Like

Your use case actually gave me a interesting idea for version 2.

1 Like

Looking forward to seeing it!

I tried like you said but the text didn’t get hidden. Maybe I need to do something else??

I re checked the code and was wrong. Though v2.0 will cover this

1 Like

Cool! :slight_smile:

I’d really appreciate if you could add the ability to toggle the lock. I tried (yes, newbie here) to add actions to allow this but I’m just not understanding (yet) how these widgets work.

  action: toggle
  actionCommand: ON
  actionCommandAlt: OFF
  actionItem: =props.lock

Much appreciated …

These actions fixed it … Hope others find this useful … Thanks again for the widget, love it …

config:
  color: '= (items[props.sensor].state === "OPEN") ? "lightblue" : (items[props.lock].state === "OFF") ? "yellow" : "white"'
  action: toggle
  actionItem: =props.lock
  actionCommand: ON
  actionCommandAlt: OFF
  expandable: false
  footer: '= "Last Updated @ " + dayjs(items[props.updated].state).format("M/D/YY h:m:ss A") + " & Battery level is " + 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: = "Door is " + items[props.lock].displayState
  on: true
  subtitle: '= (props.sensor) ? "Door is " + (items[props.sensor].state).toLowerCase().charAt(0).toUpperCase() + (items[props.sensor].state).toLowerCase().slice(1) : ""'
2 Likes

Hi there, I’m new to trying to setup my first layout pages so bear with me if I missed something obvious. :smiley:

Running : openHAB 3.3.0 Release Build on a raspberry

I want to display my garage door status but I don’t have an actual garage door item. I use a dummy item

Contact     garageDoor_contact       "Porte du Garage"                  (gGarageDoor)    ["GarageDoor", "OpenState"]    {autoupdate="true"}

I have a rule that updates that item’s status. So in my model, I can see my door status changing and I guess it’s good enough but I’m still not sure.

Right now what I was able to achieve is this :
image

I cannot remove the “Door is undefined”, also, I tried to change the footer text (I don’t need the battery level, my contact is hardwired) but it’s not reflected in the widget. Here is my yaml code :

component: widget:door_lock_status
config:
  updated: garageDoorLastUpdate
  label: Porte du garage
  footer: = "Last Updated " + dayjs(items[props.updated].state).format("DD/MM/YY
    hh:m:ss")
  sensor: garageDoor_contact
slots: null

What am I missing?
I tried adding “lock: garageDoor_contact” in the configuration but no difference.

Any help is appreciated.

So two things. It looks like you have the version 1 code for the widget vs 1.1 (lastest) not sure how you go that but the problem with seeing door is twice was fixed then. The widget was originally made for things like zwave locks and I did not think about garage doors. The footer text currently is non-hidable. But I could add that in an update. That way if parts of the footer are valid it hides them.

2 Likes

I did plan on this but was side tracked with other things. The one thing is I would want to expand the values to props so that if on and off aren’t right they can be chamged

1 Like

Ok so I got the code by installing the widget from marketplace.
I edited it with the code found here and then I altered it a bit more to suit my needs :wink:
So it’s starting to look more like what I need.
Thank you.
image

Glad you got something you like. I have had my real job pushing deadlines so I had to pause on my contributions here. Trying to remain active on the forums for help though. FYI on all my widgets there are snippets of each version and a “latest”. The latest is always the latest as it is the one karaf (marketplace) keys on since it is a raw yaml file. If you want to share code at any point for me integrate into my widget for all just DM me it and ill work on it.

I understand and thank you for your time.
I don’t think my modifications are worth sharing as I merely removed some stuff (battery and lock I don’t have). It’s the first time I’m trying to do something with widgets but if I do something better later on, I will share. :slight_smile:

@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