Hi,
I seek some assistance from a community member who is willing to assist me creating webhooks and PHP scripts in IPS.
I want to integrate LOQED in IPS using webhooks. I’ve successfully integrated LOQED with the IFTTT module in IPS, only passing on web request from IPS to IFTTT to LOQED and vice versa. I assume it must be possible to do exactly the same without IFTTT.
The LOQED webhook service supports three different actions; Open, Lock, and Unlock. These actions can be triggered by three different URLs (URLs have been sanatized):
- https://gateway.production.loqed.com/v1/locks/999999/state?lock_api_key=’$api_key’&api_token=’$api_token’&lock_state=OPEN&local_key_id=999999
- https://gateway.production.loqed.com/v1/locks/999999/state?lock_api_key=’$api_key’&api_token=’$api_token’&lock_state=NIGHT_LOCK&local_key_id=999999
- https://gateway.production.loqed.com/v1/locks/999999/state?lock_api_key=’$api_key’&api_token=’$api_token’&lock_state=DAY_LOCK&local_key_id=999999
Right now I’m using three different IFTTT instances in IPS, one for each action.
I was thinking about creating an integer variable with 3 possible values, Open, Lock, and Unlock. Each value would trigger the corresponding URL.
Status updates are POSTed by the LOQED webhook service. I suppose it must be possible to use a webhook in IPS. At the moment I have the following configured in IFTTT (and corresponding IFTTT instance in IPS):
https://999999.ipmagic.de/hook/IFTTT
POST
application/json
{"username":"user","password":"password","objectid":999999,"values":{"JsonPayload":"<<<{{JsonPayload}}>>>"}}
An update of the ‚JsonPayload‘ string variable triggers the following PHP script in IPS:
<?php
$json = GetValue(999999);
$json_arr = json_decode($json, true);
$value1 = explode(',', $json_arr['value1']);
$value1_arr = array();
foreach($value1 as $v){
$t = explode(":", $v);
$value1_arr[trim($t[0])] = trim($t[1]);
}
//print_r($value1_arr);
$state = $value1_arr['State'];
SetValue(999999, $state);
?>
How can I configure webhooks and PHP scripts in IPS to integrate LOQED directly without using IFTTT?
I hope someone can put me in the right direction. Thanks!
(crosspost)
Cheers,
Dennis.