Multi-System Reactor

696 Topics 6.8k Posts
  • Import question

    Locked
    12
    0 Votes
    12 Posts
    307 Views

    You're still going to have your work cut out for you. There's a lot of things MSR does differently. Expressions are high on that list.

  • 0 Votes
    69 Posts
    2k Views

    @toggledbits said in Running Lua Code ? And watching device properties?:

    It's not a limitation. It's the way Lua works, combined with one way Luup is broken.
    The problem is that you are declaring your delay callback/handler function in a module. It is therefore not a global function, it is a module function -- it is scoped within the module, not globally.

    To access functions inside a module, you have to use modulename.functionname(arguments), as you know, and the same is true for the delay handler/callback.

    But the way Vera implemented luup.call_delay(), it takes a function name as a string, rather than a function reference. The function, therefore, has to be global. And it's not global, it's in a module.

    One way to solve this problem (which all plugins experience, too, by the way) is to make a global alias. That means in your startup Lua, you do something like this:

    mymodule = require( "mymodule" ) -- this line loads your module

    -- Create a global alias for my delay handler
    mymodule_delayhandler = mymodule.delayhandler

    Then, in your module, instead of doing luup.call_delay( 'delayhandler', 5 ) you have to do luup.call_delay( 'mymodule_delayhandler', 5 ). This makes the delay use your global alias instead of the function name directly (which it can't).

    Just trying this "Global Alias" for function delays, for the first time, but I can't get it working. I must be doing something wrong.

    In the top of my VeraScenes.lua file I have added this code:

    module("VeraScenes", package.seeall) -- TODO: personalize it mymodule = require( "mymodule" ) -- this line loads your module -- Create a global alias for my delay handler mymodule_delayhandler = mymodule.delayhandler --Away Mode Scene function mymodule_delayhandler() local status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 419) --Status of Safe to Arm virtual switch if status == "0" then --Safe to Arm luup.inet.wget("http://SEND-TTS-MESSAGE1") else --Not Safe to Arm luup.inet.wget("http://SEND-TTS-MESSAGE2") end end luup.call_delay( 'mymodule_delayhandler', 30 )

    The test code checks the status of a virtual switch and sends a different HTTP request / TTS announcement etc.

    I wanted a 30 second delay before anything happens at all.

    When I call this function from a MSR rule by using

    VeraScenes.mymodule_delayhandler()

    I can hear the TTS announcement right away, so my 30 second delay is not happening.

    What am I doing wrong?

    @Tarkus Did you get this working?

    Thanks

  • 0 Votes
    2 Posts
    79 Views

    I'm concerned that although you say you "like keeping [your] inventory of expressions compact," what you will in fact do by being able to create variables on-the-fly from within other variables/expressions is create a long and decidedly not compact inventory of variables created by whatever other expressions are declared, thus complicating your understanding of where they came from, how they got their value, and when they change. That will also further complicate the system's ability to know what changes affect what variables where and need to trigger evaluations of rules, etc. In your example above, I'm sure you would expect, if varInner was in fact a getEntity() call, that any change to the entity would trigger a re-evaluation of varInner, as well as its parent rule and everywhere it or an effected parent is used. It's too much, and the potential for creating unsupportable nightmare scenarios too high.

  • 2 Votes
    12 Posts
    316 Views

    @cw-kid said in Is there a projected date for the release of v 1.0 of MSR?:

    Maybe we should open a bug tracker ticket for a feature request.

    Done.

  • Feature Request: MSR Rule Snapshot Exporter

    Locked
    4
    2 Votes
    4 Posts
    133 Views

    @librasun Good idea

  • Hubitat and virtual devices

    Locked
    5
    0 Votes
    5 Posts
    582 Views

    @toggledbits Yes it is but its just to toggle all off and then on so it goes quite fast.. But in Hubitat dashboard its the same thing. Because if you have all devices enabled for a dashboard it loads slower. Then they have made it so you can enable the ones you want in a dashboard. This really sucks when you make dashboard with a lot of specific devices.

  • calculate with MSR variables in LuaXP

    Locked
    9
    0 Votes
    9 Posts
    319 Views

    @toggledbits
    Yes, it works! Excellent.
    Thank you for your time! Now I can continue my project. The new variable is also useful.

  • Current Alert Tasks

    Locked
    2
    0 Votes
    2 Posts
    110 Views

    Aha... se the log it says 😁

  • Feature request on reactions side.

    Locked
    37
    0 Votes
    37 Posts
    1k Views

    @toggledbits said in Feature request on reactions side.:

    whereas buttonCodes[ . ] and buttonCodes["x"] simply make no sense.

    These are actually OK if buttonCodes is an object, not an array. You can use the square-bracket notation same as dot member access, so buttonCodes[ "x" ] (note the quotes so it's a string) is the same as buttonCodes.x. Using the square bracket notation lets you use a variable for the member name. You don't need a second array, you just need to structure buttonCodes correctly...
    buttonCodes = { '0': 'codes for 0', '1': 'codes for 1', '.': 'codes for dot' }
    key_to_send = "." # or whatever/however you get the key
    send_data = buttonCodes[ key_to_send ]

    I ended up using this method and it works great!

    Thanks for all the help.

  • 0 Votes
    2 Posts
    89 Views
  • MSR doesn't change Mode in Hubitat

    Locked
    1
    0 Votes
    1 Posts
    98 Views
    No one has replied
  • Installing build 0.1-21089

    Locked
    5
    0 Votes
    5 Posts
    164 Views

    @toggledbits ok, I thought I did that, but maybe I don't remember correctly. Not a Linux expert... yet! I am now up and running 🙂

  • TimeStamp variable in MSR

    Locked
    4
    0 Votes
    4 Posts
    149 Views

    Thanks for the quick response! I'm going to try to use it in my logic

  • Status Tab Preview

    Locked
    20
    2 Votes
    20 Posts
    484 Views

    Also, so as to minimize the number of "SET" (but otherwise inactive) Rules, I decided to change all of my

    [ Entity Attribute ] [ X ] [ is FALSE] // remains true indefinitely when OFF

    to

    [ Entity Attribute ] [ X ] [ changes ] [ (any) ] to [ FALSE ] // only true briefly when turned OFF

    Dunno if I'm OCD or just didn't want Status implying that something was "going on" when it's not. 🙂

  • This topic is deleted!

    Locked
    40
    0 Votes
    40 Posts
    123 Views
  • Parsing an expression

    Locked
    8
    0 Votes
    8 Posts
    202 Views

    Thanks guys, this worked just like I needed it to.

  • FEATURE REQUEST: URL Maker in 'Tools'

    Locked
    5
    1 Votes
    5 Posts
    163 Views

    @cw-kid said in FEATURE REQUEST: URL Maker in 'Tools':

    This website has a URL creator for Vera.

    interestingly they have several other HTTP link creators for other controllers at that site.

  • 0 Votes
    32 Posts
    636 Views

    You only care about what's in the "Device_Num_699" section of the file. You can "pretty up" the format in jsonlint.com, and if you look at that section, you'll find Armed is in there, state ID 621 at the very end of the states array.

    }, { "id": 621, "service": "urn:micasaverde-com:serviceId:SecuritySensor1", "variable": "Armed", "value": "0" }],

    The other devices are in the alerts section of the response, which isn't relevant to our work here.

  • 0 Votes
    18 Posts
    390 Views

    On my end I'll tighten up the UI so that option can't be selected when the changes operator is used.

  • Vera Run LUA Missing

    Locked
    10
    1 Votes
    10 Posts
    267 Views

    Appears to be fixed in version 21090. I can now see and select x_vera_sys.runlua on both Vera controllers.

    Thanks

Recent Topics