-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://esphome.io/changelog/2023.2.0.html #25
base: main
Are you sure you want to change the base?
Conversation
Friendly Name ESPHome now supports setting a friendly_name which is sent to Home Assistant. This name will be used for the config entry, the device name, and will be automatically prefixed to all of the entities where needed by Home Assistant. Note If you opt to use this new friendly name, take note that you should remove any friendly name (substitition) that you currently prepend onto entity name in YAML. ```yaml esphome: name: living-room friendly_name: Living Room sensor: - platform: dht pin: GPIO5 name: Temperature ``` What would be the best way of handling this?
Removing the friendly_name from all the sensor names would be recommended. With this latest update, this sees all the entities in HA updated with the (new) friendly name in the esphome: section. Given this removing the friendly_name from each sensor name (i.e. name: "{friendly_name} Total Energy" ) sees the esp device webpage get " cleaned up" with just the sensor function (i.e. Total Energy etc) being shown, and in HA you still end up with 'Friendly_Name_Voltage'. BTW if you delete or leave the friendly_name substitution empty, the athom template (that has this substitution defined) will then populate over your enduser settings. Either this substitution needs to be totally remove (at substitution and sensor entries calling it) or else you can block the Athom definition by using: friendly_name: "" |
not working as expected for me. if i remove the substitutions on other entities, they are not managed properly. |
Probably a good idea to be a bit more descriptive, throw in an example etc. Here's the code currently to overwrite the athom yaml, to be compliant with the new updates: substitutions:
device_name: "gpo-clothes-dryer"
friendly_name: ""
device_description: "Measure the energy consumption of the clothes dryer"
set_timezone: "Australia/Sydney"
set_dns_domain: ".iot.home.lan"
relay_restore_mode: RESTORE_DEFAULT_ON
esphome:
name: "${device_name}"
friendly_name: "Clothes Dryer"
comment: '${device_description}'
name_add_mac_suffix: false As mentioned previously, until the subsitution friendly_name is removed, you have to keep it with "" to overwrite the athom package settings. When you say ' other entities' heres the code for a generic, DIY esp8266 that works with lastest HA updates: substitutions:
device_description: "Measure the household gas consumption, on Elster 750 meter"
project_name: "esphome.gas-meter"
project_version: "1.2"
set_timezone: "Australia/Sydney"
set_dns_domain: ".iot.home.lan"
disable_entities: "false"
esphome:
name: "gas-meter"
friendly_name: "Gas Meter"
comment: "${device_description}"
name_add_mac_suffix: false
project:
name: "${project_name}"
version: "${project_version}" |
If of interest, here's the modified template that I'm using, that is updated for the latest HA updates (and tried to keep device web interface entries in some order). substitutions:
device_name: "gpo-clothes-dryer"
alias_name: "Clothes Dryer"
device_description: "Measure the energy consumption of the clothes dryer"
set_timezone: "Australia/Sydney"
set_dns_domain: ".iot.home.lan"
project_name: "athom.smart-plug-v2"
project_version: "1.1 (Mod)"
relay_restore_mode: RESTORE_DEFAULT_ON
esphome:
name: "${device_name}"
friendly_name: "${alias_name}"
comment: '${device_description}'
name_add_mac_suffix: false
project:
name: "${project_name}"
version: "${project_version}"
esp8266:
board: esp8285
restore_from_flash: true
preferences:
flash_write_interval: 5min
api:
ota:
logger:
baud_rate: 0
mdns:
disabled: false
web_server:
port: 80
wifi:
# WiFi credentials
ssid: !secret wifi_ssid
password: !secret wifi_password
domain: "${set_dns_domain}"
fast_connect: true
ap: {} # This spawns an AP with the device name and mac address with no password.
captive_portal:
uart:
rx_pin: RXp
baud_rate: 4800
globals:
- id: total_energy
type: float
restore_value: yes
initial_value: '0.0'
binary_sensor:
- platform: status
name: "Device Status"
entity_category: diagnostic
- platform: gpio
pin:
number: 5
mode: INPUT_PULLUP
inverted: true
name: "Power Button"
disabled_by_default: true
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at least 0.2s
then:
- switch.toggle: relay
- timing:
- ON for at least 4s
then:
- button.press: Reset
sensor:
# WiFi signal strength
- platform: wifi_signal
name: "WiFi Strength"
update_interval: 120s
entity_category: diagnostic
internal: True
# Sensor uptime in seconds
- platform: uptime
name: "Uptime Seconds"
id: uptime_seconds
update_interval: 120s
entity_category: diagnostic
internal: True
- platform: cse7766
update_interval: 10s
current:
name: "Current"
filters:
- lambda: if (x < 0.060) return 0.0; else return x; #For the chip will report less than 3w power when no load is connected
voltage:
name: "Voltage"
power:
name: "Power"
id: power_sensor
filters:
- lambda: if (x < 3.0) return 0.0; else return x; #For the chip will report less than 3w power when no load is connected
energy:
name: "Energy"
id: energy
unit_of_measurement: kWh
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
on_value:
then:
- lambda: |-
static float previous_energy_value = 0.0;
float current_energy_value = id(energy).state;
id(total_energy) += current_energy_value - previous_energy_value;
previous_energy_value = current_energy_value;
- platform: total_daily_energy
name: "Energy Daily"
restore: true
power_id: power_sensor
unit_of_measurement: kWh
accuracy_decimals: 3
filters:
- multiply: 0.001
- platform: template
name: "Energy Total"
unit_of_measurement: kWh
device_class: "energy"
state_class: "total_increasing"
icon: "mdi:lightning-bolt"
accuracy_decimals: 3
lambda: |-
return id(total_energy);
update_interval: 10s
button:
- platform: restart
name: 'Restart Device'
entity_category: diagnostic
- platform: factory_reset
name: Reset with Default Settings
id: Reset
switch:
- platform: gpio
name: "${alias_name}"
pin: GPIO12
id: relay
restore_mode: ${relay_restore_mode}
light:
- platform: status_led
name: "Status LED"
id: blue_led
disabled_by_default: true
pin:
inverted: true
number: GPIO13
text_sensor:
# Creates a sensor showing when the device was last restarted
- platform: template
name: 'Device Last Restart'
id: device_last_restart
icon: mdi:clock
entity_category: diagnostic
# device_class: timestamp
# Creates sensor for tracking the WiFi IP address
- platform: wifi_info
ip_address:
name: 'WiFi IP Address'
icon: mdi:wifi
entity_category: diagnostic
# Defines the WiFi SSID network to connect to
ssid:
name: 'WiFi SSID'
icon: mdi:wifi-strength-2
entity_category: diagnostic
# Creates sensor for tracking the WiFi IP MAC address
mac_address:
name: 'WiFi MAC Address'
entity_category: diagnostic
# Creates a sensor of the name of installed project
- platform: template
name: 'Project Name'
id: gas_meter_project
icon: "mdi:label-outline"
entity_category: diagnostic
lambda: |-
return {"${project_name}"};
update_interval: 6h
# Creates a sensor of the version of installed project
- platform: template
name: 'Project Version'
id: gas_meter_version
icon: "mdi:label-outline"
entity_category: diagnostic
lambda: |-
return {"${project_version}"};
update_interval: 6h
# Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
- platform: template
name: "Device Uptime"
entity_category: diagnostic
lambda: |-
int seconds = (id(uptime_seconds).state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days > 3650 ) {
return { "Starting up" };
} else if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else {
return { (String(seconds) +"s").c_str() };
}
icon: mdi:clock-start
time:
- platform: sntp
id: sntp_time
# Define the timezone of the device
timezone: "${set_timezone}"
# Change sync interval from default 5min
update_interval: 360min
# Set specific sntp servers to use
servers:
- 2.au.pool.ntp.org
- 1.au.pool.ntp.org
- 0.au.pool.ntp.org
# Publish the time the device was last restarted
on_time_sync:
then:
# Update last restart time, but only once.
- if:
condition:
lambda: 'return id(device_last_restart).state == "";'
then:
- text_sensor.template.publish:
id: device_last_restart
state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");' also improves uptime to present in days / hours / minutes / seconds (instead of xxxxxxxx s), adds day/date/time of device last rebooted/reset and WiFi info. |
Ok the problem was a misunderstanding of the changelog where: PS: thanks for the edit, now it is all clear |
Wouldn't this need to be done tree-wide for all configs? @athom-tech Can you review please? |
Friendly Name
ESPHome now supports setting a friendly_name which is sent to Home Assistant. This name will be used for the config entry, the device name, and will be automatically prefixed to all of the entities where needed by Home Assistant.
Note
If you opt to use this new friendly name, take note that you should remove any friendly name (substitition) that you currently prepend onto entity name in YAML.
What would be the best way of handling this?
Edit: Setting the friendly_name in the esphome: section prefixes the device name.
Then creating a long display name that is not shown on mobile home assistant app.