rodtoll / homebridge-isy-js

Homebridge platform plugin for the ISY series of home controllers from Universal Devices.
MIT License
22 stars 27 forks source link

ISY Scenes not supported #2

Closed bmilford closed 8 years ago

bmilford commented 8 years ago

Is it possible to add ISY Scenes (groups in the rest node list response)? I prefer to use scenes to control the devices in order to keep keypad lights in sync.

rodtoll commented 8 years ago

Yes. It's on my wish list/backlog as well. Thanks for entering an issue.

I was thinking of making them appear as dimmable switches. Would that work for your needs?

bmilford commented 8 years ago

Yes. That would work well I think.

Sent from my iPhone

On Dec 9, 2015, at 3:10 PM, rodtoll notifications@github.com wrote:

Yes. It's on my wish list/backlog as well. Thanks for entering an issue.

I was thinking of making them appear as dimmable switches. Would that work for your needs?

— Reply to this email directly or view it on GitHub.

rodtoll commented 8 years ago

Update: Added to base library -- isy-js. Will work it into this project soon. They will appear as lights.

PaulWieland commented 8 years ago

This will be really nice when it's done.

I have a lot of three way dimmer switches in my house - right now each switch shows as a separate device which I then have to organize into a homekit "room" in order to control it and to keep the switches in sync. When I tell Siri to "turn the dining room light off", its actually targeting a room called "dining room light" which contains two accessories - the master and slave switches. Siri then responds "the dining room lights have been turned off" which is of course odd because theres only one light.

Keypads are even worse because LEDs go out of sync with the light state when the light state is changed by homekit. On the ISY, the keypad button and the light switch with the load on it are part of a scene, which keeps their states in sync. Insteon provides no way to change the keypad button's LED backlight so there isn't even a workaround for this right now.

So once scenes are added, I think I will ignore ALL of my devices and have ISY-JS only interact with Insteon scenes.

Maybe this could also be a consideration for the config file... have some booleans for each thing to be loaded: devices, programs, scenes, variables, etc.

rodtoll commented 8 years ago

Scene support has been added. By default scenes are not enumerated and included. Most ISY devices have a LOT of scenes and this would easily tip most installations beyond the 100 device maximum.

To include all scenes in the list of devices, simply set the includeAllScenes value in the config to true and all scenes will be included.

To include just specific scenes add includeAllScenes set to false and set includedScenes to a list of the addresses of the scenes to include. As always to get a scene address you just need to hit http:///rest/nodes and search for the entry in there.

Note that scenes are not dimmable. The ISY does not allow you to issue a DON command to specific brightness. It just turns all the lights on and ignores the dim parameter. It may support increase or decrease dim level but that is not an operation homekit would support. (You could do some kind of emulation, tracking current level and calculating how many increase dim / decrease dim commands you need to send to match what the user wants -- but this is likely to be not very performant to the point of annoyance).

@fahrvergnuugen It's in.

PaulWieland commented 8 years ago

@rodtoll awesome, nice work!

I definitely will definitely test it out when I get a chance!

PaulWieland commented 8 years ago

@rodtoll What do you think about enumerating the devices in the scene in order to support specific brightness commands? I'm going to attempt to make it work but I'm still learning the structure of isy-js. If I'm successful I'll figure out how to turn it into a PR in case you want to merge it.

Anyway, the reason is that I have a lot of scenes setup for three way switches. They look something like this:

All I care about controlling here is the Dining Room Scene. In fact, Homebridge doesn't even need to know about the two dimmer devices/accessories.

Before you added support for ISY Scenes, I worked around this by creating a homekit room called "Dining Room", then added both dimmers to it. "Siri set the dining room light to 50%" works in this case, but her response is strange: "Okay, I set both dining room lights to 50%". Obviously this is because there are two lights in homekit but try explaining that to your wife :)

rodtoll commented 8 years ago

I can make it work by under the covers enumerating the devices and then sending a dim command to each one as you suggest when you dim a scene. I can do that portion of the work easy and in fact have most of it coded.

The weirdness is when you have a scene which includes non-dimmable lights. What do you send to those? Do you include the non-dimmable lights in the dimness level calculation for the scene? Do you turn them on when you set a dim level > 0?

Here is the approach I have partially coded -- dimness level of a scene is calculated against only the dimmable lights. Dim commands set the dim level for dimmable lights. For non-dimmable lights they are turned on when dim level > 0 and off when dimmable to zero. What do you think of that?

PaulWieland commented 8 years ago

@rodtoll I know what you mean. I think there are two choices, and perhaps both should be implemented depending on the kind of on/off device in the scene:

  1. Determine which devices are dimmable and only send the /DON/### level command to those. Ignore the others unless the scene is set to 0%/off or 100%/on.
  2. Send the level command to all devices which will result in the non dimming devices turning on no matter what brightness level is used. I just tested it - if I send a /DON/128 (50% brightness) command to a non-dimmable device, the device turns on. I guess the ISY simply processes the DON part and ignores the level.

I have another scene with a dimmable outlet and a keypad button B. These are part of a scene and the keypad button lights up when the light is on and turns off when the light is off. However, if I send a direct command to the outlet, the keypad button goes out of sync (light on, button LED off). In this situation, Option 2 would solve this problem because if I said siri turn the nightstands to 30% the nightstands would go to 30 and the keypad backlight would turn on. I would always make keypad buttons follow Option 2.

However if I had a Living Room scene with two dimmable lights and one on/off light and I said siri turn the living room to 30%, I don't think i would want the on/off light to turn on - so maybe in the case of on/off switches or outlets, they should follow Option 1. This one is hypothetical - I don't actually have any load bearing on/off devices mixed with load bearing dimmable devices in a scene.

I think if I had to pick one, I would go with Option 2.

rodtoll commented 8 years ago

Agreed with option 2.

What should the dim level be returned as? It should be the average across the dimmable lights only and ignoring the non-dimmable light for the calculation.

I can also have the scene appear as non-dimmable if there are no dimmable lights in it.

I'll resurrect this code and finish it.

On Wed, Jan 6, 2016 at 12:26 PM, fahrvergnuugen notifications@github.com wrote:

@rodtoll https://github.com/rodtoll I know what you mean. I think there are two choices, and perhaps both should be implemented depending on the kind of on/off device in the scene:

1.

Determine which devices are dimmable and only send the /DON/### level command to those. Ignore the others unless the scene is set to 0%/off or 100%/on. 2.

Send the level command to all devices which will result in the non dimming devices turning on no matter what brightness level is used. I just tested it - if I send a /DON/128 (50% brightness) command to a non-dimmable device, the device turns on. I guess the ISY simply processes the DON part and ignores the level.

I have another scene with a dimmable outlet and a keypad button B. These are part of a scene and the keypad button lights up when the light is on and turns off when the light is off. However, if I send a direct command to the outlet, the keypad button goes out of sync (light on, button LED off). In this situation, Option 2 would solve this problem because if I said siri turn the nightstands to 30% the nightstands would go to 30 and the keypad backlight would turn on. I would always make keypad buttons follow Option 2.

However if I had a Living Room scene with two dimmable lights and one on/off light and I said siri turn the living room to 30%, I don't think i would want the on/off light to turn on - so maybe in the case of on/off switches or outlets, they should follow Option 1. This one is hypothetical

  • I don't actually have any load bearing on/off devices mixed with load bearing dimmable devices in a scene.

I think if I had to pick one, I would go with Option 2.

— Reply to this email directly or view it on GitHub https://github.com/rodtoll/homebridge-isy-js/issues/2#issuecomment-169451210 .

PaulWieland commented 8 years ago

I guess the overall scene brightness level is tough to know because you can create an Insteon Scene with an on level for with one device at 100% and a second device at 50%.

Telling the ISY to turn this "On" should result in 100% and 50% respectively and the average scene brightness would be 75%. This might be fine unless any of the devices have really long ramp rates defined - I don't know if you can read these values and send them back to Siri in a short enough time since the ramp rates of the dimmers can be up to 8 minutes.

Incidentally, it just dawned on me that some of the weird UI slider bouncing behavior I have seen in my homekit setup is probably because of some of the slow ramp rates I have set.

Edit: To answer your question I would just average the level of the dimmer devices :)

Doughboy68 commented 8 years ago

I also have lots of virtual 3-ways and a few KeypadLincs. I have figured out a way on the ISY how to turn on/off the LEDs on the KeypadLincs to keep everything in sync.

First I have my virtual 3-ways named with like "Upstairs Hallway" and "Upstairs Hallway Slave" Also on KeyPadLincs, I have the button designation also added like "Upstairs Hallway KLD" which would be button D Then I ignore words "Slave" and all the keypads like "KLA", ... "KLD", etc. This makes a nice clean import to HomeBridge.

Now if I just have a couple SwitchLincs, I just make a program on ISY as follows:


Upstairs Hallway - [ID 004C][Parent 0033]

If Status 'Upstairs Hallway' is 100%

Then Set 'Upstairs Hallway Slave' On

Else Set 'Upstairs Hallway Slave' Off


The trick to get a KeypadLinc LED to be controlled is simply to create a new scene and add just that one button in the scene... I made a scene called "EC Upstairs Hallway KLD" and added just that one button into it.

Now my program is like this:


Upstairs Hallway - [ID 004C][Parent 0033]

If Status 'Upstairs Hallway' is 100%

Then Set 'Upstairs Hallway Slave' On Set Scene 'KPL Sync LEDs Scenes / EC Upstairs Hallway KLD' On

Else Set 'Upstairs Hallway Slave' Off Set Scene 'KPL Sync LEDs Scenes / EC Upstairs Hallway KLD' Off


Here is also an example using a dimmer (use > 1%) is only difference


Kitchen Chandelier - [ID 0034][Parent 0033]

If Status 'Kitchen Chandelier' >= 1%

Then Set Scene 'KPL Sync LEDs Scenes / Kitchen KPL Chandelier Key' On

Else Set Scene 'KPL Sync LEDs Scenes / Kitchen KPL Chandelier Key' Off


Hope this helps. Sure it is quite a bit of programs and single-device scenes but I group them in folders to help sort everything out. It takes maybe half second for switch to update but works perfect so far. I can say "Siri turn Kitchen Chandelier to 30%" and it works and updates my KeypadLinc switch correctly.

markleepgh commented 8 years ago

Hi Rod (and others),

Thanks so much for all your work on this. Please pardon my ignorance, but no matter what I do I can’t get the scenes functionality that you’ve implemented working for me. I’ve added the following lines to the config file:

        "includeAllScenes": false,
        "includedScenes": [
            "64328",
            "11321"
        ],

having obtain the scene addresses from http://isy-address/rest/nodes, e.g.:

11321
Basement 1954 23 C14 AB F E5 1 3D 30 C 1

Homebridge picks up all of the devices but I don’t see any of the scenes listed in the app I am using (HMCatalog—Apple's HomeKit demo app).

Am I missing something? Any tips or pointers in the right direction would be most welcomed and appreciated!

Kind regards,

Mark

PaulWieland commented 8 years ago

@markleepgh ive found that sometimes homekit refuses to refresh or loses its connection with homebridge.

Do your scenes appear as devices in the log that prints to the terminal when you start homebridge? Do the scenes have unique names (not overlapping any devices)?

If yes to both of these questions, try changing the bridge id in your config file and adding a new house to "start over" in hmcatalog. Theres a note about it in the readme of homebridge itself. Hth!

rodtoll commented 8 years ago

@markleepgh - @fahrvergnuugen is correct. This is the most likely cause.

Another potential cause is you have exceeded the maximum of 99 devices. Homebridge will only ever export up to 99 devices per instance as HomeKit doesn't allow more then that from a device which provides sub devices.

Another thing to try would be ensuring that your homebridge-isy-js is up to date with the latest version on npm. Unless you have a very recent version this doesn't work. Check out the package.json file in the homebridge-isy-js directory to find the version you have.

If neither of the above work we'll need to activate some debug logging to figure out the cause.

markleepgh commented 8 years ago

Hi @fahrvergnuugen and @rodtoll ,

Thanks very much for those suggestions.

@fahrvergnuugen - The scenes don't appear as devices in the startup log. I've also checked that the two scenes whose addresses I've listed under "includedScenes" in the config file have unique names that don't overlap with any of the device names.

@rodtoll - I definitely have less than 99 devices. I've also made sure I have the latest version of homebridge-isy-js (in fact I just updated again to the most recent version you posted in the last 24 hours).

What do you suggest from here? Thank you both once again for your help.

Best regards,

Mark

markleepgh commented 8 years ago

OK, I think I figured out the problem! My scenes are all in a folder called 'Scenes'. Once they are moved to the root of the ISY tree homebridge-isy-js picks them up just fine.

Strangely, my devices are in an equivalent folder (called 'Devices') yet this does not cause an issue.

Would it be possible to modify the code so that scenes located within folders will still be detected?

rodtoll commented 8 years ago

Certainly. Sounds like a bug for sure.

Next time I sit down to do some bug fixes I'll repro this and put together a fix. On Fri, Jan 22, 2016 at 7:07 PM markleepgh notifications@github.com wrote:

OK, I think I figured out the problem! My scenes are all in a folder called 'Scenes'. Once they are moved to the root of the ISY tree homebridge-isy-js picks them up just fine.

Strangely, my devices are in an equivalent folder (called 'Devices') yet this does not cause an issue.

Would it be possible to modify the code so that scenes located within folders will still be detected?

— Reply to this email directly or view it on GitHub https://github.com/rodtoll/homebridge-isy-js/issues/2#issuecomment-174117211 .