Scene/Group control with a remote

Moderator: leecollings

Post Reply
jrich523
Posts: 63
Joined: Monday 18 January 2016 21:43
Target OS: Windows
Domoticz version: 3.5196
Location: Seattle, WA
Contact:

Scene/Group control with a remote

Post by jrich523 »

So I got a minimote and i found the thread and wiki post on its configuration, its working, got all my buttons in there and it works as expected (sorta).

the one thing im having issues with is that i've got a group called bed time, which turns on a group of lights for making my way to bed. I was able to assign the button 1 short press to turn it on by adding it to the "activation" group and that works great. The problem Im having is turning it off (and really its a moot point here since i turn them off as i make my way to bed, but seem important to figure out :) )

Based on the "command" you send in the group, I would imagine i need to create a new group with the command being off but that seems pretty crazy considering the group has an On and Off button in the GUI. Am I over looking something?

What is preventing it from acting like a toggle (group toggle not device toggle, i understand the mess device toggle would cause)

thanks!
[ Domoticz 3.5196 | Win10 | AeoTec Z-Stick Gen5 ]
alexsh1
Posts: 169
Joined: Wednesday 30 September 2015 11:50
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8975
Location: United Kingdom
Contact:

Re: Scene/Group control with a remote

Post by alexsh1 »

Actually, this is an interesting question I was not able to solve with my remote. It only works as "On" for a Group, but not as "Off".
Anyone can help please?
jrich523
Posts: 63
Joined: Monday 18 January 2016 21:43
Target OS: Windows
Domoticz version: 3.5196
Location: Seattle, WA
Contact:

Re: Scene/Group control with a remote

Post by jrich523 »

I was considering looking at tweaking the code a bit to see if i could get the remotes to act as a device, basically forcing it to toggle (since it only sends one command) but I havent had time with work lately. Also im not sure how badly this would break the rules, but it seems like a great use case.
[ Domoticz 3.5196 | Win10 | AeoTec Z-Stick Gen5 ]
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Scene/Group control with a remote

Post by Egregius »

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.
jrich523
Posts: 63
Joined: Monday 18 January 2016 21:43
Target OS: Windows
Domoticz version: 3.5196
Location: Seattle, WA
Contact:

Re: Scene/Group control with a remote

Post by jrich523 »

Can you speak to the config of it?
I tried to do some stuff with LUA but was unable to because it doesnt show up as a changed device so i could never detect the On event from the remote. Its been a little bit since i looked at it, but i also considered just assigning it to an empty group/scene (not sure which yet) and then capture the scene change in LUA to do what i want. The scripting part is easy, its capturing the trigger which turned out to be rather tough.
[ Domoticz 3.5196 | Win10 | AeoTec Z-Stick Gen5 ]
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Scene/Group control with a remote

Post by Egregius »

No special config is aplied to the device. After including all buttons pressed and they appeared as switches. I just capture the name of the switch to choose wich script has to be run.
To be clear: above code isn't lua but php.
jrich523
Posts: 63
Joined: Monday 18 January 2016 21:43
Target OS: Windows
Domoticz version: 3.5196
Location: Seattle, WA
Contact:

Re: Scene/Group control with a remote

Post by jrich523 »

Yeah i have yet to play with php scripts, but i would imagine it has the same issue if the remote cant trigger an event, which was the issue in LUA. basically when i inspected the deviceChanged it was never listed in there.

Can you provide some directions or a link on how to set up these scripts? when i look at the PHP stuff on the wiki its just scripts, cant seem to find any directions on how to use php scripts.

thanks!
[ Domoticz 3.5196 | Win10 | AeoTec Z-Stick Gen5 ]
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Scene/Group control with a remote

Post by Egregius »

Search for pass2php ;)
jrich523
Posts: 63
Joined: Monday 18 January 2016 21:43
Target OS: Windows
Domoticz version: 3.5196
Location: Seattle, WA
Contact:

Re: Scene/Group control with a remote

Post by jrich523 »

So in reading that I found that it is the same as LUA (basically an extension of it) so if the LUA isnt detecting the device change then PHP wont as well. In the scripts you wrote I dont see anything related to the minimotes to say if minimote in devicechanged sort of deal. how are you getting it to trigger only for the minimote button press?
[ Domoticz 3.5196 | Win10 | AeoTec Z-Stick Gen5 ]
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Scene/Group control with a remote

Post by Egregius »

They just do, don't know what to say.
You see them on the switches tab?
And the lastupdate time updates when you press a button?
jrich523
Posts: 63
Joined: Monday 18 January 2016 21:43
Target OS: Windows
Domoticz version: 3.5196
Location: Seattle, WA
Contact:

Re: Scene/Group control with a remote

Post by jrich523 »

oh are you doing it with the "on action" script on the switch device? that makes more sense, i'll have to screw around with that one, thanks!
[ Domoticz 3.5196 | Win10 | AeoTec Z-Stick Gen5 ]
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest