-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmetrics
37 lines (28 loc) · 946 Bytes
/
metrics
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
* This is terrible. But it is simple and works. So it shall be.
*/
# Environment variables.
$hostname = getenv('SHELLY_HOSTNAME');
# For shelly "plus" branded relays, set this to "2", otherwise, specify "1" (or don't specify at all)
$generation = getenv('SHELLY_GENERATION');
# Some shelly relays have multiple switches (such as the 2PM), this allows you to select which one you want
# This can be left on the default of "0" for any relays that only have a single switch (such as the shelly plug or shelly 1PM)
$switch_id = getenv('SHELLY_SWITCH_ID');
if ($generation === false) {
$generation = 1;
}
if ($switch_id === false) {
$switch_id = 0;
}
# For simplicity's sake, I've broken up the two different api accesses into different files for my own peace of mind
header("Content-Type: text/plain");
switch ($generation) {
case 1:
require "shellygen1";
break;
case 2:
require "shellygen2";
break;
}
?>