ady624 / CoRE

CoRE - Community's own Rule Engine
GNU General Public License v3.0
222 stars 663 forks source link

Bug with relay off commands #55

Open RobinWinbourne opened 8 years ago

RobinWinbourne commented 8 years ago

I have found a bug with the "Turn off", "Toggle" and "Toggle #2" CoRE commands for a dual relay switch.

I am using a Fibaro dual relay (2x2.5kw) which has 2 relay switches in one device. To test I have a setup a simple piston i.e. IF virtual momentary switch changes THEN 'X', no restrictions).

CoRE actions ('X') for "Turn on", "Turn on #2" and "Turn off #2" work perfectly but "Turn off" never works (leaving my gate mag lock open)

In addition, "Toggle" and "Toggle #2" can turn on the corresponding relay switch but a second press never turns them back off.

I note that Rule Machine and Smart Lighting can successfully turn off or toggle switch 1, giving me faith in the community device handler, but as neither can see switch 2, I would prefer to use CoRE alone without having to patch between apps.

I don't need to use toggle so for now I'll write a custom "Off1" command into the device handler which should then show in the action list within CoRE. Would be great if you could look into this though, as others may struggle.

Thanks and keep up the great work!!

ady624 commented 7 years ago

I would start with looking at the logs in that piston - if the DTH is not correctly updating the status, CoRE may simply refuse to run the Turn off because it "thinks" it's already off. If so, you'll see a log line suggesting it is not running the command because the state is already the one you want. There is an option in the piston (advanced options) right after the debugging options to disable command optimizations - this will force the piston to execute all commands regardless of the current device state. See if this is what's going on and let me know please.

RobinWinbourne commented 7 years ago

Logs for the device parses and lists correct state instantly when relay state is changed.

Piston log shows repeated attempts to turn on instead of on / off / on / off (for toggle).

Using 'disable command optimizations' (great feature btw) gets the 'turn off' action working but 'toggle' continues to fail when trying to turn off.

Looking at the CoRE dashboard it would appear that CoRE is not seeing the state change of the relay (it thinks the relay is always off) so I am starting to think the problem lies with the device handler.

On further testing, I see that Rule Machine cannot see the state change either, but it can turn off switch 1, I assume Rule Machine (being much more basic) does not have command optimizations.

I am using this DH:

https://github.com/mellbratt/smartthings/blob/master/fibaro-relay-switch-2x15kw.groovy

Can you see anything wrong in the DH that could be causing CoRE to miss the state changes?

I note (forgot when writing the original post above) that I had added capability "switch" to mellbratt's code in order for Rule machine to see the relay. I have now tried the original code with CoRE but it still fails to see the state change.

Any help you can give on this would be appreciated!!

P.S. How can I send you donations? CoRE has changed everything for me and the Community needs a way to pay you back for all your time and effort!!!

Thanks relay log

Robin