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: April 21, 2022)
    • Call Service Automation Trigger not Working

      Pabla

      Been trying to call the service automation:trigger to trigger an automation on my HA. Below is the screenshot of the reaction but every time I hit the play button to test it nothing happens. I called the service locally on HA and it worked fine. MSR latest-22203-d7cd6357 and HA 2022.8.3. No errors in HASS logs or Reactor logs. 715cd920-effd-4d31-8ac3-ba34ef29185c-image.png

      Multi-System Reactor
    • TTS in MSR?

      F

      Hi!

      In Home Assistant I sometimes uses the TTS, either to my Sonos or Google speakers. With reactor in Vera I also use TTS.
      But in MSR I can't select the TTS-service. It's simply not there. Am I missing something, or is this the case, so far?
      Thanks!
      /Fanan

      Multi-System Reactor
    • "changes from" operator stops to detect change

      tunnus

      I have the following rule:

      Screenshot 2022-08-09 at 17.33.39.png

      Use this to detect errors in Nibe uplink service, and every time updated data is fetched, a timestamp is stored. This triggered already yesterday, but re-triggered as I tried to manually recover this rule with a reset (hence there's no original "true as of xxx" time).

      So as a clarification, service works now and timestamps are updated, but this rule does not "recover" (stays triggered / SET). Did also restart MSR during this situation, though it was not related to this.

      The condition where there was no change (and rule was working correctly) lasted over 24 hours.

      Running MSR 22179 on Synology Docker. Can PM relevant logs if needed.

      Multi-System Reactor
    • Parsing the output of http request

      tunnus

      I'd like to extract a specific part of a response to http request, in this case of link https://www.nibeuplink.com/Welcome#service_message. If there's something in "service_message" I'd store it & send using Telegram.

      I reckon I'd have to use something similar as in this thread?

      Multi-System Reactor
    • How Does MSR Handle New/Deleted Entities

      Pabla

      Deleted some entities from HA and added some new ones but MSR is still showing the old ones and not all of the new ones. I restarted MSR and it hasn't changed, is there anyway to manually discover new entities and delete the old ones? Most of the new entities have shown up but a few haven't, however none of the deleted entities were removed from MSR.

      I checked the core.entity_registry in HA and none of the entities that are shown in MSR are there.

      Edit: I see the delete option under the entities tab in MSR, is that the only way to delete them?

      Multi-System Reactor
    • Troubles Running MSR as a Service

      Pabla

      Successfully got MSR to run on a VM running Ubuntu 22.04 but am running into an issue with getting to run MSR as a service. Here is what my reactor.service file looks like below.

      However when I go to run the service I see this error: reactor.service: Failed at step CHDIR spawning /usr/bin/node: No such file or directory. Checked and the node file exists in this directory. Kinda stuck at this point, probably a simple fix but I am way in over my head 😰

      [Service] Type=simple User=armans2 WorkingDirectory=/home/reactor Environment=/home/reactor ExecStart=/usr/bin/node app -p Restart=on-failure RestartSec=5s
      Multi-System Reactor
    • MSR actions aren't running anymore-- can't find what's broken

      A

      Hey crew,
      I'm running into an issue where MSR's reactions aren't successfully running, and I can't figure out what's gone wrong.

      Backstory-- we had a big thunderstorm roll through the other day, we lost internet and the storm got bad so I unplugged most items in my homelab, including the Pi that's running MSR.

      Now that everything is powered back up, the reactions aren't running correctly. Most of my MSR automations are to use motion sensors to turn lights on/off, and I immediately noticed that even when a motion sensor is tripped, the light doesn't turn on like it's supposed to.

      I've tested a bunch of things to see what's broken, here's what I've observed:
      -I can successfully flip lights on/off manually within Vera
      -I can successfully flip lights on/off manually within MSR's Entities section
      -the motion motion sensors are correctly reporting to Vera and MSR (I can see when they're sensing motion)
      -the rules within MSR are working correctly, I can see when they flip to 'true' when I walk by a motion sensor
      -I can successfully run the Reaction within MSR (by hitting the 'play' button)

      But for whatever reason, when everything needs to work together, it doesn't successfully run the action. IE: the motion sensor trips, reports it to MSR, I can see MSR going "true" but the light does not turn on. Open to any suggestions, thank you!

      SYSTEM
      Vera has all my devices
      MSR is running bare metal on Rpi "Reactor (Multi-hub) stable-22004-6d6c6b7"

      Multi-System Reactor
    • Evaluation of time() comparisons

      CatmanV2

      Apologies in advance, I expect I am going to make a total pig's ear of explaining, so please bear with me....
      (and if it's in the manual, just tell me to read the manual)

      Going back to my heating scenario:
      We have an alarm clock that goes off at a variable time.
      We want the heating to go off at a time before that (1 hour)
      so we have created the rule set as below:
      Screenshot 2022-07-28 at 16.40.13.png

      So if current time is >= to the HeatTime, the first condition goes true.
      The second condition is to ensure that nothing (tries to) turn(s) the heating off during that 1 hour window
      The interval is there because in Reactor there was precisely that to (from memory) 'make sure the variables updated'
      In the current state it kind of works. There is no Reset action, so the heat goes on once every 15 minutes during that hour.
      In Reactor I didn't have to include the interval in the rule set. It was a stand alone rule as here:
      Screenshot 2022-07-28 at 16.47.23.png

      If I move the Interval condition out of the rule set in MSR, things do not update as time changes (and the rule never sets)

      So I guess the question I'm trying to ask it 'what causes expressions like
      time() >= HeatTime

      To be evaluated, and is there a better way than I've done here?

      Apologies again 😞

      C

      Multi-System Reactor
    • [SOLVED] FetchError: network timeout for API calls

      G

      I've been running into an issue with a couple APIs wherein they return the error FetchError: network timeout....

      A retry resolves but my ask here is around how I can monitor within MSR and trigger (at least) a notification if not a retry after a short delay.

      Multi-System Reactor
    • Vera -> HASS Migration Strategy (question)

      T

      Hi All -

      I'm currently working through a slow migration from Vera to Home Assistant with MSR being a pivotal piece of the equation.

      I have begun the effort of moving some ZWave devices as well (from Vera to HA). Unlike others that use Vera for the ZWave radio, I'm looking to completely remove it from my ecosystem, eventually.

      My issue is I have some Vera Scenes that are designed to be manually executed by the Vera Mobile app. Examples: "Go to Sleep", "Panic - Lights On", etc (Wife Acceptance Factor)

      I think MSR is the right place for any new "Scene" (including manual scenes); and from my reading, a Global Reaction makes sense.

      Question 1: Can anyone recommend a way to execute a Global Reaction from a Vera scene? I've seen some examples of HTTP calls to MSR so I assume this is it (perhaps custom Luup which I know very little about).

      Question 2: How can I (manually) execute this Reaction from Home Assistant? I'm slowly building out my custom Dashboard using "Mushroom".

      Or, maybe there's a better way. Always open to constructive criticism.

      Thanks.

      Multi-System Reactor
    • MSR setup for http request (today's date)

      T

      I would like to extract the daily gas price from my fuel supplier's API. The http call is as follows: https://octopus.energy/api/v1/tracker/G-1R-SILVER-2017-1-M/daily/past/90/1/

      I need to pick the current (i.e. today's) gas price. If I search through the text manually I can find today's data, in this case 2022-07-20.

      Can I set MSR up to do a http request and then extract the "unit_rate" into a variable so that I can set another rule up to determine if it would be cheaper to heat my hot water using the immersion heater or gas (FYI my off peak electricity price is £0.075 per kwh). Any help or guidance as always is much appreciated.

      I'm running MSR on raspberry PI 4 in docker version 22168

      Thanks.

      { "date": "2022-07-20", "market_index": 62.8463, "cost": 15.094631164947945, "standing_charge": 15.0885, "unit_rate": 8.211, "usage": 0.0007467013698630137, "unit_charge": 0.0061311649479452055, "breakdown": { "unit_charge": { "Wholesale cost": 6.28463, "Environmental & social obligations": 0.0, "Delivery & networks": 0.9681, "100% green": 0.0, "Administration, financing & margin": 0.56727, "VAT": 0.391 },`
      Multi-System Reactor
    • 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
    • Variables for fun and profit

      CatmanV2

      Well the use of expressions in my Idiot Question over there has opened many new and exciting doors which I am itching to run through. This one has slammed in myu face 😞

      So in reactor we have an expression:
      getstate( 46, "urn:upnp-org:serviceId:VClock1", "AlarmTime" )
      which returns
      Last result: "05:15:00"
      Then we convert this to time one hour earlier:
      time(AlarmTime) - 3600
      which returns
      Last result: 1658373300

      Cool!

      In MSR:
      getstate is not supported
      getEntity("vera>AlarmClock").attributes.x_vera_svc_upnp_org_VClock1.AlarmTime
      Returns:
      Last value: (string) "05:15:00"
      Marvellous!
      time (AlarmTime)
      Returns
      Last value: (null) null

      Boo! Hiss!

      OK seriously, is there a reference I've missed or somewhere I can look at this stuff. time() in Lua returns the epoch time which is fab, but what's my equivalent to the time usage in Reactor?

      TIA
      C

      Multi-System Reactor
    • Idiot questions. Feel free to ignore.

      CatmanV2

      Starting to (very slowly) migrate and improve some of my automation from Reactor to the fabulous MSR. Couple of questions which are probably really obvious but, well, you know me 😞

      Is it possible to repeat an action from a set rule? i.e. if the rule remains triggered for an hour, re-run the set reaction. And to continue re-running that every hour until the rule is reset?

      Sorry if it's really stupid.

      C

      Multi-System Reactor
    • Using duration of a rule or trigger in an expression

      D

      Hi, I have a rule that I have been using in the Vera version of Reactor for a number of years and I am trying to recreate it in MSR and need some advice. The rule monitors the state of our garage door and sends a regular alert if the door has been open for a period of time. The alert contains a variable/expression that provides the duration in minutes the door has been open - eg the end notification looks like this: "The door has been open for X minutes"

      I have everything working OK in MSR except for constructing the expression to provide the duration the door has been open. In Reactor I was using the 'getstate' function in an expression to get the runtime of the rule and then converting that to minutes and passing it to the notify action.

      In MSR I can't work out how to get any info from a rule within an expression.

      The trigger is a simple pulse every X minutes so I was hoping it would be possible to just get the duration of either the rule or the time the door has been open. In the documentation there is a lot of info on getting details of entities, but I couldn't find anything on getting the status of the rules within MSR as it doesn't look like they show up as entities? I hope I didn't miss that part of the doco.

      I did a bit of searching but couldn't find any discussion on getting this type of info so I'm hoping someone will be able to point me in the right direction.

      I'm using build 22179 on Docker and the devices are currently in Vera but I am likely to move them to HASS at some point.

      Multi-System Reactor
    • Adding remotes, scene controllers as entities to MSR

      A

      EDIT: 2022.07.01

      So I will try to remake this thread to some kind of guide for future use, or in worst case a documentation of my failure. At least that could also be useful for letting someone know what didn't work...
      I have zero knowledge of programming, so every time I need to edit a config file in HomeAssistant or similar it requires a good portion of googletime and read, re-reading instructions.
      Also is english not my native language, so bear with me.

      Two goals!
      1: Get MSR to take notice (and then actions of course) of pressed buttons on remotes.
      2: Document what I do in hope I can help someone else in the future.

      I will use a Fibaro Keyfob as described below, but what I understand from Togglebits answers most type of remotes should work in similar ways.

      Original thread:
      Fibaro Keyfob support in MSR? (thru Hassio & Z-wave JS)
      Hi

      I just bought a Fibaro Keyfob FGKF-601 and plan to give this to my son so he can control some stuff in his own room. Primary some lightning and Sonos, maybe blinds in the future.

      As the noob I am it will, of course, not work as I expected.👶🏻

      The remote handle 1x, 2x, 3x clicks per button (six of them) and "release button"
      I thought that it would appear like some "scene controller" in HA and that I could make Rules in MSR depending on what scene-entety that was triggered.
      So is not the case, and if that is because of HA, Z-wave JS or MSR I have no idea.
      I found a HA Blueprint that works in HA, but of course I would prefer to keep all automation in MSR.
      I guess a workaround could be using HA virtual switches "Helpers" that I suppose will come up as an on/off trigger in MSR, but before going this way I would like to check with the wisdom of your guys if there is a better way of doing this.

      I am using:
      MSR 22168 on windows.
      Home Assistant Core 2022.6.7
      Home Assistant Supervisor 2022.05.3
      Home Assistant OS 7.6
      Z-Wave JS version: 0.1.64

      Multi-System Reactor
    • Constraints under triggers or under constraints, what is the difference?

      A

      Need to ask, have thougth about this since the move from Rector to MSR I think.

      What is the difference between putting constraints under trigger groups, like this
      23b4a249-3292-41cd-9927-7f49c9bf1d07-image.png

      Compared to this similar rule, but the time limits is under contraints instead?
      ee596c9f-f52b-4a39-9605-f5932f3d9ed5-image.png

      I think the Constraints parts in manual is still to be done because I can only find in the chapter menu, but it is not mentioned anywhere else.

      Multi-System Reactor
    • The Home Remote with MSR

      MikeReadington

      Did anyone do/start any work on a full integration with The Home Remote application yet?

      Multi-System Reactor
    • Condition must occur after -restriction not working

      tunnus

      Running MSR 22123 in Docker container and trying to use "condition must occur after" option. Will update to the latest build and log a PR if needed, but wanted to poll first if anyone is using this option successfully?

      I have the following rules:

      Screenshot 2022-06-28 at 15.18.50.png

      Notification activity connected to "Alarm disabled" rule did not trigger. I also did another test with quite simple rules and that didn't work either (FWIIW - when observing that test in "real-time", I didn't see any timer running on the second rule while the first rule was true).

      As said, before going further with debug/logs, nice to know if someone is using this option/restriction (successfully).

      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

    Notifications from Alerts

    Multi-System Reactor
    5
    25
    381
    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.
    • Crille
      Crille last edited by

      @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.

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

        Why don't you just condition the sys_system.state attribute of the openLuup controller's system entity?

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

        Crille 2 Replies Last reply Reply Quote 1
        • Crille
          Crille @toggledbits last edited by

          @toggledbits Because I did not see that when I first looked for it 🙂
          Excellent, just what i needed, thank you!

          1 Reply Last reply Reply Quote 1
          • A
            Alan_F last edited by

            Resurrecting this older thread... does this answer mean there is no way to react to the presence of an alert within MSR? If not, this would be a useful enhancement.

            I have a camera that is switched between day and night settings by http requests sent by MSR near sunset and sunrise. Yesterday the camera stayed in night mode most of the day while there was an alert showing in MSR that the http request had failed. I realize I could capture the http response to an expression/variable and then write a rule based on that variable to notify me, but I'd have to do this for every http request in every ruleset, and I'd have to make sure I evaluate the response correctly (which is likely to be a hit or miss operation for me). That still wouldn't capture other alerts that MSR might display outside of failed http requests, but I'd like to push all alerts to my notification system. Basically, I don't want to have to check the MSR interface to make sure it's happy, I'd like it to tell me when it's not.

            1 Reply Last reply Reply Quote 1
            • A
              Alan_F last edited by

              Just a note for posterity that alerts are now available as an entity as of version 21356.

              1 Reply Last reply Reply Quote 1
              • cw-kid
                cw-kid last edited by

                So how do you translate an MSR system generated alert like a HTTP Request faiiing

                be1879ae-aae0-4ccf-b79f-322dbe4ff3e9-image.png

                In to a rules trigger ?

                8c7df97c-5201-4029-8d66-0239653d6a4e-image.png

                39c00c3e-2f1e-471d-8743-bc6109fe5e1b-image.png

                Thanks

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

                  The reactor_system.alerts attribute value is an array of objects. Each element/object contains keys id, severity, message, timestamp.

                  Here's an expression that would return an array of messages containing the words "HTTP request" in the message field. You can put this into a local expression of your rule.

                  each alert in getEntity( 'reactor_system>system' ).attributes.reactor_system.alerts: 
                      find( alert.message, "HTTP request", "i" ) >= 0 ? alert : null
                  

                  If the result of the array has non-zero length, an HTTP error has occurred. You can either just wrap the above expression in len() or use a second local expression (sometimes it's nice to keep them separate so you can more easily see what it's doing).

                  EDIT: Fixed the match string in find()

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

                  A cw-kid 2 Replies Last reply Reply Quote 0
                  • A
                    Alan_F @toggledbits last edited by

                    @toggledbits I was playing with this for about an hour, using it as an exercise to try to get better with arrays and the expression syntax. I created a rule that made a bad http request in order to throw an http request error.

                    I managed to get to a point where I could concatenate all the alert messages into a single string in an expression. That could then have been used in a rule that checked that expression for 'contains HTTP request'.

                    The expression you posted above seems like a quicker way to get to the same result, so I tried using it, but it doesn't seem to be working for me.

                    When I remove the 'find' and just return the alert.messge using:

                    each alert in getEntity ( 'reactor_system>system' ).attributes.reactor_system.alerts: alert.message
                    

                    I get:

                    Last value: (array:1) ["Reaction "Test Rule<SET>" (rule-kxkgh72o:S) step 1 HTTP request failed"]

                    But your full expression from above returns this:

                    Last value: (array:0) []

                    It seems like the 'find' part of the expression isn't matching.

                    However if I create the following expressions:

                    g_array_alert_messages = each alert in getEntity ( 'reactor_system>system' ).attributes.reactor_system.alerts: alert.message
                    

                    and

                    g_str_alert_messages = join (g_array_alert_messages, " | ")
                    

                    I get a pipe separated string of all the alert messages that I could use in a rule.

                    p.s. I also learned that if you point an expression at the alerts, and then use bad syntax in that expression, you can easily create a loop and raise the repeat alert counter to 50,000+ pretty quickly. Thank goodness for the throttling limits, since I also have a rule that sends a notification to my phone whenever an alert is raised and that only fired once per minutes, not 10,000 per minute.

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

                      Whoops, sorry, the find() is trying to match at the beginning of the string, just remove the ^ from the find match string. I fixed it in that post and tagged the edit.

                      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
                      • cw-kid
                        cw-kid @toggledbits last edited by

                        @toggledbits said in Notifications from Alerts:

                        EDIT: Fixed the match string in find()

                        That works now, it lists the latest alert error for "HTTP Request"

                        9fa5100e-55d7-46e7-8247-bdcf69d9cb21-image.png

                        If there are also other alerts errors still listed in that area of the GUI for "HTTP Request Failed" how would you also get those as well in to an expression value ?

                        Also is there a way to clear / delete a particular error alert via a rule / code ?

                        Thanks

                        toggledbits 1 Reply Last reply Reply Quote 0
                        • toggledbits
                          toggledbits @cw-kid last edited by

                          @cw-kid said in Notifications from Alerts:

                          If there are also other alerts errors still listed in that area of the GUI for "HTTP Request Failed" how would you also get those as well in to an expression value ?

                          You're already doing it. The each produces an array of all matching values. The result you are showing is just an array of 1 element because there is only 1 match.

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

                          cw-kid 2 Replies Last reply Reply Quote 0
                          • cw-kid
                            cw-kid @toggledbits last edited by cw-kid

                            This post is deleted!
                            1 Reply Last reply Reply Quote 0
                            • cw-kid
                              cw-kid @toggledbits last edited by

                              @toggledbits

                              Sorry I didn't see that there were two ID's listed in that expressions output. So you are right it does appear to be showing both alerts that contain the words "Http request".

                              1 Reply Last reply Reply Quote 0
                              • cw-kid
                                cw-kid last edited by

                                Trigger:

                                Not sure if this is the best trigger to use?

                                26c21c42-4fb0-49be-91e3-06cddf41d9dd-image.png

                                Local Expression:

                                fbcead04-5cc4-48cf-881b-749a24855c00-image.png

                                Action:

                                Send a Telegram notification with the contents of the local expression value / text.

                                87c61c63-f74b-46ab-b2f9-3b5143fc9fa0-image.png

                                However in Telegram I just get this:

                                37d151f6-7466-49a2-9844-d706d7378fda-image.png

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

                                  First, it will never be null, so that's not a valid test (I mentioned that here).

                                  For your message text, you probably need to convert it from an array to a formatted string that is actually readable. This has been covered a bunch as well (even in this very thread), so I won't give away an answer... better to practice! 🙂

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

                                  cw-kid 1 Reply Last reply Reply Quote 0
                                  • cw-kid
                                    cw-kid @toggledbits last edited by

                                    @toggledbits said in Notifications from Alerts:

                                    it will never be null

                                    Maybe I can use Variable value "is not empty" instead? As the trigger.

                                    I also tried using a Join expression to get some formatted text out of it but I still just get this:

                                    ac24a771-3114-4a90-a604-3c7b6baa2f61-image.png

                                    A toggledbits 2 Replies Last reply Reply Quote 0
                                    • A
                                      Alan_F @cw-kid last edited by

                                      @cw-kid

                                      Here's what I have... I want to be notified on all alerts, and I only want to include the message from the most recent alert in the notification. I also needed to remove the escaped quotes (") from the message string because it was messing with my notification where I was inserting the expression into the http call.

                                      So:

                                      08ac845c-8a8a-4f68-bf3f-a07bbd7de1cb-image.png

                                      g_alerts_array = get all the alerts

                                      g_last_alert = get only the alert where the timestamp == alert_last timestamp

                                      g_last_alert_replaced = remove the " from the alert message string

                                      I realize there is probably some way to combine all of these into one expression, but I was getting errors when I tried wrapping the "first" and "replace" functions around the alerts array expression.

                                      Then in my rule:

                                      5098f72d-f68a-44fe-adba-9a6e5f6592f1-image.png

                                      If you only want http errors, then you'll have to modify the above expressions to find only those, as Patrick showed above. You'd also have to use a different trigger, as you don't want to fire the event every time the alert_last changes, as some of those won't be http errors.

                                      1 Reply Last reply Reply Quote 0
                                      • toggledbits
                                        toggledbits @cw-kid last edited by toggledbits

                                        @cw-kid said in Notifications from Alerts:

                                        I also tried using a Join expression to get some formatted text out of it but I still just get this:

                                        The reason your join() doesn't work as expected is that the array contains objects, not strings. @Alan_F gives an option, but he uses first so only one alert, not in array, would result.

                                        Good efforts all around though. Let's fill in some details...

                                        When writing complex expressions, and particularly as you're learning the expression language, it's often better to break it down into pieces as @Alan_F has done. For what you seem to want to do, you started with filtering the array:

                                        Alerts_HTTP_Failed = each alert in getEntity( 'reactor_system>system' ).attributes.reactor_system.alerts: 
                                            find( alert.message, "HTTP request", "i" ) >= 0 ? alert : null
                                        

                                        This gives you an array of objects (as we've established) of only the HTTP request errors. From there, you want to get to just the message strings, but all of them, not just one/the first, so you'll use each again:

                                        HTTP_Fail_Messages = each alert in Alerts_HTTP_Failed: alert.message
                                        

                                        That simple expression loops over the objects in the array and extracts just the message field. The result of that is a new array of strings, rather than an array of objects. From there, join...

                                        HTTP_Messages_String = join( HTTP_Fail_Messages, "; " )
                                        

                                        And as they say, Robert is your mother's brother.

                                        Doing it all together:

                                        join( each alert in getEntity( 'reactor_system>system' ).attributes.reactor_system.alerts:
                                            find( alert.message, "HTTP request", "i" ) >= 0 ? alert.message : null, "; " )
                                        

                                        If it looks like I left out a step, I did, in a way... rather than having the filter loop return objects, this version just returns the message (strings) directly as an array, so it eliminates that middleman and can then be passed directly into join().

                                        @alan_f said in Notifications from Alerts:

                                        g_last_alert_replaced = remove the " from the alert message string

                                        Although the quotes look funny in the display, I don't think they will bother anything in use, as the notifiers are built to digest/handle such special characters properly.

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

                                        A cw-kid 2 Replies Last reply Reply Quote 0
                                        • A
                                          Alan_F @toggledbits last edited by Alan_F

                                          @toggledbits I'm using a self-hosted notification system (Gotify) so when I said 'send notification' it would have been more precise to say "use as the JSON content in an http post request". The " definitely broke the request when it was substituted in to the middle of the request body. I also tried to urlencode the string but while that didn't break the request, it was super ugly as it passed all the encoded characters into the displayed message. I'm not very proficient at regex, so it took an online regex tester and a bit of trial and error to arrive at the right number of backslashes to finally make it work.

                                          Another lesson learned: turn off 'auto evaluate expression' when trying to write expressions that refer to the alerts, 'cause if you get the expression wrong and throw an alert that causes the expression to reevaluate which throws an alert... I had to restart my Reactor Docker container a few times before I turned off 'auto evaluate' ¯_(ツ)_/¯

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

                                            @alan_f said in Notifications from Alerts:

                                            it would have been more precise to say "use as the JSON content in an http post request". The " definitely broke the request when it was substituted in to the middle of the request body.

                                            That would depend on how you are building it. If you are just jamming it in as a string, that's definitely going to create problems. A better approach may be to build the payload as an actual object in the expressions, and then at the end, right before sending to Gotify, put it through the stringify() function, which will convert the object to a JSON string, and that will also handle the quotes correctly to produce valid JSON with the quotes embedded. That will spare you the agony of having to sanitize every string you might ever send.

                                            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
                                            • 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