Announcement

Collapse
No announcement yet.

Turning Outlets on and Off.

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

  • Turning Outlets on and Off.

    I'm just learning to use MQTT with this Plugin.. I added two outlets to the zigbee2MQTT device and I'm able to see the Power Consumption of the Test Outlet and I can see the State Change of the Sylvania Outlet.

    What I cant figure out is how to Change either Outlet from On to Off by using a button or however it should be done..

    Click image for larger version

Name:	Screen Shot 2018-12-16 at 11.19.46 AM.png
Views:	11
Size:	18.4 KB
ID:	1266952Click image for larger version

Name:	Screen Shot 2018-12-16 at 11.20.03 AM.png
Views:	11
Size:	33.6 KB
ID:	1266953

  • #2
    The text box in green that you posted needs to be filled in with the MQTT topic that zigbee2mqtt will accept commands. This should be described in https://koenkk.github.io/zigbee2mqtt...structure.html which is the mqtt topics link from the Wiki and the applicable segment shown below

    zigbee2mqtt/[DEVICE_ID]/set

    Publishing messages to this topic allows you to control your Zigbee devices via MQTT. Only accepts JSON messages. An example to control a Philips Hue Go (7146060PH).
    { "state": "ON", // Or "OFF", "TOGGLE" "brightness": 255, "color_temp": 155, "color": { // XY color "x": 0.123, "y": 0.123, // OR // RGB color "r": 46, "g": 102, "b": 193 }, // Blinks the bulbs, possible values: // - "select": single blink // - "lselect": blinking for a longer time // - "none": stop blinking "alert": "select", // Specifies the number of seconds the transition to this state takes (0 by default). "transition": 3, }
    transition specifies the number of seconds the transition to this state takes (0 by default).

    Remove attributes which are not supported for your device. E.G. in case of a Xiaomi Mi power plug ZigBee (ZNCZ02LM) only send the "state" attribute.
    The convention is to use the same topic on which it reports and add a "/set" to the end. I think your subscribe topic is "Test_Outlet/power" so you would enter for the Pub text box "Test_Outlet/power/set". Note that topic is generally case-sensitive.

    The payload needs to be JSON format so you will also need to fill in the Publish template text box that you get to from the Edit tab of mcsMQTT. You get to this place by clicking on the Ref button on the Association tab for the device that you want to edit. JSON format starts with a left bracket and ends with a right bracket. All text is encased with quote. Numbers do not have quotes. Colon is used to separate the parameter from the parameter value. Comma is used to add additional parameterarameterValue pairs.

    So the pub template would look like {"state":"ON"} if you always wanted to turn the device ON. Since you want to turn to level commanded by HS then you would use {"state":"$$STATUS:"} where $$STATUS: is the replacement keyword for HS Device Status.

    I can see how HS control of brightness, color, and state could be awkward. I do have a color led bulb that I have not yet paired. I will need to do that to get a feel of how to best make HS and zigbee2mqtt work together for this class of product. I will also do it to confirm that my guidance above is correct.

    Comment


    • #3
      Thanks.. This may be way above my capabilities. I tried it and it actually added the on off button to the sylvania light but they don't do anything when I click them. I guess I'm going to need to read some more and look for basic screenshots..


      Originally posted by Michael McSharry View Post
      The text box in green that you posted needs to be filled in with the MQTT topic that zigbee2mqtt will accept commands. This should be described in https://koenkk.github.io/zigbee2mqtt...structure.html which is the mqtt topics link from the Wiki and the applicable segment shown below



      The convention is to use the same topic on which it reports and add a "/set" to the end. I think your subscribe topic is "Test_Outlet/power" so you would enter for the Pub text box "Test_Outlet/power/set". Note that topic is generally case-sensitive.

      The payload needs to be JSON format so you will also need to fill in the Publish template text box that you get to from the Edit tab of mcsMQTT. You get to this place by clicking on the Ref button on the Association tab for the device that you want to edit. JSON format starts with a left bracket and ends with a right bracket. All text is encased with quote. Numbers do not have quotes. Colon is used to separate the parameter from the parameter value. Comma is used to add additional parameterarameterValue pairs.

      So the pub template would look like {"state":"ON"} if you always wanted to turn the device ON. Since you want to turn to level commanded by HS then you would use {"state":"$$STATUS:"} where $$STATUS: is the replacement keyword for HS Device Status.

      I can see how HS control of brightness, color, and state could be awkward. I do have a color led bulb that I have not yet paired. I will need to do that to get a feel of how to best make HS and zigbee2mqtt work together for this class of product. I will also do it to confirm that my guidance above is correct.

      Comment


      • #4
        You can bring your prior degugging skills to play with use of mosquitto_sub to see what was actually sent by mcsMQTT. I do not think mcsMQTT has publish debug, but an easy addition so it would appear in the debug log.

        I also played with the color LED and my expectations are correct about how one controls it. It also presents additional challenge that I will need to make additional capability in mcsMQTT to handle the color mapping. I will start a separate thread on this subject.

        Comment


        • #5
          When trying to get MQTT working on my Win10 machine, I found it very useful to use MQTTLens. It is a Chrome app. It lets you publish and subscribe. Good debugging tool.

          Comment


          • #6
            Finally got things working for now.. Even added a Iris Motion Sensor 3326-L and Iris Contact Sensor and the Sylvania Outlet even works.



            Click image for larger version

Name:	Screen Shot 2018-12-18 at 8.05.48 PM.png
Views:	15
Size:	92.3 KB
ID:	1267684

            Comment

            Working...
            X