-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.php
152 lines (137 loc) · 3.78 KB
/
install.php
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/* This file is part of Jeedom.
*
* Jeedom is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Jeedom is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
*/
require_once dirname(__FILE__) . '/../../../core/php/core.inc.php';
function wes_install() {
$cron = cron::byClassAndFunction('wes', 'daemon');
if (!is_object($cron)) {
$cron = new cron();
$cron->setClass('wes');
$cron->setFunction('daemon');
$cron->setEnable(1);
$cron->setDeamon(1);
$cron->setTimeout(1440);
$cron->setSchedule('* * * * *');
$cron->save();
}
config::save('temporisation_lecture', 60, 'wes');
$cron->start();
}
function wes_update() {
$analogiques = eqLogic::byType('wes_analogique');
$boutons = eqLogic::byType('wes_bouton');
$compteurs = eqLogic::byType('wes_compteur');
$pinces = eqLogic::byType('wes_pince');
$relais = eqLogic::byType('wes_relai');
$teleinfos = eqLogic::byType('wes_teleinfo');
$temperatures = eqLogic::byType('wes_temperature');
$wess = eqLogic::byType('wes');
foreach ($wess as $wes){
if(isObject($wes)){
$wes->setEqType_name('wes');
if($wes-getConfiguration('type') == null || $wes-getConfiguration('type') == ""){
$wes->setConfiguration('type','general');
}
$wes->save();
}
}
foreach ($analogiques as $analogique){
if(isObject($analogique)){
$analogique->setEqType_name('wes');
$analogique->setConfiguration('type','analogique');
$analogique->save();
}
}
foreach ($boutons as $bouton){
if(isObject($bouton)){
$bouton->setEqType_name('wes');
$bouton->setConfiguration('type','bouton');
$bouton->save();
}
}
foreach ($compteurs as $compteur){
if(isObject($compteur)){
$compteur->setEqType_name('wes');
$compteur->setConfiguration('type','compteur');
$compteur->save();
}
}
foreach ($relais as $relai){
if(isObject($relai)){
$relai->setEqType_name('wes');
$relai->setConfiguration('type','relai');
$relai->save();
}
}
foreach ($pinces as $pince){
if(isObject($pince)){
$pince->setEqType_name('wes');
$pince->setConfiguration('type','pince');
$pince->save();
}
}
foreach ($teleinfos as $teleinfo){
if(isObject($teleinfo)){
$teleinfo->setEqType_name('wes');
$teleinfo->setConfiguration('type','teleinfo');
$teleinfo->save();
}
}
foreach ($temperatures as $temperature){
if(isObject($temperature)){
$temperature->setEqType_name('wes');
$temperature->setConfiguration('type','temperature');
$temperature->save();
}
}
$cron = cron::byClassAndFunction('wes', 'pull');
if (is_object($cron)) {
$cron->stop();
$cron->remove();
}
$cron = cron::byClassAndFunction('wes', 'cron');
if (is_object($cron)) {
$cron->stop();
$cron->remove();
}
$daemon = cron::byClassAndFunction('wes', 'daemon');
if (!is_object($daemon)) {
$daemon = new cron();
$daemon->setClass('wes');
$daemon->setFunction('daemon');
$daemon->setEnable(1);
$daemon->setDeamon(1);
$daemon->setTimeout(1440);
$daemon->setSchedule('* * * * *');
$daemon->save();
$daemon->start();
}
else
{
wes::deamon_start();
}
config::save('temporisation_lecture', 60, 'wes');
foreach (eqLogic::byType('wes') as $eqLogic) {
$eqLogic->save();
}
}
function wes_remove() {
$cron = cron::byClassAndFunction('wes', 'daemon');
if (is_object($cron)) {
$cron->remove();
}
}
?>