# Faire de la domotique libriste avec Python
### PyConFR 2018
<!-- .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
* [<!-- .element style="border:0;margin:0" --> @arthurlutzim](https://twitter.com/arthurlutzim)
* <!-- .element style="border:0;margin:0" --> [@arthurlutzim@mamot.fr ](https://mamot.fr/@arthurlutzim)
* mais aussi chez [Logilab](https://www.logilab.fr)
<!-- .element style="border:0;margin:0;border-radius:125px" -->
---
## home-assistant.io
<!-- .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
<!-- .element style="border:0" -->
[Source](https://www.thingiverse.com/thing:2316706)
---
## Matériel input

* DHT11/DHT22 pour la temperature / humidité
* sondes de distance
* sondes audio, luminosité
---
## Matériel action
* [LPD433 (433Mhz)](https://fr.wikipedia.org/wiki/LPD433)
<!-- .element style="border:0" -->
---
## Matériel action

---
[<!-- .element style="border:0;margin:-120px 0px" -->](https://www.home-assistant.io/components/#featured)
---
## Composants que j'ai testé
<!-- .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
<!-- .element style="border:0;background-color:white" -->
---
<!-- .element style="border:0;background-color:white" -->
---
## home-assistant - show us the code !
<!-- .element style="border:0" -->
[Source](https://developers.home-assistant.io/docs/en/entity_index.html)
---
## home-assistant : UI
<!-- .element style="border:0" -->
<!-- .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
<!-- .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 ?
{"metaMigratedAt":"2023-06-14T18:16:58.743Z","metaMigratedFrom":"Content","title":"Faire de la domotique libriste avec Python","breaks":true,"contributors":"[{\"id\":\"55cbf5d3-7aa6-4ba4-a19e-baf2c016a512\",\"add\":6826,\"del\":1215}]"}