# Faire de la domotique libriste avec Python ### PyConFR 2018 ![](https://www.pycon.fr/2018/fr/theme/images/logo.svg =200x)<!-- .element style="border:0" --> #### Arthur Lutz --- ## Disclaimer *~~don't do this at home~~* *I do this at home* *not my day job* --- ## Disclaimer 2 #lowtech #indépendance #bidouille #apprentisage #auto-hébergement #notprod #tempspartiel #hobby * [Projet Perso n.42](https://www.paris-web.fr/2017/conferences/projet-perso-n42-une-aventure-ultrasonique.php) via [m4dz](https://talks.m4dz.net/full-remote-guide/) --- ## Introduction * Arthur Lutz * [![](https://social.logilab.org/system/custom_emojis/images/000/002/815/original/d91b01cc6bc88981.png =30x)<!-- .element style="border:0;margin:0" --> @arthurlutzim](https://twitter.com/arthurlutzim) * ![](https://social.logilab.org/system/custom_emojis/images/000/002/814/original/63c72d3387d84738.png =30x)<!-- .element style="border:0;margin:0" --> [@arthurlutzim@mamot.fr ](https://mamot.fr/@arthurlutzim) * mais aussi chez [Logilab](https://www.logilab.fr) ![](https://mamot.fr/system/accounts/avatars/000/010/707/original/a12afe5dbd7873fa.jpeg?1491814327)<!-- .element style="border:0;margin:0;border-radius:125px" --> --- ## home-assistant.io ![](https://d33wubrfki0l68.cloudfront.net/075995fe17a5351e2699b2dd878652ec4f1d8654/8bfdd/demo/favicon-192x192.png)<!-- .element style="border:0" --> Open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. --- ## home-assistant.io & python * python3 * [asyncio](https://developers.home-assistant.io/docs/en/asyncio_101.html) * installation dynamique des modules/dépendances (détecté au démarrage en fonction de la configuration) * en dev : [pep8](https://www.python.org/dev/peps/pep-0008/), [tox](https://tox.readthedocs.io/en/latest/), [voluptous](https://github.com/alecthomas/voluptuous), [type hints (monkeytype)](https://developers.home-assistant.io/docs/en/development_typing.html) --- ## Matériel * Raspberry pi / orangepi / autre SBC (Single Board Computer) * Une machine avec python3 ![](https://cdn.thingiverse.com/renders/78/f4/e9/e5/af/2098ef66fbfa8489cda91f01a676cb08_preview_featured.jpg =300x)<!-- .element style="border:0" --> [Source](https://www.thingiverse.com/thing:2316706) --- ## Matériel input ![](http://www.luisllamas.es/wp-content/uploads/2015/12/arduino-dht11-dht22-componente.png) * DHT11/DHT22 pour la temperature / humidité * sondes de distance * sondes audio, luminosité --- ## Matériel action * [LPD433 (433Mhz)](https://fr.wikipedia.org/wiki/LPD433) ![](http://blogwifi.fr/wp-content/uploads/2014/10/raspberry_domo_433-1024x644.jpg)<!-- .element style="border:0" --> --- ## Matériel action ![](https://www.abavala.com/wp-content/uploads/Castorama-prises-582860.jpg) --- [![](https://i.imgur.com/hiIveLd.png)<!-- .element style="border:0;margin:-120px 0px" -->](https://www.home-assistant.io/components/#featured) --- ## Composants que j'ai testé ![](https://i.imgur.com/1NDw2Jz.png)<!-- .element style="border:0;margin:-200px 0px" --> --- ## Installation * HassIO - distro linux home assistant (buildroot, docker, *resin?*) * Hassbian - basé sur raspbian * `pip3 install homeassistant` --- ## home-assistant architecture ![](https://developers.home-assistant.io/img/en/architecture/home_automation_landscape.svg)<!-- .element style="border:0;background-color:white" --> --- ![](https://developers.home-assistant.io/img/en/architecture/ha_architecture.svg)<!-- .element style="border:0;background-color:white" --> --- ## home-assistant - show us the code ! ![](https://i.imgur.com/ZMNUeNR.png)<!-- .element style="border:0" --> [Source](https://developers.home-assistant.io/docs/en/entity_index.html) --- ## home-assistant : UI ![](https://developers.home-assistant.io/img/en/frontend/frontend-hero.png)<!-- .element style="border:0" --> ![](https://developers.home-assistant.io/img/en/frontend/frontend-cards1.png)<!-- .element style="border:0" --> --- ## Démo ? --- ## bonus : hass.io avec resin * [architecture hassio](https://developers.home-assistant.io/docs/en/architecture_hassio.html) * [resino.io](https://resinos.io/) * [balena.io](https://www.balena.io/) * [resin-pycon-ota -pour micropython](https://github.com/Bucknalla/resin-pycom-ota) * [resin pour microbit](https://github.com/resin-io-playground/micro-bit) --- ## graphite-carbon & graphite-api * recevoir et stocker les données avec [graphite-carbon](https://packages.debian.org/stretch/graphite-carbon) * servir les données avec [graphite-api](https://graphite-api.readthedocs.io/en/latest/) * version optimisée de graphite (sans django) --- ## node-red * https://nodered.org/ - javascript ! * mais [node-red-contrib-python3-function](https://flows.nodered.org/node/node-red-contrib-python3-function) --- ## node-red - exemple ![](https://i.imgur.com/8RPiCsj.png)<!-- .element style="border:0" --> --- ## MQTT MQTT (Message Queuing Telemetry Transport) est un protocole de messagerie publish-subscribe basé sur le protocole TCP/IP. * [hbmqtt](https://github.com/beerfactory/hbmqtt) (asyncio!) * [mosquitto](https://mosquitto.org/) * https://pypi.org/search/?q=mqtt * home-assistant : Switch, Discovery, Sensor, etc. --- ## Fin * Merci de votre attention * D'autres retours d'experiences ? * [Aidez-moi à catégoriser les composants](https://github.com/home-assistant/home-assistant.io/issues/6402) * **Have fun** * Questions ?