tomaae / homeassistant-truenas

TrueNAS integration for Home Assistant
Apache License 2.0
183 stars 16 forks source link

[Bug]Entity attributes have spaces in names #144

Closed Wire-Fox closed 5 months ago

Wire-Fox commented 6 months ago

Describe the issue

While trying to utilize some of the entity attributes in the TrueNAS integration, I encountered issues getting these to process due to the names of some of the attributes containing spaces. These can be parsed when templating, but cannot consistently be parsed in yaml configurations. I specifically could not process attributes in auto-entities-card without just doing my entire filter selection with Templating.

How to reproduce the issue

  1. Go to Developer Tools, States
  2. Select a sensor created by the TrueNAS integration (I used an app, so, "binary_sensor.blocky" is an example)
  3. Review state attributes output by entity
    attribution: Data provided by TrueNAS integration
    Name: blocky
    Human version: 0.23.0_12.2.7
    Update available: 1
    Container images update available: 0
    Portal: []
    icon: mdi:server
    friendly_name: blocky

Expected behavior

Expected to see values more like:

attribution: Data provided by TrueNAS integration
name: blocky
human_version: 0.23.0_12.2.7
update_available: 1
container_images_update_available: 0
portal: []
icon: mdi:server
friendly_name: blocky

Screenshots

N/A

Software versions

Diagnostics data

None seen.

Traceback/Error logs

None seen.

Additional context

I was exploring the code base of the integration to see if there was any clear explanation for this behavior. I am not an experienced coder, so my findings here may be of little value. Hopefully they actually are helpful!

binary_sensor_types.py defines the attributes in the manner I expect for the Apps entities (Line 74).

helper.py defines the format_attribute function, which seems to rename elements of gathered attributes into more human-readable formats. (Line 7 through 19)

entity.py calls the format_attribute variable in a block starting at line 202. My experience fails me here, but I suspect this returns the full string of formatted attributes in the extra_state_attributes variable. What is noteworthy to me is it looked like one the only calls to store these attribute values, which has them being stored in the formatted manner.

tomaae commented 6 months ago

can you check if master version has the same behaviour?

github-actions[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] commented 5 months ago

This issue was closed because it has been stalled for 5 days with no activity.