Skip to content

Commit

Permalink
remove friendly_name
Browse files Browse the repository at this point in the history
  • Loading branch information
tarontop committed Mar 22, 2023
1 parent 7f6a7b6 commit ab76339
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions athom-smart-plug-v2.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
substitutions:
device_name: "athom-smart-plug-v2"
friendly_name: "Athom Smart Plug V2"
alias_name: "Athom Plug"
project_name: "athom.smart-plug-v2"
project_version: "1.1"
relay_restore_mode: RESTORE_DEFAULT_OFF

esphome:
name: "${device_name}"
friendly_name: ""
name_add_mac_suffix: true
project:
name: "${project_name}"
Expand Down Expand Up @@ -52,14 +53,14 @@ globals:

binary_sensor:
- platform: status
name: "${friendly_name} Status"
name: "Status"

- platform: gpio
pin:
number: 5
mode: INPUT_PULLUP
inverted: true
name: "${friendly_name} Power Button"
name: "Power Button"
disabled_by_default: true
on_multi_click:
- timing:
Expand All @@ -74,27 +75,27 @@ binary_sensor:

sensor:
- platform: uptime
name: "${friendly_name} Uptime Sensor"
name: "Uptime Sensor"

- platform: cse7766
update_interval: 10s
current:
name: "${friendly_name} 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: "${friendly_name} Voltage"
name: "Voltage"
power:
name: "${friendly_name} 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: "${friendly_name} Energy"
name: "Energy"
id: energy
unit_of_measurement: kWh
filters:
Expand All @@ -109,7 +110,7 @@ sensor:
previous_energy_value = current_energy_value;
- platform: template
name: "${friendly_name} Total Energy"
name: "Total Energy"
unit_of_measurement: kWh
device_class: "energy"
state_class: "total_increasing"
Expand All @@ -120,7 +121,7 @@ sensor:
update_interval: 10s

- platform: total_daily_energy
name: "${friendly_name} Total Daily Energy"
name: "Total Daily Energy"
restore: true
power_id: power_sensor
unit_of_measurement: kWh
Expand All @@ -131,19 +132,19 @@ sensor:

button:
- platform: factory_reset
name: Restart with Factory Default Settings
name: "Reset"
id: Reset

switch:
- platform: gpio
name: "${friendly_name}"
name: "${alias_name}"
pin: GPIO12
id: relay
restore_mode: ${relay_restore_mode}

light:
- platform: status_led
name: "${friendly_name} Status LED"
name: "Status LED"
id: blue_led
disabled_by_default: true
pin:
Expand All @@ -153,9 +154,12 @@ light:
text_sensor:
- platform: wifi_info
ip_address:
name: "${friendly_name} IP Address"
disabled_by_default: true
name: "IP Address"
ssid:
name: "Connected SSID"
mac_address:
name: "Mac Address"

time:
- platform: sntp
id: my_time
id: sntp_time

15 comments on commit ab76339

@SaLuci
Copy link

@SaLuci SaLuci commented on ab76339 Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of removing friendly_name? wouldn't removing it only increase confusion if you have multiple smart plugs?

@Oinq
Copy link

@Oinq Oinq commented on ab76339 Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the friendly name removed? Will I get again 10 plugs with the same name in my energy dashboard?

@SaLuci
Copy link

@SaLuci SaLuci commented on ab76339 Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I'm having right now. I'm going to revert to the old config for now

@fozzyg
Copy link

@fozzyg fozzyg commented on ab76339 Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this
You can not set your own friendlyname anymore
My friendelyname was set in the substitute section
All my node-red flows are not working anymore

@Oinq
Copy link

@Oinq Oinq commented on ab76339 Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to avoid this? What version should I avoid?

@SaLuci
Copy link

@SaLuci SaLuci commented on ab76339 Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used commit 3526337 (the one before this one).

https://github.com/athom-tech/athom-configs/blob/3526337aec944a892e953070bd578b29162a567e/athom-smart-plug-v2.yaml

You should avoid this commit, if you have multiple smart plugs or changed the friendly name.

@tarontop
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add a friendly_name: in the esphome section

#25

image

@lichenophile
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the example.

For anyone annoyed at "athom_plug" being appended to the switch name in home assistant, add alias_name: "" to your substitutions alongside the changed mentioned in the post above.

Example:

substitutions:
  name: "bathroom-growlight-plug"
  alias_name: ""
packages:
  athom.smart-plug-v2: github://athom-tech/athom-configs/athom-smart-plug-v2.yaml
esphome:
  name: ${name}
  friendly_name: "Bathroom Growlight Plug"
  name_add_mac_suffix: false


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

Bit hacky as it leaves the switch name blank when visiting the devices page:
image
Not sure if there's a more elegant solution to avoid this approach,

@evan
Copy link

@evan evan commented on ab76339 Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit broke all my integrations when I updated because all the entity names changed back to generic names. I am reverting to the previous version.

To be clear, removing any device-specific name interpolation from the sensor names make entity renaming and differentiation in the HA integration no longer work. It is not possible to fix without manually renaming every entity in the integration or every sensor in the ESPHome yaml. Using alias_name in the current commit is not enough.

@SebTM
Copy link

@SebTM SebTM commented on ab76339 Mar 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

athom-standbylinuxserver.zip

Just fork the repository and change the username to yours, from this point you are responsible for maintaining/keeping up2date with upstream - nothing personal but you could have changed things in the uploaded archive (and GitHub provides the option to download the state of any commit as archive) so I wouldn't recommend anyone using it.

@Roving-Ronin
Copy link

@Roving-Ronin Roving-Ronin commented on ab76339 Mar 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is ridiculous... athom used friendly_name as an unofficial variable, now (a few months ago) HA happens to officially start using a variable of the name name. If you want to keep using what you had before, just enter the descriptive name you had before into alias_name and then use alias_name to define the new official friendly_name variable.

substitutions:
alias_name: "XYZ Descriptive Name"

esphome:
friendly_name: "${alias_name}"

@Oinq
Copy link

@Oinq Oinq commented on ab76339 Apr 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm struggling with this. I'm reading for hours trying to understand how to change this, but it's slipping through somewhere.
image
This is my config, but I'm not being able to differentiate the plugs when I go in history.
image
what am I doing wrong?
Also, with so many frequent updates, I see some of the changes I do become overwritten, and all comes back to the same mess.

Can someone, please point me in the right direction to avoid the recurring mess?

@evan
Copy link

@evan evan commented on ab76339 Apr 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Oinq I think this is more or less the way:

  1. Remove all esphome integrations
  2. Fork this repo and revert this commit
  3. Point the package in your yamls to your own fork of this file
  4. Add the friendly_name substitution to each yaml (what you have will work, but friendly_name: ${name} is simpler)
  5. Update all esphome devices
  6. Add integrations back to HA

Removing the all the name interpolations in the sensor ids was the big mistake in this commit. They should have been changed to alias_name, but I don't see what the problem with friendly_name was. It still works fine for me.

@tarontop
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this video is very long, I can only upload it to the cloud disk, please speed up the viewing, through this video I did not find that the entity ID will be disturbed, currently I am using the development branch, you can define the use name through friendly_name:, both homeassitant and esphome It is the latest version, please point out if I am wrong, thank you

https://drive.google.com/file/d/1fsYWzhs9tN5IZa6tZ9SnqxBA_mkXaoNj/view?usp=share_link

@Oinq
Copy link

@Oinq Oinq commented on ab76339 Apr 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, it seems I'm back on track or at least in a good direction. Thank you, Evan to point me the way, and also tarontop for the video.

Please sign in to comment.