Hi all. I’d like to check here with the community if I’m doing the best thing possible. Here’s what I want.
I want to switch inductive load. A standard electromechanical relay (EMR) alone does not work here since each switch there is a potential EMI causing the controller to reboot. So I’m doing a combination of SSR and EMR.
- Turn on means turn on SSR to gently turn on the load, then after a short delay turn on EMR to shunt the SSR (so that nearly all the current goes through EMR).
- Turn off means turn off EMR (so that all the current go again through SSR and turn off SSR after a short delay.
This is what I do (below). Is there any better way to achieve the same?
switch:
- id: relay_1
name: "Combined Relay #1"
platform: template
# These sections are required to correctly set states of the template relay
turn_on_action:
- switch.template.publish:
id: relay_1
state: ON
turn_off_action:
- switch.template.publish:
id: relay_1
state: OFF
on_turn_on:
- logger.log: "Relay #1 turned ON"
- switch.turn_on: ssr_1
- delay: 500ms
# Since there is a delay, then it's technically possible that the state of
# this combined relay gets changed. So we are checking for the state again
- if:
condition:
- switch.is_on: relay_1
then:
- switch.turn_on: emr_1
on_turn_off:
- logger.log: "Relay #1 turned OFF"
- switch.turn_off: emr_1
- delay: 500ms
# Since there is a delay, then it's technically possible that the state of
# this combined relay gets changed. So we are checking for the state again
- if:
condition:
- switch.is_off: relay_1
then:
- switch.turn_off: ssr_1
- platform: gpio
id: ssr_1
name: 'SSR Ventilation'
pin:
number: GPIO32
inverted: yes
- platform: gpio
id: emr_1
name: 'Mechanical Relay Ventilation'
pin:
number: GPIO33
inverted: yes
mode: OUTPUT