mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 13:09:12 +00:00
57 lines
1.2 KiB
YAML
57 lines
1.2 KiB
YAML
number:
|
|
- platform: template
|
|
name: "Speaker Number"
|
|
id: speaker_my_number
|
|
optimistic: true
|
|
min_value: 0
|
|
max_value: 100
|
|
step: 1
|
|
|
|
esphome:
|
|
on_boot:
|
|
then:
|
|
- speaker.mute_on:
|
|
id: speaker_id
|
|
- speaker.mute_off:
|
|
id: speaker_id
|
|
- if:
|
|
condition:
|
|
speaker.is_stopped:
|
|
id: speaker_id
|
|
then:
|
|
- speaker.play:
|
|
id: speaker_id
|
|
data: [0, 1, 2, 3]
|
|
- speaker.volume_set:
|
|
id: speaker_id
|
|
volume: 0.9
|
|
- if:
|
|
condition:
|
|
speaker.is_playing:
|
|
id: speaker_id
|
|
then:
|
|
- speaker.finish:
|
|
id: speaker_id
|
|
- speaker.stop:
|
|
id: speaker_id
|
|
|
|
button:
|
|
- platform: template
|
|
name: "Speaker Button"
|
|
on_press:
|
|
then:
|
|
- speaker.play:
|
|
id: speaker_id
|
|
data: [0x10, 0x20, 0x30, 0x40]
|
|
- speaker.play:
|
|
id: speaker_id
|
|
data: !lambda |-
|
|
return {0x01, 0x02, (uint8_t)id(speaker_my_number).state};
|
|
|
|
speaker:
|
|
- platform: i2s_audio
|
|
id: speaker_id
|
|
i2s_audio_id: i2s_audio_bus
|
|
dac_type: external
|
|
i2s_dout_pin: ${i2s_dout_pin}
|