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: September 19, 2021)
    • Reactor (Multi-System/Multi-Hub) Announcements

      toggledbits

      Build 21228 has been released. Docker images available from DockerHub as usual, and bare-metal packages here.

      Home Assistant up to version 2021.8.6 supported; the online version of the manual will now state the current supported versions; Fix an error in OWMWeatherController that could cause it to stop updating; Unify the approach to entity filtering on all hub interface classes (controllers); this works for device entities only; it may be extended to other entities later; Improve error detail in messages for EzloController during auth phase; Add isRuleSet() and isRuleEnabled() functions to expressions extensions; Implement set action for lock and passage capabilities (makes them more easily scriptable in some cases); Fix a place in the UI where 24-hour time was not being displayed.
      Multi-System Reactor
    • MSR No longer Setting Reactions

      T

      Hello Everyone -

      I have a peculiar situation that I'm hoping to get some help with.

      Running Vera which is still handling my Zwave, MySensors, Zigbee, and still a balance of my Reactors.

      However, I've also been running MSR for several months in preparation for an eventual move off of Vera.

      Vera had one of its meltdowns this morning related to my Opensprinkler plug in.

      After getting that straightened out, I added the OpenSprinkler plugin to HAAS and that's when I started having issues.

      My existing MSR reactors (even simple ones) don't seem to fire their reactions. I can see the conditions go "true". If I manually fire the Reaction, it works fine.

      I do see this a lot in the logs:

      [1.0.2-21350]2022-05-16T19:02:44.518Z <Rule:INFO> Rule#rule-460 evaluation in progress; waiting for completion

      (Various rules - 460 is just an example)

      Is there anything I can do to further troubleshoot?

      Multi-System Reactor
    • MSR Telegram Messages Stopped Working

      T

      My MSR has been working flawlessly until a couple of days ago when it stopped sending Telegram Messages (or should I say they stopped getting through!). I have updated to MSR version 22004. The reactor.log is updating and is showing no errors:

      [latest-22004]2022-05-15T17:52:31.417Z Engine:NOTICE Starting reaction Message Test (re-l37h2fkj)
      [latest-22004]2022-05-15T17:52:31.417Z Engine:INFO Message Test all actions completed.
      [latest-22004]2022-05-15T17:52:31.704Z Engine:INFO Enqueueing "Message Test" (re-l37h2fkj)
      [latest-22004]2022-05-15T17:52:31.735Z Engine:NOTICE Starting reaction Message Test (re-l37h2fkj)
      [latest-22004]2022-05-15T17:52:31.736Z Engine:INFO Message Test all actions completed.
      [latest-22004]2022-05-15T17:52:32.007Z Engine:INFO Enqueueing "Message Test" (re-l37h2fkj)
      [latest-22004]2022-05-15T17:52:32.035Z Engine:NOTICE Starting reaction Message Test (re-l37h2fkj)
      [latest-22004]2022-05-15T17:52:32.036Z Engine:INFO Message Test all actions completed.
      [latest-22004]2022-05-15T17:52:41.324Z Engine:INFO Enqueueing "Variable Telegram Test" (re-kvnm57c3)

      If I use the following in my web browser the telegram message gets through:

      https://api.telegram.org/botxxxxx......./sendMessage?chat_id=xxxxx......&text=Test Message HTTPS

      I am running MSR on my QNAP network attached storage. Any assistance would be appreciated.

      Just another question...... I would like to post in the HOME HARDWARE VERA section of Smarthome, but I do not have the option to set up a new post. Do I need to request access for this?

      Multi-System Reactor
    • SSL Certificate for Multi System Reactor via LetsEncrypt

      W

      Details of runtime environment:

      Reactor (Multi-hub) stable-22055-9b40e12 Running as a service on Windows Server 2022 Std 21H2 Connecting to HASS (HASSOS) Is a migration WIP from OpenLuup/Reactor

      A complete description of your objective:

      Using LetsEncrypt, application "certifyTheWeb", retrieve and apply SSL certificate to Multi System Reactor

      A description of your approach/solution/implementation so far:

      Reviewed Config files, can't seen mention of certificate files in there

      Actual Question:

      How do I apply a certificate to whatever web server Reactor uses? I'm familiar with managing certificates on IIS and Apache but Reactor doesn't use either of these and I have not been able to locat ethe config file that Reactor uses for this. Which config file needs editing to apply a certificate? Does it use the computer certificate store or it's own store (e.g. pem files)

      The reason I want to achieve this, other than the general goodness of having everything I can in TLS is that I have Reactor as an IFRAME in my HASS console and as HASS is HTTPS and Reactor is HTTP then the iframe refuses to open.

      Search for "certificate" or "ssl" did not reveal anything relevant in this forum.

      Multi-System Reactor
    • MSR ZEN32 weird behavior

      R

      @toggledbits
      Hi Patrick,
      Running HASS 2022.5.3
      MSR zwavejs-22126-834c3e9

      Seeing weird behavior in MSR with regards to my Zen32's. Not sure how to capture info that might be relevent but will describe what I am seeing.
      In the example below I pressed scene 001 4 times. It flashed and changed the primary value to "4". The remaining buttons were previously showing the PV as "double" I pushed each button one time and they flashed and displayed the PV as 4.
      zen32.JPG

      In the zwavejs2mqtt debug screen that sequence looks like this.

      2022-05-10 09:38:44.078 INFO ZWAVE: Node 45: value notification: 91-0-scene-001 5 2022-05-10T16:38:44.081Z CNTRLR « [Node 045] received CentralScene notification { "nodeId": 45, "ccId": "Central Scene", "ccCommand": "0x03", "payload": "0x898501" } 2022-05-10 09:38:45.982 INFO ZWAVE: Node 45: value notification: 91-0-scene-002 0 2022-05-10T16:38:45.984Z CNTRLR « [Node 045] received CentralScene notification { "nodeId": 45, "ccId": "Central Scene", "ccCommand": "0x03", "payload": "0x8a8002" } 2022-05-10 09:38:47.807 INFO ZWAVE: Node 45: value notification: 91-0-scene-003 0 2022-05-10T16:38:47.810Z CNTRLR « [Node 045] received CentralScene notification { "nodeId": 45, "ccId": "Central Scene", "ccCommand": "0x03", "payload": "0x8b8003" } 2022-05-10 09:38:48.858 INFO ZWAVE: Node 45: value notification: 91-0-scene-004 0 2022-05-10T16:38:48.861Z CNTRLR « [Node 045] received CentralScene notification { "nodeId": 45, "ccId": "Central Scene", "ccCommand": "0x03", "payload": "0x8c8004" }

      Let me know what other info you would like me to supply.
      I have played around with a bunch of other key stroke combo's and it looks like buttons 2-5 display what ever button 1 is set to.
      Have tested this on 4 different ZEN32's and it is same on all.

      Multi-System Reactor
    • HASS 2022.5 issue with ZwaveJS in MSR

      R

      Running zwavejs-22118-baab576 in MSR, HASSOS 2022.5.1

      Due to an unreported issue in HASS, when I upgraded the 2022.5 yesterday, it dropped ZwaveJS2MQTT from my HASSOS build. Finally got it reinstalled and it appears to be working the way it was previously.
      MSR is now showing zwavejs down and in entities, nothing is updating.

      Seeing this in the logs:
      ZWaveJSController#zwavejs ws_open caught [Error]Error: connect ECONNREFUSED 192.168.0.16:3000

      Are there additional steps needed that are not mentioned in the manual?
      At a loss to figure out what is causing issue.

      Multi-System Reactor
    • Global Expression – Reference Error

      wmarcolin

      Hi!

      After several tests, restarting the computer where the MSR is, and the MSR itself by Tools > Restart, I have a persistent error in the logs.

      32d45bc3-51f8-4718-a113-3381e9d7edf2-image.png

      Looking at the global expression (screen below), I see that it is highlighted as an error, however, if I look at two other expressions above that have the same structure, they do not present an error, so I do not think the problem is with the expression's code.

      ca8a7867-4ac7-4f9a-9913-15a80da18f05-image.png

      This expression uses a group, which validates 4 devices of type door sensor, whether the status is true or false, door open or closed.

      "dgc_entrance_open": name: DGC Entrance Open select: - include_entity: - "hubitat>37" - "hubitat>38" - "hubitat>99" - "hubitat>130" filter_expression: > entity.attributes?.door_sensor?.state == true

      I also compared it with other groups, the structure is identical.

      Looking at the 4 devices in this group, I see that all are active in the MSR, have similar variables, are used in other groups and rules that do not present a problem.

      52b099f4-b9c4-46cb-ad3d-c873b09b7e13-image.png

      Looking at the log, I understand that it refers to some object that would be null, at which point I am lost on what to actually look at.

      [latest-22118]2022-05-02T22:33:11.711Z <Engine:INFO> Reaction Engine starting [latest-22118]2022-05-02T22:33:11.719Z <Engine:INFO> Checking rule sets... [latest-22118]2022-05-02T22:33:11.746Z <Engine:INFO> Checking rules... [latest-22118]2022-05-02T22:33:11.748Z <Engine:INFO> Data check complete; no corrections. [latest-22118]2022-05-02T22:33:11.892Z <Engine:ERR> [Engine]Engine#1: error evaluating expression EntranceOPEN: [ReferenceError]ReferenceError: Invalid scope in reference to member attributes of (object)null [latest-22118]2022-05-02T22:33:11.893Z <Engine:ERR> [Engine]Engine#1: expression: sort(each id in ( getEntity('groups>dgc_entrance_open').attributes.sys_group.members ): getEntity(id).name) [latest-22118]2022-05-02T22:33:11.894Z <Engine:CRIT> ReferenceError: Invalid scope in reference to member attributes of (object)null ReferenceError: Invalid scope in reference to member attributes of (object)null at _run (C:\MSR\reactor\common\lexp.js:1449:31) at _run (C:\MSR\reactor\common\lexp.js:1443:33) at _run (C:\MSR\reactor\common\lexp.js:1443:33) at _run (C:\MSR\reactor\common\lexp.js:1536:38) at _run (C:\MSR\reactor\common\lexp.js:1480:33) at C:\MSR\reactor\common\lexp.js:1283:29 at Array.forEach (<anonymous>) at _run (C:\MSR\reactor\common\lexp.js:1282:28) at run (C:\MSR\reactor\common\lexp.js:1663:22) at Object.evaluate (C:\MSR\reactor\common\lexp.js:1699:20) [latest-22118]2022-05-02T22:33:12.232Z <Engine:NOTICE> Reaction Engine running! [latest-22118]2022-05-02T22:33:12.233Z <Rule:INFO> Rule#rule-kxjp2el2 (Mode DAY) started [latest-22118]2022-05-02T22:33:12.234Z <Rule:INFO> Rule#rule-kxjp7kc8 (Mode EVENING) started [latest-22118]2022-05-02T22:33:12.234Z <Rule:INFO> Rule#rule-kxjparz7 (Mode NIGHT) started [latest-22118]2022-05-02T22:33:12.234Z <Rule:INFO> Rule#rule-kxjpd0d6 (Mode AWAY ∆) started [latest-22118]2022-05-02T22:33:12.235Z <Rule:INFO> Rule#rule-kxjqrcr9 (Mode PARTY) started [latest-22118]2022-05-02T22:33:12.235Z <Rule:INFO> Rule#rule-kxjqyhnu (Mode VACATION ∆) started

      Finally, if I return the expression and press the Try This Expression button, it is executed and the error disappears.

      102e5013-b9aa-4c26-98f5-1ae545f8897f-image.png

      This situation started to occur on the latest version of Reactor 22118, on a Windows 10 Bare Metal installation. Does anyone have a similar scenario?

      Sorry for the long post, I tried to document as best as possible to try to identify the problem.

      Thanks.

      Multi-System Reactor
    • Cheapest platform on which to run MSR

      T

      Please can anyone give me advice on a cheap way to run MSR (both initial cost and ongoing electricity cost). I currently run it on my QNAP network drive (which works very well incidentally). However, this draws a constant 35Watts (£90/yr @ 30p/kWh) and given the recent rise in fuel costs I am evaluating the best way forwards. Note, I only really need to turn my QNAP on for an hour a week to back-up my computer data. I understand that MSR can run on a Raspberry PI, but I am not competent with Linux! Thanks.

      Multi-System Reactor
    • Build 22118 - entity updates

      G

      I just noticed that the new hotness picked up the entities from when I added an integration temporarily to my Home Assistant and popped a lovely info notice into the Alerts pane.

      I know the info is new - but when did MSR suddenly become more real-time with devices being added to hubs? This is great!

      Multi-System Reactor
    • [Solved] Is there a cap or max number of devices a Global Reaction should not exceed?

      G

      Noticed in the last few nights that my Global Reaction to turn on a mere six lights in the evenings the same two devices no longer turn on. One is a dimming smart bulb, the other is a wall outlet.

      This has been running flawlessly for months - just in the last few nights I've noticed these two devices being left behind and yes, it's always these two devices only.

      "What changed?"

      No Hubitat firmware updates No new devices added to Hubitat list itemTwo MSR updates (the last two, I keep up with the latest) list itemHome Assistant releases (should have zero bearing, HA is nothing more than pretty dashboards) list itemAdded MQTT to MSR

      I did do a z-wave "repair" last night and am waiting to see if this helps.

      Is there any maximum or cap on number of devices that should be included in a Global Reaction?

      *Marked as solved as the question asked was answered. The issue persists but the question was answered.

      Multi-System Reactor
    • [Solved] Which version of npm should we be running for reactor-latest-22118-0f0772c.tar.gz

      G

      I've borked my install of reactor-latest-22118-0f0772c.tar.gz for some reason and am retracing steps. Running npm i --no-save --omit dev prompted to update npm and I did (current version now 8.6.0). Currently, attempts to load via browser/s (Brave and Safari) result in "This site can’t be reached192.168.1.xxx refused to connect." I am still able to SSH into the RPi.

      I haven't panicked yet but did just pull my config and storage directories - I believe I read where that's enough for a back-up if a clean install ends up being needed.

      So the question of the day: which version of nmp should we be running on for the latest Reactor?

      Multi-System Reactor
    • Is a global timestamp expression possible ?

      B

      I’ve looked and can’t find the answer which concerns me that the answer is obvious and thats why I can't find the answer to this.

      I’m new to MSR and this is my first post, so please bare with me 🙂

      What I’m trying to do is have a global expression that contains the current time so I can use it in Global reactions as well as Rulesets as part of my syslog messages.

      Example of what I’m experiencing:
      In Expressions, create a global expression: gMyTOD = strftime("%T %D”)
      In Rulesets, in a rule, create a local expression: MyTOD = strftime("%T %D”)

      In that same rule create a Notify type of Syslog.
      Set syslog message to: gMyTOD time is ${{gMyTOD}} and MyTOD time is ${{MyTOD}}
      Trigger the rule.

      The result is that the local expression (MyTOD) contains the correct time but the global expression (gMyTOD) does not update and reflects the wrong time in the final syslog message.

      Is there a different approach I should be using?

      Thank you in advance for any insight.

      -bh

      Multi-System Reactor
    • Restart router when it's gone offline?

      F

      Hi!
      Once a month or so, my internet access is lost, and I have to cut the power to the router, to restart it. When I'm away this become a problem, so I thought that if I got a zigbee switch (in Home Assistant), problem is solved. But how do I (MSR) know if it's offline?

      What's the easiest and most effective way to make this work? Do I ping a few websites every ten minutes or so, or is there a better approch? If I'm going to ping, what URL is recommended?

      For information, I have a set up with Asus routers, Home Assistent with zigbee-, z-wave and wifi devices (a total of appr. 150) and every of my 60-70 automation is done by MSR.
      I run MSR ver. 22080-ae7212f (docker on my Home Assistant blue). HA ver 2022.4.6.
      Thanks in advance.
      Take care, you all!
      /Fanan

      Multi-System Reactor
    • MSR for Scene Controllers

      therealdb

      I still have some code running on my Vera that I want to port and it's related to scene controllers.

      I'm mostly using Fibaro's switch/roller shutter and on the Vera side I'm getting sl_CentralScene/sl_CentralSceneAttr, but it seems too fast to be intercepted by MSR.

      What's anyone using? Thanks.

      Multi-System Reactor
    • Best strategy to get the difference between pulses in MSR

      therealdb

      So, I have a rule set that it's triggered when a local variable changes. Since it's tied to my solar production, it could change very frequently, so I've just added a reset delay to calm it down, but it's not working as intended.

      What I really need is a way to, let's say, define a percentage and define a variable to understand if the new value has changed +/- 10% before going true.

      I've tried a couple of ways, but I'm posting here anyway, in case anyone has found a better way to tackle this. Thanks!

      Multi-System Reactor
    • Status of MSR in Home Assistant

      Matohl

      Perhaps a dumb question. Can I check from Home Assistant that MSR is up and running? I would like to see that in a status page in HA. I can of course ping the other Pi but it doesn't say anything about the MSR status.

      Skärmavbild 2022-04-23 kl. 18.23.03.png

      Multi-System Reactor
    • Notifications from Alerts

      Crille

      @toggledbits Is there a way to get Current Alerts as an entity so I could monitor those and send notifications if needed.
      My usecase is sometimes openLuup crashes and MSR picks that up pretty quick, sending a pushover notification to me would get my attention to restart it.
      Of course there are many ways to monitor connectivity but since MSR already is doing that it would be neat to take advantage of it.

      Multi-System Reactor
    • Invocable rules via MQTT

      therealdb

      Hey @toggledbits.
      From the docs:

      You cannot control the state of rules via MQTT. Rule state is driven exclusively by the result of its conditions.

      And I'm OK when rules are triggered by something else, but I've built a couple of rules to be used by other rules, to streamline the logic, and it'll be useful to invoke a rule via MQTT. It's probably close to what rule/:id/restart is doing in the HTTP api.

      Thanks!

      Multi-System Reactor
    • Home Assistant Script, Reaction requires seclection that isnt there

      S

      I'm trying to create some automation so I can control my pool variable speed pump from reactor rather than iAqualink (which sucks). My controller is MQTT enabled so I created several scripts for my desired speeds. (I know reactor has MQTT ability but honestly I read the docs and could not make much sense of it and since I already have it set up in Home Assistant, I figured I would just leverage that instead)

      So I created all of my scripts and tested them, they worked perfectly. The I created a rule in reactor and set running the script as the action. The problem is that reactor is telling me that I have to make a selection. I try to click the dropdown and there is nothing to select. I cant save the rule, the only option is to exit.

      9e0a3147-5058-4893-9860-2f0d759dfe3c-image.png

      Here is my script in Home Assistant. Any advice on how to get this to work? If I am looking at this the wrong way I am open to suggestions (I would rather be able to call a specific action and specify a speed value but I cannot figure out how to do that). Thanks in advance.

      bfc7ba89-70a5-47d3-a111-0c2927ac3c73-image.png

      Multi-System Reactor
    • Installed latest MSR container and host time is wrong

      M

      Hi, I've been using msr for a while now and haven't had timezone issues until today when I updated to latest docker image (latest-22080-ae7212f)

      both docker date command and my local date command show the same time, same timezone, but for some reason MSR shows the host time as 2 hours in the past as a result all my timed rules run 2 hours late.

      my locale is set correctly in the host machine and is bound into the container as well.

      One possible hint I get is maybe this from the container startup log, but other than timezone stuff everything else seems to be working fine and all my settings loaded up just fine.

      [latest-22080]2022-04-07T07:52:52.423Z <SystemController:null> Module SystemController v22080 root {} CommonJS loading [latest-22080]2022-04-07T07:52:57.236Z <Engine:CRIT> SyntaxError: Unexpected end of JSON input SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at IndividualFileStrategy.getDataObject (/opt/reactor/server/lib/IndividualFileStrategy.js:121:46) at Container.getDataObject (/opt/reactor/server/lib/Container.js:102:53) at new GlobalExpression (/opt/reactor/server/lib/GlobalExpression.js:105:179) at Function.getInstance (/opt/reactor/server/lib/GlobalExpression.js:123:89) at /opt/reactor/server/lib/Engine.js:1349:67 at Array.forEach (<anonymous>) at Engine.initializeGlobalExpressions (/opt/reactor/server/lib/Engine.js:1345:145) at Engine.start (/opt/reactor/server/lib/Engine.js:590:285) at /opt/reactor/app.js:362:103

      Let me know if I can provide further info to help debug this.

      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

    Device information in string or array

    Multi-System Reactor
    4
    18
    248
    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.
    • wmarcolin
      wmarcolin last edited by

      Hi,

      I need help to create a search within MSR that shows me the name of all sensors in a certain status.

      User case: Based on the information from category_num and subcategory_num, return in a string or array the name of all devices that meet the Tripped = 1 status.

      Example: generate a warning message of all the windows that are open before triggering the alarm.

      Which function should I use in MSR? What would this search look like?

      Thanks.

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

        Currently there is no function or "global" value that will give you all entities. I've talked with other users about this, so it's a planned feature, it just hasn't materialized yet, and since it's core, it's probably a 1.1 thing and not for 1.0.

        But, you can take a list of known entities that you specify and rip through them to see which matches a particular test (or tests). This has been covered here: https://smarthome.community/post/7041

        Author of Multi-system Reactor and Reactor, DelayLight, Switchboard, and about a dozen other plugins that run on Vera and openLuup.

        wmarcolin 1 Reply Last reply Reply Quote 0
        • rafale77
          rafale77 @wmarcolin last edited by rafale77

          @wmarcolin

          Replying to a PM so it may sound off topic.
          This is an example of how I would do it in lua:

          for k, v in pairs(luup.devices) do
             if v.device_num_parent == 1 then
               if v.category_num == 4 then
                 atr = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "ArmedTripped", k)
                 tr = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", k)
                 if atr == "1" then natr = natr + 1 end
                 if tr == "1" then ntr = ntr + 1 end
               end
               fail = luup.variable_get("urn:micasaverde-com:serviceId:HaDevice1", "CommFailure", k)
               if fail == "1" then 
                 nfail=nfail + 1 
               end
             end
           end
           return ntr,natr,nfail
          end
          

          You can see in this example that I am counting specifically devices from a bridge which is device id 1 (I think it was a vera) and am counting devices which are tripped, armed tripped and failed. It's a code that I used to run regularly to check my device status.
          You can then extract the name of the device and append it to a device list.

          local list = {}
          for k, v in pairs(luup.devices) do
               if v.category_num == 4 then
                 tr = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", k)
                 if tr == "1" then table.insert(list,v.name) end
               end
          end
          return list
          
          1 Reply Last reply Reply Quote 0
          • wmarcolin
            wmarcolin last edited by

            @rafale77 thanks, it worked inside Vera, but as I am leaving the platform, and as many of you have already said, my VeraPlus Hub will be just a radio very soon, I have to find a way to do it in MSR. And I don't think I'm far, I'll post a message in the sequence that may be that @toggledbits give me the missing information.

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

              @toggledbits first step ok, I took the example you told me to look at and that is exactly what I want to follow. I managed to reproduce the example for the battery, but now I lack the variable to test the Tripped.

              254ea07c-71a9-401c-a0ed-52fee3ade2ad-image.png

              I believe that attributes.Tripped == "1" is not the correct one to validate.

              If you can tell me what query I have to do, I would be grateful.

              wmarcolin 1 Reply Last reply Reply Quote 0
              • wmarcolin
                wmarcolin @wmarcolin last edited by

                After much trying and error, I found which attribute to use, and the problem was solved. Thanks @rafale77 and @toggledbits for the tips. Now it opens a universe of new toys to put in my automation, increasing the information.

                1e32985e-dd7a-438c-bfcb-071fc2213759-image.png

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

                  Nice job!

                  Author of Multi-system Reactor and Reactor, DelayLight, Switchboard, and about a dozen other plugins that run on Vera and openLuup.

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

                    One extra query, is it possible to put in an array a search that lists all the device names that meet a characteristic, for example category_num 4 and subcategory_num 1? An array that returns ["vera>device_1", "vera>device_2", "vera>device_3"].

                    In other words, I would like to fill in my above example, the variable OpenDoorWindList more automatically, without having to manually prepare this list.

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

                      Yes, that's what I am referring to as planned but not yet implemented in my earlier reply.

                      Author of Multi-system Reactor and Reactor, DelayLight, Switchboard, and about a dozen other plugins that run on Vera and openLuup.

                      1 Reply Last reply Reply Quote 1
                      • wmarcolin
                        wmarcolin last edited by

                        Ah, ok, thanks!

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

                          Well, I have been trying to use the above example to get a message reporting LAN connectivity failure of devices in my network.

                          So I have set up an array with devices the Global expressions named DeviceTrackerList:

                          ['hass>device_tracker_airport_time_capsule_van_hw','hass>device_tracker_airport_time_capsule_van_hw','hass>device_tracker_akita','hass>device_tracker_altherma_lan_adapter','hass>device_tracker_ap_bijkeuken' etc] 
                          

                          Then I run into problems defining the loop into a variable DeviceTrackerNotHome:

                          each id in DeviceTrackerList:getEntity( id).state == not_home ? id: null
                          

                          Which returns the entire list. I have tried a few dozen of other options but either the entire list or an empty list is returned. Obviously my .state does not do the trick but what is the correct syntax to use here? (And where could I have found that myself?...)

                          Then the next step is to use the names of the failing devices in a message.

                          My last global variable is named DeviceTrackerMessage and holds

                          join(each id in DeviceTrackerNotHome:getEntity(id).name, ', ')
                          

                          which returns a nice list of friendly names but I have no idea how to use that in my message.

                          I expected { "message": {DeviceTrackerMessage} } to work but it did not and all other attempts to construct something failed as well.

                          So I do hope someone can help here to point out to me what is probably obvious but difficult for a novice user to see. 🙂

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

                            @hansw said in Device information in string or array:

                            each id in DeviceTrackerList:getEntity( id).state == not_home ? id: null

                            The state part isn't right... everything from getEntity() to the question mark, in fact. Go to the Entities list, find one of the entities you have listed in DeviceTrackerList, and click on it to open its detail pane. You'll see the correct names of all the attributes listed there. Two things need to be fixed: (a) where you have getEntity( id ).state in the above example, you need to replace it with getEntity( id ).attributes.capabilityname.attributename (e.g. .attributes.x_hass.state or .attributes.x_hass_device_tracker.location_name); and (2) where you have not_home, there is probably no variable by that name, and I'm betting you actually meant to compare to a string here, so that needs to be surrounded in quotes: ... == "not_home"

                            @hansw said in Device information in string or array:

                            which returns a nice list of friendly names but I have no idea how to use that in my message.
                            I expected { "message": {DeviceTrackerMessage} } to work

                            The message would be something like:

                            ${{ "Trackers not home: " + DeviceTrackerMessage }}
                            

                            Author of Multi-system Reactor and Reactor, DelayLight, Switchboard, and about a dozen other plugins that run on Vera and openLuup.

                            1 Reply Last reply Reply Quote 0
                            • H
                              HansW last edited by HansW

                              Thanks again for your help @toggledbits. I had been looking at the wrong place (in HASS) for the entities but your pointer was a great help also for other uses of reactor. The expressions are working like a charm now.

                              Still having trouble getting the JSON correct using the Variable though. I am using the x_hass_system.call_service and whatever I try it fails.

                              The string looks like:
                              { "title": "The following devices fail: ", "message": XXXX } Where at the location of the XXXX I probably need a trick to insert the DeviceTrackerMessage with surrounding double quotes but I don't have a clue.

                              I even tried building the JSON into a global variable but it looks like the escape characters do not work or maybe I overlook something obvious.

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

                                Show me all of the variables involved, and your rule and it's reactions. We'll work from the point you've arrived at.

                                Author of Multi-system Reactor and Reactor, DelayLight, Switchboard, and about a dozen other plugins that run on Vera and openLuup.

                                1 Reply Last reply Reply Quote 0
                                • H
                                  HansW last edited by

                                  Thanks @toggledbits , the variables I showed you in my earlier post and I corrected them zo they evaluate properly now into a string DeviceTrackerMessage which holds the friendly name of the devices offline, separated with comma's. As a string it does not have "" around it.

                                  My rule has a lot of Entity Attribute checks of all devices checked on x_hass.state <> home and combined into an OR.

                                  Then as a constraint I check the Variable Value DeviceTrackerMessage <> ""

                                  And then the Set Reaction holds:

                                  Entity Action hass>system x_hass_system.call_service with service: notify.my_device and the data: holding
                                  { "title": "Some devices failed: ", "message": XXXXX }

                                  Where on the position of XXXX I tried all I could think of.

                                  I know the rule might not be perfect yet but just testing the Set Reaction should generate a message. When replacing the XXXX with "test" I get a message.

                                  Also I tried adding a variable called JSONString and populating that using to JSON but I cannot get the result to look like a JSON string nor to work.

                                  Hope this helps.....

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

                                    The data field requires either a string that can be parsed as JSON data, or (works but not documented), you can pass an object from an expression. Both of these will require that you use a substitution to get the object or string into the field.

                                    My suggestion is that you minimize the need to understand quoting, etc. by creating another variable to house the data object, and pass that variable in the Entity action. Two steps:

                                    1. Create an expression (could be local or global) called notify_data defined as follows:

                                       { "title": "Some devices failed", "message": DeviceTrackerMessage }
                                      
                                    2. To insert that into your Entity Action, set the data field to ${{ notify_data }}

                                    That's what I would consider to be the "easy" way, which is a little longer than the most direct route, but easier (I think) to understand (and support/remember in future). The first step creates an object with two keys and sets their values: the title is a string, and the message is the value of DeviceTrackerMessage (no quotes around that name means it's a variable reference). The second step passes the object to the data field.

                                    The other way would simply be to set the data field in your action to the JSON string directly in one step. There are several ways to do this, and one of them is to use a similar approach to what we've done above, and just have the stringify() function convert it to JSON for us (that's what it does). Set the data field in your Entity Action to:

                                    ${{ stringify( { "title": "Some devices failed", "message": DeviceTrackerMessage } ) }}
                                    

                                    You should be able to see the similarity here. The interior object definition creates an object with two keys, title and message, and their particular values. That is passed to stringify(), which converts it to JSON, and that result string becomes the value of the field passed to Hass on the service call.

                                    You can also do this without stringify(), but it's more complicated. We have to build the JSON string ourselves and insert the data from DeviceTrackerMessage into it using string concatenation, with careful use of different quotes for different purposes (the tricky part):

                                    ${{ '{ "title": "Some devices failed", "message": "' + DeviceTrackerMessage + '" }' }}
                                    

                                    Notice that before and after + DeviceTrackerMessage + we have double quotes inside single quotes (hard to see, especially at the end). But this would also work, provided DeviceTrackerMessage does not contain any double quotes itself. Quoting can be hard to get right, especially for new players, so I generally try to find solutions that avoid it, which is why I put the other two solutions first on my list.

                                    Edit: heh... actually, an even shorter version of my first alternative is to not use stringify() at all and just create and pass the object on the fly... set data field to this:

                                    ${{ { "title": "Some devices failed", "message": DeviceTrackerMessage } }}
                                    

                                    That's about as direct as it gets -- you're creating and passing the data object in one step, there is no need to convert it to a JSON string because you can pass the object directly. For clarity, no additional variable needs to be created, either. I think I like this best.

                                    Author of Multi-system Reactor and Reactor, DelayLight, Switchboard, and about a dozen other plugins that run on Vera and openLuup.

                                    1 Reply Last reply Reply Quote 0
                                    • H
                                      HansW last edited by

                                      Thanks a lot for your elaborate answer and explanation @toggledbits! I do appreciate this and it helps me further, also with other issues, to make better use of your wonderful tool! I was not aware of this ${{ }} construction and I have no idea from which language this syntax is but I guess it forces the bit in between to be evaluated.

                                      Anyway, it solved the problem! Thanks a lot!!

                                      toggledbits 1 Reply Last reply Reply Quote 1
                                      • toggledbits
                                        toggledbits @HansW last edited by toggledbits

                                        @hansw said in Device information in string or array:

                                        I was not aware of this ${{ }} construction and I have no idea from which language this syntax is but I guess it forces the bit in between to be evaluated.

                                        That is exactly what it does, and the value that results become the value of that field for the action. Similar syntax is used in many applications (it's not really a language feature as much as it is an application feature), among them Home Assistant. Reactor for Vera used plain { } but this was problematic because the more robust expression language of MSR uses those characters.

                                        Author of Multi-system Reactor and Reactor, DelayLight, Switchboard, and about a dozen other plugins that run on Vera and openLuup.

                                        1 Reply Last reply Reply Quote 1
                                        • Locked by  toggledbits toggledbits 
                                        • 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