Skip to content

Instantly share code, notes, and snippets.

@MilanPala
Created September 4, 2024 22:03
Show Gist options
  • Save MilanPala/3ec6f73e2e20dd3847e5f0c08cb64557 to your computer and use it in GitHub Desktop.
Save MilanPala/3ec6f73e2e20dd3847e5f0c08cb64557 to your computer and use it in GitHub Desktop.
Lilygo SIM800L esphome
esphome:
name: esp-gsm
friendly_name: esp-gsm
esp32:
board: esp32dev
framework:
type: arduino
uart:
baud_rate: 9600
tx_pin: TX
rx_pin: RX
logger:
baud_rate: 0
# Enable Home Assistant API
api:
encryption:
key: "..."
actions:
- action: send_sms
variables:
recipient: string
message: string
then:
- sim800l.send_sms:
recipient: !lambda 'return recipient;'
message: !lambda 'return message;'
- action: dial
variables:
recipient: string
then:
- sim800l.dial:
recipient: !lambda 'return recipient;'
- action: connect
then:
- sim800l.connect
- action: disconnect
then:
- sim800l.disconnect
- action: send_ussd
variables:
ussdCode: string
then:
- sim800l.send_ussd:
ussd: !lambda 'return ussdCode;'
ota:
- platform: esphome
password: "..."
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp-Gsm Fallback Hotspot"
password: "rPUmGQdlUuwA"
captive_portal:
light:
- platform: status_led
name: "LED status"
pin: GPIO13
id: led
sensor:
- platform: sim800l
rssi:
name: "Sim800L RSSI"
binary_sensor:
- platform: sim800l
registered:
name: "Sim800L Registered"
text_sensor:
- platform: template
id: caller_id_text_sensor
name: "Caller ID"
- platform: template
id: ussd_message
name: "USSD Code"
sim800l:
on_incoming_call:
- logger.log:
format: "Incoming call from '%s'"
args: ["caller_id.c_str()"]
- lambda: |-
id(caller_id_text_sensor).publish_state(caller_id);
id(led).turn_on();
- sim800l.disconnect
- homeassistant.event:
event: esphome.incoming_call_event
data:
payload: !lambda 'return id(caller_id_text_sensor).state;'
on_ussd_received:
- lambda: |-
id(ussd_message).publish_state(ussd);
switch:
- platform: gpio
name: "SIM800_PWKEY"
pin: 4
restore_mode: ALWAYS_OFF
- platform: gpio
name: "SIM800_POWER"
pin: 23
restore_mode: ALWAYS_ON
- platform: gpio
name: "SIM800_RST"
pin: 5
restore_mode: ALWAYS_ON
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment