PagerMon Webhook

At home, I have a Intel NUC running PagerMon (GitHub - pagermon/pagermon: Multimon-ng pager message parser and viewer) with a RLT stick on it. It captures all the pager traffic (POCSAG protocol), and display it on a website. So far, so good. I can see the posts of other fire departments and ambulances, so that works fine…

I have created a filter on a specific CAP code (kind of a “telephone number”), and set the webhook that have to be used to send everything to directadmin.

As destination URL, I’ve set http://10.0.0.100:8123/api/webhook/-c3okJuIGk9oVAVYpbktqYxfd (the NUC and the device running HA are in the same 10.0.0.0/24), and i selected some extra info field I want to have such as Message, Source, Timestamp, Alias and Agency.

When the webhook is triggered, a plug have to be switched on for 5 minutes (after 5 minutes it have to switch off) and a SMS have to be send to me (using Twilio, that is already working at HA for something else). That SMS needs to contain the Agency, the Alias and the Message. And also I want to have the latest intervention as a tile on HA if possible…

I think I can manage to set the automation that it will switch on the plug. But don’t know how I can disable it after 5 minutes. Also, I need (a lot of) help with the SMS that have to be send and some help wish the tile too.

I am a newby on HA, so please be gentle and patient :slight_smile:

The results so far…

  1. I’ve created a script that will turn on the plug, and shut it down after 2 minutes
alias: 112 Brakel aan/uit
sequence:
  - type: turn_on
    device_id: c2d63e1e240783d4cd6f57bb8b9541c9
    entity_id: 76ceff595960c446c9f06e4da94ac157
    domain: switch
  - delay:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: c2d63e1e240783d4cd6f57bb8b9541c9
    entity_id: 76ceff595960c446c9f06e4da94ac157
    domain: switch
mode: single
icon: mdi:power-plug
  1. I’ve created an automation that will trigger that script, and will also send out the SMS
alias: 112 Brakel Zwaailicht + SMS
description: ""
trigger:
  - platform: webhook
    allowed_methods:
      - POST
      - PUT
    local_only: true
    webhook_id: "xxxxxxxxxxxxxxxxxxxxxxx"
condition: []
action:
  - service: notify.twilio_sms
    data:
      target:
        - "SMS Number 1"
        - "SMS Number 2"
      message: "112 Brakel : Oproep ziekenwagen"
  - service: script.112_brakel_aan_uit
    data: {}
mode: single

So at this moment, the plug flips over for 2 minutes, and a SMS “112 Brakel : Oproep ziekenwagen” will be send to 2 numbers. So far, so good…

Now, this is all the information that is stacked into the webhook

trigger:
  platform: webhook
  webhook_id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
  json:
    address: 'xxxxxx'
    message: MED, P067 - Sociaal probleem, N5
    timestamp: 1698862769
    alias: 112 Brakel
  query:
    __type: <class 'multidict._multidict.MultiDictProxy'>
    repr: <MultiDictProxy()>
  description: webhook
  id: '0'
  idx: '0'
  alias: null

How can I get the alias and the message out of that json, and send to me by SMS? Last question : I need to have the message and the alias on a tile in HA. But how do I do this?

OK, I’m sure : some extra help would be nice :slight_smile: I tried, but I failed :slight_smile:

This post led me to PagerMon which seems like a great application. Just started using it the other day and developed a plugin to get messages into home assistant via MQTT.
Just wanted to share it with you as it seems like it could help you out. I’m currently testing it on my machine but will hopefully be implemented in a release soon.
Can be found here if you have the knowledge to set it up: GitHub - ChoffaH/pagermon at develop

I tried implementing the MQTT plugins in your fork, but ended up getting about 9 duplicated messages in pagermon for every message received. Is this something you’ve noticed?

No I haven’t had that problem. My fork is based on the develop branch so there are other changes made by the owner since the last release that might affect you.
Is “Duplicate filtering” still on in your settings?

Ah yes, I’ve just had a quick look and can see a lot of changes vs master. Can quite easily back out my changes, or just leave as is for the time being, where I’ve disabled the added plugin. Something to play with later, or possibly look at setting up a virtual server on a different machine, and bounce the message data there for testing.
BTW, I don’t use Duplicate Filtering. Seems to be the software looping something in this instance
Thanks

Okey, does it still duplicate messages when my MQTT plugin is disabled?
Doesn’t feel like my plugin should cause that :thinking:
Might take a look at implementing my changes on master as well

As soon as I disable the plugin, the duplicates stopped. Tried it a few times and had same behaviour.

For clarity, how I attempted to implement was copying in the 2 files for the plugin, and adding the reference in the other file - essentially the changes shown in github when comparing to develop. I can see when comparing to master, there are a lot(!) more changes than just these.

Okey, that might be the problem then.
Did you run npm install after adding “mqtt” to package.json?

I will try to do some tests against master when I have the time :slight_smile:
Thank you :+1:

I’ve run npm install now. Was still finding duplicate messages coming through. I’ve now set the filter to exclude duplicats, and its running. But, havent yet had any MQTT messages triggered. Have set it for a number of frequent codes and will see what happens

Sounds good.
It looks to be working good for me. I hope it works for you as well :slight_smile:

@krisken lookin into the same needs as you had last year. Just wondering where did you find the simpel webhook plugin screen? You have way more options than I have, following the current documentation you need to add a webhook via automations…

Where did you managed to find all the fields from your webhook screenshot? Thanks in advance.

Hi @snappy

The screenshot I’ve posted here was the configuration screen of the webhook as it is programmed in PagerMon. Not as it is in Home Assistant.

@krisken aai I missed that, thanks for the heads-up!

Returning to this thread as I’ve just implemented some notifications based on MQTT after originally having some troubles.

For context, I am using the simple webhook, then in Node-Red, doing some basic filtering and then publishing to MQTT topics, which I can then select in HA for different automations.

To answer your question on how to extract the alias, message etc, this is shown in the trigger, and reference to trigger in the message data below. If needing to look further, you will want to look at jinja formatting

Below runs 3 actions:

  • iphone notification with specific sound
  • echo show at my desk will announce (though I have low volume and look at the screen). Future edit will break the pagermon message and select what to announce (via node-red adjustment)
  • Flash a lamp in my office
    Like your example, this is for a capcode that I also receive on my pager/app
alias: Pagermon  MQTT to iPhone
description: ""
trigger:
  - platform: mqtt
    topic: pagermon/TOPIC
action:
  - service: notify.mobile_app_iphone
    data:
      title: "{{ trigger.payload_json.agency }} {{ trigger.payload_json.alias }}"
      message: |
        {{ trigger.payload_json.message }}
        At: {{ trigger.payload_json.timestamp }}
      data:
        push:
          sound: News_Flash.caf
  - service: notify.alexa_media_echo_show_5_2nd_gen
    data:
      title: "{{ trigger.payload_json.agency }} {{ trigger.payload_json.alias }}"
      message: "{{ trigger.payload_json.message }}"
      data:
        type: announce
  - repeat:
      count: 4
      sequence:
        - service: light.turn_on
          target:
            device_id: 123abc
          data:
            rgb_color:
              - 255
              - 0
              - 0
        - delay:
            hours: 0
            minutes: 0
            seconds: 0
            milliseconds: 50
        - service: light.turn_off
          target:
            device_id:
              - 123abc
          data: {}
mode: single