I'm using 2 minimotes.
With pass2php scripting they do exactly what I want depending on variable stuff.
Example button 2 long press: Wake nas, switch kodi on, switch amp on, switch tv on, set amp to input kodi. Switch lights on if dark. Of course all done only when needed.
Code: Select all
<?php
if(apcu_fetch('nas')=='Off')shell_exec('/home/pi/wakenas.sh');
if(apcu_fetch('skodi')=='Off')sw('kodi','On');
if(apcu_fetch('sdenon')=='Off')sw('denon','On');
if(apcu_fetch('stv')=='Off')sw('tv','On');
if($zon<10&&(apcu_fetch('stvled')=='Off'||apcu_fetch('skristal')=='Off')){sw('tvled','On');sw('kristal','On');}
$ctx=stream_context_create(array('http'=>array('timeout'=>2)));
for($x=0;$x<=50;$x++){
usleep(500000);
$denon=json_decode(json_encode(simplexml_load_string(file_get_contents('http://192.168.2.4/goform/formMainZone_MainZoneXml.xml?_='.time(),false,$ctx))),TRUE);
if($denon['ZonePower']['value']!='ON'){
lg('Denon '.$x.' Zonepower != ON');
file_get_contents('http://192.168.2.4/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FON&cmd1=aspMainZone_WebUpdateStatus%2F',false,$ctx);
}else{
if($denon['InputFuncSelect']['value']!='KODI'){
lg('Denon '.$x.' InputFuncSelect != KODI');
file_get_contents('http://192.168.2.4/MainZone/index.put.asp?cmd0=PutZone_InputFunction/DVD',false,$ctx);
}else{
lg('Denon '.$x.' OK');
sleep(1);
file_get_contents('http://192.168.2.4/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FON&cmd1=aspMainZone_WebUpdateStatus%2F&ZoneName=ZONE2',false,$ctx);
break;
}
}
}
button 2 short press: Put kodi in pause and light one of the lights in the kitchen (depending on hour of day). Second push, put kodi in play and switch off other lights downstairs.
Code: Select all
<?php
$kodi=apcu_fetch('skodi');
$wasbak=apcu_fetch('swasbak');
$werkblad=apcu_fetch('swerkblad');
if($kodi=='On'){
$ctx=stream_context_create(array('http'=>array('timeout'=>2)));
file_get_contents('http://192.168.2.7:1597/jsonrpc?request={"jsonrpc":"2.0","id":1,"method":"Player.PlayPause","params":{"playerid":1}}',false,$ctx);
$properties=json_decode(file_get_contents('http://192.168.2.7:1597/jsonrpc?request={"jsonrpc":"2.0","method":"Player.GetProperties","id":1,"params":{"playerid":1,"properties":["playlistid","speed","position","totaltime","time","audiostreams","currentaudiostream","subtitleenabled","subtitles","currentsubtitle"]}}',false,$ctx),true);
if(!empty($properties['result'])){
$prop=$properties['result'];
if($prop['speed']==0){
if($zon<100){
if(time>strtotime('7:00')&&time<strtotime('21:00')){
if($wasbak=='Off')sw('wasbak','On');
}else{
if($werkblad=='Off')sw('werkblad','On');
}
}
}
else andereuit();
}
}else{
if($wasbak=='On'||$werkblad=='On')andereuit();
else{
if($zon<100){
if(time>strtotime('7:00')&&time<strtotime('21:00')){
if($wasbak=='Off')sw('wasbak','On');
}else{
if($werkblad=='Off')sw('werkblad','On');
}
}
}
}
function andereuit(){
$items=array('pirkeuken','pirgarage','pirinkom','pirhall');
foreach($items as $item)
if(apcu_fetch('s'.$item)!='Off')
ud($item,0,'Off');
$items=array('eettafel','zithoek','garage','inkom','hall','keuken','werkblad','wasbak','kookplaat');
foreach($items as $item)
if(apcu_fetch('s'.$item)!='Off')
sw($item,'Off');
}
The minimote up stairs handles a sleep switch. One button for sleep, one to wake.
Button 1 sleep:
Code: Select all
<?php
if($status=='On'){
if(apcu_fetch('sachterdeur')!='Open'){sw('deurbel','On');telegram('Opgelet: Achterdeur open!',false,2);die();}
if(apcu_fetch('sraamliving')!='Closed'){sw('deurbel','On');telegram('Opgelet: Raam Living open!',false,2);die();}
if(apcu_fetch('spoort')!='Closed'){sw('deurbel','On');telegram('Opgelet: Poort open!',false,2);die();}
if(apcu_fetch('sbureeltobi')=='On'){sw('deurbel','On');telegram('Opgelet: bureel Tobi aan!',false,2);die();}
if($Weg!=1){apcu_store('Weg',1);apcu_store('tWeg',time);}
if(apcu_fetch('sGroheRed')=='On')double('GroheRed','Off');
if(apcu_fetch('sdampkap')=='On')double('dampkap','Off');
if(apcu_fetch('sluifel')!='Open')sw('luifel','Off','zonneluifel dicht');
if(!$auto)sw('lichten_auto','On');
if(apcu_fetch('spoortrf')=='On')sw('poortrf','Off');
}
Button 3 wake:
Code: Select all
<?php
if($Weg!=0){apcu_store('Weg',0);apcu_store('tWeg',time);}
if(apcu_fetch('shall')=='Off')sw('hall','On');
Visual confirmation is there. Light upstairs switches off/on to confirm the action.
With scripting, only your imagination is the limit of the system.