Relay is paired and on Karen's Wi-Fi — now we wire it into Home Assistant as Karen's primary control surface. The manual Richmat remote keeps working as a physical fallback. This doc covers every Smart Life setting, every HA YAML block, and a commissioning checklist before you leave her house. Entity names assume HA slugs them as switch.karen_bed_head_up / switch.karen_bed_head_down — adjust if HA picks different IDs.
Phase 01 — Smart Life app settings
P01Smart Life Config
Required
Smart Life
Why: How each channel behaves when toggled (one pulse vs stay-on) is set inside the Smart Life app and burned into the relay's flash. HA will just send on/off — the relay decides what "on" means. We use Inching (momentary) mode so if HA crashes mid-command, the bed stops on its own instead of running to the limit switch.
- Open Smart Life → tap the ST-DC4 device. You'll see
CH1 through CH4.
- Tap CH1 → Settings → rename to "Karen Bed Head Up".
- Same CH1 settings → Switch Mode → choose Inching (Momentary). Set delay to
1.0 s.
- Repeat for CH2 → rename "Karen Bed Head Down" → Inching →
1.0 s.
- Leave CH3 and CH4 as-is (future LED strip / fan — see REV 2.0 roadmap).
- Optional: tap the device gear → Power On State → set to OFF so if the relay loses power mid-cycle, it restarts idle.
Inching trade-off: Each HA command = one 1-second nudge (~1" of head travel). For longer moves, HA scripts will loop multiple pulses. Safer than Self-Lock because any failure mid-loop stops the bed.
Phase 02 — Home Assistant discovers the relay
P02HA Tuya Integration
Required
Home Assistant
Why: HA talks to the ST-DC4 through the Tuya cloud integration — no local control, no firmware flash. You need a free Tuya IoT Developer account (not the Smart Life app login) to get the Access ID and Secret.
- Go to
iot.tuya.com → sign up / log in → Cloud → Development → create a project (region: Western America).
- In the project → Overview → copy Access ID and Access Secret.
- Still in the Tuya project → Link Tuya App Account → scan QR from Smart Life app → the ST-DC4 appears linked.
- In Home Assistant: Settings → Devices & Services → Add Integration → "Tuya". Paste Access ID, Secret, and your Smart Life email.
- HA will discover the ST-DC4 and create 4 switch entities. Confirm these two show up:
- •
switch.karen_bed_head_up (CH1)
- •
switch.karen_bed_head_down (CH2)
- Go to Developer Tools → States, find each entity, click "Call Service: switch.turn_on" — bed should nudge up (~1" per call). This is your sanity check.
Gotcha: Tuya cloud has a ~1s latency minimum. If HA sends turn_on + turn_off too close together, the off may land before the on registers. HA scripts below use delay: 0.2 between state changes to handle this.
Phase 03 — HA scripts (drop into scripts.yaml)
P03Scripts — One Nudge + Presets
Required
Home Assistant
Why: Scripts are reusable action bundles. Karen's dashboard buttons call these, automations call these, Alexa calls these. One place to tune timings if bed speed changes or if you swap the actuator later.
// scripts.yaml
# ── Single nudge (~1" head travel) ─────────────────────────
karen_bed_nudge_up:
alias: "Karen Bed — Nudge Up"
sequence:
- service: switch.turn_on
target:
entity_id: switch.karen_bed_head_up
karen_bed_nudge_down:
alias: "Karen Bed — Nudge Down"
sequence:
- service: switch.turn_on
target:
entity_id: switch.karen_bed_head_down
# ── Preset: TV angle (~10s of up) ─────────────────────────
karen_bed_tv_position:
alias: "Karen Bed — TV Position"
sequence:
- repeat:
count: 10
sequence:
- service: switch.turn_on
target:
entity_id: switch.karen_bed_head_up
- delay: "00:00:01.2"
# ── Preset: Sit-up (~20s of up, reading angle) ────────────
karen_bed_sit_up:
alias: "Karen Bed — Sit Up"
sequence:
- repeat:
count: 20
sequence:
- service: switch.turn_on
target:
entity_id: switch.karen_bed_head_up
- delay: "00:00:01.2"
# ── Preset: Flatten (runs down ~35s, hits limit switch) ───
karen_bed_flatten:
alias: "Karen Bed — Flatten"
sequence:
- repeat:
count: 35
sequence:
- service: switch.turn_on
target:
entity_id: switch.karen_bed_head_down
- delay: "00:00:01.2"
# ── Emergency stop — turn both channels off immediately ───
karen_bed_stop:
alias: "Karen Bed — STOP"
mode: restart
sequence:
- service: switch.turn_off
target:
entity_id:
- switch.karen_bed_head_up
- switch.karen_bed_head_down
Tunable: count values are starting guesses. After install, press the manual remote for 10/20/35 seconds to map real head angles — then tweak. The L&P 50 II full-stroke time is listed in the Richmat HJH5 spec sheet (typically 35–40s end-to-end).
Phase 04 — Time-based automations (optional)
P04Daily Rhythms
Optional
Home Assistant
Why: If Karen has a predictable routine (morning flatten, evening TV, night flat), let HA handle it so she doesn't have to think. Skip this phase entirely if her schedule varies — dashboard buttons are enough.
// automations.yaml
- alias: "Karen — Morning Flatten"
trigger:
- platform: time
at: "08:00:00"
action:
- service: script.karen_bed_flatten
- alias: "Karen — Evening TV Angle"
trigger:
- platform: time
at: "19:00:00"
action:
- service: script.karen_bed_tv_position
- alias: "Karen — Bedtime Flatten"
trigger:
- platform: time
at: "22:30:00"
action:
- service: script.karen_bed_flatten
Gotcha: If Karen manually moves the bed using her remote before the automation fires, HA has no idea where the head is. The "flatten" script assumes it's running from an elevated position — if it's already flat, 35 × 1.2s just runs the motor against the limit switch (harmless but annoying). Consider skipping morning automation and starting with just the evening TV angle.
Phase 05 — Dashboard card for Karen's tablet
P05Lovelace Control Card
Required
Home Assistant
Why: Karen's primary interface. Big buttons. No menus. Mount a cheap Fire HD on the wall next to the bed running the HA Companion app, or use her phone. Same card works on both.
// Lovelace YAML (add via dashboard edit mode)
type: grid
columns: 2
square: false
title: "Karen's Bed"
cards:
- type: button
name: "Head Up"
icon: mdi:arrow-up-bold
icon_height: 80px
tap_action:
action: call-service
service: script.karen_bed_nudge_up
- type: button
name: "Head Down"
icon: mdi:arrow-down-bold
icon_height: 80px
tap_action:
action: call-service
service: script.karen_bed_nudge_down
- type: button
name: "TV Angle"
icon: mdi:television
tap_action:
action: call-service
service: script.karen_bed_tv_position
- type: button
name: "Flatten"
icon: mdi:bed
tap_action:
action: call-service
service: script.karen_bed_flatten
- type: button
name: "STOP"
icon: mdi:stop-circle
icon_height: 80px
tap_action:
action: call-service
service: script.karen_bed_stop
show_state: false
- Install HA Companion on Karen's tablet/phone. Log into your HA instance.
- Long-press the new dashboard tile on her home screen → "Add to Home Screen" so it launches fullscreen like a native app.
- Consider kiosk mode (browser-based):
hass-kiosk-mode HACS add-on hides all nav — just the bed buttons. Good for an always-on wall tablet.
Phase 06 — Voice control (skip unless asked)
P06Alexa / Google Hook
Optional
Home Assistant
Why it's optional: Karen barely uses Alexa. Skip unless she explicitly asks. Noted here so the instructions are complete.
- Easiest path: Nabu Casa ($6.50/mo) → HA → Settings → Nabu Casa → enable Alexa voice assistant.
- In HA: Settings → Voice assistants → Alexa → Exposed entities → expose
script.karen_bed_sit_up, script.karen_bed_flatten, script.karen_bed_stop.
- Alexa app → Discover Devices → the scripts show up as "switches". Create routines with phrases Karen actually uses.
- DIY alternative:
haaska skill via AWS Lambda — free but painful setup. Not worth it for one bed.
Phase 07 — Commissioning checklist (before you leave)
P07Pre-Departure Checks
Test
Why: Before you drive away, run through this. Cheap to fix now, expensive drive back later.
| Check |
Expected |
|
| Hardware | |
| Manual Richmat remote — Up | Head raises. Release → stops. | ☐ |
| Manual Richmat remote — Down | Head lowers. Release → stops. | ☐ |
| Relay USB power solid | Blue LED on, no flicker after 5 min | ☐ |
| Smart Life | |
| CH1 tap in Smart Life | Head nudges up ~1" | ☐ |
| CH2 tap in Smart Life | Head nudges down ~1" | ☐ |
| Both channels show Inching 1.0s | Settings screen confirms | ☐ |
| Home Assistant | |
| Tuya integration online | No yellow triangle in Devices | ☐ |
| Developer Tools → switch.turn_on CH1 | Bed nudges. No error. | ☐ |
| script.karen_bed_tv_position | Bed raises for ~10s, stops cleanly | ☐ |
| script.karen_bed_stop mid-motion | Bed stops immediately | ☐ |
| Karen's Surface | |
| Tablet dashboard — all 5 buttons | Each triggers expected script | ☐ |
| Remote still works after HA test | Manual trumps automation | ☐ |