Groov events from Node-Red

Is there a way to get the list of groov events from Node-Red?

The goal is to allow the operator to configure events through groov build and then have Node-Red pick up the event changes to send them out in something other than e-mail.

It looks like the current endpoint is using a session cookie, I would like to use an API key or nothing at all if localhost on port 3001 is workable.

The endpoints that are in active use doesn’t support API keys. However, there’s a set of API-key compatible endpoints that I never finished porting over to. So, with the caveats that:

  1. This isn’t in active use in groov View and may bit-rot at some point.
  2. This isn’t considered documented or stable so could change in any release.

You can get the list of all events in the system with their current states by using api/v0/events and you can target a particular event by using api/v0/events/:event-id where :event-id is an integer. You can get the event ids from that first endpoint.

So if you’re using groov Server for Windows, an AT1, or an AR1, you can use:

https://your-groov-address/api/v0/events?api_key=YOUR_API_KEY
https://your-groov-address/api/v0/events/:event-id?api_key=YOUR_API_KEY

And on EPIC, it’s:

https://your-epic-address/view/api/v0/events?api_key=YOUR_API_KEY
https://your-epic-address/view/api/v0/events/:event-id?api_key=YOUR_API_KEY

The output from the second form looks like this at the moment:

{
  "id": 92,
  "name": "Vegas 22010",
  "enabled": true,
  "condition": {
    "children": [
      {
        "children": [
          {
            "type": "compare",
            "comparator": ">=",
            "tag_id": 158,
            "tag_index": 0,
            "tag_count": 1,
            "bit_index": -1,
            "value": 75,
            "hysteresis": 0,
            "debounce_time": 1
          },
          {
            "type": "compare",
            "comparator": "<=",
            "tag_id": 158,
            "tag_index": 0,
            "tag_count": 1,
            "bit_index": -1,
            "value": 90,
            "hysteresis": 0,
            "debounce_time": 1
          }
        ],
        "type": "and"
      }
    ],
    "type": "or"
  },
  "sendEmailOnBegin": false,
  "sendEmailOnEnd": false,
  "beginEmail": {
    "subject": "Vegas, baby.",
    "body": "Seems like a nice day in Vegas, at {{tag(158,0,1)}}ÂșF."
  },
  "endEmail": {
    "subject": "Avoid Vegas, baby.",
    "body": "The weather's gross in Vegas now at {{tag(158,0,1)}}ÂșF."
  },
  "recipients": {
    "users": [],
    "groups": [],
    "everyone": false
  },
  "state": "INACTIVE",
  "errors": [
    {
      "tag": {
        "tagId": 158,
        "tableStart": 0,
        "tableCount": 1,
        "bit": -1
      },
      "errorCode": "CONTROLLER_CANNOT_CONNECT",
      "errorString": "Waiting 29.1 seconds until trying to reconnect to device ControlEngine-jfischer-lx.opto22.com:22010."
    }
  ]
}

The output from the first form (all events) will be an array of those entries.

3 Likes

@philip One solution to this is to use node-red as a SMTP server for the outbound groov event emails.
I have this running on a PR1 and use Twillio to delivery more reliable text message alarms.
The setup is quite easy!

In Node-Red >> manage Palette >> install >> node-red-node-email
Use the e-mail mta node

  • set the Port (can be anything above 1025 that is not in use!)

In Groov build >> configure >> Project
Configure Email settings :

  • SMTP server hostname: localhost
  • SMTP Server port

Now test your connection to node-red using the “Send Test Email” in the config menu.

In node-red the complete message object contains everything you need, mainly:
to = msg.to
message body = msg.payload
message topic = msg.topic

**The domain (@somthing) is required for the email recipient address. This can be removed in node-red using a function node if needed.

-Grant

3 Likes

Welcome to the forums Grant!!

That’s a really interesting ‘slight of hand’ to send groov View events to Node-RED.
Thanks for the share.

Thanks Ben!
One day I thought “I wish i could just send emails straight to node-red
, what about a local SMTP server?..what if node-red is the SMTP server!?!”

To keep it secure it runs on the local machine, no external ports opened.

It opens up a wide range of alert push options, while allowing alert management to happen through groov view.