Announcement

Collapse
No announcement yet.

I would appreciate some guidance on setting up a virtual device

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    I would appreciate some guidance on setting up a virtual device

    I need some guidance on setting up a virtual device in HS4. I am only using X10 at this point, and want to setup a virtual device for use as an status indicator only (i.e. not controlling a physical device). I want to be able to interrogate the status of the device as either ON or OFF. I don't want it assigned to an X10 housecode/device code in order to save available codes.

    I've setup the device and can switch it ON/OFF, but when I interrogate it using the following script, it says it's always OFF regardless of the visual status. I know that I have something wrong in the simple setup. I don't understand the various setup elements. (see image for setup)

    Here's the script snippet.

    DevRef = hs.GetDeviceRefByName("F17")
    hs.Speak "Device Ref is " & DevRef

    if hs.ison(DevRef) then
    hs.Speak "F17 is on."
    else
    hs.speak "F17 is OFF."
    end if

    This script snippet works if the device is setup through the X10 plug-in as an X10 device, but not in the attached device setup.

    Why does this always return that it's OFF?

    Attached Files

    #2
    I see that there is a control device with Device ID = 30 and it shows the original device as an Associated Device = 29. Why is there an Associated Device? It returns 29 when using hs.GetDeviceRefByName - it's 29 I want to evaluate

    Click image for larger version  Name:	ScreenHunter_01 Jan. 09 15.18.gif Views:	0 Size:	12.2 KB ID:	1446695

    Comment


      #3
      The Parent device is the status and it's Feature device is the control device; two separate devices that need unique names system-wide so that GetDefByName can return the correct one.

      What does hs.Speak "Device Ref is " & DevRef actually tell you?

      There could be an issue with
      Code:
      if hs.ison(DevRef) then
      . My HS scripting experience is very little...

      Sometimes hs.xyz needs to be &ns.xyz but I think that is a Linux anomaly...
      HS4 Pro Edition 4.2.5.0 running on Lenovo ThinkCenter & Debian Linux
      Plugins: Z-Wave (via Nortek USB stick

      Home Assistant 2021.10.6 running on HA "Blue" ODROID-N2
      Add-ons: Android Debug Bridge, Duck DNS, ESPHome, File Editor, Glances, HA Google Drive Backup, InfluxDB, Log Viewer, MariaDB, Mosquitto broker, NGINX SSL Proxy, Node-RED, Portainer, SSH & Web Terminal, Samba, TasmoAdmin, UniFi Controller, Visual Studio Code, WireGuard, Zigbee2mqtt, Z-Wave JS to MQTT
      Integrations: AccuWeather, Alexa Media Player, Glances, Google Nest, HACS, HomeSeer, Insteon, IPP, Life360, Local IP, Logitech Harmony Hub, Mobile App, MQTT, My Garage, OpenWeather, Spotify, Tuya Local. Ubiquiti UniFi, Z-Wave JS
      Insteon: 2413S Dual Band PLM
      Zigbee: zzh! CC2652R Rev A
      Z-Wave: RaZberry daughtercard on RPi 1B via ser2net

      Comment


        #4
        Originally posted by JeffCharger View Post
        I see that the Device ID = 30 and it shows an Associated Device 29. Why is there an Associated Device? It returns 29 when using hs.GetDeviceRefByName - it's 29 I want to evaluate

        Click image for larger version Name:	ScreenHunter_01 Jan. 09 15.18.gif Views:	0 Size:	12.2 KB ID:	1446695
        '29' is the control device.

        You are using
        Code:
        hs.GetDeviceRefByName("F17")
        but the panel shows the name as "system control variable F17"?? Or maybe I'm not reading the right...
        HS4 Pro Edition 4.2.5.0 running on Lenovo ThinkCenter & Debian Linux
        Plugins: Z-Wave (via Nortek USB stick

        Home Assistant 2021.10.6 running on HA "Blue" ODROID-N2
        Add-ons: Android Debug Bridge, Duck DNS, ESPHome, File Editor, Glances, HA Google Drive Backup, InfluxDB, Log Viewer, MariaDB, Mosquitto broker, NGINX SSL Proxy, Node-RED, Portainer, SSH & Web Terminal, Samba, TasmoAdmin, UniFi Controller, Visual Studio Code, WireGuard, Zigbee2mqtt, Z-Wave JS to MQTT
        Integrations: AccuWeather, Alexa Media Player, Glances, Google Nest, HACS, HomeSeer, Insteon, IPP, Life360, Local IP, Logitech Harmony Hub, Mobile App, MQTT, My Garage, OpenWeather, Spotify, Tuya Local. Ubiquiti UniFi, Z-Wave JS
        Insteon: 2413S Dual Band PLM
        Zigbee: zzh! CC2652R Rev A
        Z-Wave: RaZberry daughtercard on RPi 1B via ser2net

        Comment


          #5
          If DevRef is set as 29 and 29 is on but
          Code:
          if hs.ison(DevRef) then
          returns false, then the syntax for that "iF" is not right
          HS4 Pro Edition 4.2.5.0 running on Lenovo ThinkCenter & Debian Linux
          Plugins: Z-Wave (via Nortek USB stick

          Home Assistant 2021.10.6 running on HA "Blue" ODROID-N2
          Add-ons: Android Debug Bridge, Duck DNS, ESPHome, File Editor, Glances, HA Google Drive Backup, InfluxDB, Log Viewer, MariaDB, Mosquitto broker, NGINX SSL Proxy, Node-RED, Portainer, SSH & Web Terminal, Samba, TasmoAdmin, UniFi Controller, Visual Studio Code, WireGuard, Zigbee2mqtt, Z-Wave JS to MQTT
          Integrations: AccuWeather, Alexa Media Player, Glances, Google Nest, HACS, HomeSeer, Insteon, IPP, Life360, Local IP, Logitech Harmony Hub, Mobile App, MQTT, My Garage, OpenWeather, Spotify, Tuya Local. Ubiquiti UniFi, Z-Wave JS
          Insteon: 2413S Dual Band PLM
          Zigbee: zzh! CC2652R Rev A
          Z-Wave: RaZberry daughtercard on RPi 1B via ser2net

          Comment


            #6
            I'm using Linux version so...

            I remember having to use something like
            Code:
            &nhs.Set...(''xyz'')
            but this is where my experience is extremely limited
            HS4 Pro Edition 4.2.5.0 running on Lenovo ThinkCenter & Debian Linux
            Plugins: Z-Wave (via Nortek USB stick

            Home Assistant 2021.10.6 running on HA "Blue" ODROID-N2
            Add-ons: Android Debug Bridge, Duck DNS, ESPHome, File Editor, Glances, HA Google Drive Backup, InfluxDB, Log Viewer, MariaDB, Mosquitto broker, NGINX SSL Proxy, Node-RED, Portainer, SSH & Web Terminal, Samba, TasmoAdmin, UniFi Controller, Visual Studio Code, WireGuard, Zigbee2mqtt, Z-Wave JS to MQTT
            Integrations: AccuWeather, Alexa Media Player, Glances, Google Nest, HACS, HomeSeer, Insteon, IPP, Life360, Local IP, Logitech Harmony Hub, Mobile App, MQTT, My Garage, OpenWeather, Spotify, Tuya Local. Ubiquiti UniFi, Z-Wave JS
            Insteon: 2413S Dual Band PLM
            Zigbee: zzh! CC2652R Rev A
            Z-Wave: RaZberry daughtercard on RPi 1B via ser2net

            Comment


              #7
              Originally posted by dbrunt View Post
              The Parent device is the status and it's Feature device is the control device; two separate devices that need unique names system-wide so that GetDefByName can return the correct one.

              What does hs.Speak "Device Ref is " & DevRef actually tell you?

              ..
              Thanks for the assistance....

              hs.speak "DevRef" provides the device ID of the "true" device, which is the one I want. It appears that the actual status (the ON or OFF) is contained in the manufactured Control Device with has a Device ID = 30 (+1 to the original device). This doesn't seem right to me. It means, to evaluate the ON/OFF condition of the device, I have to evaluate the (DevRef+1) device.

              Comment


                #8
                I wasn't fully awake earlier...

                What's the name of dev id 29? "F17"?
                and is this a virtual device which is set by something else?

                What's the name of dev id 29's associated Feature (which is dev id 30)?
                "Control"?

                If id 30 is the one you want to interrogate, change that Feature's name to "F17 Control" and then you have a unique name to use with getDevRefByName i.e. ("F17 Control")...

                Or just use dev id's in your script and not have to worry about what they're named...
                HS4 Pro Edition 4.2.5.0 running on Lenovo ThinkCenter & Debian Linux
                Plugins: Z-Wave (via Nortek USB stick

                Home Assistant 2021.10.6 running on HA "Blue" ODROID-N2
                Add-ons: Android Debug Bridge, Duck DNS, ESPHome, File Editor, Glances, HA Google Drive Backup, InfluxDB, Log Viewer, MariaDB, Mosquitto broker, NGINX SSL Proxy, Node-RED, Portainer, SSH & Web Terminal, Samba, TasmoAdmin, UniFi Controller, Visual Studio Code, WireGuard, Zigbee2mqtt, Z-Wave JS to MQTT
                Integrations: AccuWeather, Alexa Media Player, Glances, Google Nest, HACS, HomeSeer, Insteon, IPP, Life360, Local IP, Logitech Harmony Hub, Mobile App, MQTT, My Garage, OpenWeather, Spotify, Tuya Local. Ubiquiti UniFi, Z-Wave JS
                Insteon: 2413S Dual Band PLM
                Zigbee: zzh! CC2652R Rev A
                Z-Wave: RaZberry daughtercard on RPi 1B via ser2net

                Comment


                  #9
                  When a virtual is set via it's control feature, the virtual device status should reflect that new state...
                  HS4 Pro Edition 4.2.5.0 running on Lenovo ThinkCenter & Debian Linux
                  Plugins: Z-Wave (via Nortek USB stick

                  Home Assistant 2021.10.6 running on HA "Blue" ODROID-N2
                  Add-ons: Android Debug Bridge, Duck DNS, ESPHome, File Editor, Glances, HA Google Drive Backup, InfluxDB, Log Viewer, MariaDB, Mosquitto broker, NGINX SSL Proxy, Node-RED, Portainer, SSH & Web Terminal, Samba, TasmoAdmin, UniFi Controller, Visual Studio Code, WireGuard, Zigbee2mqtt, Z-Wave JS to MQTT
                  Integrations: AccuWeather, Alexa Media Player, Glances, Google Nest, HACS, HomeSeer, Insteon, IPP, Life360, Local IP, Logitech Harmony Hub, Mobile App, MQTT, My Garage, OpenWeather, Spotify, Tuya Local. Ubiquiti UniFi, Z-Wave JS
                  Insteon: 2413S Dual Band PLM
                  Zigbee: zzh! CC2652R Rev A
                  Z-Wave: RaZberry daughtercard on RPi 1B via ser2net

                  Comment


                    #10
                    In HS4 by default, the parent has no status/control pairs. It's the feature that you need to name uniquely and reference in your script.
                    HS4 virtuals are now designed the same way regular devices are structured

                    Click image for larger version  Name:	Virtual Device.PNG Views:	0 Size:	28.0 KB ID:	1446760

                    That or, delete the feature "Control" and then setup the parent/root device with defined status/control pairs (which will then be and act like HS3 virtual devices)...
                    HS4 Pro Edition 4.2.5.0 running on Lenovo ThinkCenter & Debian Linux
                    Plugins: Z-Wave (via Nortek USB stick

                    Home Assistant 2021.10.6 running on HA "Blue" ODROID-N2
                    Add-ons: Android Debug Bridge, Duck DNS, ESPHome, File Editor, Glances, HA Google Drive Backup, InfluxDB, Log Viewer, MariaDB, Mosquitto broker, NGINX SSL Proxy, Node-RED, Portainer, SSH & Web Terminal, Samba, TasmoAdmin, UniFi Controller, Visual Studio Code, WireGuard, Zigbee2mqtt, Z-Wave JS to MQTT
                    Integrations: AccuWeather, Alexa Media Player, Glances, Google Nest, HACS, HomeSeer, Insteon, IPP, Life360, Local IP, Logitech Harmony Hub, Mobile App, MQTT, My Garage, OpenWeather, Spotify, Tuya Local. Ubiquiti UniFi, Z-Wave JS
                    Insteon: 2413S Dual Band PLM
                    Zigbee: zzh! CC2652R Rev A
                    Z-Wave: RaZberry daughtercard on RPi 1B via ser2net

                    Comment


                      #11
                      [QUOTE]That or, delete the feature "Control" and then setup the parent/root device with defined status/control pairs (which will then be and act like HS3 virtual devices)...[QUOTE]

                      You've opened my eyes, thank you!

                      Comment


                        #12
                        [QUOTE=racerfern;n1446794][QUOTE]That or, delete the feature "Control" and then setup the parent/root device with defined status/control pairs (which will then be and act like HS3 virtual devices)...

                        You've opened my eyes, thank you!
                        Creating the Status/control pairs manually works. This will work for me in the short term as a workaround. From reading on the forum, it appears that others have identified the inability to do this as a bug. Hopefully it will get changed in a future release.

                        Thanks for your help!

                        Comment


                          #13
                          Originally posted by dbrunt View Post
                          In HS4 by default, the parent has no status/control pairs. It's the feature that you need to name uniquely and reference in your script.
                          HS4 virtuals are now designed the same way regular devices are structured

                          Click image for larger version Name:	Virtual Device.PNG Views:	0 Size:	28.0 KB ID:	1446760

                          That or, delete the feature "Control" and then setup the parent/root device with defined status/control pairs (which will then be and act like HS3 virtual devices)...
                          How can you refer to the Control device by name? Is there a way?

                          Comment


                            #14
                            Originally posted by JeffCharger View Post

                            How can you refer to the Control device by name? Is there a way?
                            Just change its name!
                            Click into the Feature Name field and edit it, then refer to that name in your script.

                            Click image for larger version  Name:	Rename Boolean.PNG Views:	0 Size:	59.1 KB ID:	1446874

                            You can name the root and the feature anything you like that makes sense to you and is unique in the system, although they do not have to be as far the system is concerned but need to be if you want to reference by name.
                            For instance, the root could be "RF1 Boolean Root" and the feature "RF1".
                            HS4 Pro Edition 4.2.5.0 running on Lenovo ThinkCenter & Debian Linux
                            Plugins: Z-Wave (via Nortek USB stick

                            Home Assistant 2021.10.6 running on HA "Blue" ODROID-N2
                            Add-ons: Android Debug Bridge, Duck DNS, ESPHome, File Editor, Glances, HA Google Drive Backup, InfluxDB, Log Viewer, MariaDB, Mosquitto broker, NGINX SSL Proxy, Node-RED, Portainer, SSH & Web Terminal, Samba, TasmoAdmin, UniFi Controller, Visual Studio Code, WireGuard, Zigbee2mqtt, Z-Wave JS to MQTT
                            Integrations: AccuWeather, Alexa Media Player, Glances, Google Nest, HACS, HomeSeer, Insteon, IPP, Life360, Local IP, Logitech Harmony Hub, Mobile App, MQTT, My Garage, OpenWeather, Spotify, Tuya Local. Ubiquiti UniFi, Z-Wave JS
                            Insteon: 2413S Dual Band PLM
                            Zigbee: zzh! CC2652R Rev A
                            Z-Wave: RaZberry daughtercard on RPi 1B via ser2net

                            Comment


                              #15
                              Originally posted by JeffCharger View Post
                              This will work for me in the short term as a workaround. From reading on the forum, it appears that others have identified the inability to do this as a bug. Hopefully it will get changed in a future release.

                              Thanks for your help!
                              I don't expect it to get changed in the future as this is not a bug but is almost a breaking change (to quote a term from HA) in HS4. I say almost because it does not change existing virtuals and does allow you to change a new virtual back to the old design, and it's quite easy to use the new structure as I've illustrated above.
                              HS4 Pro Edition 4.2.5.0 running on Lenovo ThinkCenter & Debian Linux
                              Plugins: Z-Wave (via Nortek USB stick

                              Home Assistant 2021.10.6 running on HA "Blue" ODROID-N2
                              Add-ons: Android Debug Bridge, Duck DNS, ESPHome, File Editor, Glances, HA Google Drive Backup, InfluxDB, Log Viewer, MariaDB, Mosquitto broker, NGINX SSL Proxy, Node-RED, Portainer, SSH & Web Terminal, Samba, TasmoAdmin, UniFi Controller, Visual Studio Code, WireGuard, Zigbee2mqtt, Z-Wave JS to MQTT
                              Integrations: AccuWeather, Alexa Media Player, Glances, Google Nest, HACS, HomeSeer, Insteon, IPP, Life360, Local IP, Logitech Harmony Hub, Mobile App, MQTT, My Garage, OpenWeather, Spotify, Tuya Local. Ubiquiti UniFi, Z-Wave JS
                              Insteon: 2413S Dual Band PLM
                              Zigbee: zzh! CC2652R Rev A
                              Z-Wave: RaZberry daughtercard on RPi 1B via ser2net

                              Comment

                              Working...
                              X