Announcement

Collapse
No announcement yet.

Convince a device to behave like a standard z-wave dimmer in hs3touch

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

    #16
    Originally posted by teladog01 View Post
    On these dynamic device screens (On/Off and Dimming), the Device field is blank on the button actions, because it can be any device that is picked from the device chooser. Then HomeSeer has some programming magic under the hood to apply the action to the correct device, since it knows which device was selected from the device chooser.
    Yeah indeed I figured they have some magic working, but the magic only goes so far - there has to be *something* on the button that actually tells it to do "On" or "Off" - If I don't touch the Device control option and leave it all blank, SOMETHING is identifying that button as being ON as opposed to OFF (even if I can't choose Alert/Blink/etc. due to code). For fun, I decided to check the XML, and while I don't fully understand what happens in the XML, I did find this:

    Code:
        <anyType xsi:type="SerializeContainer">
            <objtype>HSWidgetData</objtype>
            <obj xsi:type="HSWidgetData">
                <WidgetType>HS_Label</WidgetType>
                <ScreenName>Virtual Hue Dimmer</ScreenName>
                <MyName>Label 089</MyName>
                <ID>38463.4879978</ID>
                <wp xsi:type="WidgetProp_Label">
                    <Left>20</Left>
                    <Top>485</Top>
                    <Width>86</Width>
                    <Height>41</Height>
                    <ZOrder>Front</ZOrder>
                    <MemberOfGroupName />
                    <FontName>Verdana</FontName>
                    <FontSize>14</FontSize>
                    <FontStyle>Bold</FontStyle>
                    <FontColor>-1</FontColor>
                    <TextAlign>32</TextAlign>
                    <FontColorSelected>-16777216</FontColorSelected>
                    <FontStyleSelected>Bold</FontStyleSelected>
                    <FontSizeSelected>14</FontSizeSelected>
                    <FontNameSelected>Verdana</FontNameSelected>
                    <NoPress>false</NoPress>
                    <MarqueeText>false</MarqueeText>
                    <MarqueeTextSpeed>200</MarqueeTextSpeed>
                    <MargueeTextIncrement>10</MargueeTextIncrement>
                    <ImageFile />
                    <ImageFileSelected />
                    <BackImageFile>\Tabletop\Buttons\plain-button-norm.png</BackImageFile>
                    <BackImageFileSelected>\Tabletop\Buttons\plain-button-pressed.png</BackImageFileSelected>
                    <ImageFormatSelected>Stretched</ImageFormatSelected>
                    <BackColor>16777215</BackColor>
                    <BackColorSelected>16777215</BackColorSelected>
                    <_BorderStyle>None</_BorderStyle>
                    <_IsHTML>false</_IsHTML>
                    <_AllowNavigation>false</_AllowNavigation>
                    <_HonorAllReleases>false</_HonorAllReleases>
                    <_Visible>true</_Visible>
                    <BackImageFileURL />
                    <BackImageFileSelectedURL />
                    <Text>Alert</Text>
                </wp>
                <HS_Status_Ref_Sel>0</HS_Status_Ref_Sel>
                <HS_Status_Ref_Sel_SubType>0</HS_Status_Ref_Sel_SubType>
                <HS_Status_Type_Sel>1</HS_Status_Type_Sel>
                <HS_Status_Sel_KeyNum1>0</HS_Status_Sel_KeyNum1>
                <HS_Status_Sel_KeyNum2>0</HS_Status_Sel_KeyNum2>
                <RSSRowSel>0</RSSRowSel>
                <RSSRowDeSel>0</RSSRowDeSel>
                <HS_Status_Ref_DeSel>0</HS_Status_Ref_DeSel>
                <HS_Status_Type_DeSel>1</HS_Status_Type_DeSel>
                <HS_Status_DeSel_KeyNum1>0</HS_Status_DeSel_KeyNum1>
                <HS_Status_DeSel_KeyNum2>0</HS_Status_DeSel_KeyNum2>
                <HS_Status_DeSel_ID>0</HS_Status_DeSel_ID>
                <ValueStatusModifierType>None</ValueStatusModifierType>
                <ValueStatusModifierNumber>0</ValueStatusModifierNumber>
                <Actions_Active />
                <Actions_DeActive>
                    <TouchAction>
                        <Action>55</Action>
                        <ActString />
                        <ActScriptProc />
                        <ActScriptParmControls>
                            <double>0</double>
                            <double>0</double>
                            <double>0</double>
                            <double>0</double>
                            <double>0</double>
                            <double>0</double>
                            <double>0</double>
                            <double>0</double>
                            <double>0</double>
                            <double>0</double>
                        </ActScriptParmControls>
                        <ActValue>0</ActValue>
                        <ActDouble>0</ActDouble>
                        <ActControlID>0</ActControlID>
                        <ActDvEvRef>7201</ActDvEvRef>
                        <Act_sKey />
                        <Act_iKey1>0</Act_iKey1>
                        <Act_iKey2>0</Act_iKey2>
                        <ActControl_Label>On</ActControl_Label>
                        <ActControl_Type>1</ActControl_Type>
                        <ActControl_Value xsi:type="xsd:string">ON</ActControl_Value>
                        <ActControl_Data xsi:type="xsd:string" />
                    </TouchAction>
                </Actions_DeActive>
                <Actions_Change />
                <StatusImages />
                <StatusColors />
                <SuppressAssociationAction>false</SuppressAssociationAction>
            </obj>
        </anyType>

    The Key line being towards the end:

    Code:
    <ActControl_Label>On</ActControl_Label>
    This is the stanza that, to the best I can tell, is for my Alert button. No where in my alert button in the UI do I see any place to set "On". I'm really tempted to just mess with the XML and see what I can come up with here.

    Unfortunately, I don't think you're going to be able to do what you want without a bunch of custom scripting tied to the Alert, Blink, and Loop buttons. HomeSeer will have to explicitly add support to the dynamic device screens in HSTouch, i.e. make it "JowiHue device aware", in order for this to work out of the box.
    Yeah, that might be the case, and doesn't scare me off that much. But if I do have to go that route I am a *little* bit surprised that it couldn't be done either just with the UI or the XML. I guess I'll see what I can do....

    Comment


      #17
      Originally posted by paul View Post

      Yeah indeed I figured they have some magic working, but the magic only goes so far - there has to be *something* on the button that actually tells it to do "On" or "Off" - If I don't touch the Device control option and leave it all blank, SOMETHING is identifying that button as being ON as opposed to OFF
      My guess is that Designer, even though you've not selected anything for the Command in the drop down, is setting it to On as the default value in the XML since it is the first one in the list.

      Comment


        #18
        Originally posted by teladog01 View Post

        My guess is that Designer, even though you've not selected anything for the Command in the drop down, is setting it to On as the default value in the XML since it is the first one in the list.
        I think it's getting it from the previous button - I copied from the "On" button to make my new ones. If I copy the "Off" button instead, it controls "Off" on the new button. I'm thinking its a value that just isn't exposed in the Designer, but is maintained by Designer to support their default project. I'll test as soon as I have a chance, and find out (by way of directly editing the xml).

        Paul

        Comment


          #19
          Originally posted by paul View Post

          I think it's getting it from the previous button - I copied from the "On" button to make my new ones. If I copy the "Off" button instead, it controls "Off" on the new button. I'm thinking its a value that just isn't exposed in the Designer, but is maintained by Designer to support their default project. I'll test as soon as I have a chance, and find out (by way of directly editing the xml).

          Paul
          Ahh, yes that makes sense if you copied it.

          I'm curious as well what will happen if you manually change the command in the xml...

          Comment


            #20
            Originally posted by teladog01 View Post

            Ahh, yes that makes sense if you copied it.

            I'm curious as well what will happen if you manually change the command in the xml...
            Well, my initial try didn't work, I get this in the log:

            Code:
            (5) CAPIHandleStatus failed with reason: Input string was not in a correct format.
            Need to do some more digging....

            Paul

            Comment


              #21
              Well, I haven't been able to find a way to make it happen, so I suspect I'll have to come up with a custom approach. So here's a question - I was looking at the different options for ActionsOnRelease - if I could find a way to simply set/identify the device that is being used, I can probably make a script do what I need to do. Anyone know if there is any variable that normally is set to the ID or something for the device and/or a way to pass it off on a button press to either a script, or to something else that I could then trigger an event off of to suck in that ID and from there do what I need to do?

              I guess the other thing I could do is band-aid it - I only have three switches that meet the criteria for this, I could just create three screens, use a unique custom device type for each, and hard code the button on the screen....

              Comment


                #22
                Originally posted by paul View Post
                if I could find a way to simply set/identify the device that is being used, I can probably make a script do what I need to do..
                "Run a HomeSeer script with values from elements" sounds promising The devices are already there to pass as the script parameters...devicename, devicelocation1, devicelocation2...

                Click image for larger version

Name:	Screenshot 2020-04-16 08.58.00.png
Views:	116
Size:	31.0 KB
ID:	1378217

                Comment


                  #23
                  Indeed - I was initially thinking it was going to have the same problem as Controlling a Device using Element Selection, but apparently they're not the same sort of thing at all. I'm going to play with that and see if it can send something to the script that identifies the device enough to control it.....

                  Comment


                    #24
                    Ok, so I've written a short test script. Though I'm getting an interesting failure. I've set the button to send the Device Name as parameter 0, and created a value element to allow me to send the value I want as parameter 2. I've established that the Device Name and Parameter are being correctly sent to the script when the button is pushed. But when I actually try to set the Device by Name, I'm getting an odd error. The script:

                    Code:
                    Imports System.Text
                    
                    'takes the device from a custom Device screen in hstouch and sets it to the requested value
                    'call Main with Device Name,Value in two item array.
                    
                    Sub Main(parms As Object)
                        Dim logName As String = "Custom Device Buttons Script"  'set log name for HS log
                        Dim Debug As Boolean = True
                    
                        Dim Device as String = parms(0)
                        Dim Value as Integer = parms(1)
                    
                        if Debug Then hs.WriteLog(logName, "DEBUG: Device = " & Device & " Value = " & Value)
                        hs.SetDeviceValueByName(Device, Value, True)
                    
                    End Sub
                    The error:

                    Code:
                    Running script setCustomDeviceButtons.vb :Exception has been thrown by the target of an invocation.->Does entry point Main exist in script? at
                    System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at
                    System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
                    BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Scheduler.clsRunVBNetScript.ExecuteScript()
                    If I comment out the hs.SetDeviceValueByName, the script completes and puts my values into the log. IDeas?

                    regards,

                    Paul

                    Comment


                      #25
                      Originally posted by paul View Post
                      If I comment out the hs.SetDeviceValueByName, the script completes and puts my values into the log. IDeas?
                      Looks like SetDeviceValueByName only takes two parameters...

                      http://help.homeseer.com/help/HS3/st...icevaluebyname

                      Comment


                        #26
                        Yeah, indeed I just found that about 30 min ago. I had initially grabbed the syntax from several forum threads, but then went back to the base doco, which I should have done from the start. I have the whole thing working now:

                        - Create the virtual device, set Status/Value pairs to the same as the Philips Hue device (or whatever other device you want), with whatever images you want
                        - Link the two devices together
                        - Set the Device Type string on the Advanced tab to (in my case) "Virtual Hue Dimmer"
                        - In Designer, copied the Dimming Devices screen to "Virtual Hue Dimming Devices"
                        - On my new screen, I set the Device Types array to have only "Virtual Hue Dimmer". Now when I go into the device in Touch, it grabs my new screen with slider
                        - On my new screen, changed the slider max value to 254. (the Hues go from 0-255, but 255 sets "On", which currently does last level, rather than full on).
                        - Created Alert, Blink and Colour loop buttons
                        - Created "Visible=False" buttons for Alert, Blink and Colour that contain the Text of 258, 260, and 259 respectively (the numbers jowihue uses to set those params)
                        - Set the initial buttons to run a script passing element parameters, passed the Floor, Room, Device Name and button value to the script
                        - Script takes the values and sets the device.
                        - Boom, it works, dynamically for any device with a Device Type of "Virtual Hue Dimmer".

                        The script 'setCustomDeviceButtons.vb':

                        Code:
                        Imports System.Text
                        
                        'takes the device from a custom Device screen in hstouch and sets it to the requested value
                        'call Main with Floor, Room, Device Name,Value in four item array.
                        
                        Sub Main(parms As Object)
                            Dim logName As String = "Custom Device Buttons Script"  'set log name for HS log
                            Dim Debug As Boolean = True
                        
                            Dim Floor as String = parms(0)
                            Dim Room as String = parms(1)
                            Dim Device as String = parms(2)
                            Dim Value as Integer = parms(3)
                            Dim FullDevice = Floor + " " + Room + " " + Device
                        
                            if Debug Then hs.WriteLog(logName, "DEBUG: FullDevice = " & FullDevice & " Value = " & Value)
                            hs.SetDeviceValueByName(FullDevice, Value)
                        
                        End Sub
                        The Screen with Buttons:

                        Click image for larger version  Name:	VirtualDimmerScreen.png Views:	0 Size:	34.1 KB ID:	1378306

                        The Action:

                        Click image for larger version  Name:	AlertButton.png Views:	0 Size:	595.7 KB ID:	1378307

                        And it works. W00t. Thanks all for the help....

                        Comment


                          #27
                          Originally posted by paul View Post
                          And it works. W00t. Thanks all for the help....
                          Nice job! šŸ‘ I considered attempting something along these lines several years ago but it just never became a priority. Good to know it works.

                          Iā€™m curious why you chose to use an intermediary virtual device instead of the actual Hue (jowihue?) device. Was there problems using the original?

                          Comment


                            #28
                            Originally posted by teladog01 View Post

                            Nice job! šŸ‘ I considered attempting something along these lines several years ago but it just never became a priority. Good to know it works.

                            Iā€™m curious why you chose to use an intermediary virtual device instead of the actual Hue (jowihue?) device. Was there problems using the original?
                            I did consider changing the original, but then decided that I didn't want to risk breaking devices if something changed on the JowiHue device during updates to the plugin. I thought the Virtual intermediary was safer. I've just hidden the originals out of the way and the Virtual device is what people see.

                            regards,

                            Paul

                            Comment


                              #29
                              Originally posted by paul View Post
                              I did consider changing the original, but then decided that I didn't want to risk breaking devices if something changed on the JowiHue device during updates to the plugin. I thought the Virtual intermediary was safer. I've just hidden the originals out of the way and the Virtual device is what people see.
                              I see. I do something similar here w/ my Hue devices. I used to link them to a virtual device and then do my interfacing with the virtual device, just like you are doing. But that was back before JowiHue existed and I was using Jon00's Philips Hue utility. Nowadays using JowiHue, I link the JowiHue devices to the actual z-wave dimmer (WD100's) that controls that bulb's socket (I have load wire connected to the incoming hot line so the socket is always live), and do my interfacing using the WD100 devices.

                              Glad you got it working

                              Comment


                                #30
                                Originally posted by teladog01 View Post

                                I see. I do something similar here w/ my Hue devices. I used to link them to a virtual device and then do my interfacing with the virtual device, just like you are doing. But that was back before JowiHue existed and I was using Jon00's Philips Hue utility. Nowadays using JowiHue, I link the JowiHue devices to the actual z-wave dimmer (WD100's) that controls that bulb's socket (I have load wire connected to the incoming hot line so the socket is always live), and do my interfacing using the WD100 devices.

                                Glad you got it working
                                I'm actually (sort of) doing both. I'm using Inovelli switches on the Hue bulbs, the Inovellis let you disable the load relay - I like that because it means I don't have to break code to wire the bulbs up full time. Then use the central scene on the switch to trigger the Hue bulbs. I'm still holding up hope that some day HS will add that feature too the 200 series (my understanding is that there is no more room in the code for something like that in the 100 series).

                                The only reason I've just added in the Virtual device isn't for additional controlling ability, it was purely for the vanity of preferring the slider screen of the Z-Wave devices in the default Touch project. It's not providing additional functionality, it's just making the UI look nicer.



                                Comment

                                Working...
                                X