logo elektroda
logo elektroda
X
logo elektroda

OpenBeken - deactivating Physical Switch Button from Home Assistant: Ignoring Accidental Light On

jbrande 1434 9
ADVERTISEMENT
  • #1 20658822
    jbrande
    Level 3  

    Is there any way from Home Assistant to deactivate a physical switch button, so if someone accidentally turns on the light from the physical switch, it will be ignored?
  • ADVERTISEMENT
  • Helpful post
    #2 20659401
    p.kaczmarek2
    Moderator Smart Home
    That's a great idea! I've added a flag for that, it's called "child lock" and it makes device ignore all physical button and toggle presses:
    https://github.com/openshwprojects/OpenBK7231...mmit/0ea403a17f11e40ad5b02dc1522a5025d03a1a0e
    Now, to use that, you need to send a proper MQTT packet from HA, do you know how to do that?
    Helpful post? Buy me a coffee.
  • #3 20659406
    jbrande
    Level 3  

    I know how to send an MQTT package, but what should I have as the topic and payload?
    Can I assign a fake pin number to a switch on another channel and control it that way?
  • ADVERTISEMENT
  • #4 20659423
    p.kaczmarek2
    Moderator Smart Home
    Well, you can always change Button role to something else (to None or anything) or assign a fake channel on your device. You can also control one device from another device and there are many ways to do it, including:
    - sending a HTTP GET to IP with command like POWER ON by using SendGET command
    - by using Tasmota Device Groups to group devices
    - by using HA automation
    It's up to you to choose the method that suits your needs best.

    Regarding setting flags from HA, you can use the SetFlag command, see docs:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    The flag number for child lock is 41 and you can set it to on (1) or off (0).
    SetFlag command can be send via MQTT or via HTTP, or entered manually, or also even it can be scripted. for example with HttpButton (you can create a custom button on your page that way).
    Helpful post? Buy me a coffee.
  • #5 20659428
    jbrande
    Level 3  

    I'm on the latest firmware but no flag 41

    OpenBeken - deactivating Physical Switch Button from Home Assistant: Ignoring Accidental Light On
  • ADVERTISEMENT
  • #6 20659430
    p.kaczmarek2
    Moderator Smart Home

    Sorry, it seems that the automatic build was not triggered this time! Let me try again, the new version should build automatically:
    OpenBeken - deactivating Physical Switch Button from Home Assistant: Ignoring Accidental Light On
    Helpful post? Buy me a coffee.
  • #7 20659431
    jbrande
    Level 3  
    Thanks.

    Just to be sure,

    MQTT package should be:

    Topic: "device_name/SetFlag41"
    Payload: 1
    ??

    Edit: if someone is looking to do the same this is the code you need

    tap_action:
    action: call-service
    service: mqtt.publish
    service_data:
    topic: cmnd/device_name/SetFlag
    payload: 41 1
  • #8 20660288
    jbrande
    Level 3  

    Thanks, is there any way to add this function as a toggle lock or another entity in HA? (like zigbee2mqtt does)

    OpenBeken - deactivating Physical Switch Button from Home Assistant: Ignoring Accidental Light On

    I tried to add it as a relay and addChangeEvent and it works nice.

    But it would be nice to instead of having a flag to enable or disable, that the flag creates the new entity to appear or not in Home Assistant, the child lock feature.
  • ADVERTISEMENT
  • #9 20661274
    jbrande
    Level 3  

    Ok, I found a better way to manually create a lock on MQTT config. Is there any way to get the state of a flag? So HA knows if it's locked or not?

    lock:
    - unique_id: "device_name_child_lock"
    name: "device_name_child_lock"
    command_topic: "cmnd/device_name/SetFlag"
    qos: 1
    payload_lock: 41 1
    payload_unlock: 41 0
    retain: true
    availability:
    - topic: "device_name/connected"
  • #10 20661884
    p.kaczmarek2
    Moderator Smart Home
    I can see how that can be a problem. I will need to think about it. Maybe I can add some simple mechanism for you to publish it. Something like $FLAG41 variable.

    Added after 7 [hours] 26 [minutes]:

    UPDATE: Working on it, do you know how to use publishInt?

    https://github.com/openshwprojects/OpenBK7231...mmit/8f52126fd641ccec43d9e9aa3c3bf45c739ac5f3
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around the implementation of a "child lock" feature in Home Assistant to disable the physical switch button on devices using OpenBeken firmware, preventing accidental activation of lights. A user inquires about the possibility of deactivating the physical switch through Home Assistant, and responses suggest using MQTT packets to set a flag (Flag 41) for the child lock. Various methods for controlling devices, such as changing button roles, using HTTP commands, and creating custom entities in Home Assistant, are discussed. The conversation also touches on the need for a mechanism to check the state of the flag to determine if the lock is active.
Summary generated by the language model.
ADVERTISEMENT