Hallo Tebbie,
Omdat het me niet los liet ben ik eens met andere switches gaan proberen.
Daarbij doet zich wel iets vreemds voor.
Ik was, zo blijkt aan het stoeien met componenten die geen juiste info bleken te verstrekken.
Ik heb inmiddels een aantal schakelaars in het script die worden uitgelezen en ook overeenkomstig een status in Domoticz krijgen. Door de overeenkomstige virtuele switch ook de juist aan/uit opdracht te geven kan ik die ook aan en uit zetten.
Dit gaat op voor ongeveer 60% van mijn schakelaars
Hetgeen me in het begin parte speelde, en nog steeds, is het volgende:
Ik lees de HW uit met browser, en krijg terug van bijvoorbeeld switch id 6 dat de status on is (lamp brand ook)
In domotizc is virtuele schakelaar met dit ID echter uit, en dat geeft dan ook aan.
Dit wordt door hwmon.php niet bijgewerkt.
Zet ik nu in domoticz deze switch op "aan" dan geeft domoticz weer dat de Lamp aan is.
Dat heeft dan geen effect op de lamp, want de lamp was al aan ;-)
Echter, met de volgende cyclus van hwmon werkt deze de switch bij, hij zet de lamp uit.
Terwijl de status die uitgelezen wordt toch echt op ON staat.
Zet ik nu in Domoticz de lamp aan, dan zal in Domoticz overeenkomstig de lamp op "aan" gaan,
de lamp gaat ook echt aan. Maar bij de volgende cyclus van hwmon wordt de schakelaar bijgewerkt, en gaat de lamp uit en werkt ook Domoticz bij met een "uit" symbool.
Dit heb ik met een aantal schakelaars.
Als ik HW uitlees met de browser, ontvang ik voor elke switch de juiste status, alles klopt.
hwmon.php leest met regelmaat ook uit en haalt die statussen op, maar interpreteert sommige juist en sommige net verkeerd om.
Daar snap ik helemaal niks van.
Het gaat wel altijd met dezelfde schakelaars fout en met de zelfde goed.
Hierdoor krijg ik de schakelaars die niet goed zijn ook niet aan de praat.....
Hieronder mijn beide php scripts: (WW is even naar ********** gezet ;-)
Swich ID 6 en switch ID 7 werken bijvoorbeeld net verkeerd om.
Acties via Domoticz beïnvloeden ook andere switches?
Zet ik via Domoticz switch 6 om dan reageren 4 en 5 daar ook op?
Dat gebeurd via HW app op telefoon niet, daar werkt elke switch overeenkomstig de functie en beïnvloed geen andere switches.
Alvast dank voor reactie.
hwmon.php
=========
<?php
//include voor extra functies
include '/home/homewizard/functies.php';
//scherm leegmaken en init vars
system("clear");//scherm leeg maken
$wt1 = '';
$b3 = '';
$t0 = '';
$db1 = '';
echo date('H:i:s')." HWmon is gestart\r\n";
do {
//status HW ophalen ####voer voor WACHTWOORDHW je eigen HW wachtwoord in case sensitive uiteraard.
//voer voor IPHW het ipadres van de HW in
//standaard staat de poort op 80 maar moet je aanpassen als je dat in de settings van HW ook hebt angepast
start:
$status = file_get_contents('http://192.168.10.20:80/********/get-status',true);
if($status === FALSE){echo date('H:i:s')." Verbinding met HW niet gelukt(5 sec pauze)\r\n";sleep(5);goto start;}
if (strlen($status) < 100){goto start;}
$data = json_decode($status,true);
//HW Windmeter
// $w1 = $data['response']['windmeters']['8']['ws']; //windsnelheid
// $w2 = $data['response']['windmeters']['8']['dir'];//windrichting
// $w3 = $data['response']['windmeters']['8']['gu']; //windstoot
// if($wt1 == ''){$wt1 = $w1.$w2.$w3;}
// $wt2 = $w1.$w2.$w3;//samensmelten voor vergelijken verschillen
// if ($wt1 <> $wt2 and $w2 <> ''){
//wind bearing (0-360 richting)
// preg_match_all('!\d+!', $w2, $matches);
// $WB = $matches[0][0];
//wind direction NNE etc
// $WD = trim(preg_replace("/[^A-Z\s]/", "", $w2));
// $ws5 = $w1;
// $wg5 = $w3;
// if($w1 > $w3){$w3b = $w3; $w3 = $w1; $w1 = $w3b;}//als windsnelheid groter is dan de windstoot dan omdraaien
// web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=137&nvalue=0&svalue=".$WB.";".$WD.";".($w1*2.825).";".($w3*2.90).";1;1" );
// }
//HW Zonnepanelen
// $zpn = $data['response']['energylinks']['0']['s1']['po']; //productie nu
// web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=49&nvalue=0&svalue=".$zpn."");
//schakelaars ####het nummer ['0'] tussen ['switches'] en ['status'] voorzien van het id wat je vindt als je
// http://IPHW:80/WACHTWOORDHW/get-sensors uitvoert
// 20 is de IDX van de virtuele schakelaar in Domoticz wat je op de apparaten tab kunt vinden
// Let op 20 staat er driemaal in hieronder ook in de http regel
// Dit verhaal geldt ook voor alle andere devices hieronder (beweging etc)
//LET OP ALLE SENSOREN DIE JE NIET GEBRUIKT UITSTERREN MET // VOOR IEDERE REGEL
$sw = ucfirst($data['response']['switches']['0']['status']);
if ($sw <> (dmw(119,'Status')) and $sw <> '' and time() - strtotime(dmw(119,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=119&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 0 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['1']['status']);
if ($sw <> (dmw(126,'Status')) and $sw <> '' and time() - strtotime(dmw(126,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=126&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 1 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['2']['status']);
if ($sw <> (dmw(121,'Status')) and $sw <> '' and time() - strtotime(dmw(121,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=121&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 2 gesynchroniseerd\r\n";
}
// $sw = ucfirst($data['response']['switches']['3']['status']);
// if ($sw <> (dmw(xxx,'Status')) and $sw <> '' and time() - strtotime(dmw(xxx,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=xxx&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 3 gesynchroniseerd\r\n";
// }
$sw = ucfirst($data['response']['switches']['4']['status']);
if ($sw <> (dmw(122,'Status')) and $sw <> '' and time() - strtotime(dmw(122,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=122&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 4 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['5']['status']);
if ($sw <> (dmw(123,'Status')) and $sw <> '' and time() - strtotime(dmw(123,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=123&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 5 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['6']['status']);
if ($sw <> (dmw(124,'Status')) and $sw <> '' and time() - strtotime(dmw(124,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=124&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 6 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['7']['status']);
if ($sw <> (dmw(125,'Status')) and $sw <> '' and time() - strtotime(dmw(125,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=125&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 7 gesynchroniseerd\r\n";
}
// $sw = ucfirst($data['response']['switches']['8']['status']);
// if ($sw <> (dmw(126,'Status')) and $sw <> '' and time() - strtotime(dmw(126,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=126&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 8 gesynchroniseerd\r\n";
// }
$sw = ucfirst($data['response']['switches']['9']['status']);
if ($sw <> (dmw(127,'Status')) and $sw <> '' and time() - strtotime(dmw(127,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=127&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 9 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['10']['status']);
if ($sw <> (dmw(128,'Status')) and $sw <> '' and time() - strtotime(dmw(128,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=128&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 10 gesynchroniseerd\r\n";
}
// $sw = ucfirst($data['response']['switches']['11']['status']);
// if ($sw <> (dmw(xxx,'Status')) and $sw <> '' and time() - strtotime(dmw(xxx,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=xxx&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 11 gesynchroniseerd\r\n";
// }
// $sw = ucfirst($data['response']['switches']['12']['status']);
// if ($sw <> (dmw(141,'Status')) and $sw <> '' and time() - strtotime(dmw(141,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=141&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 12 gesynchroniseerd\r\n";
// }
// $sw = ucfirst($data['response']['switches']['13']['status']);
// if ($sw <> (dmw(xxx,'Status')) and $sw <> '' and time() - strtotime(dmw(xxx,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=xxx&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 13 gesynchroniseerd\r\n";
// }
$sw = ucfirst($data['response']['switches']['14']['status']);
if ($sw <> (dmw(130,'Status')) and $sw <> '' and time() - strtotime(dmw(130,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=130&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 14 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['15']['status']);
if ($sw <> (dmw(131,'Status')) and $sw <> '' and time() - strtotime(dmw(131,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=131&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 15 gesynchroniseerd\r\n";
}
// $sw = ucfirst($data['response']['switches']['16']['status']);
// if ($sw <> (dmw(xxx,'Status')) and $sw <> '' and time() - strtotime(dmw(xxx,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=xxx&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 16 gesynchroniseerd\r\n";
// }
$sw = ucfirst($data['response']['switches']['17']['status']);
if ($sw <> (dmw(132,'Status')) and $sw <> '' and time() - strtotime(dmw(132,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=132&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 17 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['18']['status']);
if ($sw <> (dmw(143,'Status')) and $sw <> '' and time() - strtotime(dmw(143,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=143&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 18 gesynchroniseerd\r\n";
}
// $sw = ucfirst($data['response']['switches']['19']['status']);
// if ($sw <> (dmw(xxx,'Status')) and $sw <> '' and time() - strtotime(dmw(xxx,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=xxx&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 19 gesynchroniseerd\r\n";
// }
$sw = ucfirst($data['response']['switches']['20']['status']);
if ($sw <> (dmw(144,'Status')) and $sw <> '' and time() - strtotime(dmw(144,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=144&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 20 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['21']['status']);
if ($sw <> (dmw(146,'Status')) and $sw <> '' and time() - strtotime(dmw(146,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=146&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 21 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['22']['status']);
if ($sw <> (dmw(145,'Status')) and $sw <> '' and time() - strtotime(dmw(145,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=145&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 22 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['23']['status']);
if ($sw <> (dmw(147,'Status')) and $sw <> '' and time() - strtotime(dmw(147,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=147&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 23 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['24']['status']);
if ($sw <> (dmw(148,'Status')) and $sw <> '' and time() - strtotime(dmw(148,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=148&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 24 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['25']['status']);
if ($sw <> (dmw(149,'Status')) and $sw <> '' and time() - strtotime(dmw(149,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=149&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 25 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['26']['status']);
if ($sw <> (dmw(139,'Status')) and $sw <> '' and time() - strtotime(dmw(139,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=139&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 26 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['27']['status']);
if ($sw <> (dmw(150,'Status')) and $sw <> '' and time() - strtotime(dmw(150,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=150&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 27 gesynchroniseerd\r\n";
}
// $sw = ucfirst($data['response']['switches']['28']['status']);
// if ($sw <> (dmw(151,'Status')) and $sw <> '' and time() - strtotime(dmw(151,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=151&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 28 gesynchroniseerd\r\n";
// }
$sw = ucfirst($data['response']['switches']['29']['status']);
if ($sw <> (dmw(152,'Status')) and $sw <> '' and time() - strtotime(dmw(152,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=152&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 29 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['30']['status']);
if ($sw <> (dmw(153,'Status')) and $sw <> '' and time() - strtotime(dmw(153,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=153&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 30 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['31']['status']);
if ($sw <> (dmw(116,'Status')) and $sw <> '' and time() - strtotime(dmw(116,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=116&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 31 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['32']['status']);
if ($sw <> (dmw(154,'Status')) and $sw <> '' and time() - strtotime(dmw(154,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=154&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 32 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['33']['status']);
if ($sw <> (dmw(155,'Status')) and $sw <> '' and time() - strtotime(dmw(155,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=155&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 33 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['34']['status']);
if ($sw <> (dmw(156,'Status')) and $sw <> '' and time() - strtotime(dmw(156,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=156&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 34 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['35']['status']);
if ($sw <> (dmw(140,'Status')) and $sw <> '' and time() - strtotime(dmw(140,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=140&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 35 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['36']['status']);
if ($sw <> (dmw(157,'Status')) and $sw <> '' and time() - strtotime(dmw(157,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=157&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 36 gesynchroniseerd\r\n";
}
$sw = ucfirst($data['response']['switches']['37']['status']);
if ($sw <> (dmw(158,'Status')) and $sw <> '' and time() - strtotime(dmw(158,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=158&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 37 gesynchroniseerd\r\n";
}
// $sw = ucfirst($data['response']['switches']['38']['status']);
// if ($sw <> (dmw(159,'Status')) and $sw <> '' and time() - strtotime(dmw(159,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=159&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 38 gesynchroniseerd\r\n";
// }
$sw = ucfirst($data['response']['switches']['39']['status']);
if ($sw <> (dmw(160,'Status')) and $sw <> '' and time() - strtotime(dmw(160,'LastUpdate')) > 15)
{web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=160&switchcmd=".$sw."");
echo date('H:i:s')." Schakelaar 39 gesynchroniseerd\r\n";
}
// $sw = ucfirst($data['response']['switches']['40']['status']);
// if ($sw <> (dmw(xxx,'Status')) and $sw <> '' and time() - strtotime(dmw(xxx,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=xxx&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 40 gesynchroniseerd\r\n";
// }
// $sw = ucfirst($data['response']['switches']['41']['status']);
// if ($sw <> (dmw(xxx,'Status')) and $sw <> '' and time() - strtotime(dmw(xxx,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=xxx&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 41 gesynchroniseerd\r\n";
// }
// $sw = ucfirst($data['response']['switches']['42']['status']);
// if ($sw <> (dmw(161,'Status')) and $sw <> '' and time() - strtotime(dmw(161,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=161&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 42 gesynchroniseerd\r\n";
// }
// $sw = ucfirst($data['response']['switches']['43']['status']);
// if ($sw <> (dmw(162,'Status')) and $sw <> '' and time() - strtotime(dmw(162,'LastUpdate')) > 15)
// {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=162&switchcmd=".$sw."");
// echo date('H:i:s')." Schakelaar 43 gesynchroniseerd\r\n";
// }
//Deurbel [0]
// $sw = $data['response']['kakusensors']['0']['status'];
// if ($db1 == ''){$db1 = 'no';}
// if ($sw <> $db1 and $sw == 'no') {web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=56&switchcmd=Off");}
// if ($sw <> $db1 and $sw == 'yes'){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=56&switchcmd=On");
// }
$db1 = $sw;
////bewegingsmelders en deurcontacten##############################################
//Beweging [6]
// $se = $data['response']['kakusensors']['6']['status'];
// if (dmw(50,'Status') == 'Off' and $se == 'yes'){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=50&switchcmd=On");}
// if (dmw(50,'Status') == 'On' and $se == 'no'){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=50&switchcmd=Off");}
////Deurcontacten [5]
// $ts = $data['response']['kakusensors']['5']['timestamp'];
// if ($b3 == ''){$b3 = $ts;}//bij opnieuw starten van script de variabelen vullen
// if ($ts <> $b3 and $ts <> ''){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=52&switchcmd=On");}
// $b3 = $ts;
////verwarming stookt
// $vst = ucfirst($data['response']['heatlinks']['0']['heating']);
// if ($vst <> dmw(62,'Status') and $vst <> ''){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=62&switchcmd=".$vst."" );}
//cv ketel pomp draait
// $kpd = ucfirst($data['response']['heatlinks']['0']['pump']);
// if ($kpd <> dmw(67,'Status') and $kpd <> ''){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=67&switchcmd=".$kpd."" );}
//cv ketel doouche/warm water
// $dww = ucfirst($data['response']['heatlinks']['0']['dhw']);
// if ($dww <> dmw(66,'Status') and $dww <> ''){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=66&switchcmd=".$dww."" );}
////regen
// $rvd = $data['response']['rainmeters']['0']['mm'];
// web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=63&nvalue=0&svalue=0;".($rvd));
////Stroom
// $stv = $data['response']['energylinks']['0']['used']['dayTotal']; //dagtotaal
// $sta = $data['response']['energylinks']['0']['used']['po']; //actueel
// if(is_numeric($stv) and is_numeric($sta)){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=34&nvalue=0&svalue=".$sta.";".($stv*1000)."" );}//Stroom echt tt verbruik
////Stroom Enexis
// $stev = $data['response']['energylinks']['0']['aggregate']['dayTotal']; //dagtotaal
// $stea = $data['response']['energylinks']['0']['aggregate']['po']; //actueel
// if(is_numeric($stev) and is_numeric($stea)){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=117&nvalue=0&svalue=".$stea.";".($stev*1000)."" );}
////Thermometers
// $t0t = $data['response']['thermometers']['0']['te'];
// $t0l = $data['response']['thermometers']['0']['hu'];
// if ($t0 == ''){$t0 = $t0t.$t0l;}
// $t0b = $t0t.$t0l;
// if($t0b <> $t0 and is_numeric($t0t))
// {
// if ($t0l < 40){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=138&nvalue=0&svalue=".$t0t.";".$t0l.";2" );}
// if ($t0l > 60){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=138&nvalue=0&svalue=".$t0t.";".$t0l.";3" );}
// if ($t0l > 39 and $t0l <61){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=138&nvalue=0&svalue=".$t0t.";".$t0l.";1" ); }
// $t0 = $t0t.$t0l;
//Temp CV Kamertemperatuur
// $t5t = $data['response']['heatlinks']['0']['rte'];
// if($t5t <> dmw(90,'Temp')){web('n',"http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=90&nvalue=0&svalue=".$t5t."" );}
//pauzeren om HW niet te veel te belasten
sleep (10);
} while ($i = -1);
?>
Functies.php
==========
<?php
//Geeft de waarde terug van het device in Domoticz
function dmw($idx,$index)
{
$stat = file_get_contents("http://127.0.0.1:8080/json.htm?type=devices&rid=".$idx."");
$stat = json_decode($stat,true);
$stat = $stat['result'][0];
$wd = $stat[$index];
return $wd;
}
//Domoticz schakelaar besturen
function dms($idx,$actie,$return)//welk device en wat is de actie On/Off
{
$e = '';
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2("http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=".$idx."&switchcmd=".$actie."",HTTP_Request2::METHOD_GET);
try {
$response = $request->send();
if (200 == $response->getStatus() and ($return == 'j' || $return == 'J')) {echo $response->getBody();}
if (200 <> $response->getStatus())
{
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
} catch (HTTP_Request2_Exception $e) {echo 'Error: ' . $e->getMessage();}
}
//HTTP Request
function web($return,$url)//wel of geen (j/n) echo melding van de request en de url
{
$e = '';
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2($url, HTTP_Request2::METHOD_GET);
try {
$response = $request->send();
if (200 == $response->getStatus() and ($return == 'j' || $return == 'J')) {echo $response->getBody();}
if (200 <> $response->getStatus())
{
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
} catch (HTTP_Request2_Exception $e) {echo 'Error: ' . $e->getMessage();}
}
//VERW Verwarming temp instellen----------------------------------------------------------------------------------
//voer voor WACHTWOORDHW je eigen HW wachtwoord in case sensitive uiteraard.
//voer voor IPHW het ipadres van de HW in
//standaard staat de poort op 80 maar moet je aanpassen als je dat in de settings van HW ook hebt angepast
function verw($temp,$meld)//Verwarming temp instellen
{
require_once 'HTTP/Request2.php';
$url = 'http://192.168.10.20:80/********/hl/0/settarget/'.$temp;
$url = str_replace(' ', '', $url);//spaties tussen url en tempwaarde weghalen
$request = new HTTP_Request2($url, HTTP_Request2::METHOD_GET);
$response = $request->send();
//bericht versturen
if ($meld == 'J'){puso(0,'Verwarming is uit','huidige thermostaat temperatuur: '.$temp.' graden.','None','','');}
}
?>