Welcome to Animus Talk

This is where users of Animus Heart can share ideas,
solve problems and inspire fellow enthusiasts.

Animus Heart?

Set up RPi as Webhook Server (reciever)?

I wonder if someone has setup a Raspberry (pi/zero etc) as a Webhook Server for local network use.

And if so, how did you do it and what software did you use?

I would like to use the webhook in Heart to send signal to my RPi to do stuff.
Either run scripts, add sensordata to file or db.

This would allow the RPi to serve as master for example a bunch of RP Zero’s connected to relays, switches or other devices that are not zwave compatable.


Could this be something?

Sounds like something I want to do, but don’t know how to :slight_smile:

//From: https://stackoverflow.com/questions/48348262/install-go-golang-on-raspbian
//Did: The “$” is to indicate the prompt only.
// Indicates my own comments

// Update lists. I had upgrades, so i did “sudo apt-get upgrade” and rebooted befor installing golang.
$ sudo apt update
$ sudo apt install golang

// my dir is in /home/pi/ so it becomes: /home/pi/go
$ mkdir go

// this sets the path’s for my user “pi” which i’m logged in as.
$ echo ‘export GOPATH=$HOME/go’ >> ~/.profile
$ echo ‘PATH="$HOME/go/bin:$PATH"’ >> ~/.profile

// Log out and back in.
$ go env

// should give you a list of stuff listed on the webpage.
// Look for the exports
$ echo $PATH

// I have “/home/pi/go/bin:/usr/local/sbin:/usr/local/bin:” among other things.

// Time to install GIT. Gets you able to use “go get” for github
// From: https://stackoverflow.com/questions/36044275/golang-go-get-command-showing-go-missing-git-command-error
$ sudo apt-get install git

// For now i get back to the webhook on github.
//From: https://github.com/adnanh/webhook/wiki
$ go get github.com/adnanh/webhook

// This is how far inve gotten so far. Time is short for now.
// Will update as i experiment more.
// My setup is one Heart and one RPi on the same network, no internal firewalls.
// This RPi will not be accessable from the internet, so i took a relaxed firewall on it.
// The RPi is headless, i’m using Bitvise ssh client on windows for all remote stuff on my RPi.

1 Like

More tinkering, alittlebit success

I’m going to assume you know how to create directories and files, and basic file operations.

If you don’t, here’s a short runthru:

As before the $ indicate the prompt.

$ mkdir hook-output

$ mkdir hook-scripts

$ mkdir hooks

$ touch hooks/hooks.json

$ touch hook-scripts/433remote1-key3-on.sh
$ chmod +x hook-scripts433remote1-key3-on.sh

My homedirectory

pi@rpi:~ $ pwd

My go install and additional directories

pi@rpi:~ $ ls -al

Needed filelist (as per my rpi setup, your milage may vary)


#It’s contents:

id = hook-name

execute-command = the script to trigger

“id”: “433remote1-key3-on”,
“execute-command”: “/home/pi/hook-scripts/433remote1-key3-on.sh”,
“command-working-directory”: “/home/pi/hook-output”

Next file:


#It’s contents: It’s the shell she-bang: “#!/bin/sh” in the start to make it find /bin/sh


Now, in your Heart, create an automation.
I have used a Nexa PET-910 remote.

I make the following:
“When REMOTE1-KEY3-ON is pressed” then "Send Webhook: "

Save the automation (i named it hook-r1-k3-on) and watch the history-tab.

Next, you need to start the go-server.
In my system i type:

$ /home/pi/go/bin/webhook -hooks /home/pi/hooks/hooks.json -verbose

And i get some info in the terminal windows:
pi@rpi:~ $ /home/pi/go/bin/webhook -hooks /home/pi/hooks/hooks.json -verbose
[webhook] 2019/06/24 22:42:59 version 2.6.9 starting
[webhook] 2019/06/24 22:42:59 setting up os signal watcher
[webhook] 2019/06/24 22:42:59 attempting to load hooks from /home/pi/hooks/hooks.json
[webhook] 2019/06/24 22:42:59 found 1 hook(s) in file
[webhook] 2019/06/24 22:42:59 loaded: 433remote1-key3-on
[webhook] 2019/06/24 22:42:59 serving hooks on{id}
[webhook] 2019/06/24 22:42:59 os signal watcher ready


I push the remote1 key3 on;
This is the catch by webhook in terminal window:

[webhook] 2019/06/24 22:44:43 [9ad701] incoming HTTP request from
[webhook] 2019/06/24 22:44:43 [9ad701] 433remote1-key3-on got matched
[webhook] 2019/06/24 22:44:43 [9ad701] 433remote1-key3-on hook triggered successfully
[webhook] 2019/06/24 22:44:43 200 | 13.002501ms | | GET /hooks/433remote1-key3-on
[webhook] 2019/06/24 22:44:43 [9ad701] executing /home/pi/hook-scripts/433remote1-key3-on.sh (/home/pi/hook-scripts/433remote1-key3-on.sh) with arguments ["/home/pi/hook-scripts/433remote1-key3-on.sh"] and environment [] using /home/pi/hook-output as cwd
[webhook] 2019/06/24 22:44:43 [9ad701] command output:
[webhook] 2019/06/24 22:44:43 [9ad701] finished handling 433remote1-key3-on

And i go look in the automation activity in Heart:


[[HTTP/1.1 200 OK]]

This indicated the webhook went thru to the server. The info in the terminal window also identifies the incoming hook and processes the script (mind the script is empty for now during testing phase)

If the server rejects or doesnt accept your webhook connection, this shows up in the Hear log:



[Connection refused (Connection refused)]


Tinkering will continue and i kinda need to read up on my programming skills and try to understand what stuff do.

How to pass along info etc.
When i get that far, you can set up RPi’s with HAT’s to do specialized tasks, like relay boards to toggle wateringsystems in garden, flicker lights in a statusboard etc.

Usages; small rpi (or zero) with led or relay-hat that shows you discretely if perimiter motiondetector is triggered or indicate a timer running on device X or indicate an upen doorsensor somewhere.

Oh, and beware that my RPi is not accessable via internet, but my Heart is.
I have therefor not bothered so much with rpi security (yet).

Hope these posts might help someone somewhere.
I will continue to add as i go along.

1 Like

Ok, i tinkered some more.
Added another hook in hooks.json as follows;

Do note the very importand , on line 7 between the curly-bracket blocks.

“id”: “433remote1-key3-on”,
“execute-command”: “/home/pi/hook-scripts/433remote1-key3-on.sh”,
“command-working-directory”: “/home/pi/hook-output”
“id”: “433remote1-key3-off”,
“execute-command”: “/home/pi/hook-scripts/433remote1-key3-off.sh”,
“command-working-directory”: “/home/pi/hook-output”

And here notice how the webhookserver recognizes the two “ID” blocks from hooks.json

pi@rpi:~ $ /home/pi/go/bin/webhook -hooks /home/pi/hooks/hooks.json -verbose
[webhook] 2019/06/24 23:29:50 version 2.6.9 starting
[webhook] 2019/06/24 23:29:50 setting up os signal watcher
[webhook] 2019/06/24 23:29:50 attempting to load hooks from /home/pi/hooks/hooks.json
[webhook] 2019/06/24 23:29:50 found 2 hook(s) in file
[webhook] 2019/06/24 23:29:50 loaded: 433remote1-key3-on
[webhook] 2019/06/24 23:29:50 loaded: 433remote1-key3-off
[webhook] 2019/06/24 23:29:50 serving hooks on{id}
[webhook] 2019/06/24 23:29:50 os signal watcher ready
[webhook] 2019/06/24 23:30:07 [4ec1be] incoming HTTP request from
[webhook] 2019/06/24 23:30:07 [4ec1be] 433remote1-key3-on got matched
[webhook] 2019/06/24 23:30:07 [4ec1be] 433remote1-key3-on hook triggered successfully
[webhook] 2019/06/24 23:30:07 200 | 12.423441ms | | GET /hooks/433remote1-key3-on
[webhook] 2019/06/24 23:30:07 [4ec1be] executing /home/pi/hook-scripts/433remote1-key3-on.sh (/home/pi/hook-scripts/433remote1-key3-on.sh) with arguments ["/home/pi/hook-scripts/433remote1-key3-on.sh"] and environment [] using /home/pi/hook-output as cwd
[webhook] 2019/06/24 23:30:07 [4ec1be] command output:
[webhook] 2019/06/24 23:30:07 [4ec1be] finished handling 433remote1-key3-on
[webhook] 2019/06/24 23:30:10 [182de8] incoming HTTP request from
[webhook] 2019/06/24 23:30:10 [182de8] 433remote1-key3-off got matched
[webhook] 2019/06/24 23:30:10 [182de8] 433remote1-key3-off hook triggered successfully
[webhook] 2019/06/24 23:30:10 200 | 7.276674ms | | GET /hooks/433remote1-key3-off
[webhook] 2019/06/24 23:30:10 [182de8] executing /home/pi/hook-scripts/433remote1-key3-off.sh (/home/pi/hook-scripts/433remote1-key3-off.sh) with arguments ["/home/pi/hook-scripts/433remote1-key3-off.sh"] and environment [] using /home/pi/hook-output as cwd
[webhook] 2019/06/24 23:30:10 [182de8] command output:
[webhook] 2019/06/24 23:30:10 [182de8] finished handling 433remote1-key3-off

And apparantly i have no summertime in my RPi… stuck in winter :slight_smile: