/on-air

A NodeJS app for querying MS Teams presence and broadcast it to a Yeelight bulb

Primary LanguageJavaScriptApache License 2.0Apache-2.0

On-Air

On air

What is On Air?

A NodeJS solution to broadcast your Microsoft Teams presence to a Yeelight smart bulb. The app uses the Presence Api, which is available in Microsoft Graph, allowing to retrieve your presence. This could potentially allow someone to update the Yeelight light bulb from a remote machine they do not use, as long as it is on the same network.

Hardware Requirements

A Yeelight bulb will help to make this work out of the box, but you can actually use any other bulb and update src/bulb.js accordingly.

Prerequisites

To run the application, you need the following:

  • Node.js installed on your machine.
  • Either a personal Microsoft account with a mailbox on Outlook.com, or a Microsoft work or school account.

If you don't have a Microsoft account, there are a couple of options to get a free account:

Register a web application with the Azure Active Directory admin center

  • Register an application in Azure Active directory
    • Provide user.read & Presence.Read permissions and get an admin concent
    • If you are a Microsoft employee, there is a procedure for getting this, contact me (salowenh) for assistance

Configure the application

  1. Clone the repo
  2. Rename the .env.example file to .env
  3. Edit the .env file and make the following changes.
    1. Replace YOUR_APP_ID_HERE with the Application Id you got from the App Registration Portal.
    2. Replace YOUR_APP_PASSWORD_HERE with the password you got from the App Registration Portal.
    3. Replace BULB_IP with the Yeelight local IP
    4. Set INTERVAL_SECONDS with the required presence query interval, default is 2 minutes
  4. On you CLI, run the following to install dependencies:
    npm install

Run the application

  1. On you CLI, run the following to run the application
    npm start
  2. Open a browser and browse to http://localhost:3000
  3. Sign in
  4. Hit the Start button on the top bar
  5. As you Teams presence becomes " " (or equivalent), the bulb will turn on in a red light.

Bulb

Run as docker image (optional)

Node makes it super easy to turn applications into a docker image

To build the docker image

  1. Make sure Docker daemon is running
  2. On your CLI, run the following to create a docker image
    docker build -t on-air .

To run the docker image

docker run -p 3000:3000 -d on-air

The output is the container ID (or look it up by running docker ps), use it to view the logs

docker logs <ID>

Done

Now everything should be running. Feel free to open an issue if you encounter any difficulties Code contributions are also welcomed

Bulb

Credits

The application is based over this MS Graph training

Other solutions