Created
December 4, 2018 22:01
-
-
Save diplix/f58add2865f7f95dd56896eb6b7b5e31 to your computer and use it in GitHub Desktop.
homeassistant package for a timer and a fart intent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################ | |
## Packages / Snips timer & fart generator | |
################################################################ | |
timer: | |
snips: | |
duration: '00:01:00' | |
counter: | |
snips_elapsed: | |
initial: 0 | |
step: 1 | |
intent_script: | |
TimerStart: | |
speech: | |
text: >- | |
timer {{timer_duration_raw}} ab jetzt. | |
{% if timer_duration > 3600 %} | |
Timer von mehr als einer Stunde stelle ich wahrscheinlich falsch dar. | |
Felix ist da zu doof für, das ordentlich zu machen. | |
{% endif %} | |
action: | |
- service: timer.finish | |
entity_id: timer.snips | |
- service: timer.start | |
data_template: | |
entity_id: timer.snips | |
duration: '{{ timer_duration }}' | |
TimerStop: | |
speech: | |
text: >- | |
ok. | |
action: | |
- service: timer.finish | |
entity_id: timer.snips | |
pupsen: | |
async_action: True | |
action: | |
- service: shell_command.snips_wav | |
data_template: | |
site_id: "{{ site_id }}" | |
session_id: "{{ session_id }}" | |
wav_file: >- | |
{%- set file = [ | |
"Girl Fart-SoundBible.com-669012925", | |
"Quick An Small Fart-SoundBible.com-958779407.wav", | |
"Fart Reverberating Bathroom-SoundBible.com-2032114496.wav", | |
"Wet Fart Squish-SoundBible.com-332766022.wav", | |
"Fart Short Ripper-SoundBible.com-1317602707.wav", | |
"King Farthur-SoundBible.com-922925717.wav", | |
"Funny Fart Trail-SoundBible.com-1691782690.wav", | |
"Squish Fart-SoundBible.com-115133916.wav", | |
"Rigid Fart-SoundBible.com-1121832279.wav", | |
"Quick Fart-SoundBible.com-655578646.wav", | |
"Windy Fart-SoundBible.com-1980462064.wav", | |
"Bean Fart-SoundBible.com-215806729.wav", | |
"Silly_Farts-Joe-1473367952.wav" | |
] | random -%} | |
/Users/ix/.homeassistant/sounds/pupse/{{ file }} | |
automation: | |
- alias: timerstarted | |
trigger: | |
platform: time | |
seconds: '/1' | |
condition: | |
condition: state | |
entity_id: timer.snips | |
state: active | |
action: | |
- service: counter.increment | |
data: | |
entity_id: counter.snips_elapsed | |
- service: mqtt.publish | |
data_template: | |
topic: "devices/led-matrix/light/print/set" | |
payload: >- | |
{% set duration = states.timer.snips.attributes.duration %} | |
{% set elapsed = states("counter.snips_elapsed") | default(0) | int %} | |
{% set hms_split = duration.split(':') %} | |
{% set hours = hms_split[0] | int %} | |
{% set minutes = hms_split[1] | int %} | |
{% set seconds = hms_split[2] | int %} | |
{% set duration = seconds + (minutes * 60) + (hours * 60 * 60) %} | |
{{ (duration - elapsed ) | int | timestamp_custom('%M%:%S') }} | |
- alias: timerfinished | |
trigger: | |
platform: event | |
event_type: timer.finished | |
event_data: | |
entity_id: timer.snips | |
action: | |
- service: counter.reset | |
data: | |
entity_id: counter.snips_elapsed | |
- condition: state | |
entity_id: timer.snips | |
state: idle | |
- service: mqtt.publish | |
data_template: | |
topic: "devices/led-matrix/light/print/set" | |
payload: 'fertig!' | |
- service: snips.say | |
data_template: | |
site_id: "ivanka" | |
text: "dein timer ist abgelaufen" | |
shell_command: | |
snips_wav: >- | |
/usr/local/Cellar/mosquitto/1.4.14_2/bin/mosquitto_pub -h ivanka.local -p 1883 -t 'hermes/audioServer/{{ site_id }}/playBytes/{{ session_id }}' -f '{{wav_file}}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment