tts.yaml 2.84 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11

tts:
  - platform: picotts
    language: 'en-GB'

sensor:
  - platform: template
    sensors:
      average_indoor_temperature:
        value_template: !secret indoor_temperature_template

12 13 14 15 16
input_boolean:
  tts_enabled:
    name: TTS Announcements Enabled
    initial: 'on'

17 18 19 20
script:
  tts_living_room:
    alias: "Living room TTS announcement"
    sequence:
21 22 23
      - condition: state
        entity_id: input_boolean.tts_enabled
        state: 'on'
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
      - service: switch.turn_on
        entity_id: switch.living_room_tv
      - delay:
          seconds: 3
      - service: tts.picotts_say
        entity_id: media_player.tv
        data_template:
          message: "{{ message }}"

  tts_or_notify_living_room:
    alias: "TTS announcement or notification"
    sequence:
      - service_template: >
          {% if is_state("media_player.tv", "playing") or is_state("media_player.tv", "paused") %}
          notify.kodi_livingroom
          {% else %}
          script.tts_living_room
          {%- endif %}
        data_template:
          title: "Home Assistant"
          message: "{{ message }}"
          data:
            icon: !secret hass_icon_url

  tts_status_report:
    alias: Morning
    sequence:
    - service: script.tts_living_room
      data_template:
        message: >
          {% if now().strftime("%H")|int < 12 %}
          Good morning.
          {% elif now().strftime("%H")|int < 18 %}
          Good afternoon.
          {% else %}
          Good evening.
          {% endif %}
          It's currently {{states.sensor.dark_sky_summary.state}} and {{states.sensor.dark_sky_temperature.state|round}} degrees. The weather for the next 24 hours will be {{states.sensor.dark_sky_hourly_summary.state|replace(".", "")}}, with a high of {{states.sensor.dark_sky_daytime_high_temperature.state|round}} and a low of {{states.sensor.dark_sky_overnight_low_temperature.state|round}}.
          The current average indoor temperature is {{ states.sensor.average_indoor_temperature.state }} degrees.
63
          Sun protection is required between {{ states.binary_sensor.uv_protection_window.attributes.start_time.strftime("%-I:%M%p") }} and {{ states.binary_sensor.uv_protection_window.attributes.end_time.strftime("%-I:%M%p") }}. Today's max UV index is {{ states.sensor.max_uv_index.state|round(2) }}.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

automation:
  - alias: "Time to leave announcement"
    trigger:
      - platform: time
        at: '08:20:00'
    condition:
      condition: and
      conditions:
        - condition: state
          entity_id: 'binary_sensor.workday_sensor'
          state: 'on'
        - condition: state
          entity_id: 'input_boolean.on_holiday'
          state: 'off'
        - condition: state
          entity_id: 'sensor.person2_status'
          state: 'Home'
    action:
      - service: script.tts_living_room
        data:
          message: !secret message_time_to_leave