Announcement

Collapse
No announcement yet.

Set an Omni flag through a script

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

    Set an Omni flag through a script

    I've been using the plugin for many years but I've never had to do this particular action.

    I'm trying to set a flag on the OMNI using a vb script from HS. I tried hs.SetDeviceValue but realized that all that does is change the value in the object on the HS side but does not communicate this to the OMNI. Has someone already solved this problem?

    I know i can set a flag using any HS action to a pre-defined value (using the dropdown) but how else would I set the value through an action when I need to read the value in as a parameter?

    Appreciate your thoughts!

    #2
    You will likely need to use HS's CAPI interface to actually control/change the device.
    As far as reading the value in as a parm, I'm not entirely sure how you would do that.
    I'll see if I can post some CAPI code here later...
    HS4Pro on a Raspberry Pi4
    54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
    Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

    HSTouch Clients: 1 Android

    Comment


      #3
      Thanks - some example code would be great!

      Comment


        #4
        Try this (replace the Device Id with your flag's device id:
        Code:
        &hs.CAPIControlHandler(hs.CAPIGetSingleControl(1641,False,"75", False,true))
        Last edited by rmasonjr; November 26, 2018, 11:08 AM. Reason: spacing
        HS4Pro on a Raspberry Pi4
        54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
        Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

        HSTouch Clients: 1 Android

        Comment


          #5
          Worked like a charm! thank you!

          Comment


            #6
            Hello,

            This seems to have stopped working for me recently and i'm not sure why. I looked around a bit and it seems there might be a replacement function in HS4 called

            IHsController.SendControlForFeatureByValue

            I'm trying IHsController.SendControlForFeatureByValue(1973,x) where x is an integer but it no longer seems to update the flag on the omni side.

            Any thoughts?

            Thank you

            M

            Comment


              #7
              Following. As the plugin doesn't support downloading and reacting to Omni Messages, I'm converting to using Flags myself.

              Comment


                #8
                Here's a script that works in HS4, setting the feature's reference 1688 to a value of 14:

                Sub Main(ByVal parms as Object)
                hs.SendControlForFeatureByValue(1688,14)
                End Sub


                HS4Pro on a Raspberry Pi4
                54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                HSTouch Clients: 1 Android

                Comment


                  #9
                  I am trying the same

                  hs.SendControlForFeatureByValue(1973,99)

                  HS Log shows this error

                  Error during SendControlForFeatureByValue - Exception during fDEBUG_PI_CALLS for 1973 : 99 - Object reference not set to an instance of an object

                  device 1973 is just an OMNI Flag

                  ID
                  1973
                  Device Version
                  3.2
                  Value
                  6
                  Status
                  74
                  Interface
                  OMNI
                  Device Type
                  Api: 4
                  Priority Order
                  73
                  Relationship
                  Feature (Child)
                  Associated Devices
                  OMNI OMNI Root Device (42)

                  Any ideas?

                  Comment


                    #10
                    Are you running an immediate script command or a script? Both seem to work here, so I'm not sure what it could be.
                    HS4Pro on a Raspberry Pi4
                    54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                    Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                    HSTouch Clients: 1 Android

                    Comment


                      #11
                      A script

                      Sub Main(ByVal parms as Object)

                      hs.SendControlForFeatureByValue(1973,99)

                      End Sub

                      Also running on linux - HS 4.2.5.0

                      Same error when I run as an immediate

                      Comment


                        #12
                        That is really weird. Under Tools -> About, what are your HS/Mono versions:

                        Click image for larger version  Name:	screenshot1.png Views:	0 Size:	13.5 KB ID:	1521304

                        Edit: just saw your HS version - maybe try an upgrade and see if it works.
                        HS4Pro on a Raspberry Pi4
                        54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                        Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                        HSTouch Clients: 1 Android

                        Comment


                          #13
                          Upgraded to 4.2.7.0

                          Version
                          HS4 Pro Edition 4.2.7.0 (Linux)
                          MONO Version
                          Mono JIT compiler version 6.12.0.122 (tarball Mon Feb 22 17:29:18 UTC 2021)

                          same issue.

                          Plugin versions here

                          BLBackup 2.0.61.0,Device History 3.1.0.3,HS MyQ 4.0.8.0,Life360 1.2.2.1,mcsMQTT 5.21.4.1,OMNI 3.0.2.23,rnbWeather 4.2.0.0,Sonos 3.1.0.53,UltraNetCam3 3.0.6413.20219,Z-Wave 3.0.9.0,Z-Wave UI 1.0.0.0

                          Comment


                            #14
                            I'm at a loss. Try your script with an invalid device ref like 9999 or something and see if you get device not found or the same error.
                            HS4Pro on a Raspberry Pi4
                            54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                            Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                            HSTouch Clients: 1 Android

                            Comment


                              #15
                              1/18/2022 9:28:08 AM

                              Plugin
                              Error
                              SendControlForFeatureByValue failed - no device or feature with a ref of 9999 - dv is Nothing

                              1/18/2022 9:28:01 AM

                              HomeSeer
                              System
                              Control Panel Immediate Script: &hs.sendcontrolforfeaturebyvalue(9999,99)

                              Comment

                              Working...
                              X