pilotak / homeassistant-attributes

Breaks out specified attribute from other entities to a sensor
Apache License 2.0
101 stars 11 forks source link

New Issue with Zwave Related Entities #26

Closed gilperme closed 2 years ago

gilperme commented 3 years ago

Hi, thanks for all your work on this component it's been excellent when extracting key metrics for some data experiments i've run in the past. I do appreciate it.

Thanks in advance for taking a look at this.

Running HA Version supervisor-2021.02.11 Newest Version supervisor-2021.02.11 Core HA Version core-2021.2.3 Newest Version core-2021.2.3 Add-on v. 1.1.1

Unfortunately I am running into an issue that I have not experienced before. After reapplying the config from a previous test....each time I attempt to restart HA, I receive the following error when validating config (see below) The interesting thing is that this was working just fine Dec. of last year. I literally copied the code from before and just added a whole bunch more devices. I've tried scaling back to just one device and event tested with a non-z-wave device hence my suspicion this is some odd behavior.

EDIT - Also experiencing this with other sensors as well -

"Invalid config for [sensor.attributes]: Entity ID - binary_sensor.updater is an invalid entity id for dictionary value @ data['entities']. Got '-\xa0binary_sensor.updater'. (See ?, line ?)."

Notice below how the entity name changes from : zwave.aeon_labs_dsa03202_minimote to Getting n invalid entity id for dictionary value @ data['entities']. Got '-\xa0zwave.aeon_labs_dsa03202_minimote ...it's like appending xa0 to all the zwave entities.

Here's the error when trying to validate the config and below that you will find the yaml code for the config. I've read through all the open and closed issues and can't find anything that sticks out. Any help I would really appreciate it. Thanks.

nvalid config for [sensor.attributes]: Entity ID - zwave.aeon_labs_dsa03202_minimote - zwave.aeon_labs_dsc11_smart_strip - zwave.aeon_labs_zw090_z_stick_gen5_us - zwave.aeon_labs_zw117_range_extender_6 - zwave.aeon_labs_zw117_range_extender_6_2 - zwave.attic_multi6_zw100 is an invalid entity id for dictionary value @ data['entities']. Got '-\xa0zwave.aeon_labs_dsa03202_minimote -\xa0zwave.aeon_labs_dsc11_smart_strip -\xa0zwave.aeon_labs_zw090_z_stick_gen5_us -\xa0zwave.aeon_labs_zw117_range_extender_6 -\xa0zwave.aeon_labs_zw117_range_extender_6_2 -\xa0zwave.attic_multi6_zw100 -\xa0zwave.chime_a_2 -\xa0zwave.chime_b -\xa0zwave.cm160x -\xa0zwave.coach_lights_switch_ws15z1 -\xa0zwave.compressor_switch_3 -\xa0zwave.deep_fryer_switch_zw096 -\xa0zwave.dining_room_pendant_2 -\xa0zwave.family_ceiling_fan -\xa0zwave.family_room_wall_li.... (See ?, line ?).

Example of config.yaml under sensor:

zwave-device metrics RTT

RTT Request RTT

pilotak commented 3 years ago

Hi could you please try a device_class branch? there are some bug fixes and if the issue persist i will look into that

gilperme commented 3 years ago

I saw your comment on one of the open issues I believe and have already tried that...I should have mentioned it before...no luck, same error. Please do let me know if you need anything to help troubleshoot, thank you!

pilotak commented 3 years ago

Ok, could you please turn on the debug?

logger:
 default: warning
 logs:
  custom_components.attributes: debug

and to make it simpler have only one entity in the list. It would be perfect if you could also do a screenshot in devtools of that entity including its attributes

pilotak commented 3 years ago

@gilperme any progress?

you can update via HACS to version 1.2.0 should you wish

gilperme commented 3 years ago

Apologies for the delay, even after enabling logging as recommended I am not seeing anything on the logs when the error comes up during the configuration validation. All I get is the following entry:

2021-03-22 03:16:17 INFO (MainThread) [custom_components.blueiris.api.blue_iris_api] Updating data from BI Server (BlueIris) 2021-03-22 03:16:39 WARNING (MainThread) [homeassistant.loader] You are using a custom integration attributes which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-03-22 03:16:47 INFO (MainThread) [custom_components.blueiris.api.blue_iris_api] Updating data from BI Server (BlueIris)

I have the latest version already installed and still keep getting that error. Again, the odd thing is the entity names that appear in the error do not match the entity names I entered....

For instance, entity zwave.attic_multi6_zw100 is listed as \xa0zwave.attic_multi6_zw100 in the error output...it's appending \za0 to each of the entities.

Here's the YAML used in config

#Attributes extractor
#https://github.com/pilotak/homeassistant-attributes

#zwave-device metrics RTT
###RTT Request RTT

  - platform: attributes
    friendly_name: "Zwave Req RTT"
    attribute: lastRequestRTT
    unit_of_measurement: milliseconds
    icon: 'mdi:sort-clock-ascending'
    entities:
      - zwave.attic_multi6_zw100

Here's the output of the Dev Tools for the Attic Multi Sensor listed above:

node_id: 31
node_name: AEON Labs ZW100 MultiSensor 6
manufacturer_name: AEON Labs
product_name: ZW100 MultiSensor 6
query_stage: Associations
is_awake: false
is_ready: false
is_failed: false
is_info_received: true
max_baud_rate: 40000
is_zwave_plus: true
capabilities:
  - beaming
  - zwave_plus
  - routing
sentCnt: 2
sentFailed: 2
retries: 0
receivedCnt: 0
receivedDups: 0
receivedUnsolicited: 0
sentTS: '2021-03-22 03:13:08:040 '
receivedTS: '2021-03-22 03:08:51:681 '
lastRequestRTT: 7781
averageRequestRTT: 7781
lastResponseRTT: 0
averageResponseRTT: 0
battery_level: 100
wake_up_interval: 3600
application_version: '1.10'
friendly_name: Attic Multi6
pilotak commented 3 years ago

When enabling debug will see more messages like: Adding attribute: %s of entity: %s and Applying template if you don't see it, you did domething wrong

message You are using a custom integration attributes which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant is always shown for all custom integrations

anyway goto dev tools and try this template, you should see correct output

{{ state_attr('zwave.attic_multi6_zw100', 'lastRequestRTT') }}
gilperme commented 3 years ago

Ok please review what I used, I caught the error in logging which was set to default: info, I updated config and restarted...still same error... see screenshot below. To be clear the same error does show at startup as with all custom components...what happens it shows up again when I try and run config check. Hope all this helps, pls let me know if you need anything else, thanks for the help.

image

Below you'll find the output of the template from dev tools:

image

pilotak commented 3 years ago

Well picture is worth thousand words. You have problem with your config file, this is not a bug in this component.

You will have to review if you have correct amount of space under entities: and if they are really spaces not tabs and also check line ending

gilperme commented 3 years ago

@pilotak I appreciate the feedback...you mentioned "correct amount of space" and tabs....I use this integration extensively for other sensors and this is the only instance where I run into this issue. Here's a screenshot of the zwave device with the issue and other sensors that are working just fine...I can't find a difference between other than one is a zwave device and the others are sensors. Again this used to worked and then stopped working with one of the updates.

No matter what Z-wave device I use I get an error indicating that the "Invalid config for [sensor.attributes]: Entity ID - zwave.attic_multi6_zw100 is an invalid entity ID for dictionary value @ data['entities']. Got '-\xa0zwave.attic_multi6_zw100'. (See ?, line ?)."

Again it's almost as if my entry of zwave.attic_multi6_zw100 is changed to -\xa0zwave.attic_multi6_zw100 , does that make sense? Thanks for the support.

attributes-zwave

I also happen to have two instances of HA running, I used HA Remote to bring the Z-wave devices from the main instance into the running instance and the same exact thing is happening with the name, the name in the remote instance has a prefix so the name is slighlty different....but the same thing is happening....the entity name changes from zwave.hassprem_attic_multi6_zw100 to -\xa0zwave.hassprem_attic_multi6_zw100

Same thing when the config check runs the entity ID is prefixed with -\xa0

gilperme commented 3 years ago

@pilotak Ok so I started messing with different ways to list the entities and by removing the "- " next to the sensor name, the config was valid! After reboot, the sensor showed up....so unlike the other sensors that I have which are listed as "- sensor.name" it appears that the zwave entities will work if I remove the "- " from the entry, so instead of "- zwave.entity" I used "zwave.entity" and it worked. Not sure if this is an HA bug or not, but it is odd that formatting it without the leading dash and [space] which is how I understand entities need to be listed....it works.

Thanks again for the feedback.

pilotak commented 3 years ago

Perfect that you did an investigation and it now works as intended! Well i had a same feeling that array item has to begin with - interesting...

gilperme commented 3 years ago

@pilotak I meant to respond earlier but got carried away with the fam.

So it turns out that it was actually an encoding issue, as soon as I tried adding my list of zwave devices without the "- " it failed to validate...it seemed to work with just one which is what I reported earlier.

So this really bugged me and I really did not want to keep pestering so I started looking at other possibilities and that's when using an encoder and decoder i found differences in the encoded results for other non-zwave entities and those zwave entities that keep failing config check.

I'm putting all these extra notes in case someone makes the mistake I made and they keep banging their heads without a solution....

See, when I put the list of zwave devices together, I used a workbook in Excel to generate the list. It appears that the space character used wasn't an actual space but something else....

It turns out the unicode value for the bad space character (it's invisible) is 160 which is de/encoded as: -%C2%A0zwave.attic_multi6_zw100, notice the name has the A0 appended to the entity ID....

[I used a URL encoder / decoder to get here, hence the URL encoding ;)

However using the correct space character, unicode 32, the encoded URL would be: -%20zwave.attic_multi6_zw100 with %20 as encoded space character

This is why when the config validator ran, it changed the entity id from zwave.hassprem_attic_multi6_zw100 to -\xa0zwave.hassprem_attic_multi6_zw100 and could not match it to existing entity.

So after fixing this, I was able to load all the entities without an issue. I appreciate you responding and your patience. Keep up the great work with this custom integration. Again, hope others may find this information helpful.

Thank you.