forked from tarontop/athom-configs
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1c1fd5b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"IP Address", "Connected SSID", "Mac Address", "Restart with Factory Default Settings", and "Safe Mode" are missing ${friendly_name}.
What's the plan for friendly_name going forward? Are you going to try removing it again? Where should one follow/discuss that?
1c1fd5b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you need it....HA changed to automatically insert the name of the device into the entity ID.
If you added name: "${alias_name} Status LED" back in for example (can't use friendly_name as that is now an official variable in HA) it would mean you'd end up with a prefix of fridge_plug.fridge_plug.led for instance. We only needed this friendly name before, as under the older HA we would end up with duplicate entity names with a _1 or _2 etc suffix if had multiple plugs.
It also meant if we had to login to the ESPHome local device webserver everything would be prefixed with the friendly name... now none of that is required.
1c1fd5b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Roving-Ronin read the commit and history a bit? This commit is re-adding the manually-added "${friendly_name} " prefix which had been removed from sensor names in a previous commit (ab76339), for the reasons you state. The reversion isn't fully complete, as it misses the ones that I pointed at. So we ended up worse than where we started.
1c1fd5b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@palves yes this latest commit makes ZERO sense. Just pull the unofficial athom friendly_name out from substitutions and replace with alias_name, and add the HA official friendly_name under esphome section in. As mentioned before, if people still want to be able to call a subsitution as they used too, then just call ${alias_name}.
Personally seen it simpler to just move to using my own yaml for these plugs. Example here for my dishwasher.
`
substitutions:
device_name: "gpo-dishwasher"
alias_name: "Dishwasher"
device_description: "Measure the energy consumption of the dishwasher"
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
packages:
baseline: !include common/common_athom_plug_v2.yaml
api:
ota:
logger:
baud_rate: 0
mdns:
disabled: false
web_server:
port: 80
wifi:
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:
`
common_athom_plug_v2.yaml that is called being:
`
preferences:
flash_write_interval: 5min
uart:
rx_pin: RX
baud_rate: 4800
globals:
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:
then:
then:
internal: true
sensor:
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:
- 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: 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
platform: total_daily_energy
name: "Energy Daily"
restore: true
power_id: power_sensor
unit_of_measurement: kWh
accuracy_decimals: 3
filters:
button:
platform: restart
name: 'Restart Device'
entity_category: diagnostic
platform: factory_reset
name: Reset with Default Settings
id: Reset
switch:
name: "Remote Control"
pin: GPIO12
id: relay
restore_mode: ${relay_restore_mode}
light:
name: "Device Status LED"
id: blue_led
disabled_by_default: true
pin:
inverted: true
number: GPIO13
internal: true
text_sensor:
platform: template
name: 'Device Last Restart'
id: device_last_restart
icon: mdi:clock
entity_category: diagnostic
platform: wifi_info
ip_address:
name: 'WiFi IP Address'
icon: mdi:wifi
entity_category: diagnostic
ssid:
name: 'WiFi SSID'
icon: mdi:wifi-strength-2
entity_category: diagnostic
mac_address:
name: 'WiFi MAC Address'
entity_category: diagnostic
platform: template
name: 'Project Name'
id: gas_meter_project
icon: "mdi:label-outline"
entity_category: diagnostic
lambda: |-
return {"${project_name}"};
update_interval: 6h
platform: template
name: 'Project Version'
id: gas_meter_version
icon: "mdi:label-outline"
entity_category: diagnostic
lambda: |-
return {"${project_version}"};
update_interval: 6h
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:
id: sntp_time
timezone: "${set_timezone}"
update_interval: 360min
servers:
on_time_sync:
then:
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");`
Ends up looking like this on device web interface: