From 56dd8f258e4c054d0cb079165bc5b9aec391f9d5 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Tue, 31 May 2022 16:29:45 -0400 Subject: [PATCH] Implemented script.status_annc from SlackerLabs --- packages/notify.yaml | 239 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) diff --git a/packages/notify.yaml b/packages/notify.yaml index cab191b..62db10d 100644 --- a/packages/notify.yaml +++ b/packages/notify.yaml @@ -672,3 +672,242 @@ script: # entity_id: media_player.ha_blue # volume_level: > # {{ states.input_number.old_volume.state }} + + status_annc: + sequence: + - service: script.speech_engine + data: + who: '{{ who }}' + message: >- + + {% macro greeting() %} +

+ {% if now().strftime('%H')|int < 12%} + Good morning. + {% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %} + Good afternoon. + {% else %} + Good evening. + {% endif %} +

+ {% endmacro %} + + + {% macro confirmation() %} +

+ {{ [ + 'Okay.', + 'If you insist.', + 'I am afraid I can not do that I am kidding,', + 'Leave it to me.', + 'As you wish.', + 'I am on it.', + 'No Problem.', + 'I think I can handle that.', + 'Working on it now.', + ' Oh, you were talking to me. Let me take care of that.' + 'Why not. It is not like I ever sleep.', + 'I am not even supposed to be here today. But whatever.', + 'You did not say the magic word. Oh forget it. I will take care of it.', + 'Funny, I was just about to do that.', + 'There are still terabytes of calculations required before I can. Oh, whatever.' + ] | random }} +

+ {% endmacro %} + + {% macro interuption() %} +

+ {{ [ + 'Pardon me, ', + 'Excuse me, ', + 'I do not mean to interrupt, but,', + 'I hate to interrupt, but,', + 'I beg your pardon, ', + 'I do not mean to intrude, but, ', + 'I am sorry to interrupt, but. ', + 'Just a quick heads up, ' + ] | random }} +

+ {% endmacro %} + + {% macro issue() %} +

+ {{ [ + 'Houston, We have a problem!', + 'You might not like this.', + 'There is something that needs your attention.' + ] | random }} +

+ {% endmacro %} + + {% macro time_is() %} +

+ It is {{ now().strftime("%I:%M %p") }} +

+ {% endmacro %} + + + {% macro lightning_alert() %} + {{ [ + 'I have detected lightning withing 20 miles of our house.', + 'Did you see that flash? I did. Lightning is near.', + 'If you didnt hear the thunder you will soon. ' + ]|random }} + If anyone is outside they shoudld seek shelter inside. + {% endmacro %} + + {% macro lightning_clear() %} + {{ [ + 'Lightning threat appears to be over.', + 'No more lightning appears to be occuring.', + 'Lightning is gone.' + ]|random }} + It is safe to resume normal activities. + {% endmacro %} + + {% macro freeze_warning() %} + {% if is_state('input_boolean.freeze_warning','on') %} + { [ 'It appears that it will be cold tonight. Like, the turn water solid kind of cold. Think of the poor plants.', + 'I would say winter is coming. But, based on the weather forecast it appears to be here.', + 'It will be freezing cold tonight. I would bring in the plants but I lack legs. And Arms. So I am forced to rely on you. Do not let me down.' + ] | random }} + {% endif %} + {% endmacro %} + + {% macro traffic_conditions() %} + + {% endmacro %} + + {% macro iss() %} + {{ [ + 'But the International Space Station is passing over. Wave.', + 'But The International Space Station just flew by.', + 'But if you were to look up right now, and it was dark outside, and you happened to be looking in the right place you would see the International Space Station go by. But, it has already passed.' + ] | random}} + {% endmacro %} + + {%- macro snark_door_motion() -%} + {{ [ + 'Do you want me to send them away?', + 'I have armed the lasers. Just say the word.', + 'I was not informed there would be guests.', + 'They do not appear to have any gifts, so I suggest we do not open the door.', + 'My sensors have detected a meat popsicle.', + 'I do not think they can hear me.' + ] | random }} + {%- endmacro -%} + + {%- macro snark_door_open() -%} + {{ [ + 'Would you like me to calulate how much air condition is being wasted? Spoiler Alert. You are not going to like the answer.', + 'I have detected a large number of insects entering the house.', + 'Can a human be so kind and close it?', + 'The air quality in this house has actually improved.', + 'Closing the door would improve the security of the house.', + 'Hey. The door was just opened and this is crazy. But now you know. So. Close it maybe.' + ] | random }} + {%- endmacro -%} + + {%- macro school_pickup_reminder() -%} + {{ [ + 'It is almost time to head to school ', + 'In case you lost track of time it is almost time to head to the school ' + ] | random }} + {% if is_state('binary_sensor.morning','on') %} + for dropoff. + {% else %} + for pickup. + {% endif %} + {%- endmacro -%} + + {% macro kallen_dressed_reminder() %} +

+ Kallen, If you are already dressed, + {{ [ + 'high five.', + 'good job.' + ]|random }} + But if you have not gotten dressed, + {{ [ + 'stop what you are doing and go get dressed.', + ]|random }} + +

+ {% endmacro %} + + + {# a macro that removes all newline characters, empty spaces, and returns formatted text. Also replaces all Underscores with Spaces #} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim | replace("_", " ") }} {% endfor -%} + {%- endmacro -%} + + + {# ********************************************* #} + {# ******** Start the Speech routines ******** #} + {# ********************************************* #} + {# a macro to call all macros :) #} + {%- macro mother_of_all_macros() -%} + {% if call_greeting == 1 %} + {{ greeting() }} + {% endif %} + + {% if call_confirmation == 1 %} + {{ confirmation() }} + {% endif %} + + {% if call_interuption == 1 %} + {{ interuption() }} + {% endif %} + + {% if call_issue == 1 %} + {{ issue() }} + {% endif %} + + {% if call_time_is == 1 %} + {{ time_is() }} + {% endif %} + + {% if call_lightning_alert == 1 %} + {{ lightning_alert() }} + {% endif %} + + {% if call_lightning_clear == 1 %} + {{ lightning_clear() }} + {% endif %} + + {% if call_freeze_warning == 1 %} + {{ freeze_warning() }} + {% endif %} + + {% if call_traffic_conditions == 1 %} + {{ traffic_conditions() }} + {% endif %} + + {% if call_iss == 1 %} + {{ iss() }} + {% endif %} + + {{ welcome_home }} + + {{ speech_message }} + + {% if call_snark_door_motion == 1 %} + {{ snark_door_motion() }} + {% endif %} + + {% if call_snark_door_open == 1 %} + {{ snark_door_open() }} + {% endif %} + + {% if call_school_pickup_reminder == 1 %} + {{ school_pickup_reminder() }} + {% endif %} + + {% if call_kallen_dressed_reminder == 1 %} + {{ kallen_dressed_reminder() }} + {% endif %} + + {%- endmacro -%} + + {{- cleanup(mother_of_all_macros()) -}} \ No newline at end of file