diff --git a/fingerprintdoor.yaml b/fingerprintdoor.yaml index 0ec8e0d..930beb0 100644 --- a/fingerprintdoor.yaml +++ b/fingerprintdoor.yaml @@ -56,129 +56,118 @@ mqtt: on_json_message: topic: $devicename/led/command then: - - if: - condition: - not: - # todo check json length - text_sensor.state: - id: fingerprint_state - state: "cancelling enrollment" - then: - # default values speed count - - text_sensor.template.publish: - id: mqtt_json - state: !lambda |- - std::string color = x["color"]; - std::string effect = x["effect"]; - std::string speed = x["speed"]; - std::string count = x["count"]; + # Debug + - lambda: |- + const char * c = x["color"]; + const char * e = x["effect"]; + const char * s = x["speed"]; + const char * cnt = x["count"]; - return "Color:" + color + " Effekt:" + effect + " Speed:" + speed + " Count:" + count; + ESP_LOGD("main", "Cmd: Color:%s | Effect: %s | Speed:%s | Count:%s", c,e,s,cnt); + - fingerprint_grow.aura_led_control: + state: !lambda |- + std::string str = x["effect"]; + std::transform(str.begin(), str.end(), str.begin(), ::toupper); - - fingerprint_grow.aura_led_control: - state: !lambda |- - std::string str = x["effect"]; - std::transform(str.begin(), str.end(), str.begin(), ::toupper); - - uint8_t eff = 0x03; - if(str == "BREATHING") - { - eff = 0x01; - return eff; - } - else if (str == "FLASHING"){ - eff = 0x02; - return eff; - } - else if (str == "ALWAYS_ON"){ - eff = 0x03; - return eff; - } - else if (str == "ALWAYS_OFF"){ - eff = 0x04; - return eff; - } - else if (str == "GRADUAL_ON"){ - eff = 0x05; - return eff; - } - else if (str == "GRADUAL_OFF"){ - eff = 0x06; - return eff; - } - return 0; - speed: !lambda return x["speed"]; - color: !lambda |- - std::string str = x["color"]; - std::transform(str.begin(), str.end(), str.begin(), ::toupper); - - uint8_t color = 0x01; - if(str == "RED") - { - color = 0x01; - return color; - } - else if (str == "BLUE"){ - color = 0x02; - return color; - } - else if (str == "PURPLE"){ - color = 0x03; - return color; - } - else if (str == "GREEN"){ - color = 0x04; - return color; - } - else if (str == "YELLOW"){ - color = 0x05; - return color; - } - else if (str == "CYAN"){ - color = 0x06; - return color; - } - else if (str == "WHITE"){ - color = 0x07; - return color; - } - return color; - count: !lambda return x["count"]; - - text_sensor.template.publish: - id: led_color - state: !lambda |- - std::string str = x["effect"]; - std::string color = x["color"]; - std::transform(str.begin(), str.end(), str.begin(), ::toupper); - if(str == "ALWAYS_OFF" || str == "GRADUAL_OFF") - { - return "off"; - } - else - { - return color; - } - # show on webserver - - text_sensor.template.publish: - id: led_state - state: !lambda |- - std::string str = x["effect"]; - std::transform(str.begin(), str.end(), str.begin(), ::toupper); - if(str == "ALWAYS_OFF" || str == "GRADUAL_OFF") - { - return "off"; - } - else - { - return "on"; - } - - mqtt.publish_json: - topic: $devicename/led/ - qos: 1 - #retain: true - payload: |- - root["led_state"] = id(led_state).state; - root["color"] = id(led_color).state; + uint8_t eff = 0x03; + if(str == "BREATHING") + { + eff = 0x01; + return eff; + } + else if (str == "FLASHING"){ + eff = 0x02; + return eff; + } + else if (str == "ALWAYS_ON"){ + eff = 0x03; + return eff; + } + else if (str == "ALWAYS_OFF"){ + eff = 0x04; + return eff; + } + else if (str == "GRADUAL_ON"){ + eff = 0x05; + return eff; + } + else if (str == "GRADUAL_OFF"){ + eff = 0x06; + return eff; + } + return 0; + speed: !lambda return x["speed"]; + color: !lambda |- + std::string str = x["color"]; + std::transform(str.begin(), str.end(), str.begin(), ::toupper); + + uint8_t color = 0x01; + if(str == "RED") + { + color = 0x01; + return color; + } + else if (str == "BLUE"){ + color = 0x02; + return color; + } + else if (str == "PURPLE"){ + color = 0x03; + return color; + } + else if (str == "GREEN"){ + color = 0x04; + return color; + } + else if (str == "YELLOW"){ + color = 0x05; + return color; + } + else if (str == "CYAN"){ + color = 0x06; + return color; + } + else if (str == "WHITE"){ + color = 0x07; + return color; + } + return color; + count: !lambda return x["count"]; + - text_sensor.template.publish: + id: led_color + state: !lambda |- + std::string str = x["effect"]; + std::string color = x["color"]; + std::transform(str.begin(), str.end(), str.begin(), ::toupper); + if(str == "ALWAYS_OFF" || str == "GRADUAL_OFF") + { + return "off"; + } + else + { + return color; + } + # show on webserver + - text_sensor.template.publish: + id: led_state + state: !lambda |- + std::string str = x["effect"]; + std::transform(str.begin(), str.end(), str.begin(), ::toupper); + if(str == "ALWAYS_OFF" || str == "GRADUAL_OFF") + { + return "off"; + } + else + { + return "on"; + } + - mqtt.publish_json: + topic: $devicename/led/ + qos: 1 + #retain: true + payload: |- + root["led_state"] = id(led_state).state; + root["color"] = id(led_color).state; # Fingerpint functions @@ -263,13 +252,9 @@ text_sensor: count: 6 - platform: template - name: "Log Message" + name: "Fingerprint Log" id: fingerprint_state - - platform: template - name: "MQTT Message" - id: mqtt_json - - platform: template name: "LED color" id: led_color @@ -301,8 +286,8 @@ binary_sensor: filters: - invert: - delayed_on: 20ms - - delayed_off: 100ms - - delayed_on_off: 500ms + - delayed_off: 400ms + - delayed_on_off: 100ms # Door Sensor - GPIO connected to GND over reed sensor - platform: gpio