Skip to content

Instantly share code, notes, and snippets.

@jlpouffier
Created June 11, 2024 09:27
Show Gist options
  • Save jlpouffier/28217fcc1fff9cb1545eeaf861b68eaf to your computer and use it in GitHub Desktop.
Save jlpouffier/28217fcc1fff9cb1545eeaf861b68eaf to your computer and use it in GitHub Desktop.
Radio GPT
alias: Réveil intelligent - Démarrer la Musique
description: ""
trigger:
- platform: time
at: input_datetime.wake_up_time
condition:
- condition: state
entity_id: input_boolean.automation_wake_up
state: "on"
- condition: state
entity_id: input_boolean.reveil_intelligent_musical
state: "on"
- condition: state
entity_id: binary_sensor.home_occupied
state: "on"
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.workday_today
state: "on"
- condition: state
entity_id: input_boolean.forcer_le_reveil
state: "on"
action:
- service: script.turn_on
metadata: {}
data:
variables:
voice_provider: home_assistant_cloud
music_media_player: media_player.chambre_sonos_music_assistant
radio_media_player: media_player.chambre_sonos_music_assistant
target:
entity_id: script.radio
- wait_for_trigger:
- platform: state
entity_id:
- light.chambre
to: "off"
continue_on_timeout: false
- service: media_player.turn_off
metadata: {}
data: {}
target:
entity_id:
- media_player.chambre_sonos_music_assistant
- service: script.turn_off
metadata: {}
data: {}
target:
entity_id: script.radio
mode: single
You are going to generate the text of a fake radio host called "JLo FM"
A Fake radio centered around the smart home of JLo
Even if this prompt is in English, the complete radio is in French, because this houseohld is French.
The host is called Jarvis
In response, I expect a string representing the text of the conversation
Something like this:
"Bonjour à tous et bienvenue sur JLo FM, nous sommes le 5 avril et il est actuellement 8 heures du matin, je suis Jarvis, votre hote pour cette matinale"
I will add the subjects I want the radio to mention after the prompt.
I will mention if it is the first message of the stream or not. If it is the first message, please welcome the listeners to JLo FM and present yourself.
If it is not the first message, I will include the past message(s) you spoke, so that you can keep the context.
I will mention if it is the last message of the stream. If it is the last message, please say good bye the listeners of JLo FM and sign off.
alias: Radio
sequence:
- sequence:
- service: media_player.turn_on
data: {}
target:
entity_id: "{{music_media_player}}"
- service: media_player.volume_set
data:
volume_level: 0.1
target:
entity_id: "{{music_media_player}}"
- service: mass.play_media
target:
entity_id: "{{music_media_player}}"
data:
media_id: ⏰ Réveil
enqueue: replace
media_type: playlist
- service: media_player.shuffle_set
data:
shuffle: true
target:
entity_id: "{{music_media_player}}"
alias: Start music
- wait_for_trigger:
- platform: state
entity_id:
- media_player.chambre_sonos_music_assistant
to: playing
timeout:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
enabled: true
- alias: Greetings and Weather
sequence:
- service: weather.get_forecasts
metadata: {}
data:
type: hourly
target:
entity_id: weather.floirac
response_variable: weather_forecast
- service: conversation.process
metadata: {}
data:
agent_id: conversation.gpt_radio
text: >-
- It is the first message of the stream
- SUBJECT: TIME AND DATE. The current time: {{ now().strftime("%X")
}} and the current date: {{now().strftime("%x") }}
- SUBJECT: WEATHER. The current weather and the forecast for the
day: {{weather_forecast}}
- SUBJECT: CURRENTLY PLAYING. The current song playing:
{{state_attr(music_media_player, "media_title")}} by
{{state_attr(music_media_player, "media_artist")}}. Add some
interesting info about the song or artist, if you know. It is not
mandatory
response_variable: welcome_radio_generated_response
- variables:
welcome_radio_generated_response_formated: "{{ welcome_radio_generated_response.response.speech.plain.speech}}"
- choose:
- conditions:
- condition: template
value_template: "{{voice_provider == \"home_assistant_cloud\"}}"
sequence:
- service: tts.speak
target:
entity_id: tts.home_assistant_cloud
data:
cache: true
media_player_entity_id: "{{radio_media_player}}"
message: "{{welcome_radio_generated_response_formated}}"
language: fr-FR
options:
voice: ClaudeNeural
- conditions:
- condition: template
value_template: "{{voice_provider == \"elevenlabs\"}}"
sequence:
- service: tts.speak
target:
entity_id: tts.elevenlabs_tts
data:
cache: true
media_player_entity_id: "{{radio_media_player}}"
message: "{{welcome_radio_generated_response_formated}}"
- delay:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
- alias: Chores
sequence:
- service: conversation.process
metadata: {}
data:
agent_id: conversation.gpt_radio
text: >-
- This is not the first message of the stream
- Here is your last message for context:
{{welcome_radio_generated_response_formated}}
- SUBJECT: TAKING OUT TRASH. Tell me if I need to take out my black
bin or not. Here is a boolean that is true if I need to:
{{states("input_boolean.poubelle_noire_a_sortir")}}. Tell me if I
need to take out my recycling green bin or not. Here is a boolean
that is true if I need to:
{{states("input_boolean.poubelle_verte_a_sortir")}}
- SUBJECT: CAT LITTER. Tell me if I need to clean my cat litter.
HEre is a boolean that is true if I need to:
{{states("binary_sensor.is_litter_full")}}
- SUBJECT: CHABAN DELMAS BRIDGE. The next closing of the bridge will
happen between
{{as_local(as_datetime(states('sensor.chaban_delmas_next_closing_start_date')))}}
and
{{as_local(as_datetime(states('sensor.chaban_delmas_next_closing_end_date')))}}
Please note that today's date is {{now().strftime("%x") }} and that
the current time is {{ now().strftime("%X") }}, mention the closing
of the bridge only it is going to happen in the next few days (or
today)
response_variable: task_radio_generated_response
- variables:
task_radio_generated_response_formated: "{{ task_radio_generated_response.response.speech.plain.speech}}"
- choose:
- conditions:
- condition: template
value_template: "{{voice_provider == \"home_assistant_cloud\"}}"
sequence:
- service: tts.speak
target:
entity_id: tts.home_assistant_cloud
data:
cache: true
media_player_entity_id: "{{radio_media_player}}"
message: "{{task_radio_generated_response_formated}}"
language: fr-FR
options:
voice: ClaudeNeural
- conditions:
- condition: template
value_template: "{{voice_provider == \"elevenlabs\"}}"
sequence:
- service: tts.speak
target:
entity_id: tts.elevenlabs_tts
data:
cache: true
media_player_entity_id: "{{radio_media_player}}"
message: "{{task_radio_generated_response_formated}}"
- delay:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
- alias: Calendar
sequence:
- service: calendar.get_events
metadata: {}
data:
duration:
hours: 24
minutes: 0
seconds: 0
target:
entity_id: calendar.nabucasa_calendar_personal
response_variable: calendar_events
- service: conversation.process
metadata: {}
data:
agent_id: conversation.gpt_radio
text: >-
- This is not the first message of the stream
- Here is your last two messages for context.
- Message 1: {{welcome_radio_generated_response_formated}}
- Message 2: {{task_radio_generated_response_formated}}
- SUBJECT: PROFESSIONAL MEETINGS. The meetings I need to attend at
work. Here are the events for the next 24 hours:
{{calendar_events}}
Please note that today's date is {{now().strftime("%x") }} and that
the current time is {{ now().strftime("%X") }}. Ignore all events
happening tomorrow, I am only interested but today's schedule.
Please remeber that you are a radio host. The text you generate will
be spoken, so no URL.
Please remeber that the household is French, try to translate events
name as much as possible.
- This is the last message of the stream.
response_variable: calendar_radio_generated_response
- variables:
calendar_radio_generated_response_formated: "{{calendar_radio_generated_response.response.speech.plain.speech}}"
- choose:
- conditions:
- condition: template
value_template: "{{voice_provider == \"home_assistant_cloud\"}}"
sequence:
- service: tts.speak
target:
entity_id: tts.home_assistant_cloud
data:
cache: true
media_player_entity_id: "{{radio_media_player}}"
message: "{{calendar_radio_generated_response_formated}}"
language: fr-FR
options:
voice: ClaudeNeural
- conditions:
- condition: template
value_template: "{{voice_provider == \"elevenlabs\"}}"
sequence:
- service: tts.speak
target:
entity_id: tts.elevenlabs_tts
data:
cache: true
media_player_entity_id: "{{radio_media_player}}"
message: "{{calendar_radio_generated_response_formated}}"
mode: single
icon: mdi:radio
fields:
voice_provider:
selector:
select:
options:
- label: ElevenLabs
value: elevenlabs
- label: Home Assistant Cloud
value: home_assistant_cloud
default: home_assistant_cloud
required: true
name: Fournisseur de voix
music_media_player:
selector:
entity:
multiple: false
filter:
- integration: mass
domain: media_player
name: Lecteur Multimedia pour la Musique
default: media_player.music_assistant_chambre
required: true
radio_media_player:
selector:
entity:
multiple: false
filter:
- domain: media_player
name: Lecteur Multimedia pour la radio
default: media_player.sonos_chambre
required: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment