init upload
This commit is contained in:
103
standard/diagnostics.yaml
Normal file
103
standard/diagnostics.yaml
Normal file
@@ -0,0 +1,103 @@
|
||||
# NOTE: This file is not a stand-alone package. It is part of
|
||||
# a 'root' device template and expects the substitutions that
|
||||
# are hereby referenced to be defined by its parent.
|
||||
|
||||
substitutions:
|
||||
log_level: INFO
|
||||
timezone: "America/Mexico_City"
|
||||
|
||||
# Enable logging via network and disable serial port
|
||||
logger:
|
||||
level: "${log_level}"
|
||||
baud_rate: 0
|
||||
|
||||
# Provide date and time
|
||||
time:
|
||||
- platform: sntp
|
||||
id: time_service
|
||||
timezone: ${timezone}
|
||||
update_interval: 15min
|
||||
servers:
|
||||
- 0.pool.ntp.org
|
||||
- 1.pool.ntp.org
|
||||
- 2.pool.ntp.org
|
||||
|
||||
# Diagnostic output sensors
|
||||
text_sensor:
|
||||
|
||||
- platform: wifi_info
|
||||
ip_address:
|
||||
id: ip_address
|
||||
name: "IP Address"
|
||||
icon: "mdi:wan"
|
||||
|
||||
- platform: template
|
||||
name: "Uptime"
|
||||
id: uptime_human
|
||||
icon: "mdi:timer-check-outline"
|
||||
update_interval: 60s
|
||||
entity_category: "diagnostic"
|
||||
disabled_by_default: true
|
||||
|
||||
binary_sensor:
|
||||
# Diagnostic sensor for connection
|
||||
- platform: status
|
||||
icon: 'mdi:home-assistant'
|
||||
name: "API Status"
|
||||
id: sensor_status
|
||||
disabled_by_default: true
|
||||
|
||||
sensor:
|
||||
# Device Memory
|
||||
- platform: template
|
||||
id: esp_memory
|
||||
icon: mdi:memory
|
||||
name: Free Memory
|
||||
lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024;
|
||||
unit_of_measurement: "kB"
|
||||
state_class: measurement
|
||||
entity_category: "diagnostic"
|
||||
disabled_by_default: true
|
||||
|
||||
# Captures the uptime and updates the human-readable
|
||||
# text sensor displayed. This is an internal sensor only.
|
||||
- platform: uptime
|
||||
name: "Uptime"
|
||||
id: sensor_uptime
|
||||
update_interval: 60s
|
||||
entity_category: "diagnostic"
|
||||
internal: true
|
||||
on_raw_value:
|
||||
then:
|
||||
- text_sensor.template.publish:
|
||||
id: uptime_human
|
||||
state: !lambda |-
|
||||
int seconds = round(id(sensor_uptime).raw_state);
|
||||
int days = seconds / (24 * 3600);
|
||||
seconds = seconds % (24 * 3600);
|
||||
int hours = seconds / 3600;
|
||||
seconds = seconds % 3600;
|
||||
int minutes = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
return (
|
||||
(days ? String(days) + "d " : "") +
|
||||
(hours ? String(hours) + "h " : "") +
|
||||
(minutes ? String(minutes) + "m " : "") +
|
||||
(String(seconds) + "s")
|
||||
).c_str();
|
||||
|
||||
# Provide a pre-built button for restarting the device
|
||||
button:
|
||||
- platform: restart
|
||||
name: "Reboot Device"
|
||||
id: button_restart
|
||||
icon: mdi:power-cycle
|
||||
entity_category: "diagnostic"
|
||||
|
||||
# Provide a button to reset all defined flash settings.
|
||||
- platform: factory_reset
|
||||
disabled_by_default: false
|
||||
name: "Load Factory Settings"
|
||||
id: factory_reset_all
|
||||
icon: mdi:factory
|
||||
|
||||
9
standard/internaltemp.yaml
Normal file
9
standard/internaltemp.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
# NOTE: This file is not a stand-alone package. It is part of
|
||||
# a 'root' device template and expects the substitutions that
|
||||
# are hereby referenced to be defined by its parent.
|
||||
|
||||
sensor:
|
||||
- platform: internal_temperature
|
||||
name: "Internal Temperature"
|
||||
disabled_by_default: true
|
||||
icon: mdi:heat-wave
|
||||
53
standard/project.yaml
Normal file
53
standard/project.yaml
Normal file
@@ -0,0 +1,53 @@
|
||||
# NOTE: This file is not a stand-alone package. It is part of
|
||||
# a 'root' device template and expects the substitutions that
|
||||
# are hereby referenced to be defined by its parent.
|
||||
|
||||
substitutions:
|
||||
# Generated name and unique device id for the device
|
||||
# Not intended for user substitutions
|
||||
device_name: "${device_location_name} - ${device_type_name} - ${device_number}"
|
||||
device_code: "${device_site}-${device_location_code}-${device_type_code}-${device_number}"
|
||||
|
||||
# Define a global variable for CPU speed
|
||||
globals:
|
||||
- id: cpu_speed
|
||||
type: int
|
||||
restore_value: no
|
||||
initial_value: "0"
|
||||
|
||||
# Setup the integration and define some project variables
|
||||
esphome:
|
||||
name: "${device_code}"
|
||||
friendly_name: "${device_name}"
|
||||
comment: "${device_model} by ${device_make}"
|
||||
name_add_mac_suffix: false
|
||||
min_version: "2023.2.0"
|
||||
project:
|
||||
name: "${device_make}.${device_model}"
|
||||
version: "${package_version}"
|
||||
on_boot:
|
||||
- priority: 900.0
|
||||
then:
|
||||
- lambda: |-
|
||||
id(cpu_speed) = ESP.getCpuFreqMHz();
|
||||
|
||||
text_sensor:
|
||||
# Show firmware template version
|
||||
- platform: template
|
||||
name: "Deployment Version"
|
||||
lambda: return {"${package_version}"};
|
||||
disabled_by_default: true
|
||||
icon: "mdi:tag"
|
||||
entity_category: diagnostic
|
||||
|
||||
sensor:
|
||||
# Device CPU Frequency
|
||||
- platform: template
|
||||
name: "CPU Frequency"
|
||||
icon: "mdi:speedometer"
|
||||
accuracy_decimals: 0
|
||||
unit_of_measurement: Mhz
|
||||
disabled_by_default: true
|
||||
lambda: |-
|
||||
return (id(cpu_speed));
|
||||
entity_category: diagnostic
|
||||
50
standard/wifi.yaml
Normal file
50
standard/wifi.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
# NOTE: This file is not a stand-alone package. It is part of
|
||||
# a 'root' device template and expects the substitutions that
|
||||
# are hereby referenced to be defined by its parent.
|
||||
|
||||
substitutions:
|
||||
# WiFi Substitutions
|
||||
api_key: !secret api_key
|
||||
wifi_ssid: !secret wifi_ssid
|
||||
wifi_password: !secret wifi_password
|
||||
ota_password: !secret ota_password
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
# Disable reboot if no client connected (defaults to 15min)
|
||||
reboot_timeout: 0s
|
||||
encryption:
|
||||
key: "${api_key}"
|
||||
|
||||
sensor:
|
||||
- platform: wifi_signal
|
||||
name: "RSSI"
|
||||
id: sensor_rssi
|
||||
icon: 'mdi:signal'
|
||||
update_interval: 60s
|
||||
entity_category: "diagnostic"
|
||||
|
||||
# Enable OTA
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: "${ota_password}"
|
||||
|
||||
# Enable Safe Mode
|
||||
safe_mode:
|
||||
|
||||
# Enable WiFi and AP for captive portal
|
||||
wifi:
|
||||
fast_connect: false
|
||||
power_save_mode: light
|
||||
ssid: "${wifi_ssid}"
|
||||
password: "${wifi_password}"
|
||||
use_address: "${device_ip}"
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
# password for hostspot is the same as password for net AP (needs captive_portal)
|
||||
ap:
|
||||
ssid: "${device_code}-setup"
|
||||
password: "${wifi_password}"
|
||||
ap_timeout: 5min
|
||||
|
||||
captive_portal:
|
||||
Reference in New Issue
Block a user