Skip to content

Commit 3c0ac8b

Browse files
julien-maurelJulien Maurel
authored andcommitted
Update tuya_smart_life.php, add offline status
1 parent eb1f256 commit 3c0ac8b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tuya_smart_life.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
* - Required : Create one http controler per device to control your tuya devices
99
* [VAR1] : id of device (go to smart life app, edit device go to device infos, id is value on "virtual id"
1010
* Values :
11-
* OFF : value 0, url http://localhost/script/?exec=tuya_smart_life.php&actionDeviceId=[VAR1]&actionDeviceValue=0
12-
* ON : value 100, url http://localhost/script/?exec=tuya_smart_life.php&actionDeviceId=[VAR1]&actionDeviceValue=1
11+
* Off : value 0, url http://localhost/script/?exec=tuya_smart_life.php&actionDeviceId=[VAR1]&actionDeviceValue=0
12+
* On : value 100, url http://localhost/script/?exec=tuya_smart_life.php&actionDeviceId=[VAR1]&actionDeviceValue=1
13+
* Offline : masqué, value 200, url http://localhost/script/?exec=tuya_smart_life.php&actionDeviceId=[VAR1]
1314
* - Optional : Create one http sensor to update status of your controlers if you use smart life app to control your tuya devices too
1415
* Url : http://localhost/script/?exec=tuya_smart_life.php&refreshDevices=true
1516
* XPath : /root/status
@@ -34,8 +35,8 @@
3435
);
3536
// Mapping tuya id to eedomus id
3637
$devicesAssoc = array(
37-
'111222333' => '123',
38-
'444555666' => '456',
38+
'123123123' => '321321',
39+
'456456456' => '654654',
3940
);
4041

4142

@@ -213,6 +214,7 @@ function sdk_action($url, $token, $deviceId, $deviceValue) {
213214
foreach ($devicesAssoc as $tuya => $eedomus) {
214215
$value = getValue($eedomus);
215216
$newValue = $devices[$tuya]['data']['state'] ? 100 : 0;
217+
$newValue = $devices[$tuya]['data']['online'] ? $newValue : 200;
216218
if ($value['value'] != $newValue) {
217219
setValue($eedomus, $newValue, false, true);
218220
}

0 commit comments

Comments
 (0)