New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SMS Sender / Receiver #522
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks quite good to me now!
Want to add an SMS send action too? It would be pretty simple
template<typename... Ts>
class Sim800LSendAction : public Action<Ts...> {
public:
TEMPLATABLE_VALUE(std::string, recipient)
TEMPLATABLE_VALUE(std::string, message)
void play(Ts... x) {
auto recipient = this->recipient_.value(x...);
auto message = this->message_.value(x...);
this->parent_->send_sms(recipient, message);
}
};
And python side would also be simple (see usages of automation.register_action
).
}), | ||
}).extend(cv.polling_component_schema('5s')) | ||
.extend(uart.UART_DEVICE_SCHEMA) | ||
.extend(cv.COMPONENT_SCHEMA)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This extend is not necessary (polling_component_schema already extends COMPONENT_SCHEMA)
Thanks I'll do. |
binary_sensor:
platform: gpio
name: "Send sms"
pin: D8
on_press:
- sim800l.send_sms:
id: sms
recipient: "+5493624207774"
message: Hello from ESPHome yaml :P |
def sim800l_send_sms_to_code(config, action_id, template_arg, args): | ||
paren = yield cg.get_variable(config[CONF_ID]) | ||
var = cg.new_Pvariable(action_id, template_arg, paren) | ||
template_ = yield cg.templatable(config[CONF_RECIPIENT], args, str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template_ = yield cg.templatable(config[CONF_RECIPIENT], args, str) | |
template_ = yield cg.templatable(config[CONF_RECIPIENT], args, cg.std_string) |
I don't think str
will work (at least it should throw a ValueError because there are several string types and we don't know which one should be used: std::string
, const char *
, String
etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did work, the sample yaml in the previous message. I'll change it anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Yes the example does work - however it will fail for templated !lambda
values.
You can add as many commits as you want. Github automatically squashes it when I click merge ("Squash and merge") |
By the way, my change of uart serial buffer size slipped in some commits ago. # Example configuration entry
uart:
tx_pin: D0
rx_pin: D1
baud_rate: 9600
software_buffer_size: 512 # optional, default 64 |
That's fine I think - I haven't really seen instances of people hitting the memory limit yet. We can always change it back if needed. For this PR: I'd like to cut the 1.13 release soon - do you think this PR is ready in the current state? SMS support would be an awesome feature to have. I can also manually cherry-pick it into the beta branch later too - and since beta period will probably be a bit longer this time you don't have to hurry that much. |
This code works, It still needs some debugging as as soon a SMS is received it cannot parse it, it retries due to the constant polling and then it parses properly, so I'm still working on that. I plan to finish debugging this week and also get the docs done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
looks like your git branch has a wrong merge on it - see the files tab, files that are not part of this PR are showing up.
Please see the instructions in the contributing guide for the correct merging/rebasing.
|
||
|
||
SIM800L_SENS_SMS_SCHEMA = cv.Schema({ | ||
cv.Required(CONF_ID): cv.use_id(Sim800LComponent), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cv.Required(CONF_ID): cv.use_id(Sim800LComponent), | |
cv.GenerateID(): cv.use_id(Sim800LComponent), |
This way the user doesn't need to type it and the first one in the config is automatically chosen.
|
||
SIM800L_SENS_SMS_SCHEMA = cv.Schema({ | ||
cv.Required(CONF_ID): cv.use_id(Sim800LComponent), | ||
cv.Required(CONF_RECIPIENT): cv.templatable(cv.string), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cv.Required(CONF_RECIPIENT): cv.templatable(cv.string), | |
cv.Required(CONF_RECIPIENT): cv.templatable(cv.string_strict), |
3ebf118
to
f906b50
Compare
Ok I guess I applied all request here and in the docs. I had to force push them. |
Description:
This is the Sim800L Component.
so far it can receive and send sms.
It does not work with software serial due to the buffer is only 64 bytes.
test yaml:
@OttoWinter about Software Serial, do you think I could add an optional
software_buffer_size
so the 64 can be overridden in yaml? I'm pretty sure the ESP8266 can allocate more memory for this and still run reliable.Related issue (if applicable):
esphome/feature-requests#166
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: