Code Monkey home page Code Monkey logo

pir2ha's Introduction

PIR2HA: a PIR to Home Assistant script with MQTT Auto-Discovery

My search for a PIR to HA (Home Assistant) work-out-of-the-box solution wasn't a success.

Since I am not having the necessary skills to write my own script, I decided to create my Frankenstein, using the code from two working scripts: https://github.com/R4scal/mhz19-mqtt-daemon (Most of the code comes from this) https://github.com/robmarkoski/pi-motion-mqtt-sensor Thank you very much @robmarkoski and @R4skal

This python script should work on any Rpi with a PIR connected to a GPIO and will create an entity in HA through MQTT Auto Discovery.

Installation:

We need some py scripts to install first:

pip3 install paho-mqtt sdnotify colorama Unidecode

Clone the repository to your home directory

git clone https://github.com/Chreece/pir2ha
cd pir2ha

Check the values from config are ok with your installment

nano config.ini

If the values in config.ini aren't right for you, uncomment them and change only what needs to be changed (ctr+x to exit and save any changes).

Check if the service is right:

nano pir2ha.service

and then copy it to the system folder and start it:

sudo cp pir2ha.service /etc/systemd/system/

sudo systemctl daemon-reload
sudo systemctl enable pir2ha
sudo systemctl start pir2ha

After that a new binary_sensor entity should arrive in HA with the name from your host + "pir" (i.e. raspberrypi_pir). Since there is a device_class: motion it should already have the motion icon and you can also make changes in the UI because of the unique_id.

ENJOY!

pir2ha's People

Contributors

chreece 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.