Skip to content

Instantly share code, notes, and snippets.

@cpyarger
Created April 22, 2022 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpyarger/0d221da7a208180b3a3d3ac78609c34c to your computer and use it in GitHub Desktop.
Save cpyarger/0d221da7a208180b3a3d3ac78609c34c to your computer and use it in GitHub Desktop.
esphome/HA device tracker
esphome:
name: esphome-web-74a0bc
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
level: VERY_VERBOSE
logs:
homeassistant: VERY_VERBOSE
# Enable Home Assistant API
api:
ota:
globals:
- id: lat
type: float
initial_value: "51.513835"
- id: lon
type: float
initial_value: "-0.100539"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-74A0Bc"
password: "unTnQkznz1Yu"
captive_portal:
web_server:
port: 80
text_sensor:
- platform: template
name: "Template Text Sensor"
id: my_sensor
lambda: |-
return { to_string(id(lat)) + " , " + to_string(id(lon)) };
on_value:
- lambda: |-
id(lon) += 0.1;
id(lat) += 0.01;
- homeassistant.service:
service: device_tracker.see
data:
dev_id: 'device_tracker.test_tracker5'
data_template:
gps: '[ {{ myvar }} ]'
variables:
myvar: |-
return id(my_sensor).state;
- logger.log: "update value"
update_interval: 10s
switch:
- platform: restart
name: "restart"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment