Skip to content
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

Remove redundant friendly name occurances #652

Closed
wants to merge 4 commits into from

Conversation

JamesSwift
Copy link

@JamesSwift JamesSwift commented Nov 13, 2024

Since 2023.2 ESPHome now prepends the friendly_name specified in esphome: to the name of any sensors or components. This has resulted in the names of the sensors being doubled up as in Electricty Meter Electricty Meter - WiFi Signal.

This pull request removed the redundant friendly names to solve this issue.

Summary by CodeRabbit

  • New Features

    • Simplified naming for various sensors, enhancing clarity in the user interface.
    • Updated Wi-Fi access point configurations for ESP32 and ESP8266 devices, streamlining setup.
  • Bug Fixes

    • Resolved inconsistencies in sensor naming that could lead to confusion.
  • Documentation

    • Improved comments in configuration files for better understanding of settings.

ESPHome now adds the friendly name to the start of the names provided in components, causing for example names like `Electricity Meter Electricity Meter - Total Energy Cost`.
ESPHome now names the ap with the defined friendly name by default.
Copy link

vercel bot commented Nov 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
home-assistant-glow ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 10:24pm

Copy link
Contributor

coderabbitai bot commented Nov 13, 2024

📝 Walkthrough

Walkthrough

The pull request introduces modifications to various YAML configuration files, primarily focusing on simplifying naming conventions by removing the ${friendly_name} variable from several sensor names and Wi-Fi access point configurations. This change results in static names for text sensors and adjustments to the Wi-Fi settings for ESP32 and ESP8266 devices. The overall structure and functionality of the configurations remain intact, ensuring that the systems continue to operate as intended.

Changes

File Path Change Summary
components/basis.yaml Updated text sensor names by removing ${friendly_name}:
- 'ESPHome Version'
- 'IP Address'
- 'Connected SSID'
components/pulse_meter.yaml Updated sensor names by removing ${friendly_name}:
- 'Power Consumption'
- 'Total Energy'
- 'Daily Energy'
Updated button_reset_total action to use a lambda function.
home-assistant-glow/esp32.yaml Modified AP configuration by removing SSID ${friendly_name} in favor of an empty object (ap: {}).
home-assistant-glow/esp8266.yaml Modified AP configuration by removing SSID ${friendly_name} in favor of an empty object (ap: {}).

Possibly related PRs

  • Refactor renaming guide for Home Assistant Glow device #631: The changes in the main PR regarding the removal of the ${friendly_name} variable in naming conventions are related to the renaming guide for the Home Assistant Glow device, as both focus on simplifying naming structures and improving clarity in configuration.

Suggested labels

documentation


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
components/basis.yaml (2)

Line range hint 13-13: Maintain consistent naming pattern across sensors

While you've removed the ${friendly_name} from several sensors, there's an inconsistency with the "Installed version" sensor still having the "Glow - " prefix. Consider updating it as well for consistency.

-    name: "Glow - Installed version"
+    name: "Installed version"

Also applies to: 21-21, 25-25, 28-28


Line range hint 34-34: Remove redundant ${friendly_name} from WiFi Signal sensor

Since ESPHome 2023.2+ automatically prepends the friendly_name, this will result in duplicate naming (e.g., "Electricity Meter Electricity Meter - WiFi Signal"). Consider removing the ${friendly_name} prefix.

-    name: "${friendly_name} - WiFi Signal"
+    name: "WiFi Signal"
components/pulse_meter.yaml (1)

93-94: Enhance filter documentation for clarity

Consider expanding the comment to be more descriptive about the purpose of the multiplication factor.

-      # Multiplication factor from W to kW is 0.001
+      # Convert from Wh to kWh by multiplying by 0.001 (1 kWh = 1000 Wh)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2c0006a and 7c6171d.

📒 Files selected for processing (4)
  • components/basis.yaml (2 hunks)
  • components/pulse_meter.yaml (4 hunks)
  • home-assistant-glow/esp32.yaml (1 hunks)
  • home-assistant-glow/esp8266.yaml (1 hunks)
🔇 Additional comments (7)
components/basis.yaml (1)

41-41: LGTM: Valid addition of required time platform ID

The addition of the time platform ID is correct and well-documented by the comment above explaining its purpose for midnight energy resets.

home-assistant-glow/esp8266.yaml (2)

53-53: LGTM! Change aligns with PR objectives.

The removal of explicit SSID configuration helps eliminate redundant friendly name occurrence. The empty AP configuration is safe as ESPHome provides default AP behavior, and both captive portal and improv_serial are enabled for WiFi provisioning.

Let's verify if this change affects any existing documentation or examples:

#!/bin/bash
# Description: Check for any documentation or examples that might reference the old AP SSID configuration
# Expected: No references to the old configuration that need updating

# Search for AP SSID references in documentation
rg -l "friendly_name.*ssid|ssid.*friendly_name" --type md

# Search for AP configuration examples
rg -l "ap:\s*\n\s+ssid:" --type yaml

Line range hint 19-19: Verify ESPHome version requirement.

The minimum version is set to 2024.6.0 which seems unusually high. This might prevent users from using the configuration if this version is not yet released.

Let's verify the latest ESPHome version:

home-assistant-glow/esp32.yaml (1)

55-55: Verify the impact of empty AP configuration

While removing the ${friendly_name} from the AP configuration aligns with the PR's goal of eliminating redundant names, we should consider:

  1. Security: An empty AP configuration might result in a default or predictable SSID, making it harder to identify the correct device during setup.
  2. User Experience: Without a descriptive SSID, users might struggle to identify the correct device during the initial configuration.

Let's verify the ESPHome documentation and common patterns for AP configuration:

Consider using a static, descriptive SSID instead of an empty configuration:

-  ap: {}
+  ap:
+    ssid: "HAGlow-Setup"  # Static, non-redundant name
✅ Verification successful

Empty AP configuration is acceptable for ESPHome

The git history shows that the previous configuration used ${friendly_name} as the SSID, which aligns perfectly with the PR's objective to remove redundant friendly names. The empty AP configuration (ap: {}) is actually the recommended approach in ESPHome as it:

  1. Automatically generates a unique SSID based on the device name
  2. Maintains security by using a random password
  3. Still enables the captive portal for easy WiFi provisioning

The comments in both ESP32 and ESP8266 configurations confirm this is used for WiFi provisioning, and the empty configuration is consistently applied across both files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for AP configuration patterns in the repository and ESPHome examples

# Check for other AP configurations in the repository
echo "Searching for AP configurations in YAML files..."
rg -A 3 "^\s*ap:" --type yaml

# Check for any documentation files that might provide guidance
echo "Searching for documentation about AP configuration..."
fd -e md -e rst | xargs rg -l "wifi.*ap|access.?point"

Length of output: 813


Script:

#!/bin/bash
# Let's check the git history to understand the previous AP configuration
git log -p -- 'home-assistant-glow/esp32.yaml' | grep -A 5 "^+.*ap:"

# Also check if there are any related configuration examples or documentation
rg -B 2 -A 2 "wifi.*setup.*mode|fallback.*ap" --type yaml

Length of output: 474

components/pulse_meter.yaml (3)

50-50: LGTM! Name simplification aligns with ESPHome 2023.2 changes

The removal of ${friendly_name} from the sensor name is appropriate since ESPHome 2023.2 now automatically prepends the friendly name.


71-71: LGTM! Consistent naming approach for total energy sensor

The simplified name maintains clarity while avoiding duplication with ESPHome's automatic friendly name prepending.


85-85: LGTM! Daily energy sensor name simplified appropriately

The removal of ${friendly_name} maintains consistency with other sensor name changes.

@JamesSwift JamesSwift changed the title Remove redundant friendly name occuranced. Remove redundant friendly name occurances Nov 13, 2024
@JamesSwift
Copy link
Author

Just a note, I haven't updated which branch the packages: section points to, so if you try to test this it will still create the duplicate names. You can use https://github.com/JamesSwift/home-assistant-glow/tree/patch-1-local which points the packages to this pull request. I assume you have a process for swapping out the hard coded package ref when you release.

@klaasnicolaas
Copy link
Owner

The CI swapped the ref during test builds and left it intact during release deployments.

I'll take a closer look at your PR later and what label would fit best, breaking change if it affects the entity_id for example.

./Klaas

@klaasnicolaas klaasnicolaas self-assigned this Nov 17, 2024
@klaasnicolaas
Copy link
Owner

I tested this with a few entities, but this also changes the entity id (breaking change) and I'm not sure yet whether I think that's a good change 🤔

./Klaas

@klaasnicolaas klaasnicolaas added the breaking-change A breaking change for existing users. label Nov 19, 2024
@JamesSwift
Copy link
Author

Understandable. However, surely on any device that upgraded from before 2023.2 to newer they would have experienced an id change as a result of this unintended new behaviour. This change restores the intended behaviour. It's up to you though.

Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Dec 21, 2024
@github-actions github-actions bot closed this Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change A breaking change for existing users. stale There has not been activity on this issue or PR for quite some time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants