Slow PWM Output¶
Similar to PWM, the Slow PWM Output platform allows you to control GPIO pins by pulsing them on/off over a longer time period. It could be used to control a heating element through a relay where a fast PWM update cycle would not be appropriate.
This is for slow PWM output. For fast-switching PWM outputs (for example, lights), see these outputs:
ESP32: ESP32 LEDC Output
ESP8266: ESP8266 Software PWM Output
# Example configuration entry output: - platform: slow_pwm pin: D1 id: my_slow_pwm period: 15s
id (Required, ID): The id to use for this output component.
period (Required, Time): The duration of each cycle. (i.e. a 10s period at 50% duty would result in the pin being turned on for 5s, then off for 5s)
pin (Optional, Pin Schema): The pin to pulse.
state_change_action (Optional, Automation): An automation to perform when the load is switched. If a lambda is used the boolean
stateparameter holds the new status.
turn_on_action (Optional, Automation): An automation to perform when the load is turned on. Can be used to control for example a switch or output component.
turn_off_action (Optional, Automation): An automation to perform when the load is turned off.
turn_off_actionmust be configured together.
restart_cycle_on_state_change (Optional, boolean): Restart a timer of a cycle when new state is set. Defaults to
All other options from Output.
pinis defined the GPIO pin state is writen before any action is executed.
turn_off_actioncan be used togther.
state_change_actionis called before
turn_off_action. It’s recommended to use either
turn_off_actionto change the state of an output. Using both automations together is only recommended for monitoring.
output: - platform: slow_pwm id: my_slow_pwm period: 15s turn_on_action: - lambda: |- auto *out1 = id(output1); out1->turn_on(); turn_off_action: - output.turn_off: output1
If the duty cycle is not constrained to a maximum value, the Sigma-Delta Output component offers faster updates and greater control over the switching frequency. This is better for loads that need some time to fully change between on and off, like eletric thermal actuator heads or fans.