Wed, 04 Mar 2020 10:48:21 +0100
Workaround for hang during startup. Changed order of displayed fields on the yeast tab. Tooltip text changes. More decimals on the checklist for misc ingredients. More decimals for the starter on product print.
581 | 1 | <?php |
2 | ||
3 | require($_SERVER['DOCUMENT_ROOT']."/config.php"); | |
4 | ||
5 | if ($_SERVER['HTTP_USER_AGENT'] == 'ESP8266HTTPClient') { | |
6 | // /usr/bin/mosquitto_pub -h host] [-p port] [-u username [-P password]] -t topic -m message | |
7 | $publisher = '/usr/bin/mosquitto_pub -h '.MQTT_HOST.' -t '; | |
8 | ||
9 | $input = file_get_contents('php://input'); | |
10 | //syslog(LOG_NOTICE, "ispindel " . $input); | |
11 | $data = json_decode($input, true ); | |
12 | $node = 'ispindel-' . sprintf("%06x", floatval($data['ID'])); | |
13 | ||
584
c9101b2eeb6a
Interval is 3600 seconds when running on low battery.
Michiel Broek <mbroek@mbse.eu>
parents:
581
diff
changeset
|
14 | $alarm = 0; |
c9101b2eeb6a
Interval is 3600 seconds when running on low battery.
Michiel Broek <mbroek@mbse.eu>
parents:
581
diff
changeset
|
15 | $interval = $data['interval']; |
c9101b2eeb6a
Interval is 3600 seconds when running on low battery.
Michiel Broek <mbroek@mbse.eu>
parents:
581
diff
changeset
|
16 | if (floatval($data['battery']) < 3.3) { |
c9101b2eeb6a
Interval is 3600 seconds when running on low battery.
Michiel Broek <mbroek@mbse.eu>
parents:
581
diff
changeset
|
17 | $alarm += 4; |
585
fa6e702d0d24
Use the same emergency logic as the iSpindel.
Michiel Broek <mbroek@mbse.eu>
parents:
584
diff
changeset
|
18 | if (($interval * 3) < 3600) |
fa6e702d0d24
Use the same emergency logic as the iSpindel.
Michiel Broek <mbroek@mbse.eu>
parents:
584
diff
changeset
|
19 | $interval = 3600; // at least 3600 seconds when the battery is low. |
fa6e702d0d24
Use the same emergency logic as the iSpindel.
Michiel Broek <mbroek@mbse.eu>
parents:
584
diff
changeset
|
20 | else |
fa6e702d0d24
Use the same emergency logic as the iSpindel.
Michiel Broek <mbroek@mbse.eu>
parents:
584
diff
changeset
|
21 | $interval = $interval * 3; |
584
c9101b2eeb6a
Interval is 3600 seconds when running on low battery.
Michiel Broek <mbroek@mbse.eu>
parents:
581
diff
changeset
|
22 | } |
c9101b2eeb6a
Interval is 3600 seconds when running on low battery.
Michiel Broek <mbroek@mbse.eu>
parents:
581
diff
changeset
|
23 | |
581 | 24 | $uuid = 'c0ffeeee-cafe-dead-beef-' . sprintf("%06x", 0xffffff - floatval($data['ID'])) . sprintf("%06x", floatval($data['ID'])); |
25 | $topic = 'mbv1.0/ispindels/NBIRTH/' . $node; | |
584
c9101b2eeb6a
Interval is 3600 seconds when running on low battery.
Michiel Broek <mbroek@mbse.eu>
parents:
581
diff
changeset
|
26 | $payload = '{"metric":{"uuid":"' . $uuid . '","interval":' . $interval . ','; |
581 | 27 | $payload .= '"properties":{"hardwaremake":"Wemos","hardwaremodel":"D1 mini","os":"Unknown","os_version":"Unknown","FW":"Unknown"},'; |
28 | $payload .= '"net":{"address":"' . $_SERVER['REMOTE_ADDR'] . '","ifname":"sta","rssi":' . $data['RSSI'] . '}}}'; | |
29 | $pub = $publisher . $topic . ' -m \'' . $payload . '\''; | |
30 | exec($pub); | |
31 | ||
32 | $alarm = 0; | |
33 | if (floatval($data['battery']) < 3.3) | |
34 | $alarm += 4; | |
35 | ||
36 | if ($data['temp_units'] == 'K') { | |
37 | $tempC = floatval($data['temperature']) - 273.15; | |
38 | } else if ($data['temp_units'] == 'F') { | |
39 | $tempC = floatval($data['temperature']) / 1.8 - 32; | |
40 | } else { | |
41 | $tempC = floatval($data['temperature']); | |
42 | } | |
43 | ||
44 | $uuid = 'c0ffeeee-cafe-dead-bee0-' . sprintf("%06x", 0xffffff - floatval($data['ID'])) . sprintf("%06x", floatval($data['ID'])); | |
45 | $topic = 'mbv1.0/ispindels/DBIRTH/' . $node; | |
584
c9101b2eeb6a
Interval is 3600 seconds when running on low battery.
Michiel Broek <mbroek@mbse.eu>
parents:
581
diff
changeset
|
46 | $payload = '{"unit":{"uuid":"' . $uuid .'","alias":"' . $data['name'] . '","alarm":' . $alarm . ',"interval":' . $interval; |
581 | 47 | $payload .= ',"angle":' . $data['angle'] . ',"temperature":' . $tempC . ',"battery":' . $data['battery'] . ',"gravity":' . $data['gravity'] . '}}'; |
48 | $pub = $publisher . $topic . ' -m \'' .$payload . '\''; | |
49 | exec($pub); | |
50 | } | |
51 | ||
52 | ?> |