crserran / home-alarm

Alexa & Google Home alarm integrations and notifications system for your home security.
https://crserran.github.io/home-alarm
MIT License
22 stars 6 forks source link

LED activation in safe mode does not work... #11

Closed Olive80 closed 3 years ago

Olive80 commented 3 years ago

Thank you for this very interesting project. Everything works fine except the LED which does not light up when the save-mode is activated. Does the led work with MQTT? I don't have an esphome / safe-mode topic as described in the configuration ... Can someone help me please?

crserran commented 3 years ago

Hi @Olive80,

Thank you for your question.

For having the esphome/safe-mode mqtt topic working I use an automation that publish a message to this topic each time I toggle the binary_sensor.safe_mode.

The automation is the following:

alias: Safe Mode publish MQTT state
description: ''
trigger:
  - entity_id: binary_sensor.safe_mode
    platform: state
condition: []
action:
  - data_template:
      payload: |
        {% if is_state("binary_sensor.safe_mode", "off") %}
          OFF
        {% elif is_state("binary_sensor.safe_mode", "on") %}
          ON
        {% endif %}
      topic: esphome/safe_mode
    service: mqtt.publish
mode: single

You can try it and let me know if this have solved your problem. I hope I helped you. Regards

Cristian.

Olive80 commented 3 years ago

@crserran Hi Cristian, Thank you for your quick reply. My led still does not work.... Is this automation mandatory because I don't see it mentioned anywhere on your website. I am not an expert with esp32, esphome and arduino cards. I have an esp32 DevkitC v4 card with the led connected to the gpio 5. Tell me if you need a screenshot to better understand my problem

crserran commented 3 years ago

Hi @Olive80

Regarding your first question:

Is this automation mandatory because I don't see it mentioned anywhere on your website.

This automation is needed to publish a message to the MQTT topic in order to wake up all the subscribers. In our case, the subscriber is the ESP32 and then it does the action to turn on/off the LED.

Regarding your ESP32 DevkitC device, if you have used another GPIO for connecting the LED, then you need to modify the rc522_sensor.h for using the GPIO 5 in your case.

Line 6 #define LED_PIN 5 // Configurable

If you haven't done it previously, you should have this line pointing to PIN 5 and then re-compile the ESP32.

Feel free to send me further information if this solution hasn't solved your issue :) Regards.

Cristian.

Olive80 commented 3 years ago

Hi @crserran I have already changed my led on the GPIO several times by modifying the rc522.h file but nothing has changed. My led is not burned out. I've been trying to solve my problem for several weeks before contacting you, I'm starting to despair ...

I will try to look by the MQTT side.

Question: Is it normal that I have duplicate RFID entities? (esphome and mqtt) rfid Is my automation good? automatisation_mqtt

Thank for your help

Oliver

crserran commented 3 years ago

Hi @Olive80

Sorry for the delay answering. Your automation seems OK.

Regarding the entities, I have the same entities than you in my config:

Captura de pantalla 2021-06-15 a las 16 23 32

I use the sensor.rfid_id_tiempo_real entity for configuring an automation that toggles the safe_mode entity like this:

alias: Identificación RFID
description: ''
trigger:
  - platform: template
    value_template: >-
      {{ is_state("sensor.rfid_id_tiempo_real", "XXXXXXX") or
      is_state("sensor.rfid_id_tiempo_real", "XXXXXXX") or
      is_state("sensor.rfid_id_tiempo_real", "XXXXXXX") or
      is_state("sensor.rfid_id_tiempo_real", "XXXXXXX") }}
condition: []
action:
  - data: {}
    entity_id: input_boolean.safe_mode
    service: input_boolean.toggle
mode: single

For having more information about your issue maybe you can try to modify the rc522_sensor.h and set a print on line 46 and 48 which is the method that receives the MQTT message and will be able to see it from the logs. If we see that the message is received correctly then the problem can be on the physical connections probably.

You can also send me the Config Logs in your configuration in order to see if there are Warnings or Error messages.

Regards.

Cristian.

Olive80 commented 3 years ago

Hi @crserran, I already use this automation because it is mentioned on your website.

If I listen to the esphome / safe_mode topic and activate the input_boolean.safe_mode, I receive a message.

What should I change on lines 46 and 48 of the rc522_sensor.h file?

Regards Oliver Capture

Olive80 commented 3 years ago

Here is the log of my manipulation. Is it normal that the playload is empty? InkedCapture2_LI

crserran commented 3 years ago

Hi @Olive80,

The payload shouldn't be empty. Here you have my traces:

Captura de pantalla 2021-06-16 a las 10 08 30

Logs:

Captura de pantalla 2021-06-16 a las 9 41 03

Can you send me the full yaml of your automation?

Regards, Cristian.

Olive80 commented 3 years ago

Hello @crserran,

We get closer ... :-)

InkedCapture_LI

1) I made a mistake on the entity. 2) I realized that I had no binary sensor. So I created one in my config file Like this:

template:
  - binary_sensor:
    - name: safe_mode
      state: >-
        {% if is_state('input_boolean.safe_mode', 'on') %}
          on
        {% else %}
          off
        {% endif %}   

Now I receive the messages playload on / off But the led still does not work ...

I will try the led on diffferent GPIO to see, but i dont know which one i can use. Any ideas ?

Best regards, Oliver

crserran commented 3 years ago

Good news!

For helping you better, do you have the schema of your ESP32? It would be helpful if you have a simple schema of the connections you have done between your device and the LED.

BR!

Cristian.

Olive80 commented 3 years ago

It's DONE.... WORKING I started on GPIO 5 for the led, then change to 34 but I didn't have the binary sensor.

From ESPHOME website about Genenic Esp32: GPIO34-GPIO39 can not be used as outputs (even though GPIO stands for “general purpose input output”…)

Back to GPIO 5 and work perfectly

I thank you very much for your patience and your help I'm really happy !!!

Best regards, Oliver

crserran commented 3 years ago

Very good news!!

Thank you @Olive80 for supporting this project.

I proceed to close this issue. If you have new concerns, please, open a new one and I'll be really happy to help you.

Regards,

Cristian.