Announcement

Collapse
No announcement yet.

Control of HS3 device

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

  • Control of HS3 device

    Hello.

    I've got the plugin working and sending out the MQTT when a native HS3 device is changed. Is there a way to control the HS3 device with a MQTT command?

    For example, the following gets published when the device is changed.

    DRPC/mcsMQTT/Z-Wave_Node_3_Dave_Office
    Off

    Thank You,

    Dave

  • #2
    I had not considered this case, but will be easy to add.

    What needs some discussion is the mechanism by which other plugin devices are controlled. I assume that CAPI would be used of will a change of the DeviceValue achieve the desired effect?

    What will be the payload on this topic to control the HS device? Is it a number or something like text for a Dim level?

    Comment


    • #3
      Thank you for being so quick to respond.

      Wouldn't most devices work in a similar way to what you already have for MQTT that are accepted in? For example, if it's a number, set the value, if it's non numeric set the string, and those on/off specials?

      Comment


      • #4
        That works fine for devices owned by mcsMQTT plugin because mcsMQTT understands the behaviors that are being managed.

        If the VSP of the ZWave device is something like Off=0, Heat=1, Cool=2, FanOnly=3 then the MQTT command payload could be either Heat or 1 with the same control objective being desired. If I treated Heat as text then it goes into DeviceString and the Zwave plugin likely would not recognize this as being a control. Something like the Label vs. Number option that exists for receive command to mcsMQTT devices could be used. I could also see text in the payload and search the VSP and if any match then convert to a number and store the number in DeviceValue. I just don't know what is the best approach and looking for guidance.

        My other concern is if I set DeviceValue, will the Zwave plugin recognize a change in the value and use this to change the state of the physical Zwave device. Normally control is done through SetIOMulti which normally is called from a UI button or similar. Do you have experience of trying to control your device using SetDeviceValue?

        Comment


        • #5
          I did some research and found CAPI is the way to control other plugin devices. Now testing with devices created in the sample plugin in the SDK. Should have it ready tomorrow.

          Comment


          • #6
            That's great! Thank you, that is a very quick turnaround! I was planning to get on tonight to do some testing with controlling via the SetDeviceValue in a script. I can't wait to see how it works when you get it done!

            Comment


            • #7
              V3.2.0.0 has been posted. Much has changed to try to get a user-friendly means to associate devices and messages for all directions and situations. The dynamic updating of the Manual and Association tabs has much logic so possible that some situations are not correctly updated. Just let me know of any inconsistencies observed.

              For commanding existing HS devices from MQTT topics there are three ways to do it.
              1. On Associations Tab ... If the Topic that will be used to control HS device has already been discovered in the Association Table then there will be a text box in the Ref column where the existing HS device that will be controlled can be specified.
              2. On Manual Tab Pub Table ... enter the HS device ref at the top and then enter the subscribe text that will be used to control it.
              3. On Manual Tab Sub Table ... enter the topic that will be used to control HS device at the top. Enter the HS device ref at the bottom.

              In all three cases other options are made available such as entry for the status/acknowledge topic, QOS etc.

              The SDK plugin I used to testing CAPI control was somewhat of a shell so I could test logic paths, but could not test any real plugin. Enable debug to get the CAPI control info that is being attempted.

              The segment of code that I am using for this is below. sValue is MQTT Payload received and iRef is the HS device reference being controlled by the MQTT message. If we have issues then others may be able to make suggestions.

              Code:
                                      Dim arrCAPI As CAPIControl() = hs.CAPIGetControl(iRef)
                                      For Each oCAPI As CAPIControl In arrCAPI
                                          If oCAPI IsNot Nothing Then
                                              If gDebugLog Then
                                                  Dim sRange As String = "Nothing"
                                                  If oCAPI.Range IsNot Nothing Then
                                                      sRange = oCAPI.Range.RangeStart.ToString & " to " & oCAPI.Range.RangeEnd.ToString
                                                  End If
                                                  hsWritelog(PLUGIN_DEBUG, "Command " & iRef.ToString & " to " & sValue & " ControlValue=" & oCAPI.ControlValue.ToString & ", Range=" & sRange & _
                                                      ", ControlType=" & oCAPI.ControlType.ToString & ", ControlString=" & oCAPI.ControlString & ", Label=" & oCAPI.Label & ", ControlUse=" & oCAPI.ControlUse.ToString)
                                              End If
                                              If IsNumeric(sValue) Then
                                                  If nValue = oCAPI.ControlValue Then
                                                      hs.CAPIControlHandler(oCAPI)
                                                      bFound = True
                                                      Exit For
                                                  ElseIf oCAPI.Range IsNot Nothing Then
                                                      If oCAPI.Range.RangeStart <= nValue AndAlso oCAPI.Range.RangeEnd >= nValue Then
                                                          bFound = True
                                                          hs.CAPIControlHandler(oCAPI)
                                                          Exit For
                                                      End If
                                                  End If
                                              Else
                                                  If oCAPI.Label.ToUpper = sValueUC Then
                                                      bFound = True
                                                      hs.CAPIControlHandler(oCAPI)
                                                      Exit For
                                                  ElseIf oCAPI.ControlString IsNot Nothing AndAlso oCAPI.ControlString.ToUpper = sValueUC Then
                                                      bFound = True
                                                      hs.CAPIControlHandler(oCAPI)
                                                      bValueChange = True
                                                      Exit For
                                                  End If
                                              End If
                                          End If
                                      Next
                                      If Not bFound Then
                                          For Each oCAPI As CAPIControl In arrCAPI
                                              If oCAPI IsNot Nothing Then
                                                  If IsNumeric(sValue) Then
                                                      If (oCAPI.ControlType = Enums.CAPIControlType.TextBox_Number OrElse oCAPI.ControlType = Enums.CAPIControlType.TextBox_String OrElse oCAPI.ControlType = Enums.CAPIControlType.Values OrElse oCAPI.ControlType = Enums.CAPIControlType.ValuesRange OrElse oCAPI.ControlType = Enums.CAPIControlType.ValuesRangeSlider OrElse oCAPI.ControlType = Enums.CAPIControlType.Radio_Option) Then
                                                          bFound = True
                                                          hs.CAPIControlHandler(oCAPI)
                                                          Exit For
                                                      End If
                                                  Else
                                                      If (oCAPI.ControlType = Enums.CAPIControlType.TextBox_String OrElse oCAPI.ControlType = Enums.CAPIControlType.Single_Text_from_List OrElse oCAPI.ControlType = Enums.CAPIControlType.Single_Text_from_List OrElse oCAPI.ControlType = Enums.CAPIControlType.TextList) Then
                                                          bFound = True
                                                          hs.CAPIControlHandler(oCAPI)
                                                          bValueChange = True
                                                          Exit For
                                                      End If
                                                  End If
                                              End If
                                          Next
                                      End If
              Last edited by Michael McSharry; March 25th, 2018, 11:25 PM.

              Comment


              • #8
                Wow, that was a quick turn around! I attempted to install it via the web interface and keep getting "Install/Update of package mcsMQTT failed." Thoughts?

                Comment


                • #9
                  When I install via updater I first disable the plugin, install, enable the plugin. I did confirm the updater install worked for me yesterday. Looks like other user had issue with the execution after the install, but the install worked.
                  Last edited by Michael McSharry; March 26th, 2018, 11:25 AM.

                  Comment


                  • #10
                    Thanks for the suggestion of disabling it first, that worked.

                    But, my association tab has no devices listed anymore.

                    And, I see this in the log:
                    mcsMQTT PostBack Line 0 An item with the same key has already been added

                    Thoughts?

                    Comment


                    • #11
                      You now need to click the button at the bottom of the association tab to see the table. First setup any checkbox and pulldown filters to restrict display as desired. This was done to improve the page load time for cases where you may want to go to a different tab than Association one and the table can take awhile to build if large number of devices or messages are to be shown.

                      Comment


                      • #12
                        I can use some help with evaluating using mcsMQTT to control non-plugin (e.g. Zwave) devices via MQTT topics. CAPI is needed to control these devices and the plugin author sets up the CAPI parameters that they want to use. In mcsMQTT I used heuristics to try to assess what that author did, but I have no means to test these other plugins. There is much debug available in this area when General Debug checkbox is used to provide information about the other plugin for which control is being attempted.

                        Comment


                        • #13
                          I was able to control lights managed by the JowiHue and Zwave plugins. I turned a light off, on and set different dim levels. Is there anything else you would like for me to try?

                          Comment


                          • #14
                            That is excellent. Zwave is the most important since it is the native one within HS. The second was a bonus. Thank you

                            Comment


                            • #15
                              I've gotten most of my important items working with it now. One of my biggest peeves with HS is the interface, particularly the mobile interface. HSTouch is OK but requires a lot more overhead and going through more steps. I'm a relative newb to Home Assistant but I am currently using it as my interface. Same with the wife. She prefers it to the HSTouch client as well. All of my Z-Wave devices working as well as virtual devices. I haven't yet added in my Jowihue, choosing to use the HASSIO stuff because I'm not sure about the color picker working with MQTT.

                              Couple of screenshots of my current HASS setup.

                              Click image for larger version

Name:	hassio.PNG
Views:	1
Size:	77.6 KB
ID:	1196346

                              Click image for larger version

Name:	hassiophone.jpg
Views:	1
Size:	29.6 KB
ID:	1196347

                              It's simple and fast, which leads to positive WAF. Not as much as voice control but still nice.

                              Comment

                              Working...
                              X