Skip to main content

YoLink (hc-yolink)

The hc-yolink plugin bridges the YoLink cloud MQTT service to HomeCore. YoLink devices (door sensors, motion sensors, temperature sensors, outlets, etc.) are registered as HomeCore devices.

Prerequisites

  • A YoLink account and hub
  • Your YoLink MQTT credentials (UAID and secret key — available in the YoLink app under Account settings)

Configuration

[homecore]
broker_host = "127.0.0.1"
broker_port = 1883
plugin_id = "plugin.yolink"
password = ""

[yolink]
# MQTT credentials from YoLink app
uaid = "your-uaid"
secret = "your-secret-key"
mqtt_host = "mqtt.yosmart.com"
mqtt_port = 8003

Running

cd /path/to/hc-yolink
./hc-yolink config/config.toml

The plugin connects to the YoLink cloud MQTT broker, discovers all devices associated with your account, and registers them with HomeCore.

Device IDs

YoLink device IDs follow the pattern yolink_{device_id} where device_id is the YoLink-assigned device identifier (16 hex characters):

yolink_d88b4c01000e82eb    ← door sensor
yolink_a3f291b200045c12 ← temperature sensor
yolink_cc8102a3000b7e45 ← smart outlet

Supported device types

YoLink devicedevice_typeKey attributes
Door/window sensordoor_sensoropen (bool), battery (int)
Motion sensormotion_sensormotion (bool), battery (int)
Temperature/humiditysensortemperature (float), humidity (float), battery (int)
Smart outletswitchon (bool), power_w (float)
Leak sensorsensorwet (bool), battery (int)
Vibration sensorsensorvibration (bool), battery (int)

Common rule patterns

Door open alert

name = "Front door — alert"
enabled = true

[trigger]
type = "device_state_changed"
device_id = "yolink_d88b4c01000e82eb"
attribute = "open"
to = true

[[actions]]
type = "notify"
channel = "telegram"
message = "Front door opened"

Low battery alert

name = "YoLink — low battery"
enabled = true
cooldown_secs = 86400 # alert once per day max

[trigger]
type = "device_state_changed"
device_id = "yolink_d88b4c01000e82eb"
attribute = "battery"

[[conditions]]
type = "device_state"
device_id = "yolink_d88b4c01000e82eb"
attribute = "battery"
op = "Lt"
value = 20

[[actions]]
type = "notify"
channel = "telegram"
message = "YoLink front door sensor battery is low: {{device.battery}}%"

Plugin actions

hc-yolink declares one capability action the admin UI exposes as a button on the plugin detail page:

rescan_devices (sync, user)

Force an immediate inventory refresh — fetches the full device list from the YoLink hub and republishes registration for each. Use this after pairing a new YoLink device through the YoLink app: the plugin normally polls the inventory on inventory_interval_secs, but rescan_devices is the on-demand path so a freshly-paired device shows up in homeCore without waiting for the next poll cycle.

SDK adoption

hc-yolink is built on the official Rust plugin SDK (hc-plugin-sdk-rs) and supports the full management protocol: heartbeat monitoring, remote configuration, and dynamic log level.

Background initial state fetch

On startup, hc-yolink fetches the current state of all devices from the YoLink cloud API. This fetch runs as a non-blocking background task (tokio::spawn) so it does not delay plugin startup or MQTT subscription.

The fetch begins after initial_fetch_delay_secs (default: 10 seconds) to allow the MQTT connection to stabilize first:

[yolink]
initial_fetch_delay_secs = 10 # seconds before background getState begins
poll_interval = 3600 # periodic refresh interval (seconds, default: 3600)
YoLink hub rate sensitivity

The YoLink hub is sensitive to burst API traffic. The background fetch spaces getState calls to avoid overwhelming the hub. If you have many devices, the initial fetch may take a minute or more to complete.

The default poll_interval is 3600 seconds (1 hour). Shorter intervals increase API traffic and are generally unnecessary since real-time state updates arrive via the YoLink cloud MQTT stream.


Device name sync

When a device is renamed in the YoLink app, the new name is synced to HomeCore at the next state update from that device. The update only takes effect after a confirmed state message — not immediately on registration. Restarting hc-yolink forces a full re-registration that syncs all names immediately.

Troubleshooting

ProblemSolution
Plugin fails to connectCheck UAID and secret in config; verify YoLink account credentials
Devices not appearingCheck that devices are online in the YoLink app and have been used recently
State not updatingYoLink cloud MQTT may have a delay; check YoLink app for offline sensors
online/offline flappingCheck device battery level and WiFi/LoRa range

Log rotation

hc-yolink writes logs to logs/hc-yolink.log. Rotation and compression are configured in config/config.toml:

[logging]
level = "info" # stderr log level; RUST_LOG overrides this
rotation = "daily" # daily | hourly | weekly | never
max_size_mb = 100 # rotate when file exceeds this MB (0 = time-only)
compress = true # gzip rotated files in a background thread
FileDescription
logs/hc-yolink.logActive log (always uncompressed)
logs/hc-yolink.2026-03-27.log.gzRotated daily file (compressed)
logs/hc-yolink.2026-03-27.1.log.gzSecond rotation in same period (size limit hit)