SendGrid Smart-Home-Integration, kostenlos und Open Source

Unofficial: e-mails from your scenes sent through your SendGrid account.
Die Dokumentation dieser Integration wird von ihrem Autor geschrieben und ist bisher nur auf Englisch verfĂŒgbar.
Unofficial integration, not affiliated with Twilio SendGrid. It sends e-mails from your scenes through your SendGrid account with the Mail Send API v3; it never reads any. This integration has never been tested with a real SendGrid account: it was built from the official SendGrid documentation and tested against local fake servers. Reports are welcome.
What leaves, and whenâ
An e-mail leaves only on one of these two paths:
- The âSend an e-mail with SendGridâ scene action: one plain-text e-mail, with an optional subject (the
default subject otherwise), to the recipients of the configuration: all of them when the
âRecipientâ field is empty, or the one it names. An address that is not in the list is refused and
nothing leaves: a scene cannot write to anyone else. Each recipient receives the e-mail alone (nobody
sees the others). Its output
message_idis the SendGrid id of the e-mail (X-Message-Id). - The Test button, in SendGrid sandbox mode, to the first recipient: SendGrid checks the key and the test message and delivers nothing. Whether SendGrid also checks the sender in sandbox mode is not confirmed: the first real e-mail tells. The button calls SendGrid at each click, outside the daily limit (bounded by the 2 requests at once and the pause). If SendGrid ignored the sandbox flag, the test e-mail would really be delivered (not checked on a real account yet).
Nothing is sent at start-up, on a schedule, on a reconnection or when the configuration is saved. The Gladys messages (âSend a messageâ action, system messages) are not relayed: this integration only serves scenes.
Setting upâ
- In SendGrid, Settings â API Keys â Create API Key, choose Restricted Access and give Mail Send
only (full access works too, but is not needed). Copy the key (it starts with
SG.; SendGrid shows it once). - Settings â Sender Authentication: verify the sender address (Single Sender Verification) or authenticate its domain. Without it, SendGrid refuses every e-mail (ânot the sender addressâ).
- In Gladys, fill in the key, the data region (EU only for an account or subuser created in the SendGrid EU region), the sender address, optionally the sender name, the recipients (1 to 10 addresses separated by commas), the default subject and the daily limit; save, then click Test.
The API key is kept by Gladys in its database, never shown again, and sent only to SendGrid.
What protects your account and your planâ
- Fixed recipients and sender: only the administrator chooses them, in the configuration.
- Daily limit (20 by default, 1 to 500): at most this many e-mails over any 24 hours, one per
recipient (an e-mail to 3 recipients counts 3). Beyond it nothing is sent (an e-mail that does not fit
for all its recipients is refused whole) and the action fails with the time of the next possible e-mail.
The count is kept in
/dataacross restarts. An e-mail is counted before it leaves. It is given back only when nothing left: SendGrid answered 400, 401, 403, 413 or 429, or the connection never opened (connection refused, unknown name, network unreachable). No answer, a cut connection, a 5xx or any other 4xx (408, 418, a company relay's 499...) keep it counted: it may have left. - /data not safe: while
/datais not read yet, unreadable, too slow (more than 1 second) or a write fails, the count could not survive a restart. Then only 2 e-mails per rolling 24 hours leave (counted in memory, one per recipient); the next is refused (â/data is unread, unreadable or cannot be writtenâŠâ) and the status says so. A/datathat does not exist yet (first start) is normal: the daily limit applies. Once/dataworks again, the normal limit applies again. - Never sent twice: SendGrid accepts an e-mail with a
202 Accepted; the integration never sends an e-mail again, whatever happened (no answer, a cut connection, a server error). When SendGrid did not confirm, the action fails with âit may have been sent, so it is not sent againâ. - Texts bounded: subject on one line (line breaks removed), 200 characters at most; text 10,000 characters at most; plain text only, click and open tracking turned off.
- At most 2 e-mails at once, 10 waiting; beyond, or when the wait would leave too little time, âtoo many e-mails at onceâ and nothing is sent. An e-mail waiting while the key, the region or the sender changes, or whose recipient is removed from the list, is not sent.
- Slow down: after a 429 (too many requests) or a SendGrid server error (5xx, even with an unreadable
body), nothing is sent for 60 seconds, doubled at each new failure up to 1 hour (a
Retry-AfterorX-RateLimit-Resetof SendGrid is followed up to 6 hours), Test included. The pause is kept in/data; an e-mail accepted while it began does not lift it. - Refused key: only a 401 carrying SendGrid's own error body. Then nothing more is sent with this key
until the key or the region changes or the Test button succeeds (the Test button tries a refused key too,
outside a pause). Only two 8-bit prints of a salted HMAC are kept in
/data, never the key; a new key entered while the integration runs is tried even if its prints happen to match (a key entered while it was stopped is blocked by such a match, 1 chance in 65,536: the Test button then lifts it). Not a refusal of the key: a 401 without SendGrid's body (empty, a proxy page, a cut answer), a 403 (sender not verified, key without the âMail Sendâ access), a refused e-mail (400, 413). A 401 without SendGrid's body and a 403 are not tried again at each e-mail either: they set the same pause as a 429 (60 seconds doubled up to 1 hour, kept in/data, Test included); nothing is kept about the key. Saving another key, region or sender address lifts such a pause at once (a 429 or 5xx pause stays).
Statusâ
| Status | Meaning |
|---|---|
| Ready | Settings filled in; the key is checked at the first e-mail or the Test button. |
| SendGrid accepted the last e-mail | With the count of the last 24 hours and the limit. |
| SendGrid accepted the key and the test message | The last Test succeeded (nothing delivered). |
| Refused key / sender not verified / paused / daily limit reached | Nothing is sent; the text says until when or what to change. |
| Daily counter not saved | /data is unread, read-only or slow: only 2 e-mails per 24 hours leave until it works. |
Privacyâ
The logs show addresses masked (j***@e***.com); the key, subjects and texts are never logged, put in the
status or written to /data, nor the texts of SendGrid's error answers (they may quote an address).
/data/sendgrid.json holds the times of the e-mails of the last 24 hours, the pause and the prints of a
refused key.
Limitsâ
- Plain text only; no attachment, no template, no HTML.
- E-mails are not received.
- The sending quotas of your SendGrid plan apply on top of the daily limit; every e-mail counts in your plan.
Konfigurationseinstellungenâ
Diese Einstellungen fragt SendGrid in seinem Konfigurationsbildschirm in Gladys ab.
| Einstellung | Typ | Pflichtfeld | Beschreibung |
|---|---|---|---|
| SendGrid in Gladys | section | Nein | Unofficial integration, not affiliated with Twilio SendGrid. It only sends e-mails, never reads any, through the âSend an e-mail with SendGridâ scene action, and only to the recipients listed below. In SendGrid, create an API key with the âMail Sendâ access only (Settings, API Keys, Restricted Access), verify the sender address (Single Sender Verification) or its domain, then click âTestâ: SendGrid checks the key and a test message in sandbox mode and delivers nothing. Every e-mail counts in your SendGrid plan; the daily limit below stops a runaway scene. |
| API key | secret | Ja | Starts with âSG.â; give it the âMail Sendâ access only. Kept by Gladys in its database, never shown again, sent only to SendGrid. |
| Data region | select | Nein | EU only for an account or subuser created in the SendGrid EU region (its key only works on the EU host). |
| Sender address | string | Ja | Must be verified in SendGrid (Single Sender Verification, or an authenticated domain), otherwise SendGrid refuses every e-mail. |
| Sender name | string | Nein | |
| Recipients | string | Ja | 1 to 10 addresses separated by commas. The scenes write only to these: to all of them, or to the one the action names. Each recipient receives the e-mail alone (no one sees the others) and counts as one e-mail. |
| Default subject | string | Nein | Used by the scene action when it gives no subject. |
| Daily limit of e-mails | number | Nein | At most this many e-mails in any 24 hours, one per recipient (Test excluded); beyond, nothing is sent and the action fails. Kept across restarts. |
So installierst du SendGrid in Gladysâ
- Ăffne in Gladys Integrationen: SendGrid erscheint im Katalog neben den nativen Integrationen, mit einem Community-Badge.
- Klicke auf Installieren. Gladys lÀdt das Docker-Image (
ghcr.io/lm1lc3n7/gladys-sendgrid:0.1.1) herunter, startet es in einer vom Kern isolierten Sandbox und erzeugt die OberflĂ€che der Integration (GerĂ€te, Erkennung und Konfiguration). - Ăffne den Bildschirm Konfiguration der Integration, fĂŒlle die Einstellungen aus und speichere.
- Du kannst sie auch direkt ĂŒber die URL ihres Repositorys installieren: https://github.com/LM1LC3N7/gladys-sendgrid.
SendGrid benötigt Gladys >=5.1.0. Der Katalog in Gladys wird stĂŒndlich aktualisiert, eine neue Version ist also spĂ€testens eine Stunde nach ihrer Veröffentlichung verfĂŒgbar.
Du nutzt Gladys noch nicht? Es ist kostenlos und Open Source: folge der Installationsanleitung, um loszulegen.
Ăber externe Integrationenâ
SendGrid ist eine externe Integration: eine Community-Integration, die als Docker-Container verpackt und auf GitHub veröffentlicht wird. Gladys installiert sie mit einem Klick und fĂŒhrt sie in einer vom Kern isolierten Sandbox aus. Sie wird von LM1LC3N7 veröffentlicht und gepflegt, nicht vom Gladys-Kernteam.
- Alle Integrationen durchsuchen, native und aus der Community
- Deine eigene externe Integration bauen und veröffentlichen
- Quellcode auf GitHub â Quelle dieser Dokumentation