Skip to content

Tonio101/YoLinkHome

Repository files navigation

[Deprecated] Use YoLink API V2: https://github.com/Tonio101/YoLinkAPI_V2

YoLinkHome

Simple script that will send a broadcast message to your Google device(s)
whenever a door opens (or mailbox).

If you are only interested in integrating with YoLink products via the
MQTT protocol, you can skip the setup for Assistant Relay and go to
YoLink Integration steps.

Parts Needed

Prereqs

Follow the steps here to install and configure Assistant Relay.
This will essentially configure the Raspberry Pi as anther Google device in
order to broadcast messages to other Google devices in your network.

YoLink API Documentation

As mentioned in the API documentation wiki, contact Chi Yao ([email protected])
to request your YoLink account API keys.

KEEP YOUR YOLINK ACCOUNT API KEYS SECURED!

Ensure you have the following information: Required YoLink Account API Keys:

  • CSID
  • CSName
  • CSSecKey
  • SVR_URL

Using a QR Code Scanner, gather all the IoT device(s) serial number (32 char code).
List them somewhere as they will be required to enable the API for each device.

Testing Google Assistant Relay

I'm assuming that at this point you have carefully followed the steps mentioned
above to configure Assistant Relay on the Raspberry Pi.

On your Raspberry Pi run the google_assistant_relay_test.py script to ensure
that Assistant Relay is working.

/usr/bin/python3 tests/google_assistant_relay_test.py --url http://192.168.1.199:3000/assistant --user bob

YoLink Integration

YoLink API Documentation
YoLink supports both HTTP callback API (webhook) or MQTT report topic.

This script will go over subscribing to the YoLink MQTT broker topic to receive
sensor events such as open/close. It will broadcast a message to your Google
devices whenever a door is opened

Install python required modules:

/usr/bin/python3 -m pip install -r requirements.txt

Add the IoT device(s) serial number to yolink_data.yml.

Execute the python script providing your YoLink account API keys:

* Note: For mqtt_url arg, discard the "https://" in {SVR_URL}

/usr/bin/python3 src/yolink.py --url {SVR_URL}/openApi \
                               --mqtt_url {SVR_URL} \
                               --mqtt_port 8003 \
                               --csid {CSID} \
                               --csseckey {CSSecKey} \
                               --topic {CSName}/report \
                               --file src/yolink_data.yml

Populate the yolink credentials in start_yolinkhome.sh.
Then simply execute the script.

YoLink Cron Job

Add a cron job to start the process on startup.
Use start_yolinkhome.sh for the cron job entry. Or even better, create a systemd service.

YoLink Systemd Service

systemd service documentation

Modify the yolinkhome.service file.

Copy this file into /etc/systemd/system as root.

sudo cp yolinkhome.service /etc/systemd/system/yolinkhome.service

Inform systemd about the new service.

sudo systemctl daemon-reload

Start the service.

sudo systemctl start yolinkhome.service

When you are happy with the results, enable the service.
It should now start automatically at startup.

sudo systemctl enable

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published