Presence

A simple presence list widget that shows the presence (green) or away (red) state of a person using color and a badge. It works with Switch Items

Changelog

Version 0.1

  • initial release

Resources

uid: rlk_presence_list
tags:
  - list
  - presence
props:
  parameters:
    - description: The label for the widget
      label: Person
      name: title
      required: false
      type: TEXT
    - context: item
      description: The presence switch Item
      label: Item
      name: item
      required: false
      type: TEXT
  parameterGroups: []
component: oh-label-item
config:
  icon: f7:person_circle
  iconColor: '=(items[props.item].state == "ON") ? "green" : "red"'
  color: '=(items[props.item].state == "ON") ? "yellow" : "gray"'
  title: =props.title
  item: =props.item
  badgeColor: '=(items[props.item].state === "ON") ? "green" : "red"'
  badge: '=(items[props.item].state === "ON") ? "PRESENT" : "AWAY"'
1 Like

@rlkoshak Hi Rich,

thanks! awesome widget. Does it also work with “0” and “1”?
I have implemented my presence switch with digital numbers not with the “ON” and “OFF” strings.
And may I kindly ask you to provide a sitemap example?

Cheers
Justus

You’ll have to edit the widget to use “0” and “1”. This is a MainUI widget and will not work with sitemaps.

Ok, thanks for the info! I apologize that I am not yet so familiar with the new MainUI :slight_smile:

@rlkoshak Hi Rich,

First things first, great work with the widget and with all the support that you and the other guys provide in the forum.

I’m fairly new to OH, I just started tinkering with it about a week ago. Anyway, I was able to setup openHabian in a RPi4 and I have started to implement presence.

I used your Generic Presence Detection post to set it up without problems.

But when I tried to use your widget to show it in my Overview Page I run into two problems.

  • Item does not update according to the state of the Item is connected to (Always show “AWAY” but the state of the Item is “ON”)
  • The visuals of the widget are not the same

imagen

Any idea why the widget is shown in a block instead of in a line and why do it has a black dot before?

Thanks in advance for any help you can provide

That’s your problem. This is a List Item Widget, not a Stand Alone Widget. The widget above is used when showing the Item inside a list, such as in a Locations card on the Locations tab of the Overview page. It is no designed to be a widget you plop onto a Layout page by itself.

As for the state changing, it will only show “green” and “present” when the Item configured in the widget’s props is “ON”. If the Item’s state is “OFF”, “NULL”, “UNDEF”, or if you misstyped and selected the wrong Item it will always show as red and away. So check you have the right Item configured for the Widget.

Thanks for the quick reply.

When I add the widget inside a list it works correctly, so that part is done.

For the state, after I reload a couple times it started to work correctly so… that seems ok.

Last thing to ask (I have been trying for a while to solve that on my own…) is that the status of the Item appears at the end (IMHO that´s redundant and besides, I don’t see that behaviour in your picture)

imagen

Any idea why that is happening? Thanks!

1 Like

You have to use stateDescription pattern

For textual item configuration it would be:

Switch Item_Name “Item Description” { stateDescription=" “[ pattern=” " ] }

If you use only UI then something like this:

At least such method works for me.

1 Like

Thank you, that made the trick.

Just to make sure, since @rlkoshak is the creator of the widget. Is this how you intended it to be? Should I need to set stateDescription of the Presence Items to " "?

1 Like

That’s how the base widgets for MainUI work. I can’t say if it’s how it’s intended but thats how it works.

I am trying to solve the same problem with displayed item state next to the presence status.
Unfortunately placing " " this kind of pattern inside the StateDescription does not make the ON/OFF status disappeared. What shall be the right pattern to high the item status text? Is this the intended place to define the pattern in OH3?

This does not work for me. I also set this in code tab of the Item’s stateDescription directly. the “ON/OFF” is always visible. :frowning:
What do I do wrong?

Set it to just a space. No quotes.

Does not work.

Presence Item code (state description)

value: " "
config:
  options: ""
  pattern: " "

Item is switchable coming from Network Binding (Pingable Device)

Item State still appears:
image

All I can say is it works for me on 3.3.0 M5 using this UI widget.

State Description metadata:

value: " "
config:
  pattern: " "
  readOnly: true

I am on 3.2.0. Will make an update…

After 10min…
It seems that 3.2.0 is the latest stable release. Making an update and upgrade through

openhabian-config

does not update to 3.3.0. I will wait for the next stable release than…

You will have to change to the testing repo to upgrade to a milestone release. However, this widget has worked, with the space in the state description since before 3.0 was released. I’ve not modified it.

I removed all presence items. Rebooted and added newely with stateDescription pattern " ".
Now it works. Thanky you for your support.

I’m not sure what more help I can provide. I’m not able to reproduce the behavior. It works for me as shown above.