esphome:
name: nfc
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
http_request:
useragent: esphome/device
timeout: 10s
web_server:
port: 80
auth:
username: admin
password: admin
# Enable Home Assistant API
api:
ota:
password: "c26e8dacc00237c50d170ffb3f24e120"
wifi:
ssid: Mi wifi
password: behnam123
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Nfc Fallback Hotspot"
password: "Br9hto7sU50G"
captive_portal:
# Example configuration entry
uart:
baud_rate: 9600
tx_pin: 22
rx_pin: 21
spi:
clk_pin: 18
mosi_pin: 19
miso_pin: 23
output:
- platform: ledc
pin:
number: 16
inverted: true
id: rtttl_out
rtttl:
output: rtttl_out
sim800l:
on_sms_received:
- logger.log:
format: "Received '%s' from %s"
args: [ 'message.c_str()', 'sender.c_str()' ]
sensor:
- platform: sim800l
rssi:
name: "Sim800L RSSI"
pn532_spi:
cs_pin: 5
update_interval: 1s
id: pn532_board
on_tag:
then:
- rtttl.play: 'two short:d=4,o=5,b=100:16e6,16e6'
- delay: 5s
- sim800l.send_sms:
recipient: !lambda |-
if (id(behnam).state) return "+8912639743";
if (id(mohamad).state) return "+8914993564";
if (id(farzane).state) return "+8914993564";
else return "+912639743";
message: !lambda |-
if (id(behnam).state) return "behnam galdi";
if (id(mohamad).state) return "mohamad galdi";
if (id(farzane).state) return "farzane galdi";
else return "Hey new nfc card ";
- delay: 5s
- http_request.get:
url: !lambda |-
char data[400];
sprintf(data , "&UniqueID=%s" , id(template_text).state );
return ((std::string) "https://script.google.com/macros/s/AKfycbxDsmnLgRWukqZAfe4x959lqhwIpOoVeuetO4dNb93o2sdF58znUilqHk4Ht1/exec?" + data ).c_str();
headers:
Content-Type: application/json
verify_ssl: true
on_response:
then:
- logger.log:
format: 'Response status: %d'
args:
- status_code
text_sensor:
- platform: template
name: "template text sensor"
id: template_text
binary_sensor:
- platform: sim800l
registered:
name: "Sim800L Registered"
- platform: pn532
uid: 2A-69-D2-1E
name: "PN532 NFC Tag"
id: behnam
on_state:
- text_sensor.template.publish:
id: template_text
state: "behnam_fahimifar"
- platform: pn532
uid: 0C-7C-56-D9
name: "PN532 NFC Tag mohamad"
id: mohamad
on_state:
- text_sensor.template.publish:
id: template_text
state: "mohamad_fahimifar"
- platform: pn532
uid: BE-CB-12-5B
name: "PN532 NFC Tag farzane"
id: farzane
on_state:
- text_sensor.template.publish:
id: template_text
state: "farzaneh_fahimifar"
not sending correctly.
http_request:088]: HTTP Request failed; URL: https://script.google.com/macros/s/XXXLongSecretXXX/exec?UniqueID=\xf0\xe3\xfc?; Code: 400
Logs please,
thanks you for reply . this problem resolved with add ".c_str()" to end of "id(template_text).state".