Coder Social home page Coder Social logo

acme.mqtt.alive's Introduction

Acme.Mqtt.Alive

Why ?

To simplify device tracking in Home Automation and, of course, for fun!

How ?

This tool will be installed as a Windows Service and simply set a MQTT topic to online when connected to home network and to offline when the device is shut down but also when it's not available: network issues, sleep, hibernate, ...

Setup

Edit the appsettings.json and complete the MQTT section.

{
  "Mqtt": {
    "Host": "MQTT_HOST",
    "UserName": "MQTT_USERNAME",
    "Password": "MQTT_PASSWORD",
    "Topic": "MQTT_TOPIC",
    "ActionTopic": "OPTIONAL_MQTT_ACTION_TOPIC"
  }
}

And publish the project:

dotnet publish --configuration RELEASE --self-contained -r win-x64 -p:PublishTrimmed=true

Windows Installation

Run a shell with admin rights:

sc create "MQTT Alive" start=auto binpath="[path_to_exe_fileπŸ˜‰]"
sc start "MQTT Alive"

Home Assistant integration

device_tracker:
  - platform: mqtt
    devices:
      my_pc: "monitor/mqtt/olivier"
    qos: 1
    payload_home: "online"
    payload_not_home: "offline"
    source_type: router

Bonus

If you set ActionTopic variable in appsettings.json You can remotely bring the targeted machine to sleep / hibernate.

Enjoy πŸ€–β—

Be creative with your automation...

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.