Then, can we use them in meshbots like: Turn off All Lights?
You already have the concept of Rooms and we can declare which devices are in them. It would be great if I could have different devices in say the Living Room like a few lights, the TV, a motion sensor and a camera. Then a meshbot could be written to ‘turn of the living room lights’ which would use the living room group and just turn of the light devices in that group.
Maybe something like this? I know this works without the >>>
and (device.room == "room_number")
local items = core.get_items()
if items then
for _, item in ipairs( items ) do
if item.name == “switch” then
local device = core.get_device( item.device_id )
if device and ( device.category == “dimmable_light” or ( device.category == “switch” and ( device.subcategory == “interior_plugin” or device.subcategory == “exterior_plugin” or device.subcategory == “in_wall” ) ) ) and (device.room == “room_number” ) then
core.set_item_value( item.id, false ) – false turns off, true turns on