I am trying to get the RTTTL song to loop until the switch is turned off but failed to do so. I’ve tried seeking chatgpt for help but it hasn’t been successful. Can you review what is wrong with the while-then block?
output:
- platform: ledc
pin: GPIO25
id: buzzer_output
- platform: gpio
pin: GPIO26
id: amp_relay
#inverted: true # HIGH = siren off, LOW = siren on
rtttl:
output: buzzer_output
switch:
- platform: template
name: "Buzzer"
id: siren_switch
turn_on_action:
- output.turn_on: amp_relay # supply power to amplifier
- while:
condition:
switch.is_on: siren_switch
then:
- rtttl.play: 'MissionImp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d'
# Wait until song finishes
- wait_until:
condition:
not:
rtttl.is_playing
# Optional: short pause before repeating
- delay: 500ms
turn_off_action:
- rtttl.stop
- output.turn_off: amp_relay # cut power to amplifier