nragon / keeper

A service to monitor and maintaining MQTT and HomeAssistant
MIT License
28 stars 6 forks source link
failover high-availability homeassistant keeper mqtt python watchdog

Welcome to Keeper

License: MIT

Keeper is an open source service manager. Currently, monitors home assistant service and mqtt services. MQTT service is monitored by checking connections to the service and home assistant is monitored using an heartbeating mechanism. Through MQTT we exchange heartbeat messages with home assistant in order to determine if its running. Every 3 missed messages between Keeper and home assistant, Keeper will attempt to restart home assistant. Then, if after 3 restarts home assistant still not responding, the system is rebooted. In MQTT case, it's only performed a service restart every 3 missed connections

Table of Contents

Installation

systemd

curl -sSL https://raw.githubusercontent.com/nragon/keeper/master/setup/systemd/setup | bash

Hass.io

Follow instructions on how to install third party add-ons here. Use the following URL when required:

https://github.com/nragon/keeper/tree/master/setup/hassio

Configuration

You can find a set of properties in a json file inside config directory that can be tuned and configured according with you own settings

Configuration Definition
heartbeat.interval Interval between heartbeat message. This should match number of seconds in home assistant automation
heartbeat.delay Number of seconds we should wait before considering a miss heartbeat message
heartbeat.topic Heartbeat topic
ha.restart.command Command to restart home assistant service
system.restart.command Command to restart system
mqtt.broker MQTT broker ip
mqtt.port MQTT broker port
mqtt.user MQTT user used
mqtt.pass MQTT user password
mqtt.restart.command Command to restart MQTT service

Home Assistant

In home assistant side we should configure an automation capable o sending heartbeat messages to Keeper. The number of seconds and topic are different depending on Keeper configurations

- id: keeperheartbeat
  initial_state: "on"
  trigger:
    platform: time
    seconds: "/<numberofseconds>"
  action:
    service: mqtt.publish
    data:
      topic: "<heartbeattopic>"
      payload: "1"

Contributing

Pull requests and issues on github are welcome. Feel free to suggest any improvement.

Licensing

This project is licensed under the MIT License - see the LICENSE file for details