Ajout de l'arret automatique au bout d'une heure

This commit is contained in:
Julien Cabillot 2017-04-25 01:05:39 +02:00 committed by Cabillot Julien
parent 54341b836b
commit 022caef111
3 changed files with 33 additions and 17 deletions

View File

@ -9,6 +9,16 @@ Un exemple de configuration pour home-assistant se trouve dans [configuration.ya
Inspiré de ce site : http://ronmar.co/ha/2017/03/10/Ultimate-Alarm-Clock/ + https://community.home-assistant.io/t/creating-a-alarm-clock/410 Inspiré de ce site : http://ronmar.co/ha/2017/03/10/Ultimate-Alarm-Clock/ + https://community.home-assistant.io/t/creating-a-alarm-clock/410
Avancement
==========
WIP.
Le partie arduino fonctionne.
La partie home-assistant fonctionne, le reveil configuré est bien envoyé à l'arduino.
TODO: gitlab-ci : on peut checker la syntax en lancant un docker home-assistant !!!
TODO: voir si c'est possible de changere la couleur de l'icone de la scene, avoir une icone bleue pour une couleur orange ...
TODO: tester en prod ^^
Matériel Matériel
======== ========
* 1x ESP8266 Lolin (Nodemcu v3) * 1x ESP8266 Lolin (Nodemcu v3)
@ -32,12 +42,7 @@ Médias
![Fritzing BreadBoard](medias/alarmclock_bb.png) ![Fritzing BreadBoard](medias/alarmclock_bb.png)
![IRL](medias/irl1.jpg) ![IRL](medias/irl1.jpg)
Avancement Astuce firewalld
========== ================
WIP.
Le partie arduino fonctionne, mais pour le moment il n'y a pas d'arret automatique de l'alarme. Pensez à la zone trusted ...
La partie home-assistant fonctionne, le reveil configuré est bien envoyé à l'arduino.
TODO: gitlab-ci : on peut checker la syntax en lancant un docker home-assistant !!!
TODO: HA Il faut des scenes pour retrouver les couleurs classiques
TODO: Ard pas d'arret une fois le reveil lancé
TODO: voir si c'est possible de changere la couleur de l'icone de la scene, avoir une icone bleue pour une couleur orange ...

View File

@ -157,9 +157,10 @@ void callbackMQTT(char* topic, byte* payload, unsigned int length)
if (stopic == MQTT_LED_COMMAND) { if (stopic == MQTT_LED_COMMAND) {
if (msgString == "ON") { if (msgString == "ON") {
ledState = true; ledState = true;
curbrightness = LED_BRIGHTNESS_DEFAULT;
startTime = millis();
} else { } else {
ledState = false; ledState = false;
curbrightness = LED_BRIGHTNESS_DEFAULT;
ledBlackAll(); ledBlackAll();
} }
mqttSendState(); mqttSendState();
@ -281,15 +282,22 @@ void loop() {
client.loop(); client.loop();
// LED // LED
if (!ledState) {
FastLED.delay(1000);
} else {
if (startTime + LED_DURATION <= millis()) {
Debug.println("END");
ledState = false;
ledBlackAll();
mqttSendState();
} else {
EVERY_N_SECONDS(10) { EVERY_N_SECONDS(10) {
if (curbrightness <= maxBrightness) { if (curbrightness <= maxBrightness) {
curbrightness++; curbrightness++;
} }
} }
if (!ledState) {
FastLED.delay(1000);
} else {
ledDisplay(); ledDisplay();
} }
} }
}

View File

@ -17,6 +17,8 @@ RemoteDebug Debug;
#define LED_MAXBRIGHTNESS_DEFAULT 80 #define LED_MAXBRIGHTNESS_DEFAULT 80
#define LED_BRIGHTNESS_DEFAULT 6 #define LED_BRIGHTNESS_DEFAULT 6
#define LED_COLOR_DEFAULT CRGB::Red #define LED_COLOR_DEFAULT CRGB::Red
// 1000 * 60 * 60 = 1h
#define LED_DURATION 3600000
// Corresponds à un max brightness configurable via HA // Corresponds à un max brightness configurable via HA
int maxBrightness; int maxBrightness;
@ -25,6 +27,7 @@ int curbrightness;
int color; int color;
CRGB leds[LED_NUM]; CRGB leds[LED_NUM];
boolean ledState; boolean ledState;
unsigned long startTime;
// WIFI // WIFI
#define WIFI_SSID "XXX" #define WIFI_SSID "XXX"