A Home Assistant integration that converts any text into Morse code audio and plays it on any media_player entity.
This integration works in two ways:
- TTS Engine — appears in the media player "more-info" panel alongside other TTS providers (e.g., Google TTS).
- Service Call —
ttm.playcan be called directly from automations, scripts, or Developer Tools.
- Convert arbitrary text into Morse code audio.
- Adjustable:
- Transmission speed (Words Per Minute / WPM)
- Tone frequency in Hz
- Output volume (0.0–1.0)
- Outputs WAV audio for maximum compatibility.
- Fully integrated with Home Assistant's Text-to-Speech (TTS) UI.
- Works on all media players that support WAV playback over HTTP.
- No
ffmpegdependency — works with pure Python audio generation. - Simple to extend or customize.
- Go to HACS → Integrations → Menu (⋮) → Custom repositories.
- Add https://github.com/crom1e/ttm as the repo.
- Select category Integration.
- Install Text to Morse (ttm).
- Restart Home Assistant.
- Download or clone this repository.
- Copy the
custom_components/ttmfolder into:config/custom_components/ttm - Restart Home Assistant.
Add this to your configuration.yaml:
tts:
- platform: ttm
name: Text-to-Morse
wpm: 18 # Optional, default 18
frequency: 700 # Hz, optional
volume: 1.0 # 0.0–1.0, optionalRestart Home Assistant.
Now you will see Text-to-Morse (ttm) in the TTS dropdown of the media player’s more-info panel.
This works even without adding the tts: entry above.
Call the service ttm.play:
service: ttm.play
data:
text: "SOS Testing 123"
entity_id: media_player.living_room
wpm: 18 # Optional
frequency: 700 # Hz, optional
volume: 0.8 # OptionalYou can call it:
- From Developer Tools → Services
- From Automations
- From Scripts
This automation plays "ALERT" in Morse code whenever a specific sensor triggers:
alias: Alert in Morse
trigger:
- platform: state
entity_id: binary_sensor.door_sensor
to: "on"
action:
- service: ttm.play
data:
text: "ALERT"
entity_id: media_player.kitchen
wpm: 20
frequency: 750
volume: 1.0
mode: single- Text is mapped to Morse symbols (
.for dits,-for dahs) usingmorse.py. - Timing is calculated according to the PARIS standard:
- 1 unit = dit length =
1200 / WPMmilliseconds - dah = 3 units
- intra-character gap = 1 unit
- inter-character gap = 3 units
- word gap = 7 units
- 1 unit = dit length =
- Audio is generated using
pydubwith a sine wave generator. - In TTS mode, the WAV bytes are streamed directly to the media player through HA’s TTS system.
- In service mode, the WAV file is saved in
/config/www/ttmand played via/local/ttm/<filename>.wav.
- Home Assistant 2023.8.0 or newer.
pydub(installed automatically via manifest).- A media player that supports WAV playback via HTTP (most do).
You can fork this repo and:
- Change the default tone frequency.
- Change audio format (WAV → MP3, OGG, etc.).
- Add extra service fields (e.g., adjustable tone length).
- Localize the Morse mapping for non-English alphabets.
- Place the integration under
config/custom_components/ttm. - Use Settings → Developer Tools → YAML → Restart to reload.
- Watch logs under Settings → System → Logs.
- Update
versioninmanifest.jsonfor every release so HACS detects updates.
Consider adding a script blueprint under blueprints/script/ttm/play_morse.yaml so users can create a ready‑made script with a form UI without copying YAML.
MIT License — see LICENSE file for details.
- pydub for audio generation.
- Morse code timing based on the PARIS standard.