@tmrobert8 Finally found the time to do some testing. What a great job you have done! I have not stress tested it yet, but here are my first findings.
The transport nicely discovered and allowed me to expose all my openHAB lights to NEEO. Great job there. I do notice some issues with lables on the NEEO side, but that may not be because of the transport. For normal light switches, the label on the NEEO is a concatenation of the name given on the NEEO and the name as in the transport. For dimmers, where it shows a slider on the NEEO, the name is just the name given on the NEEO side.
I then went on experimenting with using the NEEO as a zwave controller. I installed my Christmas lights outside and connected it to a Zwave plug. I then went on trying to control this from openHAB, using the binding. This turned out to be a more elaborate exercise than expected.
The Zwave plug is exposed in NEEO as a switch. However, in the binding, I only have 2 macros (to turn on and off) and the overall Brain trigger channel to control it. This forced me to define quite a few roles if I wanted to just have an on/off switch on a sitemap. I may have missed a simpler way to do this, just keen to get your suggestions. Here is the result of my effort:
- defined item: Kerst
- defined 2 items linked to the 2 macro channels: KerstNEEOD487672e_Macros_TurnOn and KerstNEEOD487672e_Macros_TurnOff
- rules file:
rule "NEEO"
when
Channel 'neeo:brain:d487672e:forwardActions' triggered
then
var data = receivedEvent.getEvent()
var String action = transform("JSONPATH", "$.action", data);
var String device = transform("JSONPATH", "$.device", data);
var String room = transform("JSONPATH", "$.room", data);
var String actionparameter = transform("JSONPATH", "$.actionparameter", data);
if ((device == "Kerst") && (room == "Buiten")) {
if (action == "BINARYSWITCH On/Off") {
if (actionparameter == "true") {
Kerst.postUpdate(ON)
} else if (actionparameter == "false") {
Kerst.postUpdate(OFF)
}
} else if (action == "turnOn") {
Kerst.postUpdate(ON)
} else if (action == "turnOff") {
Kerst.postUpdate(OFF)
}
}
end
rule "Kerstverlichting aan"
when
Item Kerst received command ON
then
KerstNEEOD487672e_Macros_TurnOn.send(ON)
end
rule "Kerstverlichting uit"
when
Item Kerst received command OFF
then
KerstNEEOD487672e_Macros_TurnOff.send(ON)
end
rule "reset macro kerst on"
when
Item KerstNEEOD487672e_Macros_TurnOn received command ON
then
// because this is a switch for openHAB, but representing a button, turn it back off
Thread::sleep(200)
KerstNEEOD487672e_Macros_TurnOn.postUpdate(OFF)
end
rule "reset macro kerst off"
when
Item KerstNEEOD487672e_Macros_TurnOff received command ON
then
// because this is a switch for openHAB, but representing a button, turn it back off
Thread::sleep(200)
KerstNEEOD487672e_Macros_TurnOff.postUpdate(OFF)
end
sitemap test label="Test"
{
Frame {
Switch item=Kerst
Switch item=KerstNEEOD487672e_Macros_TurnOn mappings=[ON="ON"]
Switch item=KerstNEEOD487672e_Macros_TurnOff mappings=[ON="OFF"]
}
}
The last 2 lines in the sitemap just work as push buttons.
It looks like everything is in sync this way.
I think the fundamental problem is that I cannot easily get and set the state of the NEEO light in openHAB. The risk with my rules is that it will be out of sync if I restart openHAB, as I do not set the state of the light at startup.
I also think it might be worthwhile to turn of the macro switch in the binding (do a postUpdate), as these are really buttons and not switches. This would avoid a few lines of code above.
As the light is represented as a switch on the NEEO, is there no way to control that switch directly, rather than the on and off macros?
Interested in your view on this.
I am fine leaving the functionality as is right now and focus on debugging. I am willing to contribute towards a next version, but I do think the first focus should be to get the current binding merged.