diff --git a/packages/jarvis.yaml b/packages/jarvis.yaml new file mode 100644 index 0000000..68f0c19 --- /dev/null +++ b/packages/jarvis.yaml @@ -0,0 +1,55 @@ +############################################################################### +# @author : Jeffrey Stone +# @date : 07/09/2019 +# @package : Jarvis +# @description : Brining some Jarvis to Home Assistant +############################################################################### + +automation: +- id: guest_mode_feedback + alias: Guest Mode Audio Feedback + trigger: + - platform: state + entity_id: + - input_boolean.guest_mode + from: 'off' + to: 'on' + action: + - service: script.jarvis_voice + data_template: + message: > + {{ [ + "Guest Mode has been enabled.", + "I have switched to the system to guest mode.", + "I have enabled guest mode. ", + "Guest Mode is on." + ] | random }} + +script: + activate_house_party_protocol: + sequence: + - service: script.jarvis_voice + data_template: + message: !include ../templates/jarvis_confirmations.yaml + - delay: + seconds: 3 + - service: scene.turn_on + entity_id: scene.house_party_protocol + - service: script.jarvis_voice + data_template: + message: > + {{ [ + "Anchorage House has been configured for a House Party.", + "Incense has been turned on.", + "I have enabled house party protocol." + ] | random }} + + activate_guest_mode: + sequence: + - service: script.jarvis_voice + data_template: + message: !include ../templates/jarvis_confirmations.yaml + - delay: + seconds: 3 + - service: input_boolean.turn_on + entity_id: input_boolean.guest_mode \ No newline at end of file diff --git a/templates/jarvis_confirmations.yaml b/templates/jarvis_confirmations.yaml new file mode 100644 index 0000000..95b4be1 --- /dev/null +++ b/templates/jarvis_confirmations.yaml @@ -0,0 +1,31 @@ + > + {% macro getConfirmation() %} + {{ [ + "OK.", + "Sure.", + "If you insist.", + "I can do that.", + "Leave it to me.", + "Consider it done.", + "As you wish.", + "By your command.", + "Affirmative.", + "No Problem.", + "I think I can handle that.", + "Working on it now." + ] | random }} + {% endmacro %} + {# a macro that removes all newline characters, empty spaces, and returns formatted text #} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim }} {% endfor -%} + {%- endmacro -%} + + {# a macro to call all macros :) #} + {%- macro mother_of_all_macros() -%} + {{ getConfirmation() }} + + {%- endmacro -%} + + {# Call the macro #} + {{- cleanup(mother_of_all_macros()) -}} \ No newline at end of file diff --git a/templates/jarvis_interuptions.yaml b/templates/jarvis_interuptions.yaml new file mode 100644 index 0000000..c579511 --- /dev/null +++ b/templates/jarvis_interuptions.yaml @@ -0,0 +1,23 @@ + > + {% macro getInteruption() %} + {{ [ + "Pardon me,", + "Excuse me,", + "I do not mean to interupt, but.", + "I thought you might like to know." + ] | random }} + {% endmacro %} + {# a macro that removes all newline characters, empty spaces, and returns formatted text #} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim }} {% endfor -%} + {%- endmacro -%} + + {# a macro to call all macros :) #} + {%- macro mother_of_all_macros() -%} + {{ getInteruption() }} + + {%- endmacro -%} + + {# Call the macro #} + {{- cleanup(mother_of_all_macros()) -}} \ No newline at end of file diff --git a/templates/jarvis_issue.yaml b/templates/jarvis_issue.yaml new file mode 100644 index 0000000..838d728 --- /dev/null +++ b/templates/jarvis_issue.yaml @@ -0,0 +1,23 @@ + > + {% macro getIssue() %} + {{ [ + "I have detected an issue!", + "We have a problem!", + "You might not like this.", + "There is something that needs your attention." + ] | random }} + {% endmacro %} + {# a macro that removes all newline characters, empty spaces, and returns formatted text #} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim }} {% endfor -%} + {%- endmacro -%} + + {# a macro to call all macros :) #} + {%- macro mother_of_all_macros() -%} + {{ getIssue() }} + + {%- endmacro -%} + + {# Call the macro #} + {{- cleanup(mother_of_all_macros()) -}} \ No newline at end of file