New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Isy binding #109
Isy binding #109
Conversation
: also fix one more instance of list of variable being empty
adding older style inline lync's to definition
Support for Insteon Smoke bridge to Onelink Smoke Alarms https://www.smarthome.com/insteon-2982-222-smoke-bridge.html
initial cut for venstar thermostat (potentially others too)
venstar thermostat
|
||
public class IsyHandlerBuilder { | ||
|
||
IsyDeviceHandler handler; | ||
|
||
protected IsyHandlerBuilder(Thing thing) { | ||
this.handler = new IsyDeviceHandler(thing); | ||
// for thermostat, return a specialized handler based on type UID | ||
if (IsyBindingConstants.VENSTAR_THERMOSTAT_THING_TYPE.equals(thing.getThingTypeUID())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to not add the thermo support to this builder. I created this builder so we could use a generic handler for most of the isy items. However thermostats are quite the beast on their own, and you underestandably you created the specific handler. In the handler factory I would just instantiate the handler you wrote, and then you could embed all that channel mapping right into the handler class, instead of creating it and passing in to the builder. Make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I wasn't too happy about this choice myself - it was basically the fastest way to get that handler created. I'll change it to what you say here, just give me a couple days.
// (TH) POTENTIAL HACK | ||
// it would be nice to restart the web socket to the ISY after discovery is done | ||
// the web socket is started to early, before any isy "things" are created, thus the initial ws update from the | ||
// isy is missed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TH, I have done quite a bit of work on a couple other bindings since I started this one. There is a channelLinked method (I think in thing handler chain of hierarchy) which can be overridden and we can query the ISY for initial updates when items are discovered. I spend a good bit of the year away from my house which has the isy so I have fallen behind on refactoring this binding until I get back there. I will be returning to that house early jan so can get started soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specifically, you can override channelLinked within the handler. This method gets called whenever a channel is linked to an item, so then you get the info from the isy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I noticed on the ISY is that the websocket (on initial connect) spits out device information that I cannot get on the REST interface. I'm not sure if that's intended or a bug on the ISY side.
Just throwing this in: If the web service handler could keep the information from the initial contact (organized by insteon address, perhaps) and then forward that information as a update to the device on "channelLinked", that would be the best option I think (but probably also the hardest to implement)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s interesting. Never thought about all that other info maybe because I hadn’t got to wanting to use it. Do you mean things like ramp rate, on level, etc for lights for example? I haven’t used my isy now in 6 mos so a little rusty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I noticed is a field called "UOM" (you may see some commented references in the code), which is only send on the initial websocket connect. I believe that's the current unit setting for the thermostat, which I should probably consider (need to read some more on the thermo doc's). I may have to do a different conversion based on that setting, but for now it's lost and I don't see it in the (browseable) REST interface. Not sure what else is sent that isn't part of what can be seen on the REST side
IsyHandlerBuilder see discussion: QuailAutomation#109 (comment)
@@ -118,7 +119,7 @@ protected ThingHandler createHandler(Thing thing) { | |||
.addChannelforDeviceId(CHANNEL_SMOKEDETECT_LOWBAT, 6) | |||
.addChannelforDeviceId(CHANNEL_SMOKEDETECT_MALFUNCTION, 7).build(); | |||
} else if (thingTypeUID.equals(VENSTAR_THERMOSTAT_THING_TYPE)) { | |||
return IsyHandlerBuilder.builder(thing).addChannelforDeviceId(CHANNEL_VENSTAR_MAIN, 1) | |||
return VenstarThermostatHandlerBuilder.builder(thing).addChannelforDeviceId(CHANNEL_VENSTAR_MAIN, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thomas. I may have confused you with my suggestion before. I don't think we need a builder for the Thermo handler. I think within the handler factory you should just instantiate the thermostat handler directly.
eg. return new VenstarThemostatHandler(thing)
I just used that builder pattern because for a lot of the isy devices, it is really just handling on/off commands, so I went the route of creating generic code. For the thermostat, I think you need a custom handler as you have written.
Here is an example of the factory for another binding I worked on with one of the more prolific committers for Openhab. Check out how we just directly instantiate the handlers based on the thing type. this would eliminate your thermo builder class, and all that channel mapping which is done for the more generic isy handlers would just be encapsulated within the thermostat handler.
Let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the problem is that the Venstar is a mix between the two - one channel is special, the remaining 3 are handled like any other you already implemented. One reason I followed your pattern is that I don't know if any other Thermos use the same channel id's for channels handled the standard way (which then could be adapted in that factory for that new device) Alternatively, we could just create another class for any new thermo device.
But I guess you're right, we could worry about that when that actually comes up. I'll make a change to just set everything up in the handler ctor for now..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, 3rd is a charm (I hope :) )
Commit 7a8f194
Thanks Thomas. I realize this is more difficult on you because there isn’t
a clear pattern used for the more sophisticated handlers.
That omnilink binding is a really good reference that I will be refactoring
this binding to look more like when I get back to my isy, which will be
within 2 months.
Cheers,
Craig
…On Sun, Nov 19, 2017 at 5:24 PM Thomas Hentschel ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
addons/binding/org.openhab.binding.isy/src/main/java/org/openhab/binding/isy/handler/IsyHandlerFactory.java
<#109 (comment)>
:
> @@ -118,7 +119,7 @@ protected ThingHandler createHandler(Thing thing) {
.addChannelforDeviceId(CHANNEL_SMOKEDETECT_LOWBAT, 6)
.addChannelforDeviceId(CHANNEL_SMOKEDETECT_MALFUNCTION, 7).build();
} else if (thingTypeUID.equals(VENSTAR_THERMOSTAT_THING_TYPE)) {
- return IsyHandlerBuilder.builder(thing).addChannelforDeviceId(CHANNEL_VENSTAR_MAIN, 1)
+ return VenstarThermostatHandlerBuilder.builder(thing).addChannelforDeviceId(CHANNEL_VENSTAR_MAIN, 1)
Well, the problem is that the Venstar is a mix between the two - one
channel is special, the remaining 3 are handled like any other you already
implemented. One reason I followed your pattern is that I don't know if any
other Thermos use the same channel id's for channels handled the standard
way (which then could be adapted in that factory for that new device)
Alternatively, we could just create another class for any new thermo device.
But I guess you're right, we could worry about that when that actually
comes up. I'll make a change to just set everything up in the handler ctor
for now..
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#109 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AK5qXronOJxRW_wLKnAFJvsBBc7eb0dWks5s4NTJgaJpZM4Qf_fN>
.
|
Craig, yea, no problem, I think I can see your intend of trying to keep that handler factory from becoming too unwieldy (esp. for cases where it's not really needed). |
https://github.com/QuailAutomation/openhab2-addons into QuailAutomation-isy-binding
merged upstream, so should be able to apply pull request |
Thanks for the changes Thomas. Please test this build, I can't. |
I will advise when the build is complete |
build is done, is avail via marketplace or s3 download link |
Ok, installed via marketplace, everything looks good, poked around in some of the devices after install. Discovery works well here, and actuation of items as well. One snag I ran into (and that doesn't have to do anything with the build): I had created a prior add-on build for testing on my RPi via 'mvn clean package' and dropped that build into the 'add-on' directory of ohab. It appears that the marketplace add-on install and the install via 'add-on' doesn't work too well together yet. As a result I saw a similar error as someone had posted on the UDI forum (https://forum.universal-devices.com/topic/21026-isy-binding-for-openhab-2/?p=207562), which could explain the issue seen back then. Anyway, stopping the service, removing the build in 'add-ons' and restarting the service got things going again with the build installed from the marketplace. |
pull request for:
Venstar Thermostat has all functionality, just need to find a way to get a choice (selection) thing going in paper UI. For now, just set thermostat mode + fan setting with the same strings as the drop-downs in the UDI isy994 management console.
The venstar has a problem in that it may take a few tries to get all the states updated. This is even visible in the UDI management console, sometimes some of the states there are blank.
I don't have one of the newer smarthome thermostats, but I believe the venstar functionality should be adaptable (need type UID for those)
Thanks,
-Th