Yandex Station

repository·master·Indexed 23 days ago

https://github.com/alexxit/yandexstation

A Home Assistant integration for controlling Yandex Station speakers and Yandex Smart Home devices. It supports local and cloud control modes, enabling voice notifications (TTS), media playback, and advanced local control for supported hardware. Features include TTS speech effects, Yandex Music playback (local mode only), and the ability to trigger Home Assistant automations via Yandex Station scenarios.

Tokens
10.7K
Snippets
26
Records
36
Agent score
34%

What's inside yandexstation

  1. Manage Alarms via Calendar integration

    master

    Yandex Stations support alarm management. Each station can be represented as a Home Assistant calendar entity.

    Key Details:

    • Enablement: Calendars are disabled by default. You must manually enable them for the stations you want to manage.
    • Triggers: You can use calendar triggers (e.g., "X minutes before an event").
    • Functionality: Alarms can be set for specific dates/times or weekly repetitions and can be turned off.
    • Sync: Alarms synchronize with Home Assistant once per minute. Calendar triggers synchronize every 15 minutes (due to Home Assistant limitations).
  2. Understand Local vs Cloud control for Yandex Station

    master

    The component supports two modes of operation depending on the device type. Understanding the difference is critical for feature availability and state accuracy.

    Control Modes

    • Local Control (Local Mode): Automatically enabled on supported Yandex brand speakers. It offers superior functionality, including real-time feedback (playing/paused status, actual volume) and advanced features like track scrubbing and cover art retrieval.
    • Cloud Control: Supported by all speakers and Yandex Smart Home devices. However, it lacks feedback; Home Assistant may not know if a speaker is playing, paused, or what its actual volume is if commands were issued outside of this component.

    Device Support Matrix

    Device TypeLocal ControlCloud Control
    Yandex Brand SpeakersYesYes
    Other Brand SpeakersNoYes
    Yandex ModulesYesNo
    Yandex Smart Home DevicesNoYes

    Note: For every speaker, a service scenario named ХА <UUID> is created in the Yandex app. Do not delete this scenario; if deleted, restart Home Assistant.

  3. Use YandexDialogs for advanced TTS and interaction

    master

    If you have the YandexDialogs component installed, you can use advanced TTS features. This method supports TTS special effects, has no 100-character limit, and the speaker will not listen for a user response after speaking.

    Usage: Set media_content_type to text:<dialog_name> or dialog:<dialog_name>:<tag>. The case of the name does not matter.

    Dialog Interaction: You can start a dialogue, receive a response from the user, and then perform actions based on that response. Use a tag in the media_content_type (e.g., dialog:smart_home:morning) to identify which question the user is answering in your automation.

    # Advanced TTS with special effects
    script:
      yandex_tts3:
        sequence:
          - service: media_player.play_media
            entity_id: media_player.yandex_station_irbis
            data:
              media_content_id: <speaker is_whisper="true">Хозяин, пора бы спать
              media_content_type: text:умный дом
    
    # Starting a dialogue with a tag for response tracking
    script:
      yandex_dialog:
        sequence:
          - service: media_player.play_media
            entity_id: media_player.yandex_station_mini
            data:
              media_content_id: <speaker is_whisper="true">Хозяин, уже утро, пора вставать!
              media_content_type: dialog:умный дом:утро
  4. Configure static IP for Yandex Station (Local Mode only)

    master

    In local mode, devices are discovered via mDNS (zeroconf). If you are using Docker without network=host or a Virtual Machine with NAT, mDNS may not work. To resolve this, assign a static IP to your speaker in your router and specify it in the Home Assistant configuration using the host key under the device's device_id.

    Note: You can find your device_id in the Yandex mobile app.

    yandex_station:
      devices:
        12345678901234567890:  # your device_id
          host: 192.168.1.123
          name: Яндекс Станция
  5. Receive commands from Yandex Station via Scenarios

    master

    You can trigger Home Assistant automations based on actions performed by a Yandex Station by creating a Scenario in the Yandex IoT interface.

    Setup Steps:

    1. Create a new Scenario in Yandex.
    2. Set the If condition to "Phrase".
    3. Set the Then action to "Any smart device".
    4. Choose an action like "Execute command", "Read text aloud", or "Play sound".

    Silent Execution Tip: To trigger an automation without the speaker making noise, set the command to ничего не делай (do nothing).

    Events in Home Assistant: When a scenario runs, Home Assistant receives one of two events:

    • yandex_speaker: Triggered ONLY by "Execute command" actions. Note: This may not trigger if YandexGPT 2 beta is enabled.
    • yandex_scenario: Triggered by almost any action in the "Then" section.

    Note: You cannot see the phrase the user said; you can only see the command/phrase the speaker was instructed to execute.

    Debugging: To inspect these events, go to Home Assistant Developer Tools > Events, subscribe to yandex_speaker (or yandex_scenario), and listen for incoming data.

    # Example yandex_speaker event data
    instance: text_action
    value: ничего не делай
    entity_id: media_player.station_mini
    name: Яндекс Мини
    
    # Example yandex_scenario event data
    instance: sound_play
    value:
      sound: boot-1
      sound_name: Загрузка (8 бит)
    entity_id: media_player.station_mini
    name: Яндекс Мини
    scenario_name: Тест
  6. Trigger Text-to-Speech (TTS) on Yandex Station

    master

    You can trigger TTS using the media_player.play_media service.

    Starting from integration version v3.19.0, the command is sent in local mode if the column supports it, otherwise it uses cloud mode.

    Cloud Mode Limitations:

    • Maximum text length is 100 characters. The component will automatically truncate text exceeding this limit.

    Local Mode Capabilities:

    • Supports advanced speech effects and specialized content types like dialog.
    script:
      yandex_tts1:
        sequence:
        - service: media_player.play_media
          entity_id: media_player.yandex_station  # replace with your column
          data:
            media_content_id: 'Температура в комнате {{ states("sensor.temperature_hall")|round }} градуса'
            media_content_type: text
  7. Stream music from Yandex Station to other speakers

    master

    In local mode only, you can stream music from a Yandex speaker to other smart speakers integrated with Home Assistant.

    Requirements:

    • A Yandex speaker that supports local control (Yandex Modules do NOT support this).
    • An active Yandex Music subscription.
    • A target speaker with a Home Assistant integration that supports streaming (e.g., Chromecast, DLNA, Sonos, etc.).

    Behavior:

    • To prevent sync issues, the Yandex speaker's volume is lowered during streaming, but returns temporarily when interacting with Alice.
    • The Yandex speaker's volume can be synchronized with the external speaker. You can disable this with sync_volume: False or use a Jinja2 template for custom mapping (e.g., sync_volume: "{{ volume_level / 2 }}").

    Important: For many integrations (like SamsungTV), your Home Assistant server must be accessible in your local network via HTTP and its IP address (e.g., http://192.168.1.123:8123/).

    yandex_station:
      media_players:
        - entity_id: media_player.yas_306
          name: Yamaha
        - entity_id: media_player.mpd
          name: MPD
          speaker_id: [media_player.yandex_station]
        - entity_id: media_player.yas_306
          name: Yamaha (no sync)
          sync_volume: False
        - entity_id: media_player.yas_306
          name: Yamaha (custom sync)
          sync_volume: "{{ volume_level / 2 }}"
        - entity_id: media_player.samsung
          name: SamsungTV
          media_content_type: url
        - entity_id: media_player.nest_hub
          name: Chromecast
          quality: lossless
          codecs: flac-mp4,aac-mp4,mp3
  8. Configure Yandex Station Notifications and Alerts

    master

    The component supports Home Assistant notifications and alerts.

    Notifications: Notifications are an alternative way to trigger TTS. They must be configured in configuration.yaml. You define a name and a list of entity_ids (speakers) where the notification should play. This creates a new service for that notification. You call this service with a message parameter. You can optionally include a title.

    Alerts: You can use these notifications within Home Assistant alert entities to repeat messages at specific intervals (e.g., if a door is left open).

    # Configuration for a custom notification service
    notify:
      - name: alice_alert
        platform: yandex_station
        data:
          entity_id: media_player.yandex_station_mini
          media_content_id: >-
            {% if title is defined %}<speaker effect="megaphone">{{ title }}<speaker effect="-"> sil <[200]>{% endif %}{{ message }}
          media_content_type: dialog
    
    # Using the notification in an alert
    alert:
      garage_door:
        name: Гараж открыт
        done_message: Гараж закрыт
        entity_id: input_boolean.garage_door
        state: "on"
        repeat: 5
        can_acknowledge: true
        skip_first: true
        notifiers:
          - alice_alert
  9. Play media via URLs (Yandex Music, YouTube, etc.)

    master

    Local mode only. You can play content by passing supported URLs to the media_player.play_media service.

    Supported URL types:

    • Yandex Music: Tracks, Albums, Artists, Playlists, and Audiobooks.
    • Yandex Books: Audiobooks.
    • Devices with screens (Station/Module): YouTube and Kinopoisk/Kinopoisk HD.

    When using the service, the media_content_type value is not strictly checked for validity but must be provided.

    script:
      yandex_play_url:
        alias: Проигрывание медиа по ссылке
        sequence:
        - service: media_player.play_media
          entity_id: media_player.yandex_station  # replace with your entity_id
          data:
            media_content_id: https://music.yandex.ru/album/2150009/track/19174962
            media_content_type: xxx  # type doesn't matter, but must be present
  10. Use TTS speech effects and special features

    master

    Advanced speech effects are available in local mode (using media_content_type: text or dialog) or in cloud mode via integration with Yandex Dialogs.

    Supported features include:

    • Speech Tuning: Adjusting generation parameters.
    • Voice Effects: Applying effects like megaphone.
    • Whisper: Using <speaker is_whisper="true">.
    • Sound Library: Playing built-in sounds using <speaker audio="...">.
    • Custom Audio: Playing uploaded files (up to 120 seconds) using <speaker audio="dialogs-upload/...">.
    • Voice Selection: Changing the voice using <speaker voice="...">.

    Warning: If an invalid voice is specified, the column may glitch. Send a stop command or restart the device to recover.

    To use these, set media_content_type to dialog for local columns.

    script:
      yandex_tts:
        alias: TTS c эффектами
        sequence:
        - service: media_player.play_media
          entity_id: media_player.yandex_station  # replace with your column
          data:
            media_content_id: <speaker audio="alice-sounds-game-win-1.opus"> sil <[500]> Объявление погоды на сегодня...
            media_content_type: dialog  # works only on local columns