This is a simple Motor/Relay pulse bridge that drives specified GPIO outputs for a specified period of time. Such implementation is actually used for controlling latching relays in Tuya switches. I also used it succesfully in Tuya valve.
- Add this external component to your yaml
external_components:
- source: github://szupi-ipuzs/esphome-external-components
components: mr_bridge
- Add a switch and specify 2 gpio outputs as
pin_forward
andpin_reverse
. You also need to definepulse_length
which specifies the time (in ms) during which the outputs should be driven high. The allowed range is 10ms - 10000ms (10 seconds).
Additional optionaloptimistic
parameter (True/False) specifies if the switch state should be changed immediately (True) or only after the pulse is finished (False). The default is True.
switch:
- platform: mr_bridge
id: test_mrbridge_switch
name: "Test M/R bridge"
pin_forward: GPIO16
pin_reverse: GPIO17
pulse_length: 1000ms
optimistic: False
It should be noted that I based this code greatly on OpenBeken's "bridge driver".