Page 1 of 2
Improve 433Mhz reliability
Posted: Friday 31 March 2017 20:04
by gerard76
I created this script to improve the reliability of my 433Mhz devices. I hate it when Domoticz thinks something is on, while the receiver never got the signal. Whenever a device changes the script sends the same command another 2 times to make sure the receiver gets it. Because the RFXcom also picks up the signal from my remote, those signals are also multiplied and the reliability improved.
You need to create integer uservariables with the same name as your devices, they are used to prevent getting stuck in a loop.
Code: Select all
commandArray = {}
my_devices = {"Lamp in hoek", "Lamp naast bank", "Lamp naast tv", "Lamp naast kachel", "Lamp bij trap", "TV" }
-- loop through the changed devices
for device_name, device_value in pairs(devicechanged) do
for i, my_device in pairs(my_devices) do
if device_name == my_device then
if device_value == "On" and uservariables[device_name] == 0 then
commandArray['Variable:' .. device_name] = "1"
commandArray[0]={[device_name]='On'} -- send signal again
commandArray[1]={[device_name]='On'} -- and again..
elseif device_value == "Off" and uservariables[device_name] == 1 then
commandArray['Variable:' .. device_name] = "0"
commandArray[0]={[device_name]='Off'} -- send signal again
commandArray[1]={[device_name]='Off'} -- and again..
end
return commandArray
end
end
end
return commandArray
Re: Improve 433Mhz reliability
Posted: Friday 31 March 2017 20:38
by lvsigo
Hi,
Don't lets us manualy create devices...
Do it in the script
http://easydomoticz.com/forum/viewtopic ... ilit=Twice
Re: Improve 433Mhz reliability
Posted: Friday 31 March 2017 21:30
by K3rryBlue
Be carefull, as this will not work well with dimmers.
Sending the on command twice will cause the mayority of dimmers to start the auto dim sequence.
Better sending:
Code: Select all
commandArray[0]={[device_name]='Off'}
commandArray[0]={[device_name]='On'} -- send signal again
commandArray[1]={[device_name]='Off'}
commandArray[1]={[device_name]='On'} -- and again..
Re: Improve 433Mhz reliability
Posted: Friday 31 March 2017 22:08
by zak45
Re: Improve 433Mhz reliability
Posted: Friday 31 March 2017 22:35
by Siewert308SW
Really, using Domo since 2015 and never knew the repeat command.
To be honest... As i searched the chagelog, i think a lot of those added features aren't mentioned in the chagelog and there for unknown to all users.
Re: Improve 433Mhz reliability
Posted: Sunday 02 April 2017 6:56
by gerard76
Nice. Hadn't seen that in the docs. Much cleaner. I changed the user variables to strings containing 'On' and 'Off'. Also saves a few lines of code.
Code: Select all
commandArray = {}
my_devices = {"Lamp in hoek", "Lamp naast bank", "Lamp naast tv", "Lamp naast kachel", "Lamp bij trap", "TV" }
-- loop through the changed devices
for device_name, device_value in pairs(devicechanged) do
for i, device in pairs(my_devices) do
if device_name == device then
if uservariables[device_name] ~= device_value then
commandArray['Variable:' .. device_name] = device_value
commandArray[device_name] = device_value .. ' REPEAT 2 INTERVAL 1'
end
return commandArray
end
end
end
return commandArray
Re: Improve 433Mhz reliability
Posted: Sunday 02 April 2017 11:04
by Mediacj
Thanks for sharing it works great!
Re: Improve 433Mhz reliability
Posted: Sunday 02 April 2017 12:43
by Derik
mmm
Scripting is not my thing.. [ to stupid to understand all this epxert stuff. ]
Only will give sometimes the scripts that i think they are usefull a try..
Also like this one..
Have some devices in the grey places of the RFXcom ...
And i will send them 2 or 3 times a 433 command.
Only how is this script activeted? [ crontab? ]
Where to place?
Is there a time setting? [ each minute or? ]
Can i send more then 2 times??
Working for on and off?
Re: Improve 433Mhz reliability
Posted: Sunday 02 April 2017 20:27
by gerard76
You put it in Domoticz under Setup - More options - Events. Set the pull downs to 'Lua' and the other to 'Device', check the 'activate' mark. Paste the script and change the names to your on/off 433 devices.
You can send more than 2 times, change the 'repeat 2' to 3 or whatever. Remember that 2 means 2 extra times, so 3 total. You have the original signal and then the 2 repeats. I have 5 switchable lights +TV in my living room and the more I repeated the signal the longer it took to turn them all on at once. So pick the lowest number that works for you.
Re: Improve 433Mhz reliability
Posted: Sunday 02 April 2017 21:04
by Derik
Ok will give it a try...
Is the last script in this thread for on and of?
The first script they are separated?
Re: Improve 433Mhz reliability
Posted: Sunday 02 April 2017 21:25
by gerard76
Yes, On and Off.
Do not forget to create the user variables with the same name as your devices under Setup - More Options - User Variables with type string.
Re: Improve 433Mhz reliability
Posted: Sunday 02 April 2017 21:32
by Derik
gerard76 wrote:Do not forget to create the user variables with the same name as your devices under Setup - More Options - User Variables with type string.
This part i do not understand,
Please a screendump of the settings

Re: Improve 433Mhz reliability
Posted: Sunday 02 April 2017 21:54
by gerard76

- user variables example
- Screen Shot 2017-04-02 at 21.53.09.png (54.57 KiB) Viewed 5005 times
Re: Improve 433Mhz reliability
Posted: Sunday 02 April 2017 21:58
by Derik
mm
Thanks
Sorry for my dombo questions..
Only why 1 device on and the other off?
Re: Improve 433Mhz reliability
Posted: Monday 03 April 2017 6:48
by DaWauZ
I dont understand this exactly.
First, I do not have any problems with my rfxcom (-e type) switching things on and off.
Sometimes, I using a remote to put the lights off, and yes, domoticz thinks device is on, but what should this script helps about that?
Is the script triggered by the remote signal, how?
Re: Improve 433Mhz reliability
Posted: Monday 03 April 2017 6:58
by gerard76
@derik that is just the current state of my lights
@DaWauZ this script helps when domoticz sees the signal from the remote, but the lights do not or if you send signals from domoticz. For example if you have a scene to turn on all lights, but sometimes 1 light will not turn on because it missed the signal.This script fixes that.
In your case I would suggest bringing the RFXcom closer to where you use the remote.
Re: Improve 433Mhz reliability
Posted: Monday 03 April 2017 7:08
by DaWauZ
The only problem with my remote, is not the distance but a kaku hotel switching. I using 2 senders behind wall switch, and also domoticz to put that light automatically on. I also have a hand remote for that same light.
I think I used the remote signal for domoticz, but not the 2 of the wall switches.
Re: Improve 433Mhz reliability
Posted: Monday 03 April 2017 7:44
by Derik
Did set a string..
Only what do i need to fill in by value:

- ScreenShot210.jpg (55.45 KiB) Viewed 4953 times
Re: Improve 433Mhz reliability
Posted: Monday 03 April 2017 10:54
by gerard76
Doesn't really matter. The program will fill it out after the first time you switch.
Re: Improve 433Mhz reliability
Posted: Monday 03 April 2017 19:51
by Derik
mm
Got an error:
Code: Select all
2017-04-03 19:48:00.876 Error: EventSystem: in Lua: Extra Schakeling Aan: [string "commandArray = {}..."]:5: bad argument #1 to 'pairs' (table expected, got nil)
This is my setting:

- ScreenShot211.jpg (58.79 KiB) Viewed 4864 times
And:

- ScreenShot212.jpg (86.01 KiB) Viewed 4864 times
Looks there is something wrong