GithubHelp home page GithubHelp logo

damhau / teamsstatus Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 73 KB

Teams Status is a pair of script to use a Luxafor light as a status indicator for Teams

PowerShell 79.86% Python 20.14%
luxafor busylight teams powershell pyhton luxafor-light presence

teamsstatus's Introduction

Teams Status

Introduction

Python and Powershell script to scrape the presence status from Teams log file and update a Luxafor Bluetooth USB Busy light.

The app provided by Luxafor had to be runnning on my PC and didnt work with Teams so I took the inspiration from https://github.com/EBOOZ/TeamsStatus and https://github.com/vmitchell85/luxafor-python to create the script in this repo.

The powershell script (Get-TeamsStatus.ps1) start a loop that get the status from the Teams log file and will send an http request that contain the color change for the Luxafor busy light to the Flask web server.

The flask web server is started with the Pyhton script (luxafor-web.py) running on a Raspbery PI (or any other device).

The python script use PyWinUSB to send the command to the Luxafor light to chagne the color.

Keep in mind that there is no security for the web endpoint exposed by the Python script, this is expected to be run in a trusted network.

Presence state and light color

The default configuration of the powershell script will process the following event:

  • If you are in a call the light will be red
  • If you are not in a call the light will be green
  • If you are available the light will be green
  • If your presence is do not disturb the light will be red
  • If your precense is away the light will turn off

You can fine tune this from line 214 to 267 in the powershell script.

Pre requesite

Installation

Linux

  • Connect the Luxafor USB Bluetooth dongle or usb cable

You can check if the id is by runnning dmesg when you insert the usb connector for the luxafor busry light

[10807489.281366] usb 1-1.4: current rate 8436480 is different from the runtime rate 48000
[10977261.175819] usb 1-1.3: new full-speed USB device number 4 using xhci_hcd
[10977261.315509] usb 1-1.3: New USB device found, idVendor=04d8, idProduct=f372, bcdDevice= 1.00
[10977261.315525] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[10977261.315538] usb 1-1.3: Product: LUXAFOR BT
[10977261.315550] usb 1-1.3: Manufacturer: GREYNUT LTD
[10977261.399011] hid-led 0003:04D8:F372.0003: hidraw2: USB HID v1.11 Device [GREYNUT LTD LUXAFOR BT] on usb-0000:01:00.0-1.3/input0
[10977261.400747] hid-led 0003:04D8:F372.0003: Greynut Luxafor initialized
  • create the file /etc/udev/rules.d/60-luxafor.rules and add the following (to allow access for non root users)
# add Luxafor LED flag
SUBSYSTEMS=="usb", ATTR{idVendor}=="04d8", ATTR{idProduct}=="f372", MODE:="0666"
  • Copy the python script in any folder, I've used /opt/luxafor-web/

  • The flask web server will listen to 8080, if you need to change it update the varaible PORT at line 21 in the script.

  • Cd to your folder (eg. /opt/luxafor-web/)

  • Install PyWinUSB and Flask

pip3 install PyWinUSB Flask
  • Create the file /etc/systemd/system/luxafor-web.service and add the following
[Unit]
Description=Luxafor Web
After=multi-user.target
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/python3 /opt/luxafor-web/app.py
[Install]
WantedBy=multi-user.target
  • Enable and start the service
systemctl enable luxafor-web
systemctl start luxafor-web
  • Check if the service started sucesfully
root@raspberrypi:/opt/luxafor-web# systemctl status luxafor-web

● luxafor-web.service - Luxafor Web
   Loaded: loaded (/etc/systemd/system/luxafor-web.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2022-12-08 12:57:08 CET; 1s ago
 Main PID: 6175 (python3)
    Tasks: 2 (limit: 4915)
   Memory: 11.2M
   CGroup: /system.slice/luxafor-web.service
           └─6175 /usr/bin/python3 /opt/luxafor-web/luxafor-web.py

Dec 08 12:57:08 raspberrypi systemd[1]: Started Luxafor Web.
Dec 08 12:57:09 raspberrypi python3[6175]:  * Serving Flask app "app" (lazy loading)
Dec 08 12:57:09 raspberrypi python3[6175]:  * Environment: production
Dec 08 12:57:09 raspberrypi python3[6175]:    WARNING: Do not use the development server in a production environm
Dec 08 12:57:09 raspberrypi python3[6175]:    Use a production WSGI server instead.
Dec 08 12:57:09 raspberrypi python3[6175]:  * Debug mode: off
Dec 08 12:57:09 raspberrypi python3[6175]:  * Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)
  • You can test the webook with the following command, this should switch the led to red.
curl -X POST http://localhost:8000/webhook -H 'Content-Type: application/json' -d '{"color":"red"}'

Windows

  • If you want to use the eventlog you have to run the command below in an elevated powershell prompt, otherwise you can log to a file.
New-EventLog -LogName Application -Source "TeamsStatus"
  • Copy the powershells script Get-TeamsStatus.ps1 to any folder on windows, I've copied it in %userprofile%\AppData\Local\TeamsStatus

  • Edit Get-TeamsStatus.ps1 and change the following parameters

    • $logType: can be either file to log to a file or eventlog to log to event log
    • $webhookUrl: the full url of the webhook running on your Raspberssy Pi. for me it is "http://192.168.1.34:8000/webhook"
  • Open a powershell prompt and run the script with debug mode to check that everyhitng works

cd $env:USERPROFILE\AppData\Local\TeamsStatus
.\Get-TeamsStatus.ps1 -debugEnabled $true
12/08/2022 13:03:11 - Teams Status started
12/08/2022 13:03:11 - Processing Teams log file: C:\Users\Damien\AppData\Roaming\Microsoft\Teams\logs.txt
12/08/2022 13:03:11 - Status: Available
12/08/2022 13:03:11 - Activity: Not in a call
12/08/2022 13:03:11 - Wehook http://192.168.1.34:8000/webhook called
12/08/2022 13:03:11 - Wehook http://192.168.1.34:8000/webhook called
12/08/2022 13:03:16 - Status: Available
12/08/2022 13:03:16 - Activity: Not in a call
12/08/2022 13:03:21 - Status: Available
12/08/2022 13:03:21 - Activity: Not in a call

You should be able to change your presence to "do not disturb" in Teams and the light should turn to red.

Windows - Install a Service

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Unblock-File .\Get-TeamsStatus.ps1
Start-Process -FilePath .\nssm.exe -ArgumentList 'install "Microsoft Teams Status Monitor" "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-command "& { . C:\Users\<username>\AppData\Local\TeamsStatus\Get-TeamsStatus.ps1 }"" ' -NoNewWindow -Wait
Start-Service -Name "Microsoft Teams Status Monitor"

Don't forget to replace with your username

  • After completing the steps below, start your Teams client and verify if the status and activity is updated as expected.

  • If you have used the eventlog logging type you can check the log in the event logs

    image image

Thanks

teamsstatus's People

Contributors

damhau avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.