Announcement

Collapse
No announcement yet.

MQTT On/Off plus Color Control

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

  • MQTT On/Off plus Color Control

    Trying to use mcsMQTT to control a Tasmota device (an H801 RGB controller) via HomeSeer. I do not with to use Hue Emulation. I'd like to control both power and color, but from what I can tell this requires separate HomeSeer devices, since Power and Color are different MQTT topics. So from an Alexa perspective, I must call out different devices to turn the device and a different device to change its color.

    Is there a way to do this on a single device? I think I'm asking for a single HomeSeer device that will send two MQTT topics, depending on whether I am asking for power or color.

    Thanks in advance.

    DavBro

  • #2
    The HS UI is a little wanting for color light control. They have a color picker, but that combines brightness and color into a single value where the color lights have these parameters controlled independently. Using two HS devices is awkward as you point out for the power and color control.

    Describe your ideal scenario given the constrains of the HS Device properties and what the bulb is expecting and I will see if mcsMQTT can make it happen. When you control a device from the HS UI you be changing the DeviceValue. On a color picker device this will be a #RRGGBB value. On a Numeric it will be some number in a range. On a VSP it will be some form of enumeration.

    Another option that exists is to setup an event that calls your script when your single H801 device is to be changed. Your script will evaluate what power and RGB values to send and then use the mcsMQTT plugin function "SendMqttMessage' to deliver the MQTT message or messages.

    In either of the two approaches you then need to consider how you want the status feedback from the bulb to be presented in the HS UI. If for example, your H801 sends a JSON payload with power and color state then you can setup an event using mcsMQTT MQTT message receive trigger and the action of that event is your script that looks at the JSON payload and populates HS devices that is best for you.

    Comment


    • #3
      Thanks for the fast reply. An ideal device would respond to two MQTT subscriptions (stat/DevName/color and stat/DevName/POWER) and publish on two topics (cmnd/DevName/color and cmnd/DevName/power). I can make two individual devices, but Alexa can't deal with them having the same name, so I end up calling by a different name when I need to power on/off and change colors. In an ideal world, it would be a 3 way device, responding to stat/DevName/dimmer and publishing on cmnd/DevName/dimmer, but now I am getting greedy.

      The script option is intriguing. I'll look close at that.

      I know that HomeSeer allows me to have 'Linked Devices' which may let me accomplish what I am trying to do, but if I could do a pure MQTT solution it would be simpler.

      The end goal is that I want seamless Alexa control, and reduce my reliance on cloud-based skills (I'm looking at you, MagicHome!). So if I can make the RGB controllers run Tasmota on pure MQTT, I can eliminate some cloud dependencies.

      I just got done building an IR to MQTT bridge that lets me map IR signals to MQTT based devices. Thanks to mcsMQTT, I can even use it to control some legacy X10 devices. This RGB device conundrum is the last piece of the puzzle. Thanks!

      Comment


      • #4
        It seems to me that your primary constraint is Alexa. Have you considered using Alexa routines to accomplish what you want?

        As an example , I have a routine “open garage door” and it sends a “on” command to my Tasmota garage door controller using the Belkin emulation in Tasmota. You could do something similar using commands that are appropriate for hue emulation.

        In in this scenario my garage door status is published by Tasmota and HS device is updated. HS also has ability to command garage door via mcsMQTT.

        in your ideal scenario you seem to b trying to overcome the name uniqueness. What I do not yet visualize is if you want two HS devices or only one. If one then where is power vs color information maintained? What will be showing for the device status on the Hs device management page?

        Comment


        • #5
          I incorrectly stated part of the info above. I only need to subscribe to one topic to get status.

          A single device is what I am after. This device needs to subscribe to stat/DevName/RESULT to get status. The trick is it needs to publish to both cmnd/DevName/power and cmnd/DevName/color to control the target. From what I can tell though, mcsMQTT devices only subscribe and publish to single topics. I guess that is what it boils down to. So here is the MQTT traffic that need to occur:

          Alexa, Turn MoodLights On. (publish: cmnd/DevName/power 1) (status returns on subscription: stat/DevName/RESULT)
          Alexa, Set MoodLights to Orange. (publish: cmnd/DevName/color #FFA500) (status returns on subscription: stat/DevName/RESULT)

          A third possible option for completeness would be:

          Alexa, Dim MoodLights to 50%. (publish: cmnd/DevName/dimmer 50) (status returns on subscription: stat/DevName/RESULT)

          So in a perfect world, a single HomeSeer device publishing to 3 MQTT topics.

          As for the Status Graphics tab, it needs a color picker, an On/Off button, and a dimmer slider, all with the usual ranges and values. The only way I see to do this now is 3 separate devices. I don't think Alexa routines has any play here because they require a fixed command. "Alexa, MoodLighting routine <insert color here>" doesn't work as far as I am aware.

          Comment


          • #6
            Using the HUE emulation of Tasmota you are able to accept the commands to control your light as desired. I know I have done Alexa, turn lamp blue and Alexa, turn lamp on. I don't know all the commands that Phillips setup, but I suspect it does brightness too. This means you do not need any HomeSeer capability to control the color lights.

            If you want HomeSeer to be part of the game then use mcsMQTT and let it create the three devices for the three types of control. You will then get status in HS and be able to control the light with HS on a function by function basis.

            Only the JSON payload will go into HS DeviceString if you only have one device created based upon the topic. You cannot do any useful control based upon information in the DeviceString. It can only be observed and it will be in its raw JSON format.

            There was a period of time when the Arduino library that is used by Tasmota for HUE emulation did not work without a patch. It was a problem with incorrect protocol being used by Alexa and the patch was needed to work around Alexa's issue. I am not certain if current builds include the patch or not. In my Tasmota builds I have included the patch.

            Comment


            • #7
              FYI, and not your issue, Hue emulation on the H801 RGB controller for Tasmota does not work for color control of a 5050 strip. It only works with WS8211 or similar. So for the moment I am going with 3 HS devices, one for power, one for color and one for dimmer.

              Comment


              • #8
                I have a magichome controller that I had loaded with Tasmota and now it has Espurna loaded. Espurna does not support HUE, only Wemo. I never tried Alexa with the Tasmota, but I did see a github post about Tasmota's support of it and it seem to be a dead thread. I looked at the Tasmota emulation source and do not see why it would not be able to support anything except for the neopixels. Likely because nobody ever did the testing.

                When you try are you able to have Alexa recognize the commands, but no response on the lights or is it a lack of recognition of the commands?

                Was your plan to use Homeseer's capability for Alexa integration? Did you look into the scripting approach for mcsMQTT?

                Comment


                • #9
                  Have not tried scripting yet. As for Tasmota w/ Hue emulation, Alexa thinks it is all ok. She responds with OK to every command. Power on/off commands work, but color change commands have no effect even though she acknowledges 'OK' for each one. I saw suggestions elsewhere about the Tasmota SetOption15 command, but it does not help. I believe you are right that pixel strings work, but the 5050 PWM strips were never tested. So when Alexa responds as if the command is working, it is likely that Tasmota send WS2812 protocol out correctly, but that would not be visible on a 5050 strip.

                  Meanwhile, MQTT control for color (and power and dimming) work fine, so the HomeSeer/mcsMQTT combination will work for me. I have MagicHome modules running native firmware, but I am trying to eliminate that cloud dependency which is why I am trying to coax the H801 to work.

                  Comment


                  • #10
                    I loaded Tasmota 6 into my 5050 light strip and did confirm what you indicated about the Alexa response and lack of color control. There is brightness and on/off control. I will poke at the Tasmota code, but I do not have my magichome controller wired for serial debug so may be difficult to understand sufficiently to make edits.

                    Going down your path you indicate you want the following result:

                    Alexa, Turn MoodLights On. (publish: cmnd/DevName/power 1) (status returns on subscription: stat/DevName/RESULT)
                    Alexa, Set MoodLights to Orange. (publish: cmnd/DevName/color #FFA500) (status returns on subscription: stat/DevName/RESULT)
                    Alexa, Dim MoodLights to 50%. (publish: cmnd/DevName/dimmer 50) (status returns on subscription: stat/DevName/RESULT)
                    Let us say you have a virtual device called MoodLights with voice control enabled. I assume that after you let Alexa discover the HS device that you are then able to request any of the three Alexa commands. Alexa will respond with, I assume, a HUE request to HS. What does HS do with the virtual device at this point? I have never worked with Alexa control via HS so don't know how HS integrates with Alexa. If you can explain this then I likely can provide the script that will give you the control you desire via MQTT.



                    Comment


                    • #11
                      I would expect it to show correct status values for the three values (power, dimmer and color). Regardless of emulation state, Tasmota always returns those properties via MQTT stat/MoodLights/RESULT, so HS should be able to return them as status. I don't generally rely on device state from HS because I come from an X10 background where status was unreliable at best. Even so, it seems like anything outside of X10 is pretty reliable.

                      BTW, to your comment about serial debug and your MagicHome device, you can still get the info without that. The Tasmota device page has a console option where you can see the same output that goes to serial. In fact, on the Config page, you can raise the logging level to get pretty detailed debug logging. I use that along with MQTTbox to monitor output of Tasmota.

                      Comment


                      • #12
                        I have played with the HUE emulation on my magichome LED controller. When I first configured it I selected magichome as the module type. It turns out that the PWM channel mapping was different between this configuration and my hardware. When the lights were red I gave Alexa command to turn them green and got no response. I concluded the situation was as you described with no response to Alexa. As I got into it I discovered the reason for no response is that the green channel was already being commanded even though the lights were red.

                        I setup Tasmota to be a generic device per the last table on https://github.com/arendst/Sonoff-Ta...rip-controller as the PWM configuration for my hardware. I was then able to command Alex, turn light strip green and the lights would turn green and included a MQTT response such as:

                        MQT: LightStrip/RESULT = {"POWER":"ON","Dimmer":16,"Color":"000028","HSBColor":"240,1 00,16","Channel":[0,0,15]}

                        I could also do on and off as well as percentages for dimming via Alexa. What I was not able to do was command White because the HUE emulation expects to control a white channel that I do not have on my hardware.

                        I looked at the H801 configuration and it did respond to Alexa commands but with funky results since my hardware uses GPIO 5, 12 and 13 for RGB and these map in the H801 configuration to W2,B,G.

                        Code:
                          { "H801",            // Lixada H801 Wifi (ESP8266)
                             GPIO_USER,        // GPIO00 E-FW Button
                             GPIO_LED1,        // GPIO01 Green LED
                             GPIO_USER,        // GPIO02 TX and Optional sensor - Pin next to TX on the PCB
                             GPIO_USER,        // GPIO03 RX and Optional sensor - Pin next to GND on the PCB
                             GPIO_PWM5,        // GPIO04 W2 - PWM5
                             GPIO_LED2_INV,    // GPIO05 Red LED
                                               // GPIO06 (SD_CLK   Flash)
                                               // GPIO07 (SD_DATA0 Flash QIO/DIO/DOUT)
                                               // GPIO08 (SD_DATA1 Flash QIO/DIO/DOUT)
                             0,                // GPIO09 (SD_DATA2 Flash QIO or ESP8285)
                             0,                // GPIO10 (SD_DATA3 Flash QIO or ESP8285)
                                               // GPIO11 (SD_CMD   Flash)
                             GPIO_PWM3,        // GPIO12 Blue
                             GPIO_PWM2,        // GPIO13 Green
                             GPIO_PWM4,        // GPIO14 W1 - PWM4
                             GPIO_PWM1,        // GPIO15 Red
                             0, 0
                          },
                        Since I do not have H801 hardware I cannot do a total evaluation, but once I configured my magichome version properly I had no issues with allowing Alexa to control the 5050 LED strip. If I want to use it in the future I will need to hack the white HUE response to control RGB rather than W1/2 because of the limitation of my hardware.

                        From my perspective there is no inherent reason Alexa is not able to control 5050 lights using Tasmota. What I worked with it a variant of 6.4.1.

                        If you want to pursue it on your end I have included a binary that contains some info level debug to trace through the lighting command. It contains //mcs comments at the end of the lines were the debug was added. It is crude, but did what I needed to see the flow and data. The source is also there. It was compiled with "default" and "default" for SSID/PW and "default" with no password for second one. It is at http://mcsSprinklers.com/mscTasmota6HUEDebug.zip

                        Comment


                        • #13
                          Very interesting. I have been looking at the generic device template over the past few days due to another issue (new Sonoff Basic modules have no exposed GPIO14). I will check this out when I have some time to play with it. Looks pretty promising. Thanks.

                          Any timeline on getting mcsTasmota running in Linux (like HS Zee?)

                          Have a good weekend!

                          Comment


                          • #14
                            mcsTasmota is a collection of variants from github Tasmota. They run on ESP8266 such as magichome controllers, Sonoff devices, Wemos, Nodemcu etc. Effectively is its own OS. Don't know what you mean be it running in Linux. mcsMQTT does run in either Linux or Windows.

                            Comment


                            • #15
                              I was checking out my WS212 plug using HUE emulation and Alexa would not recognize the request. I then went back to the light strip and it no longer worked. In my investigation I learned two things. One was the Arduino library I was using was 2.4.2 and had to go back to 2.3.0 for it recognize HUE. The second was that Alexa though my light strip was an Color XY device rather than a HSB one.

                              17:03:24 HTP: Hue API (/XZ2i4dzhNazFshOPslYj435QggNK9wjoC1HZbBEC/lights/1/state)
                              17:03:24 HTP: Hue POST args ({ "on": true, "xy": [0.7006062331309042,0.2993009868421053] })

                              I delete the light strip using Alexa app and did discovery again. This time it went back to seeing it as HSB, but it would not respond to brightness control.

                              20:20:53 HTP: Hue API (/c59b62/lights/1/state)
                              20:20:53 HTP: Hue POST args ({"hue":0,"sat":254})

                              I asked Alexa for discover devices again and then gave it a command to turn off and then on and then brightness. They all worked. I don't know if they worked because I did discovery again or if I first did on/off requests.

                              20:39:32 HTP: Hue API (/XZ2i4dzhNazFshOPslYj435QggNK9wjoC1HZbBEC/lights/1/state)
                              20:39:32 HTP: Hue POST args ({"on": true,"bri":76})

                              20:35:20 HTP: Hue API (/c59b62/lights/1/state)
                              20:35:20 HTP: Hue POST args ({"bri":77})

                              I tried color change to orange and Alexa went back to requesting Color XY

                              20:46:36 HTP: Hue API (/XZ2i4dzhNazFshOPslYj435QggNK9wjoC1HZbBEC/lights/1/state)
                              20:46:36 HTP: Hue POST args ({ "on": true, "xy": [0.5608335071330063,0.41771987447492515] })

                              I did discovery again and Alexa did not discover any new devices. It continued to use Color XY

                              Seems like the next step is to either understand why Alexa changed from HSB to Color XY or to add Color XY to RGB transformation in Tasmota.

                              My guess is that the difficulty you are having with H801 has to do with Color XY rather than HSB, but you can easily confirm it with Console and Log set to More Debug. You can do this with your build as it does not depend upon anything in my builds.


                              The build with Arduino 2.3.0 library is at http://mcsSprinklers.com/firmwareDebugHUE23.zip

                              Comment

                              Working...
                              X