Announcement

Collapse
No announcement yet.

Help with device and MQTT topic result

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

  • Help with device and MQTT topic result

    Hi,

    I've read though the manual, and still a little unsure of how to do this. I'm hesitant to "just try" things as I broke my last mqtt setup and don't want to do the same again

    I have a virtual device that has a value of 0 or 1, I'd like to have a MQTT topic contain the devices value.
    Would I be best to create an event that monitors the the virtual device and sends an MQTT message, or can this be done directly in the plugin itself?

    Thanks

  • #2
    You have the most flexibility if you can let your virtual device be a mcsMQTT device that is created when you checkbox the A column of the topic that reports status from your MQTT end point. If you then want to command this end point from HS then enter a Pub topic for the created device on the Association or Edit page. If you need to transform a status from the end point to a numeric value then select Button as the control/status UI type on the Edit page. Edit the VSP mapping on that page is necessary. If you want to transform a numeric status to a different number then use the numeric expression on the Edit page.

    If you do want to use a non-plugin device then click the A checkbox of this device on the Association tab and edit the default publish topic for it to be whatever topic you want. When the non-plugin device changes DeviceValue then mcsMQTT will publish the value of the device. The event used to publish the topic is selected from the top of the Edit page, but it defaults to DeviceValue. If you want to command your non-plugin device from an MQTT end point then enter the subscribed topic for it. The payload of this subscribed topic will need to match the CAPI property of the device which I assume has been setup to be something like 0 and 1 for the two states.

    You should not use HS events unless there is some special reason to do so.

    Comment


    • #3
      Thanks for the explanation, will see if I can get it working!
      Cheers

      Comment


      • #4
        I've created a new topic 'Homeseer/AlexaSpeak' in the "Add/Edit" tab, but I cant see the virtual device in HS, have I missed something?
        Thanks

        Click image for larger version

Name:	mqtt1.PNG
Views:	88
Size:	166.2 KB
ID:	1315199
        Click image for larger version

Name:	mqtt2.PNG
Views:	88
Size:	86.2 KB
ID:	1315200
        Attached Files

        Comment


        • #5
          Device 34 was created. Are you Device Management filters hiding this device?

          Comment


          • #6
            Originally posted by Michael McSharry View Post
            Device 34 was created. Are you Device Management filters hiding this device?

            Ahh that was it, my bad thank you!
            The device updates when I send an update via MQTT, is it possible to have the control buttons populated, and if they're clicked then the topic is updated accordingly?

            Click image for larger version

Name:	aaa.PNG
Views:	48
Size:	29.3 KB
ID:	1317178
            Cheers

            Comment


            • #7
              Control button are populated after you enter a Publish topic on the association on the Association or Edit tabs. On the Edit tab make certain you select the type of Control that you want e.g. Buttons, List pulldown, Number box, Text box, etc.

              Comment


              • #8
                Thanks, getting a bit closer, I've set it up like this, only I'd like the control buttons to be ON/OFF (0=OFF, 1=ON).

                Click image for larger version

Name:	mqtt4.PNG
Views:	38
Size:	21.3 KB
ID:	1317547
                Click image for larger version

Name:	mqtt3.PNG
Views:	38
Size:	472.4 KB
ID:	1317548

                Comment


                • #9
                  Yesterday I posted a discussion on how to manage VSPs at https://forums.homeseer.com/forum/li...vsp-management

                  It will apply to your case as well. Before you use Device Management to get the ON and OFF for the button text, use the mcsMQTT VSP list to define both states that your HomeSeer/AlexaSpeak topic will be using. This is normally automatic as mcsMQTT sees both states being received.

                  I suspect you will have an issue with using the same topic for both publish and subscribe. Do you have a device that subscribes to the Homeser/AlexaSpeak topic? Does it also publish its status on the same Homeser/AlexaSpeak topic? You could end up with circular logic with both HS and this device sending the same information. Perhaps a description of what you are actually trying to accomplish would make it easier to get to the desired result quicker.

                  Comment


                  • #10
                    Thanks Michael,

                    I'm really just playing around with things, currently using MQTT in HS and node-red to trigger a flow. Just wanted some flexibility so I could either use the HS ON/OFF controls, or MQTT to update the topic, but sounds like it could cause a logic loop if using the same topic.

                    Ideally I'd want the HS device to be treated like a virtual device, so I can control it with HS events, then have the topic updated with the value 0/1 depending on the device state, there's be noting publishing updates directly to the topic other then HS.

                    Comment


                    • #11
                      If your orientation is with events rather than devices then you can use the mcsMQTT event triggers and actions rather than making it transparent via HS devices. McsMQTT will let you use whichever approach you are comfortable.

                      You indicate that no status reporting will be done by the MQTT node. This means you have no trigger for events and no status update for devices. In essence what I see you trying to do is send a command from HS and assume the end device receives it. This is the original 1960’s X10 approach.

                      Comment

                      Working...
                      X