WebCoRe expression help please

I am really trying to understand how to use expressions but for some reason I’m just not getting it.

How can I create a list of devices assigned to a room and Then use those devices in an action?

This way as I assign bulbs to rooms they will be used in pistons without needing to update the Webcore piston.

I'm not exactly sure I understand your question. Are you wanting to assign a group of devices to a particular room (ie variable) and then use an expression to control those devices as a group? If so, take a look here and here for some explanations and examples.

Not really. So in Hubitat there are rooms that you can assign devices to. I see in webcore there is a variable $room which has an ID per room and some kind of value which I assume is a representation of the device.

I want to utilize that so as I add bulbs to that room they can be used in webcore without needing to manually add the device to the piston.

I just need to figure out how to get that $room data and then figure out what the devices are listed there.

1 Like

I don't use rooms in HE or webcore, so I am of little help here. :slight_smile:

just a few thoughts off the top of my head…

  • Can you identify your rooms easily using the room i’d variable? I’m assuming they work as implied.
  • I’m guessing what you want to do is turn on/off all lights in a room, based on their room id?
  • You dont want to edit pistons when you add a new device?

Assuming the above, you could add all devices to a global list of devices, then code your piston(s) to parse all devices in the list and carry out actions based on the room id. A potential downside of this, would be that lights may not change simultaneously, whereas they tend to if you use a with light1,light2 etc statement

I’ve had similar thoughts to this myself, I have a “light walk” piston that turns lights on at a set brightness & time when a defined motion sensor is triggered. It also has different options for night/day mode. If a device is added, it’s just a change to a few variables at the top of the piston. However, the piston is quite complex, and looking back, I’m not sure it was worth the effort to develop, compared to a simple piston per room.

Another way of doing it could be to define a virtual device and call it 'Lounge Bulbs' for example.
You could then have one piston......

IF
Lounge Bulbs turns On
DO
Turn on bulb1, bulb2, bulb3 etc.
ELSE
Turn off bulb1, bulb2, bulb3 etc.
END

As you add more bulbs you amend this piston only.

You can then reference the virtual device 'Lounge Bulbs' in as many pistons as you like without having to change those pistons.

Just another way of doing it.

Thanks everyone for your thoughts. One of the things I’ve always hated about rules and pistons is the fact that you’d have to assign a device that you want to use. I mean typically I’ll ad a bulb to a room and want to do things like capture its current state so I can change it back later. I may add a bulb to a room and hate that I have to update every other piston or rule to do that.

I definitely could do a group but once again I have to add it to a group. Logically it makes more sense to me to say find all bulbs in a room and do stuff.

I’ll give all of your suggestions some thought. Meanwhile if you happen to stumble on a way to utilize rooms please let me know.

Thanks again!

I'm not sure if you can use rooms in webCoRE, but I would use the Mirror Me or Groups and Scenes apps.

Mirror Me will mirror a 'parent' device settings to all the 'child' devices. Turn the parent light on, they all go on.

Groups and Scenes will create a virtual device for a group of devices. Turn on the virtual device and they all go on.

If you're determined to keep this in webCoRE, I would make a global device variable and add all your lights to that. Then you can perform whatever action you want on the device variable. If you need to add or remove lights, you can just update the variable and it will work across all your pistons.

2 Likes

Ooooo. I wonder if I can use maker api to query for device types daily and store that in the global variable in webcore! I can name devices with the room name so I can filter down the bulbs and switches.

Thanks for the suggestions everyone!

I thrive on this back and forth because it helps me think of other solutions.

@bobbles
I’ve used this solution too and it works well. A further advantage is that you can adjust brightnesses of different bulbs, so 50% on the virtual bulb can set 50% on bukb1 and 25% on bulb2, so they are both the same brightness

1 Like

Is there really no way to get a list of all devices registered to your hub?

I’ve no idea how to do it, however, it must be possible.
You have to add devices to webcore in its settings menu. This has a full list of all devices to enable you to add them. Perhaps a look at the webcore source code could give some clues, if you want a challenge!
If you did get the list, I’m not sure how useful it would be, as you still need to add the devices in the webcore settings.

1 Like

Never mind. I was being stupid. Even if I wanted to have a dynamic list in a global variable, I’d still have to have the device assigned in Webcore to do anything with it.

Thanks everyone for the conversation. I really appreciate it.

1 Like

The needing to assign a device for an app to use it is an HE security feature. So webcore needs to be given access.

The rooms variables are dynamic

$roomids gives a list of the available rooms

Using an entry from that list as an index to $rooms will give you the room name, and list of devices assigned to that room.

There is a field m: in the $rooms, that provides a list of device IDs in a room, that webcore cannot access so if you have 1200 there

ie http://hubid/device/edit/1200 was not given to webcore.

You can see these room values by editing a piston, then scrolling down in System variables on the right

3 Likes