www.homeseer.com    
 

Go Back   HomeSeer Message Board > 3rd Party Plug-Ins/Scripts > Plug-ins by Author > Click Here for List of Author Forums > MCS Plug-Ins and Scripts > mcsMQTT (3P)

mcsMQTT (3P) Discussion of mcsMQTT plug-in

Reply
 
Thread Tools Display Modes
  #1  
Old March 24th, 2018, 02:07 AM
drodegeb drodegeb is offline
Seer Deluxe
 
Join Date: Oct 2002
Posts: 184
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
__________________
Dave
Reply With Quote
  #2  
Old March 24th, 2018, 02:28 AM
Michael McSharry's Avatar
Michael McSharry Michael McSharry is offline
OverSeer
 
Join Date: Jul 2001
Location: North Bend, WA, USA
Posts: 13,783
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?
Reply With Quote
  #3  
Old March 24th, 2018, 02:30 AM
drodegeb drodegeb is offline
Seer Deluxe
 
Join Date: Oct 2002
Posts: 184
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?
__________________
Dave
Reply With Quote
  #4  
Old March 24th, 2018, 03:12 AM
Michael McSharry's Avatar
Michael McSharry Michael McSharry is offline
OverSeer
 
Join Date: Jul 2001
Location: North Bend, WA, USA
Posts: 13,783
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?
Reply With Quote
  #5  
Old March 24th, 2018, 11:56 PM
Michael McSharry's Avatar
Michael McSharry Michael McSharry is offline
OverSeer
 
Join Date: Jul 2001
Location: North Bend, WA, USA
Posts: 13,783
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.
Reply With Quote
  #6  
Old March 25th, 2018, 12:39 AM
drodegeb drodegeb is offline
Seer Deluxe
 
Join Date: Oct 2002
Posts: 184
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!
__________________
Dave
Reply With Quote
  #7  
Old March 26th, 2018, 12:13 AM
Michael McSharry's Avatar
Michael McSharry Michael McSharry is offline
OverSeer
 
Join Date: Jul 2001
Location: North Bend, WA, USA
Posts: 13,783
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 26th, 2018 at 12:25 AM.
Reply With Quote
  #8  
Old March 26th, 2018, 02:43 AM
drodegeb drodegeb is offline
Seer Deluxe
 
Join Date: Oct 2002
Posts: 184
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?
__________________
Dave
Reply With Quote
  #9  
Old March 26th, 2018, 12:14 PM
Michael McSharry's Avatar
Michael McSharry Michael McSharry is offline
OverSeer
 
Join Date: Jul 2001
Location: North Bend, WA, USA
Posts: 13,783
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 at 12:25 PM.
Reply With Quote
  #10  
Old March 26th, 2018, 12:35 PM
drodegeb drodegeb is offline
Seer Deluxe
 
Join Date: Oct 2002
Posts: 184
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?
__________________
Dave
Reply With Quote
  #11  
Old March 26th, 2018, 01:19 PM
Michael McSharry's Avatar
Michael McSharry Michael McSharry is offline
OverSeer
 
Join Date: Jul 2001
Location: North Bend, WA, USA
Posts: 13,783
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.
Reply With Quote
  #12  
Old April 8th, 2018, 12:53 PM
Michael McSharry's Avatar
Michael McSharry Michael McSharry is offline
OverSeer
 
Join Date: Jul 2001
Location: North Bend, WA, USA
Posts: 13,783
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.
Reply With Quote
  #13  
Old April 11th, 2018, 12:46 PM
bdickhaus's Avatar
bdickhaus bdickhaus is offline
Super Seer
 
Join Date: Feb 2002
Location: Miami, FL
Posts: 2,092
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?
Reply With Quote
  #14  
Old April 11th, 2018, 12:58 PM
Michael McSharry's Avatar
Michael McSharry Michael McSharry is offline
OverSeer
 
Join Date: Jul 2001
Location: North Bend, WA, USA
Posts: 13,783
That is excellent. Zwave is the most important since it is the native one within HS. The second was a bonus. Thank you
Reply With Quote
  #15  
Old April 13th, 2018, 07:52 PM
rmiles7721's Avatar
rmiles7721 rmiles7721 is offline
Seer Master
 
Join Date: Feb 2002
Location: Temple, GA USA
Posts: 608
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.

Name:  hassio.PNG
Views: 74
Size:  77.6 KB

Name:  hassiophone.jpg
Views: 74
Size:  29.6 KB

It's simple and fast, which leads to positive WAF. Not as much as voice control but still nice.
Reply With Quote
  #16  
Old April 14th, 2018, 12:16 AM
Michael McSharry's Avatar
Michael McSharry Michael McSharry is offline
OverSeer
 
Join Date: Jul 2001
Location: North Bend, WA, USA
Posts: 13,783
Quote:
I'm not sure about the color picker working with MQTT.
HS control via Device color picker will deliver a MQTT payload. This option became available with 3.2.18.0.
Reply With Quote
  #17  
Old June 13th, 2018, 04:09 PM
donstephens's Avatar
donstephens donstephens is offline
OverSeer
 
Join Date: Dec 2001
Location: Hamilton, MT
Posts: 2,791
Broker question

Trying to use this with Sonoff 4Ch Pro. (Thanks Pete, for all the help)

How does one use the broker? I see that it's not online according to the Statistics page. Do I have to install it? I've gone over Michael's instructions, and if so, I must have missed it.

Thanks
__________________
Don
Reply With Quote
  #18  
Old June 13th, 2018, 04:28 PM
Michael McSharry's Avatar
Michael McSharry Michael McSharry is offline
OverSeer
 
Join Date: Jul 2001
Location: North Bend, WA, USA
Posts: 13,783
There are a couple attachments provided by another user at the top sticky of this forum. It provides a step by step to setup MQTT environment.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Control Device Dim Up Dim Down DonMor HS3 Event Clinic 3 May 8th, 2016 10:03 AM
Can a virtual Harmony Hub device control a real device or activity in HS? rayvino Harmony Hub 15 April 13th, 2016 07:53 AM
Device Control Log travisdh HomeSeer General Discussion Area 2 January 22nd, 2012 08:13 PM
cannot control device from HS in4ni HomeSeer Z-Wave Plug-in 5 February 21st, 2004 06:08 PM
Control Device from a URL... Ceer123 Web Server and Interface 6 November 18th, 2003 09:27 AM


All times are GMT -4. The time now is 02:29 AM.


Copyright HomeSeer Technologies, LLC