j-eissler / Windows-MQTT-Listener

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Windows-MQTT-Listener

This application allows you to shut down your windows computer with an mqtt message. It was written to be used with a Home Assistant smart home.

How to use

  1. Download this repository. All you need is the folder 'app'. It contains the application executable and config file. Place the app folder somewhere in your system and rename it (i.e. 'C:\mqtt_listener\). The path must not contain spaces!
  2. Open 'config.json' and enter your settings. The setting are explained below.
  3. Add this application to windows task scheduler. This allows it to run even before a user is logged in. Use the following settings to make sure it works:
    • Run as User: SYSTEM
    • Trigger: On Startup
    • Action:
      • Run Program
      • Enter path to 'app.exe'
      • IMPORTANT: Enter the application directory to 'Start in (optional)'. Otherwise the process wont start.
  4. Send an MQTT message to the shutdown topic and watch your pc shut down.

config.json settings

  • mqtt_user: Username required to log into your MQTT broker.
  • mqtt_password: Password required to log into your MQTT broker.
  • mqtt_broker_hostname: Hostname of your MQTT broker
  • hostname: Hostname of the computer this application is running on. This is used to set the topic this app listens to.
    Example:
    Hostname is 'mycomputer'. The shutdown topic is then set to 'mycomputer/shutdown' so this is where you have to publish the shutdown message to.

About


Languages

Language:JavaScript 100.0%