Navigation

    Discussion Forum to share and further the development of home control and automation, independent of platforms.

    SmartHome Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Unsolved
    (Last Updated: February 26, 2021)
    • PR #178 In-place modification of arrays in "each"

      toggledbits

      I'm moving the discussion on this out of the Mantis PR #178 for the benefit of all/documentation, and also because it's easier to type and format here.

      @LibraSun wrote in that PR:

      I'm 99% certain you'll explain this one away as "expected" but I naively believed it would yield different results:
      In an expression defined by:
      a=[1,2,3],
      each i in a:
      shift(a)
      // result (array) [1,2] (unexpected
      // expected [1,2,3]

      This has me thinking that 'each' is leaving items on the table, as I tried unsuccessfully pointing out above.

      The issue here is that your expression shift(a) is modifying the iteration subject array in place. Basically, here are the iteration steps that are run, starting with a=[1,2,3]

      First iteration: a=[1,2,3]; the local i is assigned the first array element 1, but it is not used in the expression. The expression shift(a) results in 1 and causes a to be reduced to [2,3] (the first element is shifted off and becomes the result). Since this is the last value in the expression, 1 is added to the each result array. Second iteration: a is now [2,3] because the previous iteration modified it. So i is assigned 3, because the iteration is on the second element/iteration through the array, but i is not used in the expression. The shift(a) causes a to be reduced to [3] and its return value is 2, so the value 2 is added to the iteration result array. Third iteration: a is now [3], and we are on the third iteration, but the iteration index of 3 (third iteration) is now off the end of the array (only 1 element long), so iteration stops.

      The result of this each is therefore [1,2] because those are two values that were shifted out, and a is left at [3] because there was no third run of shift() to remove it.

      As I said in the PR, modifying an array you are iterating through can be dangerous and confusing in many languages, because iterators keep state during iteration, and some operations you can do inside the iteration can and will invalidate that state in some way. In Lua on Vera, this often leads to deadlocks and crashes so bad that the box reboots, not just a Luup reload. It's a Bad Idea, and programmers who know are very wary of doing this type of thing in any language unless they are certain of the side-effects/lack of side-effects.

      Your additional example:

      a=[1,2,3], // The array 'a' is [1,2,3]
      a=unshift(a,0), // The array 'a' is [0,1,2,3]
      a=push(a,4), // The array 'a' is [0,1,2,3,4]
      each i in a: // Iterating over the 5 elements of 'a'
      shift(a) // Take the first element of 'a' and append it to result array [ ]
      // result [0,1,2] (unexpected)
      // and array 'a' is now [3,4]! (also unexpected)

      Also correct result. All of the gyrations before the each are not relevant to behavior here. At the start of the each, the array is [0,1,2,3,4] (5 elements). Iterations:

      a=[0,1,2,3,4], i=0, shift(a) returns 0 and modifies a to [1,2,3,4]; the each result array is now [0] a=[1,2,3,4], i=2, shift(a) returns 1 and modifies a to [2,3,4]; the each result array is now [0,1] a=[2,3,4], i=4, shift(a) returns 2 and modifies a to [3,4]; the each result array is now [0,1,2] Iteration stops because the iteration index/step is 4, but there remain only two elements in a=[3,4] (we're off the end of the array).

      So the each result is [0,1,2] and a is left with [3,4] and this is correct operation.

      Key points:

      each keeps state during the iteration (as most iterators do) about the subject of the iteration; if the subject changes in a way that affects the state, unexpected results may occur; The functions push(), pop(), shift() and unshift() modify the array in place. If you say b=shift(a) you get a value in b and a modified (shorter) a.
      Multi-System Reactor
    • Feature request: drag & drop between "triggers" and "constraints"

      PerH

      I've imported all reactors from openLuup, and find myself moving a lot of entity-actions from triggers to constraints.. It would help a lot to have "drag & drop", or a move function for this?

      Multi-System Reactor
    • Low-priority GUI feedback

      PerH

      Just thought i'd mention it, as I've walked into it multiple times when editing rules:
      dbc9e2c8-887e-46bd-8e3c-1364eb99bb03-image.png

      When I make/edit rules, i'm used to pressing "save" through the process, and when I do that, theres only the red one left to press. It does make sense, as its already saved, but I'll stop and think one more time when it says w/o saving.
      In my head, a exit button which causes a pop-up warning if changes are not saved makes more sense - like in vera reactor.

      Feel free to discard the idea, its just something to get used to mabye. 🙂

      Multi-System Reactor
    • Problems with Up grading existing MSR.

      Black Cat

      Followers will be aware of the problems I had setting up MSR, so it won;t come as a surprise that now I have problems Upgrading to the latest version. (How much I wish for a "Click to Upgrade" Button.....)
      I've been stuck on this for 6 days and am ready to throw in all into the to hard basket, surely HA shouldn't be this problematic?
      There, I've said it now I feel better....
      So what's the problem, I can upload the file using WINSCP but no matter what I've tried it won't un-tar and over write the existing files in the Reactor Directory.
      I receive the following error message which may as well be written in Martian 🙂 in my case.
      Command 'tar -xz --directory="reactor" -f "reactor-0.1-21101-0db64f0-generic.tar.gz"'
      failed with return code 2 and error message
      tar: reactor: Cannot mkdir: Permission denied
      tar: reactor: Cannot mkdir: Permission denied
      tar: reactor/INSTALL.md: Cannot open: No such file or directory
      tar: reactor: Cannot mkdir: Permission denied
      tar: reactor/LICENSE.md: Cannot open: No such file or directory
      tar: reactor: Cannot mkdir: Permission denied
      cut for sanity sake....

      This goes on for ad infinitum for every file.

      I tried with both users, no change, can anyone decipher this and explain why WINSCP won't untar the file?

      Multi-System Reactor
    • Adding Homeseer as a Controller

      Black Cat

      How can I do this?
      The topic in the instructions is very limited.

      Other Controllers
      Other controllers that you may find as add-ins will each have their own specific configuration instructions. Please refer to their accompanying documentation.

      What information should I be looking for?

      I've tried port 1880 which is used for node-red, assuming that this is a listening port - no go. Really not sure how to go about this as everything I do is mostly trial & error.

      BTW, I added my Vera Lite into the mix successfully, HS4 would make it a trifecta!

      Multi-System Reactor
    • Vera vs MSR lock code logic

      MikeReadington

      Hi Everyone,

      In the Vera Reactor logic, I used to use the operator "updates" in a lock condition.

      If I entered the door and the code used was "Mike," it would hold the condition true indefinitely because "Mike" was the last stored value. Since it is held indefinitely, setting the condition to pulsed would not allow the condition to fire again because it never went false. If I entered a different code, the condition would go false, then entering "Mike" again would cause the condition to go true.

      I did this using the operator "updates" in an AND condition along with the lock code. The code condition would stay true with "Mike," and when "Mike" is entered consecutively, the "updates" condition will go true each time, and then the whole condition would go true, triggering the action.

      Since "updates" no longer appears to be an operator, how would I do this in the new logic? I think I remember a discussion about this, but I searched and can't seem to find it.

      I'm not a programmer, so I am probably missing the easy way to do this.

      Screen Shot 2021-04-18 at 4.54.27 PM.png

      Multi-System Reactor
    • Why can't I run this LUA code ?

      cw-kid

      I have created a Global Reaction with this LUA code for my Vera to run.

      However when I run the Reaction nothing happens. I can't see anything in the log file either about this rules ID number.

      If I run the same LUA code on Vera in the test window it works OK.

      OR any other suggestions how I can set this up in a global Reaction (Scene) in MSR ?

      Instead I could use the VeraScenes.lua file in the Vera startup library, but I am wondering why I can't just paste the LUA code directly in to the MSR rule.

      Thanks

      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://SOME-HTTP-REQUEST") luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","SetHouseMode", {Mode = 2}, 0) --Set House Mode to Away luup.inet.wget('SOME-HTTP-REQUEST' ,5); else --Not Safe to Arm luup.inet.wget("SOME-HTTP-REQUEST") luup.inet.wget('SOME-HTTP-REQUEST' ,5); end
      Multi-System Reactor
    • Replacing SiteSensor Plugin (Vera) with MSR

      LibraSun

      For MSR users with SiteSensor still installed back on Vera, you might want to consider letting MSR take over those duties. Here's a quick run-down of how I imported one of my SiteSensor recipes into a Rule on MSR, using OpenWeather API* as an example.

      STEP 1: Copy the Basics from Vera
      (a) Go to your Vera > Devices, locate SiteSensor (the main instance, not one of its children devices) and click ► for details then click SETTINGS.
      (b) Copy and paste (into Notepad or other text editor) the Request URL along with each of the defined expressions.

      STEP 2: Create a Rule on MSR
      (c) Jump into Rule Sets and click "Create Rule". Click its title to rename the rule 'OpenWeather (API)" and click 'Rename'.
      (d) Decide on appropriate Triggers (in my case, it's an OR group that includes an [INTERVAL] set to "Every 3 hours" plus a few [ENTITY ATTRIBUTE] entries reacting to things like entering/leaving home, waking up, etc.).
      (e) In Set Reacion, create an [HTTP REQUEST] > [GET] action.
      (f) Paste your old "Request URL" into the "Request URL" box.

      FYI GET calls to OpenWeather API* take the form:

      http://api.openweathermap.org/data/2.5/weather?zip=<your_ZIP_code>&id=<your_Wx_ID>&appid=<app-id>&units=imperial

      (g) Create four new blank Expressions (name them openWx, Tx, Hx and Rx).
      (h) Click SAVE & EXIT

      STEP 3: Process the Response
      (i) Re-open rule "OpenWeather (API)" by clicking the 'Edit' icon.
      (j) Within the [HTTP REQUEST] action, assign "Capture response to:" ► openWx
      (k) Down in Expressions, click "[+]Add Expresssion" then enter the following:
      Tx := round(openWx.main.temp,1)
      // yields current outdoor temperature
      Hx := round(openWx.main.humidity)
      // yields current humidity conditions
      Rx := openWx.rain ? ( openWx.rain['3h'] ? openWx.rain['3h'] : 0) : 0
      // yields predicted rainfall, if present; otherwise 0
      (l) Click SAVE & EXIT. Enjoy!

      Naturally, your specific needs and workflow will differ from the one I've outlined here. For instance, you may wish to explore the contents of the JSON object in openWx for additional data of interest to you, and define variables to match.

      My goal here has been to illustrate some key concepts needed for moving from SiteSensor over to MSR:

      Some syntax is the same, such as dot notation for object.item.access; Other syntax has changed, such as the use of ternary A ? B : C in place of IF (A, B, C); Manually setting an [INTERVAL] in lieu of SiteSensor's timed schedule;

      Pro tip: If your workflow demands that other Rules react to the output of the "OpenWeather (API)" rule, then be sure to create all of the aforementioned Expressions under "Global Expressions" instead, so they become accessible across all Rule Sets.

      Once the transition is complete, you can either DISARM SiteSensor on Vera or remove it entirely with "Remove Device" (which will automatically remove all of its child devices).

      *Additional reading:
      OpenWeather API : https://openweathermap.org/api
      FREE SUBSCRIPTION REQUIRED TO USE THIS SERVICE

      PRO TIP: See below for optimal way to incorporate OpenWeatherMap into your MSR workflow(s), by enabling the service directly in the reactor.yaml config file.

      Multi-System Reactor
    • Rethinking HVAC moving from Reactor (Vera) to MSR

      G

      In my Vera config I have two SiteSensors (one for Ambient Wx, one for OpenWxMap) that point to two unique Reactor devices for controlling HVAC in my home. This is done for redundancy - if the Ambient API drops it returns zero data which then triggers a standalone Master API Reactor device to flip on the OWM SiteSensor and corresponding HVAC Reactor device to continue controlling the house conditions.

      Once the Ambient API returns to available the Master API Reactor device flips back to the Ambient SiteSensor and corresponding HVAC Reactor device, turning OFF the SiteSensor for OWM to save on API calls.

      I've been able to duplicate one half of this, including the Master API role, in MSR. But... here's the tricky part... I can't turn "off" the MSR Rule Sets for the OWM version. As such, HVAC is sent conflicting data and doesn't know what to do.

      Before I go alls deep into explaining how all of this currently works, am I missing something somewhere that would allow me to trigger the on/off of MSR Rule Sets?

      Multi-System Reactor
    • Expressions and LuaXP Functions

      LibraSun

      Knowing that MSR Preview may not yet fully implement LuaXP (CORRECTION: MSR uses a different language lexpjs), I could not resist whipping up some text expressions for fun. Whereupon two things popped out at me:

      The new scaling (0.00 - 1.00) of Dimming Level will require a rewrite of certain Expressions that I use to balance my light levels. For example, it was my custom to monitor one lamp's brightness (0 - 100) with Reactor Luup, then set another lamp to 93% of that level, using this Expression: floor(getstate( 9, "urn:upnp-org:serviceId:Dimming1", "LoadLevelTarget" ) * 0.93)

      Now, in MSR, it will become necessary to modify that to read:

      floor ((getEntity( "vera>device_9" ).attributes.dimming.level * 0.93)*100)/100

      which effectively scales the value up x 100 (so that floor() can act upon it correctly), then downscale it / 100. Just an FYI to ponder.

      I'm noticing that every edit, however minor, of an Expression in MSR requires an immediate SAVE click before the 'Run' button will become active. That is to say, I cannot repeatedly evaluate the Expression during editing, without clicking SAVE first.

      Only mentioning this latter behavior since it departs so dramatically from Reactor Luup's paradigm.

      Multi-System Reactor
    • MSR API functions and documentation

      cw-kid

      Hi

      I am assuming in time MSR will have some API documentation.

      I am going to ask Bill the developer of the Home Remote dashboard app if he can add support for MSR.

      Specifically support for MSR global Reactions (Scenes), where hopefully they can be imported in to the Home Remote Designer application and then we can more easily create dashboard tiles that when pressed would run a particular MSR global Reaction etc.

      Currently in Home Remote it's possible but not so easy to create a tile that runs a http request when pressed and I have tested this and it does work and will run an MSR global Reaction.

      But I'd much prefer if in the Home Remote Designer application MSR could be added as a device type and then all its global Reactions
      imported as it does with Vera and other systems.

      Multi-System Reactor
    • Global Reactions - Constraints ?

      cw-kid

      Hi

      Will Global Reaction rules have Constraints added at some point?

      And maybe the other functions like Reset Reaction and Expressions.

      Thanks

      Multi-System Reactor
    • Creating Rules with Conditional Logic

      K

      How are folks handling situations where they want to have Conditional Actions or Branching Logic in their Set Reactions for a rule? Are you creating Duplicating the same trigger and setting different conditions and Actions?

      Is there an approach where you combine a main rule with your entity triggers with sub rules that trigger off Expressions? You then could write your conditions as Set Variable actions in the Main Rule for the Expressions that evaluate to true or false. Each sub rule would trigger based on the expression changing to true and then could also change it back to false after.

      Not sure if that's worth the complexity for the reusability and control over duplicate triggers.

      Multi-System Reactor
    • Multi-System Reactor Developer Preview AVAILABLE

      toggledbits

      OK, people, here we go! At long last, Multi-System Reactor developer preview is available!

      The package can be downloaded from the Reactor bug tracker, a MantisBT system (at https://reactor.toggledbits.com/mantisbt/). There is a download button in the left margin, as well as links to the documentation, which you will need for installation.

      UPDATE 2021-02-24 -- To keep spammers off, I've locked down registration on the Bug Tracker. To get access to the Bug Tracker and preview downloads, please PM me (not reply here) your full name and email address and I will set up an account for you.

      This version of MSR will run on Linux systems, including RPi's under Raspios Buster, running node.js version 12.10 or higher (v14.15.1). For RPi users, there is an installation script that will install a local copy of node.js (for the logged-in user).

      Bugs reports will be handled through the bug tracker only. Discussion and questions in this forum are fine, though (if that leads to a bug report, we'll transition).

      This version supports Vera (and openLuup to the degree it's compatible with Vera Luup), Hubitat, and Home Assistant. Some of the device support on the H platforms is still a bit basic, but it is largely controlled by configuration and progress can be made quickly.

      The documentation beyond installation is a mess. Of course, I started with the existing documentation and have been massaging into MSR's particulars, but it still has a long way to go on the detail.

      I know I don't have to say this, but I will anyway... let me know how it goes!

      Multi-System Reactor
    • Feature Request - Reaction to MQTT

      S

      I looked through the forum, but could not find it, so my apologies if this has been asked. It would be nice to be able to push a message to MQTT for further upstream integrations.

      Multi-System Reactor
    • Import question

      T

      Is the import feature supported by stock Vera or only open loop or is it both?

      Multi-System Reactor
    • Running Lua Code ? And watching device properties?

      cw-kid

      Hi

      In some of my PLEG actions I run Lua code.

      I guess I can't do that now with MSR. Assume I have to create a Vera scene with that same LUA code and have the MSR action call that scene etc.

      What about the people who were using Reactor plugin for Vera? I assume they can run Lua code.

      But won't be able to when using MSR on a separate box to Vera.

      I am also seeing other things I am doing in PLEG but don't think I will be able to on MSR? Like monitoring devices for certain things.

      For example I use PLEG with Fibaro Dimmer 2 modules to enable me to use the Scene Activation for double and triple clicks on the actual wall switches, PLEG sees this happening and then my action can run a Vera scene or whatever else I want.

      I have three "Device Properties" setup in PLEG to monitor those aspects of the Fibaro Dimmer 2 device.

      078cad4f-ebee-4951-a631-304da033d60f-image.png

      Then this condition in PLEG:

      (LoungeSceneActivated;LoungeLastSceneTime) and (LoungeLastSceneID == 14)

      Runs an action when I double click the Lounge Light wall switch.

      Thanks

      Multi-System Reactor
    • Feature Request: Declare new variables inside existing expressions

      LibraSun

      @toggledbits food for thought (and I hope I haven't already proposed this)... Could references to global expressions be expanded such that declared variables inside them could be accessed?

      Example:
      varEx := varInner = [1,2,3], varInner[2]
      // returns 3

      Currently:
      varB := varEx.varInner
      // returns (null)

      Proposed:
      // returns (array) [1,2,3]

      Thoughts? I'm increasingly using these hybrid definitions that are neither "pure" array nor object. I also like keeping my inventory of expressions compact.

      Multi-System Reactor
    • Is there a projected date for the release of v 1.0 of MSR?

      Black Cat

      @toggledbits

      Is there a release date for MSR v1.0?

      Multi-System Reactor
    • Rule for devices battery level ?

      cw-kid

      Hi

      Wanted to create a rule for monitoring the battery level of Z-Wave devices on my Vera hub.

      I can select the battery level as the trigger OK.

      But not sure how to handle the Reaction to send an alert / notification ?

      If in the triggers I have multiple devices monitored for their battery level

      39a2f0af-c2e4-450b-a1ce-f542df31d02d-image.png

      How could I create say a TTS announcement or text alert that mentions the name of the device who's battery level has dropped below 10% ? The device that has triggered the rule.

      I'd rather not have to create an individual rule for each device etc.

      Any ideas?

      Thanks

      Multi-System Reactor
    For those who registered but didn't received the confirmation email, please send an email to support@smarthome.community with the email you used

    Dashboard graphical issue

    Multi-System Reactor
    2
    2
    34
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • rafale77
      rafale77 last edited by

      Screen Shot 2021-02-25 at 19.56.59.png

      Some font issues to be addressed I think on the dashboard.

      1 Reply Last reply Reply Quote 0
      • toggledbits
        toggledbits last edited by

        It's the flex placement and styles. Although the dash isn't a huge priority at the moment, I'll see if I can knock this out today.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Welcome. If you’d like to participate in the discussion, rather than just read, then you can join the forum. As a member, you can interact with others here to share your experience and ask the questions you need answered.

        Powered by NodeBB | Contributors
        Hosted freely by PointPub Media Communications Inc. | Contact us