Skip to content

Webhooks

TheYOSH edited this page Dec 8, 2018 · 4 revisions

It is possible to enable 'simple' webhooks. At the notification settings you can specify an url where the data will be posted to in JSON when a notification has triggered.

The webhook url can contain variables like %name% and %state% to translate to a special webhook url.

The data is posted as JSON. And can be read out like this in PHP:

<?php
$raw_json_data = file_get_contents('php://input');
$php_object = json_decode($raw_json_data);
?>

Then you will get a PHP object like this:

object(stdClass)#1 (15) {
  ["water_flow"]=>
  float(0.1)
  ["timer_on_duration"]=>
  int(0)
  ["current_water_flow"]=>
  float(0.1)
  ["timer_off_duration"]=>
  int(0)
  ["hardwaretype"]=>
  string(4) "wemo"
  ["timer_start"]=>
  string(5) "00:00"
  ["timer_enabled"]=>
  bool(false)
  ["current_power_wattage"]=>
  float(33)
  ["state"]=>
  int(100)
  ["address"]=>
  string(12) "192.168.5.55"
  ["id"]=>
  string(32) "52bf5188168c87f6a2389c35a7a189b7"
  ["now"]=>
  string(24) "Thu Dec  6 22:45:30 2018"
  ["timer_stop"]=>
  string(5) "00:00"
  ["power_wattage"]=>
  float(33)
  ["name"]=>
  string(8) "wemotest"
}
Clone this wiki locally