[ANSWERED]Virtual Device not working as expected

Posted on
Wed Apr 08, 2015 6:52 pm
Turribeach offline
Posts: 429
Joined: Feb 06, 2015
Location: London, UK

[ANSWERED]Virtual Device not working as expected

Hi,

I have added a Virtual Device => Device Group called "All Lights" to my devices. In it I selected two of my light switches as shown in the picture below:

VirtualDevice.png
VirtualDevice.png (118.77 KiB) Viewed 7360 times


I am now trying to switch on and off these two switches from this virtual device. The Off action works fine, but then On doesn't. Looking at the event logs (see below) I can see that when I press on Off it then sends Off to both switches. But when I press On it does the same thing! My expectation is that if I set the virtual device to On it should send On to all the devices. Any ideas what's going on here or am I not understand how virtual devices work?

8 Apr 2015 22:02:03
Virtual Devices sent "All Lights" off
Z-Wave sent "012 - Switch Kitchen Main" off
Z-Wave sent "012 - Switch Kitchen Side" off
Virtual Devices sent "All Lights" on
Z-Wave sent "012 - Switch Kitchen Main" off
Z-Wave sent "012 - Switch Kitchen Side" off

Thanks!

Posted on
Wed Apr 08, 2015 7:15 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Virtual Device not working as expected

Make sure the devices are on - then edit the device group and click on the "Update all" button and save the config dialog - it may be that the saved state for those devices got hosed.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Apr 09, 2015 5:21 pm
Turribeach offline
Posts: 429
Joined: Feb 06, 2015
Location: London, UK

Re: Virtual Device not working as expected

I have tried this several times without any luck. In fact this was working fine initially, then something happened and it started to behave in this way. I tried also deleting the Virtual Device and recreating it with a different name, same thing. I tried selecting other switches, and it does the same thing (when I click on Turn On it turns the switches Off) .

Posted on
Fri Apr 10, 2015 9:45 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Virtual Device not working as expected

I'm not able to reproduce this. Here were my exact steps:

  1. Turned on two devices (an Insteon lamplinc and a Z-Wave appliance module)
  2. Created a new device group
  3. In the config dialog, selected the lamplinc and the appliance module
  4. The Group goes ON when popup is set to All devices are ON
  5. The Dimmers are ON when is set to Brightness >= saved value
  6. The On/Off devices are ON when is set to On
  7. I checked the Update All checkbox (though for a new device it's not strictly required since it will do it anyway)

Saved the dialog and closed the Create Device dialog. I then hit the turn off and turn on button and the lights worked appropriately.

If following these steps doesn't work for you, then follow these steps:

  1. Select the Event Log window
  2. Click the Clear Window button
  3. Select the Interfaces->Virtual Devices->Toggle Debug menu item
  4. Select your device group and click the Turn On/Turn Off buttons once each
  5. Select the Interfaces->Virtual Devices->Toggle Debug menu item again
  6. Select all the text in the Event Log window and post it into a reply post

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Apr 10, 2015 2:13 pm
Turribeach offline
Posts: 429
Joined: Feb 06, 2015
Location: London, UK

Re: Virtual Device not working as expected

Doesn't work for me. I got it working fine using an Action Group, but I would prefer to use a Virtual Device since I want to be able to see the state of the group.

Code: Select all
 Virtual Devices                 sent "All Lights" off
  Z-Wave                          sent "Kitchen Main Lights" off
  Virtual Devices Debug           deviceUpdated called for: Kitchen Main Lights which is in the activeDeviceMap
  Virtual Devices Debug           deviceUpdated called for: Kitchen Main Lights which is in the deviceSceneMap
  Virtual Devices Debug           Calling updateScene for device: Kitchen Main Lights
  Virtual Devices Debug           Performing device group update for "All Lights"
  Z-Wave                          sent "Kitchen Side Lights" off
  Virtual Devices Debug           deviceUpdated called for: Kitchen Side Lights which is in the activeDeviceMap
  Virtual Devices Debug           deviceUpdated called for: Kitchen Side Lights which is in the deviceSceneMap
  Virtual Devices Debug           Calling updateScene for device: Kitchen Side Lights
  Virtual Devices Debug           Performing device group update for "All Lights"
  Virtual Devices                 sent "All Lights" on
  Z-Wave                          sent "Kitchen Main Lights" off
  Z-Wave                          sent "Kitchen Side Lights" off

10 Apr 2015 21:08:37
  Virtual Devices Debug           reconcileOnly: 0
  Virtual Devices Debug           deviceListDict: {"relays": {"322101079": false, "546959439": false}, "dimmers": {}}
  Virtual Devices Debug           deviceStopComm: All Lights
  Virtual Devices Debug           Stopping device with device ids: deviceList : (list)
     Item : 322101079 (string)
     Item : 546959439 (string)
  Virtual Devices Debug           deviceStartComm: All Lights
  Virtual Devices Debug           Starting device with device ids: deviceList : (list)
     Item : 322101079 (string)
     Item : 546959439 (string)
  Virtual Devices Debug           Performing device group update for "All Lights"
  Virtual Devices                 sent "All Lights" off
  Z-Wave                          sent "Kitchen Main Lights" off
  Z-Wave                          sent "Kitchen Side Lights" off
  Virtual Devices                 sent "All Lights" on
  Z-Wave                          sent "Kitchen Main Lights" off
  Z-Wave                          sent "Kitchen Side Lights" off
 

Posted on
Fri Apr 10, 2015 4:04 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Virtual Device not working as expected

Email your database file to me - support@indigodomo.com and include a reference to this thread.

[EDIT] - never mind, I see what's wrong. You have the saved state for those devices set to OFF:

Code: Select all
  Virtual Devices Debug           deviceListDict: {"relays": {"322101079": false, "546959439": false}, "dimmers": {}}


That means that the stored state for each of the3 relay device is false (which means OFF to the plugin), which is what it sets the device states to when you turn the group ON. An ON to a device group means "restore the saved state of each device in the group", not "turn on every device in the group". To update the saved states, you must first turn ON the devices, then either edit the device group and check the "Update all" button and save OR select the Interfaces->Virtual Devices->Update Device Group Saved States... menu item. This will look through all devices in the group and update the saved state.

If you notice in my post above about trying to recreate the steps, I explicitly mention that I turned the devices ON before creating the group.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Apr 12, 2015 4:40 pm
Turribeach offline
Posts: 429
Joined: Feb 06, 2015
Location: London, UK

Re: Virtual Device not working as expected

Hi Jay,

Yes, you are right, when I tested doing the update I had the devices turned off. I incorrectly assumed that you meant to make sure the devices were on (i.e. powered on) rather than to turn them on in Indigo. Now that I have followed the steps properly I got the issue fixed. Somehow the saved state must have got out of sync. But I do find this "Update All" confusing though. Wouldn't it make more sense to do the Update All even if the devices are turned off? That will have avoided the situation I ended on. If there is a reason behind that behaviour then I would argue that the screen should indicate that the update only happens if the device is on (as currently there is nothing indicating that). Also the screen itself shows the device state so it could even warn the user that the update will not happen since the devices are actually off. But I would prefer my first suggestion.

The other thing is that clearly these states can go out of sync, is there a way that I can update the device state every time the Device Group fires? Is that an overkill for a "rare" issue?

Thanks,
Christian

Posted on
Wed Apr 15, 2015 10:14 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [ANSWERED]Virtual Device not working as expected

If you do an Update all when some/all of the devices are turned OFF, then the saved state for those devices becomes OFF. When the group is sent an ON command, those devices will go OFF because the ON command doesn't actually mean "turn it on" but rather "set it to it's saved state". It's a bit counter-intuitive, but for a scene (which is one use for a device group) you may often want to explicitly turn a device OFF while turning on others. The key point is this: you only want to update the saved states of each device when you want to explicitly change the default ON settings for each device.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Apr 15, 2015 10:55 am
Turribeach offline
Posts: 429
Joined: Feb 06, 2015
Location: London, UK

Re: [ANSWERED]Virtual Device not working as expected

OK having re-read the Virtual Devices help page I think I now understand Virtual Devices much better. Basically virtual devices save a default state for each device, so people can define a predefined state for a group of devices and then turn that predefined state "on" right? In my case I was just using it to turn a group of devices on/off, all of them at the same time, all to the same state. I used Virtual Devices since I wanted to see a state, so for instance I have a "All Lights" virtual device and I wanted to be able to switch all the lights off when going to bed, so knowing if any light was On is very useful for this requirement.

I see that perhaps I should be using a Virtual On/Off Device which seems more appropriate for my use. Although I do note that a Virtual Device requires much less setup than a Virtual On/Off Device will do, as a Virtual On/Off Device will need the Action Groups and variables setup first. I now see that updating the state when some/all of the devices are turned OFF will make no sense at all. Perhaps you guys can simply modify the existing note below the Update All check box (changes in bold):

"Check this button if you want to update the saved states of all the devices on this group. Only Devices that are On will have their state updated."

Thanks for solving this mystery!

Posted on
Wed Apr 15, 2015 11:27 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [ANSWERED]Virtual Device not working as expected

But, that's not true. All devices in the group, regardless of whether they're on or off, will have their state updated. Example: if a dimmer in the group has a current saved state of 50, but is now turned OFF, then when you update the state its saved state will now be OFF.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Apr 16, 2015 2:48 pm
Turribeach offline
Posts: 429
Joined: Feb 06, 2015
Location: London, UK

Re: [ANSWERED]Virtual Device not working as expected

Oh dear, I am being thick again :oops:

I got it now, I needed to have all the devices On when saving the state since that's the state I wanted them to go when I switch the Virtual Device On. My confusion came from the fact that I thought that the state was to allow the Virtual Device to report the group state. Perhaps adding this might help others? "The saved state is the state that the device will go to when the Virtual Device is turned On".

Thanks for the patience in explaining how this works! :mrgreen:

Posted on
Thu Apr 16, 2015 3:38 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [ANSWERED]Virtual Device not working as expected

Updated the docs in a couple of places to make it more clear. Thanks for the feedback.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat May 16, 2015 9:52 am
brian.vanheesch offline
Posts: 17
Joined: May 05, 2014

Re: [ANSWERED]Virtual Device not working as expected

It took me a while to figure this one out as well. I had a device group of Hue lights that would not turn on (as a group); and left it as probable bug in the plugin somewhere. This solution above fixed that problem. I went ahead and wrote this update script to properly save all the device states within all device groups. I do not see a reason for having the device state saved as "OFF". Too often when I define a group, I do not pay attention to the device state.

This script need only be run once.

Code: Select all
plugin = indigo.server.getPlugin("com.perceptiveautomation.indigoplugin.devicecollection")

# Iterate over all devices and only process Device Groups.
for module in indigo.devices:
   if "Device Group" in module.model:
      indigo.server.log("Checking Device Group [%s]" % module.name)

      # Issue 'turnOn' to all the nested devices.
      for child in module.globalProps["com.perceptiveautomation.indigoplugin.devicecollection"]["deviceList"]:
         ls=indigo.devices[int(child)]
         indigo.device.turnOn(ls.id)

      # update the device group settings.
      plugin.executeAction("updateSnapshot", deviceId=module.id)

      # Turn off the device group.  This has never been a problem.
      indigo.device.turnOff(module.id)

      indigo.server.log("The Device Group [%s] should be off at this time." % module.name)

      # Testing time.  Turn on the device group.
      # Note: these 2 commands now replace that previous ugly for-loop.
      indigo.device.turnOn(module.id)
      indigo.device.turnOff(module.id)

      indigo.server.log("Check the log output.  You should see the individual devices actually turn on.")

indigo.server.log("Finished.")


A word of caution: you should disable all your triggers. This script will turn on and off switches which in-turn will fire all sorts of triggers.

Posted on
Sat May 16, 2015 11:50 am
Turribeach offline
Posts: 429
Joined: Feb 06, 2015
Location: London, UK

Re: [ANSWERED]Virtual Device not working as expected

brian.vanheesch wrote:
I do not see a reason for having the device state saved as "OFF". Too often when I define a group, I do not pay attention to the device state.


I think the idea is to have a virtual device such as "Read a book" then you should set which lights you want on and off in an zone when you switch that device on. The way were using it is still valid but yes I agree it's confusing how the states are saved.

Posted on
Sat May 16, 2015 12:57 pm
akimball offline
Posts: 559
Joined: Aug 07, 2013
Location: Sandy, Utah

Re: [ANSWERED]Virtual Device not working as expected

This is a very good discussion. I've run into this recently and wondered why... but didn't have time yet to investigate. Now I know and I fee 'educated.' Appreciate very much this forum and the active participation. Thank you all... and thanks Jay for touching up the instructions on virtual devices; I look forward to reviewing.

-Al

Who is online

Users browsing this forum: No registered users and 2 guests