Page 1 of 2

Smarter way of using multiple remotes?!

Posted: Monday 01 February 2016 19:10
by Nebby
So the scenario is, I have an Energenie 4 way power block. The RFXtrx can control it, but cannot 'hear' the remote that comes with it. So, step one, bin the Energenie remote.

Now, I have homeeasy remotes, which are fine with Domoticz / RFX, but can't be learned by the Energenie.

So, I add the devices on the Energenie manually, and get the Energenie to learn the signals from the RFXtrx. Now Domoticz is controlling the devices fine, and I want to add 2 homeeasy remotes.

As far as I can tell, the only way of doing this is to add each button on the remote as a switch, and then add the Energenie devices as sub devices for each of the remotes. The problem with that, is that I then have a total of 12 'switches' on Domoticz for controlling one bank of 4 sockets.

It may be that this is the only way of doing this, and I'll just have to deal with it. But asking here, in case there is a neater way of doing it!

Any thoughts or suggestions welcome!

Re: Smarter way of using multiple remotes?!

Posted: Monday 01 February 2016 20:12
by Nebby
Actually, I don't think I've even understood the slave device idea correctly, as if I add the device I programmed (which itself works fine) as a slave device to a remote button, it doesn't actually turn the device on / off...?

Re: Smarter way of using multiple remotes?!

Posted: Monday 01 February 2016 20:23
by Nebby
Ok, of course I was doing it the wrong way round, corrected that so that the remote is a sub/slave of the lights. The problem I've got is that if you use the remote (slave) to turn the lights on / off nothing happens. I guess that is because one is supposed to teach the device all the remotes that will control it. This Energenie can only use one remote though as far as I can tell, so I basically need the slave device (remote) to tell Domoticz to send the signal for the main device. Is that possible?

Re: Smarter way of using multiple remotes?!

Posted: Monday 01 February 2016 20:53
by niceandeasy
Yes, but you will need to do it with scripting: Blocky or LUA.
In this case, I'd do something like this:
Name your Energenie switches sensible: for example: Corner lamp, Ceiling lamp, Moisturizer, TV lamp. (hey, it's just an example, come on)
Name the switches of your first remote like this: zza Corner lamp, zza Ceiling lamp, zza Moisturizer, zza TV lamp.
Second remote's switches are named zzb Corner lamp, and so on.
A LUA script will run if a switch is triggered which name starts with zz. That script needs to:
Put the incoming command in a local variable.
And the rest of the name (from the 5th char onward) will be the name of the device that needs to be triggered: put that also in a variable.
The script ends with putting these variables in the commandArray, which will be executed by Domoticz.

This simple script allows you to have 26 different remote controls for controlling the same devices. Just keep yourself to the naming convention. No configuring sub/slaves, nothing. The script will take care of it.
The remote control's zz-switches do not need to be on the dashboard. Just leave them in the devices list. (If you're running the beta, you will need to add them, but don't worry, you can hide them.)

Re: Smarter way of using multiple remotes?!

Posted: Monday 01 February 2016 21:22
by niceandeasy
More specific, on the script I mentioned:

Code: Select all

-- Remote control translator
-- Your remote control's switches are named with 'zzX devicename' and not on your Domoticz dashboard
-- Your actor switches are named 'devicename' and are on your Domoticz dashboard

commandArray = {}				-- always start clean
local dev=next(devicechanged)	-- dev will be the device that changed
local cmd=devicechanged[dev]	-- cmd will be the command
if (dev:sub(1,2) == 'zz') then	-- if the dev starts with zz
	local devout=dev:sub(5,-1)	-- devout is dev without the 1st four chars (starting at 5), until the end (-1)
	commandArray[devout]=cmd	-- Put these things in the output
	print(dev)						-- put this in the log
	print(cmd)						-- so you can see if it's working well
	print(devout)					-- remove these if you're sure it works
end								-- end of the if-then-loop
return commandArray				-- return it to Domoticz
(untested, sorry, no time)

Re: Smarter way of using multiple remotes?!

Posted: Monday 01 February 2016 21:23
by Nebby
Great, that sounds logical. New to LUA but used to Python so should be ok. I've modified this from the howto, but not sure about my if statement, as I'm guessing I need to refer to a particular property of the device otherwise it's going to be referencing the device name rather than the state?

Code: Select all

-- ~/domoticz/scripts/lua/script_device_PIRs.lua

commandArray = {}

tc=next(devicechanged)
v=tostring(tc)
if (v:sub(1,2) == 'zz') then
    c=v:sub(5)
    if tc == 'On' then
        commandArray[c] = 'On'
        tmess = c..' On'
    else
        commandArray[c] = 'Off'
        tmess = c..' Off'
    end
    print(tmess)
end
 
return commandArray

Re: Smarter way of using multiple remotes?!

Posted: Monday 01 February 2016 21:43
by Nebby
Ok, I've modified my script to the below... doesn't appear to be running though (tried restarting) - is there something I need to do to make the script active?

Code: Select all

print('My script is running!')

commandArray = {}

tc=next(devicechanged)
cmd=devicechanged[dev]
print(cmd)
v=tostring(tc)
if (v:sub(1,2) == 'zz') then
    c=v:sub(5,-1)
    commandArray[c] = cmd
end

return commandArray

Re: Smarter way of using multiple remotes?!

Posted: Monday 01 February 2016 22:10
by niceandeasy
cmd=devicechanged[dev]
should be:
cmd=devicechanged[tc]

Check your log. I think, print(cmd) would cause an error in this case, because in your script, dev empty, so cmd will be empty / nil

It would be good to put your print-statement in the if-then-end loop, so it will only run when necessary.

Re: Smarter way of using multiple remotes?!

Posted: Monday 01 February 2016 22:24
by Nebby
Yes good point, updated it to the correct var name. Still not actually running the script though, it should at the very least print the first line... how do I active it?

Re: Smarter way of using multiple remotes?!

Posted: Monday 01 February 2016 22:59
by niceandeasy
Well, if there are no errors in the log and it seems that it's not running...

The name of the script must be like script_device_nameofthescript.lua
..and it needs to be in the domotics/scrips/lua directory
In Settings, there's a setting that can disable the event system. Make sure it's enabled.

Re: Smarter way of using multiple remotes?!

Posted: Tuesday 02 February 2016 1:47
by Nebby
What should script_device be, given that there are multiple devices involved?

Re: Smarter way of using multiple remotes?!

Posted: Tuesday 02 February 2016 2:29
by niceandeasy
script_device_xxxxxxxxx.lua
Script is a keyword that Domoticz recognizes as the file being a script. It's mandatory.
Device is a keyword that indicates a device script, which is triggered on a device change. (there's also time scripts and variable scripts)
The underscores are seperators.
xxxxxx is a name you can give your script. Don't use the name demo, because that's also a keyword.
.lua is also mandatory extension. Without it, Domoticz will not look at it.
I suggest that you google for domoticz lua, or look at the wiki at domoticz.com. Sorry for not being clear at my earlier answer.
There should be some scripts in the lua directory already, ending at _demo.lua. There's some useful info in the comments and it's a good starting point. Take a look at script_device_demo.lua.

Re: Smarter way of using multiple remotes?!

Posted: Tuesday 02 February 2016 13:12
by Nebby
Ah that sorted it, thanks - name is now script_device_remotes.lua and placed in the lua directory.

Interestingly, although the script runs regardless of whether I create the remote as a main device, or as a slave device (for neatness), the 'if' statement only activates if it's a main device. I'm trying to figure out why, as the variable seems to be the same in both situations, but there must be some white space or something which is causing it...?

Re: Smarter way of using multiple remotes?!

Posted: Tuesday 02 February 2016 18:31
by niceandeasy
I don't know about whether or not a device should trigger a script when it's a slave device. I've already decided for myself that I'm not using the sub/slave function. It's not compatible with what I need to do. Probably it's explained in the wiki.

Re: Smarter way of using multiple remotes?!

Posted: Tuesday 02 February 2016 20:40
by Nebby
Got it. Thanks for your help niceandeasy, much appreciated.

Re: Smarter way of using multiple remotes?!

Posted: Wednesday 09 March 2016 18:07
by boudicca
Just came across this, was trying to add some energenie ener002-c sockets.

It just clicked when you have a Homeeasy remote. (No pun intended)

0. Set mode on the RFXCOM hardware device in Domoticz to ARC only

1. Put the energenie socket in Learning mode.
2. Press On/off on 1. on the homeeasy remote.
3. The Energenie remote will trigger on/off (and place an entry in the devices list on Domoticz)
4. Rename that device (not essential but easier to know which you have done.)
It should have an entry for example of RFXCOM1--------K----5--------ARC etc

5. It should now trigger as on/off in Domoticz. (Obviously If you have homeeasy devices and are using the remote, it means the remote is now relatively useless (as it will trigger two devices) but I'm not so now I have a Homeeasy Socket and a Energenie socket working independently of each other with a common "Learn" but if you stick to domoticz and rfxcom it doesn't trigger both.

6 Repeat for the other sockets.

Re: Smarter way of using multiple remotes?!

Posted: Wednesday 09 March 2016 18:40
by Nebby
What does ARC do exactly? When I was originally setting this up, I couldn't get the energenie to recognise the Homeeasy remotes at all...?

Re: Smarter way of using multiple remotes?!

Posted: Wednesday 09 March 2016 18:46
by boudicca
haven't got a clue....I assume that's the protocol the Energenie uses. It just works :)......I thought I had bought a "Lemon" but, the mentioning of the Homeeasy remote, Must be similar to AC the one Homeeasy uses but ARC appears in Domoticz when you press the buttons on the homeasy remote when put the Energenie in learn.

As I said yep if you press the homeasy button you will get two sockets on, but in domoticz and I assume rfxcom, they are seperate and can be triggered seperately.
energenie.png
energenie.png (42.39 KiB) Viewed 3349 times

Re: Smarter way of using multiple remotes?!

Posted: Wednesday 09 March 2016 19:22
by Nebby
Awesome, I'll give it a try, thanks! Will have to get access to a PC as I'm Mac, and RFXmgr doesn't run on a VM for some reason - probably can't get the right hardware access to the USB port...

Re: Smarter way of using multiple remotes?!

Posted: Wednesday 09 March 2016 20:18
by boudicca
Just to add I did all this without rfxmgr, only using Domoticz's Hardware Screen - Rfxcom (Set Mode) and Devices screen from the Domoticz webgui on the RPI.