This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Scene on Mosaic
#1
Good afternoon,
A simple info.... Is it possible create event script to run scene created in mosaic?
Best regards Cristian
Reply
#2
Try this. Change title variable to the title of your scene widget (case sensitive). If you have multiple scenes with the same title then this script will run all such scenes.
Code:
title = 'my scene'

config = storage.exec('get', 'mosaic30:config:0')
config = require('json').decode(config)

function checkwidget(widget)
  if widget.type ~= 'user_scene' then
    return
  elseif widget.title ~= title then
    return
  end

  for addr, value in pairs(widget.settings.objects) do
    grp.write(addr, value)
  end
end

for _, floor in ipairs(config.floors or {}) do
  for _, room in ipairs(floor.rooms or {}) do
    for _, widget in ipairs(room.widgets or {}) do
      checkwidget(widget)
    end
  end
end
Reply
#3
(30.03.2023, 05:55)admin Wrote: Try this. Change title variable to the title of your scene widget (case sensitive). If you have multiple scenes with the same title then this script will run all such scenes.
Code:
title = 'my scene'

config = storage.exec('get', 'mosaic30:config:0')
config = require('json').decode(config)

function checkwidget(widget)
  if widget.type ~= 'user_scene' then
    return
  elseif widget.title ~= title then
    return
  end

  for addr, value in pairs(widget.settings.objects) do
    grp.write(addr, value)
  end
end

for _, floor in ipairs(config.floors or {}) do
  for _, room in ipairs(floor.rooms or {}) do
    for _, widget in ipairs(room.widgets or {}) do
      checkwidget(widget)
    end
  end
end

Thanks admin, I will try and I let you know.
Best regards Cristian
Reply
#4
(30.03.2023, 05:55)admin Wrote: Try this. Change title variable to the title of your scene widget (case sensitive). If you have multiple scenes with the same title then this script will run all such scenes.
Code:
title = 'my scene'

config = storage.exec('get', 'mosaic30:config:0')
config = require('json').decode(config)

function checkwidget(widget)
  if widget.type ~= 'user_scene' then
    return
  elseif widget.title ~= title then
    return
  end

  for addr, value in pairs(widget.settings.objects) do
    grp.write(addr, value)
  end
end

for _, floor in ipairs(config.floors or {}) do
  for _, room in ipairs(floor.rooms or {}) do
    for _, widget in ipairs(room.widgets or {}) do
      checkwidget(widget)
    end
  end
end

Hi admin,
tested and it works, thank you so much.
Could I suggest an improve?
It could be interesting add some delay between a command and other. It could be useful for scene that interest TV command for example.
BR Cristian
Reply


Forum Jump: