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

doc: Simplify Home Assistant sensors, add device_class to allow changing measurement units #4472

Merged

Conversation

longzheng
Copy link
Contributor

When reviewing #4470 I had a thought why are the Home Assistant sensors defined as template sensors rather than MQTT sensors with a transform in value_template. Then I went down a rabbit hole, why even have different sensors for different measurements (miles vs. km) at all if Home Assistant can automatically transform the unit of measurement

image

(It's my assumption that Home Assistant automatically picks the correct unit of measurement based on the server's locale/region, but please correct me if I'm wrong)

So I made the following changes

  • moved parking brake sensor from binary_sensor.yaml to mqtt_sensors.yaml with a value_template transform
  • removed several "mi" template sensors and added device_class: distance to the "main" sensor so the unit can be changed
  • renamed some sensors like tesla_est_battery_range_km to tesla_est_battery_range so they are not unit specific (since the unit can be changed)
  • kept the separate bar/psi tyre pressure sensors since that isn't so much a region-specific unit of measurement but a preference (Home Assistant still allows changing between bar/psi)
  • removed separate sensor.yaml and binary_sensor.yaml files from the docs
  • updated ui-lovelace.yaml to reference just the main sensors (and not both km/miles)

I think this approach reduces the complexity of the sensor definitions but I'm not sure if there's any downsides I've missed.

Copy link

netlify bot commented Jan 5, 2025

Deploy Preview for teslamate ready!

Name Link
🔨 Latest commit 84a8cf0
🔍 Latest deploy log https://app.netlify.com/sites/teslamate/deploys/6779d6852322770009248d87
😎 Deploy Preview https://deploy-preview-4472--teslamate.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@brianmay
Copy link
Collaborator

brianmay commented Jan 5, 2025

I would really like to see us implement mqtt auto discovery, so this config can be part of teslamate and not have to be manually updated.

https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery

But I have no idea how feasible this would be.

@longzheng
Copy link
Contributor Author

I would really like to see us implement mqtt auto discovery, so this config can be part of teslamate and not have to be manually updated.

https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery

But I have no idea how feasible this would be.

I agree auto discovery would be handy but I also don't have emough experience with Home Assistant ot Elixer to implement it.

I think this PR will make it easier to transition to auto discovery as the duplicate measurement unit sensors are removed and it's all just MQTT sensors remaining.

@JakobLichterfeld JakobLichterfeld added the kind:documentation Adds or improves documentation label Jan 6, 2025
Copy link
Collaborator

@JakobLichterfeld JakobLichterfeld left a comment

Choose a reason for hiding this comment

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

Awesome, thanks you so much!

@longzheng
Copy link
Contributor Author

Do you want me to resolve the conflicts due to the other merge?

@JakobLichterfeld JakobLichterfeld merged commit 95dbb90 into teslamate-org:master Jan 6, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:documentation Adds or improves documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants