telus-smarthome-ha
  • Python 99.3%
  • Dockerfile 0.7%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Bungeetaco 7979d3e3e7 docs, tools, compose: match the code; audit recorded in BACKLOG with no open row
README tuning table, endpoints, /health keys, entity table, test commands and
troubleshooting are checked against the code in both directions [F17-F27].
ARCHITECTURE no longer describes removed designs [F49-F51]. The tracked
compose file disables MediaMTX's unused RTMP/HLS/WebRTC/SRT listeners [F52].
tools/fetch_clips.py follows the integration's clip logic [F73];
tools/login_test.py, which printed session data and had drifted, is removed
[F74]. Duplicate icon files are removed; the integration's brand/ directory
is what Home Assistant serves [F28]. hacs.json minimum is 2025.8.0 [F72].

docs/BACKLOG.md gains the "2026-11-17 audit" section: 82 rows (F1-F74,
K1-K8), 75 done and 7 declined with the reason. CHANGELOG has the 0.15.0
entry.
2026-11-18 00:27:30 +00:00
custom_components/telus_smarthome_plus integration 0.15.0: keep the bridge session open, survive failed logins, remove unused platforms 2026-11-18 00:27:30 +00:00
docs docs, tools, compose: match the code; audit recorded in BACKLOG with no open row 2026-11-18 00:27:30 +00:00
gst_bridge docs, tools, compose: match the code; audit recorded in BACKLOG with no open row 2026-11-18 00:27:30 +00:00
tests integration 0.15.0: keep the bridge session open, survive failed logins, remove unused platforms 2026-11-18 00:27:30 +00:00
tools docs, tools, compose: match the code; audit recorded in BACKLOG with no open row 2026-11-18 00:27:30 +00:00
.env.example docs, tools, compose: match the code; audit recorded in BACKLOG with no open row 2026-11-18 00:27:30 +00:00
.gitignore docs, tools, compose: match the code; audit recorded in BACKLOG with no open row 2026-11-18 00:27:30 +00:00
CHANGELOG.md docs, tools, compose: match the code; audit recorded in BACKLOG with no open row 2026-11-18 00:27:30 +00:00
hacs.json docs, tools, compose: match the code; audit recorded in BACKLOG with no open row 2026-11-18 00:27:30 +00:00
LICENSE V 0.4.0 2026-10-17 03:44:21 -06:00
README.md docs, tools, compose: match the code; audit recorded in BACKLOG with no open row 2026-11-18 00:27:30 +00:00

TELUS SmartHome+ for Home Assistant

Bring your TELUS SmartHome+ cameras and devices into Home Assistant — live video, AI detections, sensors and all — without giving up the TELUS app.

HACS Custom Home Assistant License: MIT Pre-release


⚠️ Unofficial. This project is not affiliated with, endorsed by, or supported by TELUS. It was built by reverse-engineering the TELUS SmartHome+ app for personal interoperability with equipment the owner already pays for. Use it with your own account, at your own risk. TELUS could change their platform and break it at any time.

TELUS SmartHome+ is a closed, white-label platform with no public API. This project gives Home Assistant a native integration for it, plus a small streaming bridge that turns the camera's AWS Kinesis WebRTC feed into a plain RTSP stream HA (and Apple HomeKit) can play.

✨ Features

  • 🔐 Headless login with your SmartHome+ email + password — no tokens to copy, auto-refreshes itself.
  • 🔊 Audio with the live stream (can be switched off).
  • 📹 Live camera video in Home Assistant (and on to Apple HomeKit / Apple TV via HA's HomeKit Bridge).
  • 🤖 AI Sensor — see what the camera detected: Person · Vehicle · Animal · Package · Motion, with confidence and bounding box.
  • 🏃 Motion, connectivity, Wi-Fi signal, and device-temperature sensors.
  • ♻️ Self-healing stream — the bridge notices a stalled or dropped stream and reconnects on its own in seconds. No more reloading HA.
  • 🎞️ Recorded clips — browse and play your TELUS cloud recordings from HA's Media sidebar.
  • 🧩 Multi-camera — one bridge container serves every TELUS camera on your account automatically.
  • 🍏 HomeKit-ready — the RTSP stream works with HA's built-in HomeKit Bridge.

🧭 How it works

The integration owns authentication and data. Live video needs a tiny helper because the camera speaks AWS Kinesis Video Streams (WebRTC), which HA can't play directly — so a bridge converts it to RTSP once, and everything downstream just reads RTSP.

                    ┌─────────────────────────────┐
                    │   TELUS SmartHome+ Cloud     │
                    │  (Platform API + AWS KVS)    │
                    └───────────────┬─────────────-┘
          auth, device data,        │        camera: KVS WebRTC (H.264)
          live-stream config        │
                    ┌───────────────┴──────────────┐
                    ▼                               ▼
        ┌───────────────────────┐      ┌────────────────────────────┐
        │  HA Integration       │      │   gst_bridge (Docker)      │
        │  custom_components/    │ POST │  webrtcbin → RTSP          │
        │  telus_smarthome_plus       ├─────►│  + MediaMTX  + watchdog    │
        │  (login, entities,     │ /start      │                     │
        │   AI Sensor, camera)   │      └──────────────┬─────────────┘
        └───────────┬───────────┘                      │ RTSP
                    │                                   ▼
                    │                        ┌────────────────────┐
                    └───────────────────────►│  Home Assistant    │
                       entities + stream     │  → HomeKit / Apple │
                                             └────────────────────┘

There are two pieces to install:

Piece What it does Required for
custom_components/telus_smarthome_plus Login, devices, sensors, AI Sensor, camera entity Everything
gst_bridge/ (Docker) KVS-WebRTC → RTSP converter Live video only

If you only want sensors and AI detections, you can skip the bridge. For live video, run the bridge on any always-on Docker host on your LAN.

📦 Installation

Open in HACS

  1. In Home Assistant: HACS → ⋮ (top right) → Custom repositories.
  2. Add this repository URL, category Integration, and click Add.
  3. Find TELUS SmartHome+ in HACS, click Download.
  4. Restart Home Assistant.
  5. Settings → Devices & Services → Add Integration → TELUS SmartHome+, and sign in with your SmartHome+ email and password.
Or install manually

Copy custom_components/telus_smarthome_plus/ into your HA config/custom_components/ folder and restart.

2 — Streaming bridge (for live video)

On any always-on machine with Docker on your LAN:

git clone https://github.com/akramercury/telus-smarthome-ha.git
cd telus-smarthome-ha/gst_bridge
cp ../.env.example .env        # then edit .env and set LAN_IP to this host's IP
docker compose up -d --build

Then in HA: Settings → Devices & Services → TELUS SmartHome+ → Configure, and set the bridge URL to http://<this-host-ip>:8787.

The compose file caps memory/CPU/processes and rotates logs, so a misbehaving container is restarted instead of growing. Audio is on by default; set ENABLE_AUDIO=0 in .env to never ask the camera for audio (the stream then carries a silent track). The camera mic is quiet, so AUDIO_GAIN_DB (default 15) boosts it; raise it to 25 if speech is still faint. LAN_IP in .env must be set or HA is told 127.0.0.1 and can't find the stream.

Check it's healthy any time:

curl -s http://<this-host-ip>:8787/health

🎛️ Entities

Entity Type Notes
Outdoor Camera camera Live view via the bridge
AI Sensor sensor Person / Vehicle / Animal / Package / Motion + confidence, bounding box
Motion binary_sensor PIR + AI motion
Connectivity binary_sensor Online/offline
Wi-Fi signal sensor dBm
Device temperature sensor °C
Siren, HDR switch Only on cameras that report the resource
Type Detect / Type Notify switch One pair per AI detection type (Person, Vehicle, ...): recording and notification
Spotlight, Night vision select off / on / auto
Doorbell press event Fires ring; a press older than 180 s is not fired
Bridge stream binary_sensor Diagnostic: on while the bridge has video flowing for this camera; bridge counters as attributes
Bridge reconnects sensor Diagnostic: session restarts since the bridge started

Tip: automate on state of the AI Sensor — e.g. "when AI Sensor is Person after sunset → turn on the porch light."

🗺️ Roadmap

  • On-demand streaming — only hold the camera while HA is actively viewing, freeing it (and upload bandwidth) for the TELUS app and clip playback.
  • Audio in the HA stream (0.7.0).
  • Real-time events via MQTT — instant Person/Vehicle/Package alerts, matching the app's push notifications.
  • Saved clips — Media browser, download-to-MP4, and optional auto-save (0.6.0).
  • Doorbell press event, siren switch, spotlight select.

🎞️ Recorded clips

Open Media in the HA sidebar -> TELUS SmartHome+ -> pick a camera. Clips are the same ones the TELUS app shows (retention depends on your TELUS plan). Pick one to play it, or use it in a dashboard Media Control / cast it to a speaker or TV.

Saving clips as MP4

  • One at a time: in the Media browser pick Play & download — the clip is saved to media/telus_clips/ and plays from your HA (use the player's ⋮ menu to download it to your PC).
  • Automatically: Settings -> Devices & Services -> TELUS SmartHome+ -> Configure -> enable Auto-save new recorded clips and choose how many days to keep. Off by default; clips are typically 10-100 MB each. A clip that fails to save is tried 3 times (one per 5-minute pass), then again after 6 h.
  • Choose where they go: set Save folder for clips in Configure — e.g. a mounted network share like /media/nas/cameras. Blank = media/telus_clips.
  • From an automation: call the service telus_smarthome_plus.download_clip (optionally with device_id / clip_id; default is the newest clip).

Requires ffmpeg on the HA host (included with Home Assistant OS/Container).

🩺 Troubleshooting

  • Media browser shows no clips: an error from TELUS is shown in the media browser itself ("Could not list clips: ..."). If the list is simply empty, run python tools/fetch_clips.py --debug on your own machine and open an issue with the output (remove anything private) so field names can be adjusted.
  • All entities go Unavailable after a few minutes: fixed in 0.4.0 (token now refreshes on 403). Make sure you're on the latest.
  • Camera black / "404" in HA stream logs: the bridge isn't publishing — check docker compose logs -f bridge and the /health endpoint, and confirm the bridge URL and LAN_IP are correct.
  • Stream stays dark for a few minutes after MediaMTX or the publish side was down: after six failed attempts in a row (about 45 s) the bridge gives up and waits for a /start; the integration sends one every 150 s in that state, so the stream can take up to about 3 minutes to return once the fault is gone. An outage of a few seconds is healed by the bridge itself.
  • "Sign in again" prompt: TELUS answered the stored password with a 4xx (other than 408/429). The integration sends TELUS nothing further until you enter the password in the prompt or reload the integration. Any other failed login (408, 429 or 5xx, a timeout or a connection error, at any of its three steps) is treated as an outage instead: polling goes on and logins for that username pause for 5 minutes at a time, across setup retries and reloads. The sign-in form is held by the same pause, so "cannot connect" there can mean "wait 5 minutes" (a restart of Home Assistant clears it).
  • Stream drops every ~10 minutes: no longer expected (sessions run for hours). Check reasons and reconnects_total in /health and look for auto-reconnect in the bridge logs.

🎨 Branding

The logo and icon ship with the integration, in custom_components/telus_smarthome_plus/brand/:

custom_components/telus_smarthome_plus/brand/
├── icon.png      # 256×256
├── icon@2x.png   # 512×512
├── logo.png      # wide banner
└── icon.svg      # vector source

Since Home Assistant 2026.3, custom integrations serve their own brand images locally from this brand/ folder — they override the brands CDN, so the icon shows on the device/integration card with no submission to home-assistant/brands and no extra config. Just install and restart. Supported filenames also include dark_icon.png, dark_logo.png, and the @2x variants.

🙏 Acknowledgements

Built through API reverse-engineering of the TELUS SmartHome+ app. TELUS SmartHome+ is a white-label platform; your mileage may vary by region and firmware.

📄 License

MIT © 2026 Akram Mahmoud

Bind everything to loopback so nothing else on the LAN can read the stream or publish onto it (MediaMTX allows anonymous publish by default). In gst_bridge/docker-compose.override.yml (auto-merged by compose, gitignored; docker compose config shows the effective result):

services:
  mediamtx:
    environment:
      MTX_RTSPADDRESS: "127.0.0.1:8556"   # also moves off 8554 if another RTSP server owns it
  bridge:
    environment:
      RTSP_PUBLISH_BASE: "rtsp://127.0.0.1:8556"
      RTSP_READ_BASE: "rtsp://127.0.0.1:8556"
      BRIDGE_HOST: "127.0.0.1"

and set the integration's bridge URL to http://127.0.0.1:8787. If Home Assistant runs on another machine, keep the defaults and set LAN_IP in .env instead; the bridge logs a warning at startup when RTSP_READ_BASE is loopback-only. When the API is reachable from other hosts, set BRIDGE_TOKEN in .env (openssl rand -hex 24) and the same value in the integration's "bridge token" option; the bridge then refuses /session/* and /debug/clock/* without it. The signaling endpoints in a /start body are always checked against ENDPOINT_ALLOW_RE (AWS Kinesis Video hosts only).

Verifying the bridge

  • curl -s http://127.0.0.1:8787/health | jq — healthy looks like ok: true, degraded: false, one session with healthy: true, secs_since_frame near 0, nack_negotiated: true, and process.ffmpeg_children equal to the number of cameras. Failure signatures: secs_since_frame past 8 (camera stopped sending), gave_up: true (the bridge stopped dialling; while TELUS reports the camera online the integration posts a fresh /start on its own for every enabled camera without a healthy session, opened through HA or not: at most one per 5 minutes, one per 150 s once the bridge reports gave_up; a /start that found nothing listening does not count), wedged_sessions > 0 or ffmpeg_children above the session count (restart the container), MediaMTX logging no one is publishing (nothing reached the publish step).
  • In Home Assistant the same data is on binary_sensor.<camera>_bridge_stream (attributes) and sensor.<camera>_bridge_reconnects.
  • Audio: /health shows audio_source (camera once the camera's audio has been heard, else silence), audio_rms_db for the camera's decoded audio and for the published mix (within a few dB of each other when the mixer is placing the camera's audio; a mix 40 dB below the camera means its buffers arrive later than AUDIO_MIX_LATENCY_MS), last_au_age_s per track (which side stopped), and the two pre_keyframe_* counters (what was dropped before the first video keyframe at start-up).
  • Tests run inside the bridge's test image (the runtime image has no H.264 encoder): docker build --target test -t gst_bridge-test gst_bridge/ then docker run --rm --init --ulimit nofile=65536:65536 -v $PWD/gst_bridge/tests:/t:ro -v $PWD/gst_bridge/telus_gst_bridge.py:/app/telus_gst_bridge.py:ro gst_bridge-test python3 -I -m unittest discover -s /t (the second mount makes a re-run test the working tree, not the copy baked into the image). The integration has its own suites in tests/ (API client; camera keep-open, doorbell ring age, auto-light select and clip retry decisions); they need aiohttp but no Home Assistant, so the same image runs them without installing anything on the host: docker run --rm --network none -v $PWD:/w:ro -w /w gst_bridge-test python3 -m unittest discover -s tests
  • The bridge logs answer rtcp-fb: ... nack, nack pli once per session: that is the camera agreeing to retransmit lost packets. If nack disappears, loss recovery is off and recordings will smear again.
  • Timestamps: ffprobe -rtsp_transport tcp -show_entries packet=pts_time -read_intervals '%+15' rtsp://127.0.0.1:8556/telus_<id> should take about 15 wall-clock seconds and show PTS spacing equal to the camera's real frame interval (the bridge muxes arrival-time, smoothed PTS into MPEG-TS for ffmpeg; a raw H.264 pipe would make ffmpeg invent a fixed-rate clock). Start-up from "publishing" to the stream appearing on MediaMTX is 1-2 s (ffmpeg's 1 s TS probe).
  • docker kill -s USR1 gst_bridge-bridge-1 dumps every thread's stack into the container log when something hangs.
  • Docker marks the container unhealthy on HTTP 503 but never restarts it on its own; pair it with a restart policy watcher (autoheal, a cron) if you want that.

gst_bridge tuning knobs (environment)

Variable Default What it does
WEBRTC_NACK 1 Negotiate RTCP NACK on the video transceiver so lost RTP packets are retransmitted (the camera supports nack and nack pli). 0 disables (the three on/off flags in this table take 0, false, no or off, any case, as off).
WEBRTC_JITTER_MS 300 webrtcbin jitterbuffer depth; must cover one retransmission round trip for NACK to help.
FFMPEG_KILL_GRACE_SEC 3 After closing ffmpeg's pipes and sending SIGTERM, wait this long before SIGKILL.
H264_GAP_GATE 1 Drop video from a lost reference picture until the next keyframe (and ask the camera for one). 0 disables.
ENABLE_AUDIO 1 Request the camera's audio (Opus). 0 = never ask for it; the published stream still carries a (silent) AAC track so its track count never changes.
AUDIO_GAIN_DB 15 Mic boost applied by ffmpeg before the AAC encode (the camera mic is quiet; a limiter follows).
AUDIO_MIX_LATENCY_MS 1000 The camera's audio is decoded into a live mixer with a silence source; this is how late its buffers may arrive before the slot is filled with silence, and the audio latency it adds.
BRIDGE_TOKEN empty Shared secret for /session/* and /debug/clock/{id}: callers must send it as X-Bridge-Token (the integration's "bridge token" option). /health stays open.
ENDPOINT_ALLOW_RE AWS KVS pattern Regex the signaling endpoints in a /start body must match (wss/https hosts under *.kinesisvideo.<region>.amazonaws.com); anything else is refused with 400.
RTSP_PUBLISH_BASE / RTSP_READ_BASE rtsp://mediamtx:8554 Where the bridge publishes, and the base of the URL it hands Home Assistant (compose sets the publish base to rtsp://127.0.0.1:8554 and the read base from LAN_IP).
BRIDGE_PORT 8787 Control API port.
WATCHDOG_INTERVAL_SEC 3 How often the self-healing watchdog looks at every session.
(timing) built in RTP packets are re-stamped with their arrival time and each track runs through a smoothing clock (_Pll, 8 s rate window, 1.5 s envelope); /health shows rtp_restamped, rtp_unstamped, clock_resyncs (the clock jumped after an outage) and arrival_hist (inter-arrival histogram at the jitterbuffer input). GET /debug/clock/{id}?kind=video (or audio; token) returns the last CLOCK_TRACE_LEN (12000) arrival/stamped pairs. The camera's own RTP clock is frame-count based and its Wi-Fi delivery bursty, see docs/BACKLOG.md.
PIPE_BUFFER_BYTES 1048576 Capacity of ffmpeg's stdin pipe (F_SETPIPE_SZ) so fdsink hands a whole keyframe over in one write.
BRIDGE_HOST 0.0.0.0 Bind address of the control API. Use 127.0.0.1 when Home Assistant runs on the same host.
MAX_SESSIONS 8 Concurrent sessions accepted before /start answers 429.
STREAM_STALE_SEC / STARTUP_GRACE_SEC / MAX_AUTO_RECONNECTS / STOP_TIMEOUT_SEC 8 / 25 / 6 / 5 Self-healing watchdog (see comments in telus_gst_bridge.py). STOP_TIMEOUT_SEC is never below FFMPEG_KILL_GRACE_SEC + 3, so it is 6 with the defaults. The reconnect counter is cleared only by a session that stayed healthy for longer than STARTUP_GRACE_SEC.
RESTART_BACKOFF_SEC 120 After the bridge gave up on a camera (MAX_AUTO_RECONNECTS failed), one fresh attempt per this many seconds, however often /start is called. The integration posts /start every 150 s in that state (GAVE_UP_REKICK_INTERVAL in camera.py); raise that too if you raise this.

GET /health returns ok, degraded + reasons, version (git revision the image was built from), per-session started / healthy / secs_since_frame / reconnect_attempts / reconnects_total / gave_up / nack_negotiated / audio_requested / audio_active / audio_source / audio_rms_db / audio_bytes / video_bytes / video_drops / audio_drops / rtp_restamped / rtp_unstamped / au_without_pts / pre_keyframe_dropped / pre_keyframe_audio_dropped / frame_gaps / gap_frames_dropped / gap_gate_armed / clock_resyncs / last_au_age_s / arrival_hist, and a process block (fds, threads, ffmpeg_children, session_objects, wedged_sessions, watchdog_age_s). frame_gaps / gap_frames_dropped rising means the gap gate is dropping video after packet loss; gap_gate_armed: false means the gate is off or could not read the stream's SPS, so those two stay 0 either way. audio_fallback is still emitted because the integration reads it, and is always false. More than one ffmpeg child per camera, or fds climbing session after session, means a leak. HTTP 503 means the service itself is sick (watchdog thread silent, a session wedged in teardown for > 5 min) and a container restart is the right response; a camera outage shows as degraded: true with HTTP 200 and must not restart the bridge. Build with GIT_SHA=$(git rev-parse --short HEAD) docker compose up -d --build so the version is stamped. Tests: see "Verifying the bridge" above. Review and audit findings with their status: docs/BACKLOG.md.