Skip to content

odtgit/evmqtt

Repository files navigation

Linux input event to MQTT gateway

This program allows you to capture linux input events via evdev and publish them to an MQTT broker. This can for example be used to turn IR button presses to triggers in Home Assistant.

Based on the original gist by James Bulpin.

As of the latest merge the payload will be sent as JSON with 2 attributes, key and devicePath of the generator.

Installation as a service

Get the repo, install python3-pip, install prerequisites with:

git clone https://github.com/odtgit/evmqtt
sudo apt install python3-pip
pip3 install paho-mqtt evdev

Configuration

Check out config.json and modify for your requirements. The topic will be expanded automatically to send to /state for payload and /config for autodiscovery.

Run in a docker container

Very simple to build and run using docker something like this

docker build . -t evmqtt
docker run -d --network host --device=/dev/input/event3 --name evmqtt <image_id>

Or you can also use the docker-compose.yaml example directly.

Run as a service

In the evmqtt.service file change the path to the script and the executing user. Copy it to /etc/systemd/system and run with

sudo systemctl enable evmqtt
sudo systemctl start evmqtt

Integration with Home Assistant

MQTT autodiscovery should take care of adding a sensor to HA. By default this is called sensor.event_gateway_mqtt You can still create automation based on MQTT messages directly. I've found this works best with toggle service. Or you can create a flow like this in Node-Red

About

Linux input event to MQTT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published