Dynamic display of devices

Hello

I have 15 doors / windows sensors.
I am usinf the group app to have a status of all devices:

  • if all “closed”, no alrm symbol shown
  • if at least one device is “open”, it reports an alarm (orange question mark symbol"
    This works perfectly and is very useful to check statuts when leaving the house.
    I would like to go one step further:
  • when 1 / several devices are “open” I would like a way to get the list of open devices (only these devices).
    This could be either by clicking on the “group” icon i have created, or simply by displaying the open devices somewhere.
    If I need to change the approach (not using the groupe app) this is fine.

I have no idea how to achieve this.

Thanks

Read this thread, please:
https://community.homey.app/t/help-with-a-flow-when-raining-notify-which-doors-windows-are-open/48331/11?u=peter_kawa

Here’s the script I use:

// Check if certain doors or windows is open?

let devices = await Homey.devices.getDevices();
let windowText = "";
let currentText = "";
let logText = "";
let windowOpen = false;

_.some(devices, device => 
{
if ( device.class == 'sensor' ) 
// device.class is found at https://tools.developer.homey.app/tools/devices
  {
  if( device.capabilitiesObj &&
  device.capabilitiesObj.alarm_contact &&
  device.capabilitiesObj.alarm_contact.value )
    {
    currentText = "";
    // to compare and see if there is no typing error
    //console.log(`- Open door/window script check: \nName: ${device.name} \nZone: ${device.zone} \n(ZoneName: ${device.zoneName}) \n[device.class: ${device.class} \ndevice.capabilities: ${device.capabilities}]`); 

      if(device.name != ""){
      windowOpen = true;
      if(windowText=="")
      windowText = device.name + "\t(Zone: " + device.zoneName + ")";
      
      else
      windowText = windowText + "\n" + device.name + "\t(Zone: " + device.zoneName + ")";
      }
    }
  }
});

if(windowOpen == true)
windowText = "\nThese windows/doors are still open:\n" + windowText + "\n";
else
// comment this out if you don't want a msg when all's fine:
windowText = "All windows & doors are closed.";

Homey.flow.runFlowCardAction({
        uri: 'homey:manager:notifications',
        id: 'create_notification',
        args: {
          text: String(windowText) + '\n[Peter Away - window/door Open Notif]'
        },
      });

//just to check
console.log("\nOutput:", String(windowText));

// Create / update HomeyScript variabele
await tag("door_windowText", String(windowText));

return (true);

// Initial script by RonnyW.


The script is called with a flow like this:


Maybe this indicator is useful as well


Check out this post for the flow and howto:

1 Like

A different option (not using the group app) would be to use a virtual device that reports the status of each door/window in the capabilities tab and a summarized status indicator displayed on the virtual devices tile.

I created this post on how to create such a virtual device on the Dutch section of the forum before.

1 Like

Not sure if you hinted to me about not using the group app, but I only use the Device Capabilities app in my flow :grimacing::blush:

No I didn’t :blush:, but the OP indicated he uses that app and I was not sure whether my suggestion would we applicable, as it is not based on that app.

1 Like

Hello both and thanks for your valuable inputs.
I will check both solutions.
If one can work without a script Inwould tend to favor it unless the script being added value if course
And sorry I had not seen the other thread although I had done some research.
This is typically the type of standard need that should be covered by Homey with a standard solution IMHO
Thanks

1 Like

I have spent some time trying to understand what the Device Capability does. I have followed some examples provided by Arie, but I am not sure.
Can it actually trigger any action in the app, or it can only gather info from multiple devices to be used in a flow (to then trigger action).
Thanks

This is what’s possible with the DC app, outside of DC, as THEN cards:

From the flowcards overview below:

  • “Set from…” cards:
    You can set/command multiple devices with certain common properties, as mentioned on these cards

  • “Retreive insights value…” cards:
    gets the last known value from a devices’ capabilitity (known to Insights), when “minutes ago” is set to 0;
    Or, get the value as it was at a certain time, like, an hour ago, 24h ago, a week ago, asf.

  • Execute expression:
    All javascript (supported by Homey) goes

  • Find all flows containing … :
    When you want to find out in which flows an object is used, like:


    The results can be filtered.

Overview of THEN cards for use outside of DC app:

For any related questions, I recommend to use the DC app topic

1 Like

Thanks Peter I really appreciate your help
However this sounds a bit Chinese to me, I don’t even know what cards are.
I am posting on the DC app topic as per your suggestion.

I’m trying right now just to show multiple values from my weather app (let’s say temp and pressure).
I select textfield I can select the first value from any device fine. As soon as i select another value on the same DC device, it’s forcing me to put BLL. I don’t understand why I simply want to display values.
I tried using number fields, same problem i need to give some logic (mean, average…), no way I can do it simple
I’m about to give up…

thanks

YW.

Ah yes, with cards I mean flow cards.

Yeah it’s not the simplest app to use
But for many questions often many answers are here :wink:

When you select a real device property, of which the type (text, number or yes-no) is different than the AVD property type, you will need to convert it somehow, thats why BLL is then mandatory.

Thanks Arie for taking the time to answer me.

I hope you did not feel I was not critisizing the logic, I was just saying I could not undertsand.
I can definitely see the power of your app, but also that there is a steep learning curve for a non technical person like me.
I spent a few hours and I now understand what my problem was: I was trying to put 2 values into a single place holder, and therefore the system logically was asking me how the should be aggregated.
But the reason I did not understand is very simple: I was trying to do something else: simply display 2 info (device capabilites) on a signle AVD tile.
I now understand that for this I need to create 2 AVD fields (obvious, right of course, but not really for me since whn you create the first field you have an option to add another device (to be aggregated in the same field, therefore not what I was trying to do).
Now I understand I simply need to put 1 device per field, and then create another field, with another device, in the same AVD tile.

It probably all seems obvious to you, but I was lost :slight_smile:
I will create a mini tutorial on the forum as I say it could be helpful for other newbies like me

Thanks Arie

PS: where do i find the BLL expressions? I have installed BLL but when I try to enter a BLL there is no list of values if I click on the field, is that normal?

See the better logic app settings for more info on expressions :wink:

Thanks Arie but should’t I get a list of values shown in the BLL field? It is empty (although I have installed BLL) and i have seen screenshots of your app with list of values it seems.

thanks

Hello @SunBeech

I’m trying your approach (@Peter_Kawa I prefer to avoid using a script initially if i can although you have been kind enough to provide it, but it seems more complicated to me).
I have tried translating the Dutch forum with Google translate, but it does a very poor job which makes it hard to understand.
Just to make sure I understand, does your solution allow to display only the open devices, or simply all devices, with an indicator showing (maybe in red) which ones are open?
Because I am really looking for a solution that only displays the open ones.
I actually have over 20 windows with sensors, and going through the list is quite cumbersome, and clearly not wife friendly.
Beside the format used by Device Capability app is not great, as it does not allow to display a list (which would be better in my case) but only tiles, where the text is cut out.

Yes, translations via Google can sometimes give some remarkable results :grinning:.

The virtual device I created consists of:

  • The device tile itself of which the indicator displays a summarized status;
  • A sensors/capabilities page that indicates for each individual door whether it is opened or closed + contains the summarized status, which is also displayed on the devices tile.

The summarized status shows a count of all (and only) open doors or (if none are open) a text indicating that all doors are closed. The status information is a combination of the count itself and some text. E.g. ‘1 Open’. The count is based on a BLL variable that is updated by a flow that is triggered when a door is opened or closed.

  • The tile that is set to show the Status field as indicator:

  • This Status field is based on the BLL variable bllDeurenRamenStatus (in EN: bllDoorsWindowsStatus)

  • The BLL variable bllDeurenRamenStatus is updated by a flow when a door opens/closes.

The sensors/capabilities page shows which doors are open and which are closed. So not only the open ones. You have to preset/preconfigure the fields/items shown on the sensors/capabilities page. Each item displays a text value (Open or Closed, so it is not a Yes (red)/No (not red) sensor), which is based on a BLL variable per door that is updated every time I open or close that specific door.

I don’t think you can populate this page dynamically (to only show the open doors). Also, as far as I know, you can only include icons/sensors on this page (the standard Homey layout); not a list.

I only have a handful of door sensors, so it is manageable for me to setup that page upfront and then use a flow for each door to set its status (open/closed) on the said page.

The screenshot shows:

  • That the balcony door in the bedroom (Balkondeur Slaapkamer) is open, and the three other doors are closed;
  • The summarized Status field (1 Open) that is used for the device’s tile.

In short: my solution is a static one, that you need to setup upfront. Of course the status per door and the summarized status is dynamic/updated when a door opens/closed.

I hope this clarifies the way I have implemented it.

@SunBeech very clear indeed, thanks a lot (much better than Google!)
You are confirming what I thought:

  • statis view, not dynamic
  • no list view, only icons (I do like the list view that you have in the climate view for instance where it lists all the temperatures by room)

I see that you are using a textfield, I was using a YES/NO field. I see that with the YES/NO field open doors show up in red which is nice (it seems to do it automatically). Any way to do the same with text field?
Since I’m curious and always want to learn / understand I have tried using your approach with text field, but I’m facing some issues:

  • how do you get to set the nice door icon at device level? It’s only offering me a few standard icons that do not correspond
  • strange because I do get the same door icon than you when setting up the DC device, but not inside the device
  • in the reflecteer field if I also select BLL library, then my list of variables is empty, is that normal? I was expecting to get my list of exisiting variables.
  • You are telling your BLL variable is updated with a flow to fetch the status. I get the principle I think. Does it mean if I have 20 doors, I need to create 20 variables and 20 flows? Because when I use the YES / NO variable I get the status directly from the device in DC app (without having to create the variable + flow). Did you do this just to get the words “open” “closed” to display instead of yes / no (which is better indeed)

Sorry for asking so many questions, but this app is great, but the documentation is hard to find :slight_smile:

I don’t think that is possible. There is no color property that you can set for text fields. It’s Homey’s default way of working for Yes/No fields to display the Yes condition in red.

The icons displayed in the field’s pull down menu is a different list than the one you are presented with, when creating the virtual device. However, can change any of those icons to another one (either those available in the app itself or upload your own icon (SVG file in black).

In order to change icons, you need to go to the settings of the Device Capabilities app itself. Select the custom icons tab and change the icon for one of the fields:

After changing icons, restart the Device Capabilities app. Next you can assign the icon to a field in virtual device’s settings.

If you did not create a BLL variable in the BLL app upfront, then that list will indeed be empty. Or in other words: you first need to create your variable in the BLL app. If you go to the settings page of the BLL app and select the Variables tab, you can create/maintain your BLL variables:

Click the Add variable (Variabele toevoegen), provide a name, choose your type (e.g. text/string) and add it. Then it should be added to the list below. Now you can go back to the virtual device’s settings and select the BLL variable at the reflect option.

Yes, you got it :grinning:. If you just want to display existing sensors/values in the virtual device (like the contact alarm value of the door sensor), then there is no need to use BLL variables. You simply select the device and subsequently the contact alarm capability at the reflect option.

Since I wanted to display a different text then Yes/No I opted for the option to use BLL variables. Though you also have an option to format available device values as something different in the BLL expression section of the field. However, I didn’t know that at the time, and I found it more manageable to create my texts in a flow. So that was a personal preference. This does mean indeed, that I created a BLL variable per door (so 4 in total) plus one for the summarized status field.

@SunBeech thanks so much for your explanations, they are very helpful

I was able to change the icons, looks much better now :slight_smile:
I also now understand the principle of BLL variables, i thought I could use Homey variables, that was my mistake. I will see if I need to use the variables. I don’t really need to display the number of doors open. Currently I’m using the group device which displays a warning sign and it’s perfect.

if I could simply replicate the same principle in my DC device that would be great.
I have seen on a post it is possible to choose the icon to display on the device tab, and I’m hoping that using a variable I will be able to display the same icon showig that at least 1 is open. Not sure yet if it’s feasible from within the same DC device.

At least I’m making good progress thanks to your help

Olivier

You’re welcome.

I think in order to get such an alarm sign, you need to create a yes/no field in the virtual device and set the sensor type to one of the alarm types, e.g. Alarm (custom). I haven’t used this before, but you might give it a try.