-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMiSwitch.php
More file actions
73 lines (66 loc) · 2.1 KB
/
MiSwitch.php
File metadata and controls
73 lines (66 loc) · 2.1 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/*
* Homegear Xiaomi Smarthome for Homegear with PHP 7.4
* (c) Frank Motzkau 2020
*/
include_once 'MiConstants.php';
include_once 'MiBaseDevice.php';
class MiSwitch extends MiBaseDevice
{
private $_type_id;
public function __construct($config, $model)
{
$this->_model = $model;
switch ($model)
{
case MiConstants::MODEL_SWITCH_V2:
case MiConstants::MODEL_SWITCH:
$this->_type_id = 0x287c;
break;
case MiConstants::MODEL_SWITCH_AQ2:
case MiConstants::MODEL_REMOTE_B1ACN01:
$this->_type_id = 0x287d;
break;
case MiConstants::MODEL_LUMI_SWITCH_AQ3:
case MiConstants::MODEL_SWITCH_AQ3:
$this->_type_id = 0x2878;
break;
default:
$this->_model = MiConstants::MODEL_UNKNOWN;
}
parent::__construct($config);
}
public function getTypeId() { return $this->_type_id; }
public function updateData($hg, $data)
{
parent::updateData($hg, $data);
if (property_exists($data, 'status'))
{
switch ($data->status)
{
case 'click':
$hg->setValue($this->_peerId, 1, 'PRESS_SHORT', TRUE);
break;
case 'long_click_press':
$hg->setValue($this->_peerId, 1, 'PRESS_LONG', TRUE);
break;
case 'long_click_release':
$hg->setValue($this->_peerId, 1, 'PRESS_LONG_RELEASE', TRUE);
break;
case 'double_click':
$hg->setValue($this->_peerId, 1, 'PRESS_DOUBLE', TRUE);
break;
case 'shake':
$hg->setValue($this->_peerId, 1, 'SHAKE', TRUE);
break;
default:
break;
}
}
}
public function updateEvent($hg, $event)
{
//parent::updateEvent($hg, $event);
return FALSE;
}
}