finity69x2 / nws_alerts

An updated version of the nws_alerts custom integration for Home Assistant
84 stars 29 forks source link

Errors with variables and attribute split #42

Closed ghost closed 1 year ago

ghost commented 2 years ago

I seem to be having an issue running the nws_alerts_custom_package_full.yaml. I'm getting the errors below. I've tried it with both the HACS add on and plugging in my zone_id manually.

2022-07-11 16:40:35 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'int object' has no attribute 'split' when rendering '{{ (trigger.to_state.attributes.event_id).split('-')[0] }}' 2022-07-11 16:40:35 ERROR (MainThread) [homeassistant.components.automation.nws_update_event_id_variable] NWS Update Event ID Variable: Error executing script. Error for call_service at pos 2: Error rendering data template: UndefinedError: 'int object' has no attribute 'split' 2022-07-11 16:40:35 ERROR (MainThread) [homeassistant.components.automation.nws_update_event_id_variable] Error while executing automation automation.nws_update_event_id_variable: Error rendering data template: UndefinedError: 'int object' has no attribute 'split' 2022-07-11 16:40:38 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'int object' has no attribute 'split' when rendering '{{ (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] not in states.variable.nws_alerts_event_ids.attributes.values()|list) and (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] != states('variable.nws_alerts_event_ids')) }}' 2022-07-11 16:40:38 WARNING (MainThread) [homeassistant.components.automation] Error evaluating condition in 'NWS Weather Alert Pop Up Control': In 'condition' (item 3 of 3): In 'template' condition: UndefinedError: 'int object' has no attribute 'split' 2022-07-11 16:40:38 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'int object' has no attribute 'split' when rendering '{{ (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] not in states.variable.nws_alerts_event_ids.attributes.values()|list) and (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] != states('variable.nws_alerts_event_ids')) }}' 2022-07-11 16:40:38 WARNING (MainThread) [homeassistant.components.automation] Error evaluating condition in 'NWS Notification Weather Alert': In 'condition' (item 3 of 3): In 'template' condition: UndefinedError: 'int object' has no attribute 'split' 2022-07-11 16:40:38 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'int object' has no attribute 'split' when rendering '{{ (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] not in states.variable.nws_alerts_event_ids.attributes.values()|list) }}' 2022-07-11 16:40:38 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'int object' has no attribute 'split' when rendering '{{ (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] != states('variable.nws_alerts_event_ids')) }}' 2022-07-11 16:40:38 WARNING (MainThread) [homeassistant.components.automation] Error evaluating condition in 'NWS Announce Weather Alert': In 'condition': In 'and' (item 4 of 5): In 'template' condition: UndefinedError: 'int object' has no attribute 'split' In 'and' (item 5 of 5): In 'template' condition: UndefinedError: 'int object' has no attribute 'split' 2022-07-11 16:40:38 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'int object' has no attribute 'split' when rendering '{{ (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] not in states.variable.nws_alerts_event_ids.attributes.values()|list) }}' 2022-07-11 16:40:38 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'int object' has no attribute 'split' when rendering '{{ (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] != states('variable.nws_alerts_event_ids')) }}' 2022-07-11 16:40:38 WARNING (MainThread) [homeassistant.components.automation] Error evaluating condition in 'NWS Announce Weather Alert for MBR': In 'condition': In 'and' (item 4 of 6): In 'template' condition: TypeError: argument of type 'NoneType' is not iterable In 'and' (item 5 of 6): In 'template' condition: UndefinedError: 'int object' has no attribute 'split' In 'and' (item 6 of 6): In 'template' condition: UndefinedError: 'int object' has no attribute 'split' 2022-07-11 16:40:38 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'int object' has no attribute 'split' when rendering '{{ (trigger.to_state.attributes.event_id).split('-')[0] }}' 2022-07-11 16:40:38 ERROR (MainThread) [homeassistant.components.automation.nws_update_event_id_variable] NWS Update Event ID Variable: Error executing script. Error for call_service at pos 2: Error rendering data template: UndefinedError: 'int object' has no attribute 'split' 2022-07-11 16:40:38 ERROR (MainThread) [homeassistant.components.automation.nws_update_event_id_variable] Error while executing automation automation.nws_update_event_id_variable: Error rendering data template: UndefinedError: 'int object' has no attribute 'split'

finity69x2 commented 2 years ago

It's going to be really hard to help you troubleshoot this since there are quite a bit of moving parts in that package.

First things I can think of are did you change the name of the sensor when you created it in HACS? If you did then you will need to adjust the sensor entity_ids in the package for the new sensor name.

and did you install the "hass-variables" custom integration via HACS? if not then you need to install it or remove the parts of the package that uses that integration.

ghost commented 2 years ago

Sensor name is the default sensor.nws_alerts, tried uninstalling the packages and reinstalling them to no luck. It seems like my HA isn't creating those variables like it should with that variables integration.

finity69x2 commented 2 years ago

There should only be one variable entity created.

it should be called "variable.nws_alerts_event_ids".

Do you not see thar listed in your dev tools->states list?