Pulse Width Modulation of Relays

After hours of frustration and apparently a complete lack of understanding of the available options, I need assistance with pulse width modulation control of several relays on an 8 relay esp8266 pcf_expander. The relays are configured as binary lights.

The relay board is controlling pneumatic valves that fill or purge air from the air bags on my motorhome to keep it level based on output from an accelerometer. The code works perfectly (if not elegantly) however the rear airbags have approximately twice the volume as the fronts so it takes twice as long to fill them. Thus, I want to modulate the front relays to @ 50% ON time then tweak the percentage from there so the front and rear rise or fall at the same rate.

I have tried to configure both esp8266_pwm and slow_pwm with no sucesss. The closest I got was having the relay modulate constantly (at my desired % on/off time) with no on/off control from the code. I have not included any of my numerous attempts below as they didn’t work but have included the current esphome config from the board and a snippet of the relevant script code that is properly controlling the relays without the required modulation.

Any assistance is humbly accepted and greatly appreciated!!

ESP8266/pcf_expander

esphome:
  name: 8ch-relay
  friendly_name: 8CH_Relay

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "NNNNNNNN"

ota:
  password: "NNNNNNNN"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "8Ch-Relay Fallback Hotspot"
    password: "NNNNNNN"

captive_portal:

i2c:
  sda: 4
  scl: 5
  scan: true
  id: bus_a                                                                   
                                                                                
pcf8574:                                                                        
  - id: pcf_expander                                                            
    address: 0x27 

light:
  - platform: binary
    name: "LF Fill"
    output: relay_7

  - platform: binary
    name: "LF Purge"
    output: relay_6

  - platform: binary
    name: "RF Fill"
    output: relay_5

  - platform: binary
    name: "RF Purge"
    output: relay_4

  - platform: binary
    name: "LR Fill"
    output: relay_3

  - platform: binary
    name: "LR Purge"
    output: relay_2

  - platform: binary
    name: "RR Fill"
    output: relay_1

  - platform: binary
    name: "RR Purge"
    output: relay_0               
    
output:                                                                         
  - platform: gpio                                                              
    id: relay_0                                                                 
    pin:                                                                        
     pcf8574: pcf_expander                                                      
     number: 0                                                                 
     # One of INPUT, INPUT_PULLUP or OUTPUT                                     
     mode: OUTPUT                                                               
     inverted: True                                                             
                                                                                
  - platform: gpio                                                              
    id: relay_1                                                                 
    pin:                                                                        
      pcf8574: pcf_expander                                                     
      number: 1                                                                 
      # One of INPUT, INPUT_PULLUP or OUTPUT                                    
      mode: OUTPUT                                                              
      inverted: True                                                            
                                                                                
  - platform: gpio                                                              
    id: relay_2                                                                 
    pin:                                                                        
      pcf8574: pcf_expander                                                     
      number: 2                                                                 
      # One of INPUT, INPUT_PULLUP or OUTPUT                                    
      mode: OUTPUT                                                              
      inverted: True 
                                                                         
  - platform: gpio                                                              
    id: relay_3                                                                 
    pin:                                                                        
      pcf8574: pcf_expander                                                     
      number: 3                                                                 
      # One of INPUT, INPUT_PULLUP or OUTPUT                                    
      mode: OUTPUT                                                              
      inverted: True

  - platform: gpio                                                              
    id: relay_4                                                                 
    pin:                                                                        
     pcf8574: pcf_expander                                                      
     number: 4                                                                 
     # One of INPUT, INPUT_PULLUP or OUTPUT                                     
     mode: OUTPUT                                                               
     inverted: True                                                             
                                                                                
  - platform: gpio                                                              
    id: relay_5                                                                 
    pin:                                                                        
      pcf8574: pcf_expander                                                     
      number: 5                                                                 
      # One of INPUT, INPUT_PULLUP or OUTPUT                                    
      mode: OUTPUT                                                              
      inverted: True                                                            
                                                                                
  - platform: gpio                                                              
    id: relay_6                                                                 
    pin:                                                                        
      pcf8574: pcf_expander                                                     
      number: 6                                                                 
      # One of INPUT, INPUT_PULLUP or OUTPUT                                    
      mode: OUTPUT                                                              
      inverted: True 
                                                                         
  - platform: gpio                                                              
    id: relay_7                                                         
    pin:                                                                        
      pcf8574: pcf_expander                                                     
      number: 7                                                                 
      # One of INPUT, INPUT_PULLUP or OUTPUT                                    
      mode: OUTPUT                                                              
      inverted: True

Code Snippet

 - if:
  - type: is_value
	condition: device
	device_id: 5041ec09e6b48fe1b1bfbcdbe9e022bd 
	entity_id: 131d0c6cc0d47944cf65e959685d13ac #Accel Sensor Y
	domain: sensor
	below: -0.3
  - type: is_value
	condition: device
	device_id: 5041ec09e6b48fe1b1bfbcdbe9e022bd 
	entity_id: 97c4ba1bab5b47dc61bd2c0a0cedd9ee #Accel Sensor X
	domain: sensor
	above: 0.4
	below: 0.6
then:
  - type: turn_on
	device_id: 43d10517571fdae81451a6b8c6dfbf4d 
	entity_id: bd32cd0cee01422724da049f19892d5e #Relay RF Fill
	domain: light
  - type: turn_on
	device_id: 43d10517571fdae81451a6b8c6dfbf4d 
	entity_id: b5c7db786764111ae2bb905b6c783dcd #Relay LF Fill
	domain: light
  - wait_for_trigger:
	  - type: value
		platform: device
		device_id: 5041ec09e6b48fe1b1bfbcdbe9e022bd 
		entity_id: 131d0c6cc0d47944cf65e959685d13ac #Accel Sensor Y
		domain: sensor
		above: -0.3
		below: -0.1
	continue_on_timeout: false
  - type: turn_off
	device_id: 43d10517571fdae81451a6b8c6dfbf4d
	entity_id: b5c7db786764111ae2bb905b6c783dcd #Relay LF Fill
	domain: light
  - type: turn_off
	device_id: 43d10517571fdae81451a6b8c6dfbf4d
	entity_id: bd32cd0cee01422724da049f19892d5e #Relay RF Fill
	domain: light