glmnet / esphome_devices

54 stars 17 forks source link

SIM800L, on sms received trigger not working #3

Closed satekp closed 2 years ago

satekp commented 3 years ago

Hi I am trying to use sim800l esphome component to automate my gate . Esphome config and logs as follows . Sms send action is working well, but onsms received trigger not working as expected, though the log (verbose dot debug) shows the incoming SMS text and the sender number every time i send SMS. please see my esphome config ,logs and advice..

ESPHOME config

Enable logging

logger: level: VERBOSE

Enable Home Assistant API

api: password: "xxxxx123" services:

uart: baud_rate: 9600 tx_pin: 17 rx_pin: 16

sim800l: on_sms_received:

LOGS on receiving SMS

[12:57:51][D][sim800l:129]: RSSI: 15 [12:57:51][V][sim800l:048]: R: - 11 [12:57:51][V][sim800l:048]: R: OK - 11 [12:57:51][V][sim800l:041]: S: AT+CMGL="ALL" - 11 [12:57:51][V][sim800l:048]: R: - 12 [12:57:51][V][sim800l:048]: R: OK - 12 [12:57:52][V][sim800l:048]: R: - 13 [12:57:52][V][sim800l:048]: R: +CMT: "+xxxxxxx773","","20/10/31,18:27:49+22" - 13 [12:57:52][V][sim800l:048]: R: Hello open - 13

LOG on sending SMS from sim800L

[13:00:51][V][sim800l:048]: R: OK - 12 [13:01:00][D][switch:021]: 'OUT_LT2' Turning ON. [13:01:00][D][switch:045]: 'OUT_LT2': Sending state ON [13:01:00][D][sim800l:252]: Sending to +xxxxxxxx73: Hello there [13:01:01][V][sim800l:041]: S: AT+CSCS="GSM" - 1 [13:01:01][V][sim800l:048]: R: - 8 [13:01:01][V][sim800l:048]: R: OK - 8 [13:01:01][V][sim800l:041]: S: AT+CMGS="+xxxxxxxxx773" - 8 [13:01:01][V][sim800l:048]: R: - 9 [13:01:01][V][sim800l:048]: R: > - 9 [13:01:01][D][sim800l:196]: Sending message: 'Hello there' [13:01:04][V][sim800l:048]: R: - 10 [13:01:04][V][sim800l:048]: R: +CMGS: 57 - 10 [13:01:04][D][sim800l:209]: SMS Sent OK: +CMGS: 57 [13:01:04][V][sim800l:048]: R: - 11 [13:01:04][V][sim800l:048]: R: OK - 11

glmnet commented 3 years ago

May be te state is not updated properly there.

Try moving the if condition into the on_value trigger of the text sensor

Another option will be using a lambda using the passed in args

satekp commented 3 years ago

Tried Your suggestions. giving compiling errors. Is any thing wrong in sim800l.h that prevent parsing the SMS received text data....?

glmnet commented 3 years ago

Paste your code and errors

satekp commented 3 years ago

Compiling /data/test2/.pioenvs/test2/src/main.cpp.o src/main.cpp: In lambda function: src/main.cpp:325:7: error: could not convert '{received_sms_body}' from '' to 'esphome::optional<std::__cxx11::basic_string >' }; ^ *** [/data/test2/.pioenvs/test2/src/main.cpp.o] Error 1 ========================= [FAILED] Took 22.04 seconds =========================

satekp commented 3 years ago

Since text sensor value is not updating how can we use "on_value" trigger .?

glmnet commented 3 years ago

I'm sorry I'm too busy to help you. This is most likely not an issue with sim800l

Please join ESPHome discord chat (look for link ESPHome GitHub page) there are some great guys which will help you out and get it running in no time.