Why isn't this H Bridge code giving me reverse?

I’m going to use a H Bridge box to run an actuator (the cover over the protective box for the speakers in my boat - it will be triggered when the amp is turned on). And theoretically this should work, only it doesn’t give me reverse, only on/off. Can somebody please help me with why it’s not there?

output:
- platform: ledc
  pin: GPIO14
  id: motorstart
- platform: ledc
  id: motor_forward_pin
  pin: GPIO27
- platform: ledc
  id: motor_reverse_pin
  pin: GPIO26

fan:
  - platform: hbridge
    id: aktuator
    name: "Actuator for lid to speaker box"
    pin_a: motor_forward_pin
    pin_b: motor_reverse_pin
    enable_pin: motorstart
    decay_mode: fast

There are about ten different Cover components for specific use cases, you should use one of them instead of Fan.

Thanks, @Karosm ! So you’re thinking about a template cover? I actually thought there were several ready made and fuctioning H-Bridge stuff for ESPHome, but I see it’s only lights and fans in the manual.

It all depends on your hardware, but you only mention “actuator”.
Different motor drivers can have different control logic, actuators normally have endstops etc.
Tell us what you have…

To be fair I did mention H-bridge as well, so you know I have one of those to do the physical power switching. The actuator has endstops, and it will be fully controlled by the ESP, no manual input at all. I built something from the template cover:

cover:
  - platform: template
    name: "Aktuator in speaker box"
    open_action:
      - switch.turn_on: aktuator_out
      - delay: 10s
      - switch.turn_off: aktuator_out
    close_action:
      - switch.turn_on: aktuator_inn
      - delay: 10s
      - switch.turn_off: aktuator_inn
    stop_action:
      - switch.turn_off: aktuator_out
      - switch.turn_off: aktuator_inn
    optimistic: true

switch:
  - platform: gpio
    name: "Open speaker box"
    retain: False
    id: aktuator_out
    pin:
      number: 27
      inverted: True
    restore_mode: ALWAYS_OFF

  - platform: gpio
    name: "Close speaker box"
    retain: False
    id: aktuator_inn
    pin:
      number: 26
      inverted: True
    restore_mode: ALWAYS_OFF

The switches on the ESP web server and in Hass won’t be used much, it’s basically going to be done the way that the headunit in the boat is turned on from Hass, and that will turn on both the amps and the active subs, and when the front amp (this is the front speaker box) is turned on, it sends an MQTT mesage to the broker, which then will trigger the opening with the actuator. And when it’s turned off, it will close the box.

The speakers themselves are Wharfedale Titan outdoors passive 8" monitors that can take 150 watts RMS and 600 watts peak, so they make some noise on my heavy metal (well, light metal, aluminium…) boat Mad Max, I bring my friends along for beer, fishing and music, which is the main reason for doing this. The speakers can take being exposed while in use, but since my boat is on the water all year round they would probably not survive more than a few years if they were exposed to the elements all the time. So the box will have rubber seals that the door presses against and be closed everywere else with Tec7 glue. :grin:

Yep, but there are many different logics. I asked because your code had pwm on dir pins. Many drivers expect continuous on dir pins and pwm on enable pin.

1 Like

Honestly I had no idea what I did with that first code, LIke I normally do I searched the forum, found something I hoped could work and tested it, but it didn’t do the direction change. The second, totally different version is more in my wheelhouse (to keep it maritime), I am very used to working with switches and relays and stuff like that.