logo elektroda
logo elektroda
X
logo elektroda

[Solved] OpenBeken for Treatlife 3-way switch - how to setup stairs switches pair in OBK

chri5k 1530 17
ADVERTISEMENT
  • #1 20480900
    chri5k
    Level 5  
    Hi All,

    The OpenBeken firmware is an awesome project. I have been able to use it to "cut the cloud" and enable local control of many devices.

    I am having trouble with a Treatlife 3-way switch. The main switch in the 3-way setup works fine when using the button or via HA. However, when using the remote "dumb switch" the LED on the main switch or the switch depiction in HA do not track the actual status of the lights. When using the button on the main switch, the LED is on when the lights are off. The LED turns off when the button is pressed and the lights turn on. Using the "dumb switch", the lights turn on and off but the LED on the main switch does not change. I found a post on this forum where another user was having the same issue. Per the reply to that post I added a dInput_n to PIN 26 and set it to MQTT channel 4. HA shows a new sensor for this pin and the sensor tracks the state of the lights when they are actuated from either switch. What I can't figure out is how to make the LED on the main switch track this sensor. Below is the configuration of the main switch.

    {
    "vendor": "Tuya",
    "bDetailed": "0",
    "name": "Full Device Name Here",
    "model": "enter short model name here",
    "chip": "BK7231T",
    "board": "TODO",
    "keywords": [
    "TODO",
    "TODO",
    "TODO"
    ],
    "pins": {
    "6": "Btn;1",
    "8": "LED;1",
    "24": "Rel;1",
    "26": "dInput_n;4"
    },
    "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
    "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }
  • ADVERTISEMENT
  • #2 20480930
    p.kaczmarek2
    Moderator Smart Home
    Hello, I would need some more information about the device because I am not yet sure what exactly is the issue.

    Is your device a stairs switch, the switch where one bulb is connect basically to two switches and it's not possible to simply tell whether the bulb is on by checking the single relay state?

    And you are using it indeed in the 3-way switch configuration?
    OpenBeken for Treatlife 3-way switch - how to setup stairs switches pair in OBK
    Helpful post? Buy me a coffee.
  • #3 20480959
    chri5k
    Level 5  
    Yes, the device and wiring are as in the stair switch picture you posted. The "main / smart switch" is switch 1 in the picture and the "dumb switch" is switch 2 in the picture. The relay state does not change on the device when the light bulb is actuated by the "dumb switch". The sensor in HA that tracks dInput_n on PIN 26 does show the actual state of the light bulb.

    This seems to be the same issue in the previous posts but I did not find a resolution to these posts.
    https://www.elektroda.com/rtvforum/topic3866123-390.html#19973258
    https://www.elektroda.com/rtvforum/topic3866123-390.html#19973661
  • #4 20480970
    p.kaczmarek2
    Moderator Smart Home
    Ah, I remember that issue. I am not sure if it was resolved.

    What about doing a work around?

    SOLUTION 1 - link switches by GET packet
    On switch A, change Relay role to AlwaysLow
    On switch A, add following code in autoexec.bat:
    
    // send POWER ON to second switch
    alias send_on SendGet http://192.168.0.112/cm?cmnd=Power%20On
    // send POWER OFF to second switch
    alias send_off SendGet http://192.168.0.112/cm?cmnd=Power%20Off
    // do certain action when channel changes
    addChangeHandler Channel1 == 0 send_off
    addChangeHandler Channel1 == 1 send_on
    

    change IP to be the IP of switch B.

    Then, switch A relay is always off, but when toggled it sends data to switch B and switch B really operates relay...

    EDIT: maybe this could be done even better. Instead of sending On/Off, just send Toggle in both cases, this will avoid a little 'desync' issue when you first tap switch A, and then switch B... just change "ON" and "OFF" in SendGET to Toggle..

    If you don't like solution, here is alternative.
    SOLUTION 2 - link switches by device group
    On switch A, change Relay role to AlwaysLow
    On both switches, setup two-way DGR:
    OpenBeken for Treatlife 3-way switch - how to setup stairs switches pair in OBK
    OpenBeken for Treatlife 3-way switch - how to setup stairs switches pair in OBK

    DGR should be a bit better, because first solution may not sync-back the state of second switch in the current state of my script.

    What do you think about those solutions, do they fit your use case? If not, we can think about one more way to solve the problem.
    Helpful post? Buy me a coffee.
  • #5 20480985
    chri5k
    Level 5  
    Switch B is a dumb switch so there is no way for switch A to signal it. I was wondering if there is a way to control the LED on switch A. If so, automation in HA or on the switch could set the state of the LED by tracking dInput_n from pin 26.
  • ADVERTISEMENT
  • #6 20481013
    p.kaczmarek2
    Moderator Smart Home
    In case of DGR solution the LED (channel 1 state) is synced in both ways on both switches.

    The HTTP GET solution could also sync LED on dummy switch with some callback trickery.

    Added after 1 [minutes]:

    chri5k wrote:
    switch could set the state of the LED by tracking dInput_n from pin 26.

    This will also work, as long as dInput_n provides a valid 1 or 0 output. Just set dInput_n channel to the same channel that has LED, for example, use channel 2 or something.
    Helpful post? Buy me a coffee.
  • #7 20481022
    chri5k
    Level 5  
    Switch B is not a smart switch. It's just a plain old mechanical 3-way switch from the home improvement store.

    The building previously used a Kasa smart switch with this same wiring and it worked as expected. It also worked with the stock 3-way Treatlife firmware. Once I "cut the cloud" by flashing OpenBeken, I ran into this issue.
  • ADVERTISEMENT
  • #8 20481036
    p.kaczmarek2
    Moderator Smart Home
    Ah ok, now I understand what you mean.
    I was under impression that you was referring as "dumb" in a way that it just sends data and has no control, but you mean not a smart switch.
    I was confused because I saw people buying Treatlife 3-way switches that are sold in pairs....
    OpenBeken for Treatlife 3-way switch - how to setup stairs switches pair in OBK

    Ok, so we are now forced to use dInput solution.

    Tell me, does having that dInput on channel, let's say, channel 2, gives you a reliable reading showing whether light is ON or OFF? Does it really always yields 1 for ON and 0 for Off, etc?
    (or dInput_n, if you want negation).

    If that's working , then we can easily use that value futher.

    Added after 2 [minutes]:

    Now that I consider your post again, with understanding that you meant that one of your switches is not smart, then:

    chri5k wrote:
    Per the reply to that post I added a dInput_n to PIN 26 and set it to MQTT channel 4. HA shows a new sensor for this pin and the sensor tracks the state of the lights when they are actuated from either switch. What I can't figure out is how to make the LED on the main switch track this sensor.

    Solution is simple - if you have dInput on channel 4, set LED channel to 4 as well. And that's all.
    Helpful post? Buy me a coffee.
  • #9 20481056
    chri5k
    Level 5  
    Sorry for the confusion. I may not have explained well.

    Yes, dInput_n seems to accurately reflect the state of the light bulb. I actuated both the "smart switch" and the "dumb switch" about 50 times each and dInput_n always had the correct state of the light bulb.
  • Helpful post
    #10 20481062
    p.kaczmarek2
    Moderator Smart Home
    No problem, so the solution is very simple. Just set the same channel for LED and dInput. Please try and tell me if it works.

    You could also setup your HA yaml to "listen" for the channel publish of dInput channel and use it to display light state in HA.
    Helpful post? Buy me a coffee.
  • #11 20481159
    chri5k
    Level 5  
    Yes! That worked. Below is the config from the web application.

    {
    "vendor": "Tuya",
    "bDetailed": "0",
    "name": "Full Device Name Here",
    "model": "enter short model name here",
    "chip": "BK7231T",
    "board": "TODO",
    "keywords": [
    "TODO",
    "TODO",
    "TODO"
    ],
    "pins": {
    "6": "Btn;1",
    "8": "LED;2",
    "24": "Rel;1",
    "26": "dInput_n;2"
    },
    "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
    "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }
  • #12 20481187
    p.kaczmarek2
    Moderator Smart Home
    Haha, I am really sorry for not getting that earlier, but I somehow didn't think you'd ask for a such simple fix. Anyway, now that's working, I think we can close this topic.

    If you have any other questions, or need a particular feature, feel free to ask, I'll try to help
    Helpful post? Buy me a coffee.
  • #13 20481194
    chri5k
    Level 5  
    Yes, please close the topic. Also, you may want to update the configuration on the website where the modules pull configuration when using the web application. That is where I received the initial configuration after flashing to OpenBeken.
  • #14 20481200
    p.kaczmarek2
    Moderator Smart Home
    I was not aware about that dInput back then. Template is now updated:
    https://github.com/OpenBekenIOT/webapp/commit/5f5f0b304cb113fbda8c73d708dac75079a61ed8
    Helpful post? Buy me a coffee.
  • #15 20541383
    jaymcentire
    Level 1  
    Can you help me with the MQTT code for Home Assistant on this? The existing yaml code doesn't work as intended. When the dumb switch gets used, the switch in HA gets all messed up. Thanks in advance.
  • Helpful post
    #16 20541684
    p.kaczmarek2
    Moderator Smart Home
    Hello, how your current Yaml looks like?

    I think you need to use channel 2 (dInput_n) to track the state of the light...
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #17 20759455
    Zain00
    Level 10  
    I just got a 3-way switch but came with WR2E
    I see an IC on the back of the WIFI module and I was wondering if this chip has something to do with the 3-way function.
    Because the switch claim to work with regular mechanical 3-way switch.

    OpenBeken for Treatlife 3-way switch - how to setup stairs switches pair in OBK
    the marking in the chip

    GD HH2032
    25Q16CTIG
    AP26305

    I still haven't flashed openbeken yet.
  • #18 20759462
    chri5k
    Level 5  

    Yes! That worked. Below is the config from the web application.

    {
    "vendor": "Tuya",
    "bDetailed": "0",
    "name": "Full Device Name Here",
    "model": "enter short model name here",
    "chip": "BK7231T",
    "board": "TODO",
    "keywords": [
    "TODO",
    "TODO",
    "TODO"
    ],
    "pins": {
    "6": "Btn;1",
    "8": "LED;2",
    "24": "Rel;1",
    "26": "dInput_n;2"
    },
    "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
    "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }

Topic summary

The discussion revolves around configuring the OpenBeken firmware for a Treatlife 3-way switch setup, specifically addressing issues with LED status synchronization when using a "dumb switch" alongside a smart switch. The main switch operates correctly via Home Assistant (HA) and its button, but the LED does not reflect the actual light status when the dumb switch is used. Users suggest utilizing a dInput_n on PIN 26 to track the light's state accurately. A solution is proposed to set the LED channel to the same channel as dInput_n, which successfully resolves the issue. Additional inquiries about MQTT code for HA and the compatibility of a different switch model are also discussed.
Summary generated by the language model.
ADVERTISEMENT