Open wtstreetglow opened 2 years ago
I started a topic involving this on the home assistant forum at: https://community.home-assistant.io/t/hoping-to-get-some-guidance-on-making-my-logs-a-little-less-chatty-for-certain-error-issues/433778
It looks like you probably have an outdated weatheralerts yaml package file installed. The yaml package files don't update automatically with the integration so you'll have to download and install the updated weatheralerts_1.yaml file manually. If you haven't made any custom modifications to your local weatheralerts_1.yaml file, simply download the new file and copy it over the existing file. If you did make any modifications to the yaml package, backup your existing file so you can copy your modifications from the backed up file into the new package file.
If you are still encountering log spamming from weatheralerts after installing the updated yaml package, post those log snippets and I'll see what I can do to make them unnecessary warnings and errors go away or minimize them as much as possible.
Thank you for your response here @jlverhagen. I believe Home Assistant may have been just having a bad day the day this happened. After a restart, all of these log issues went away. I installed the package around a week or so ago using weatheralerts_1 as the file for my package directory.
I follow you on the weatheralerts_1 not updating automatically and will keep that in mind for the future if I run into any issues. And thank you for the reminder of copying modifications over in case I had made any.
Thank you all for what you have built here, it is really great!
I will close this for now because everything seems to have cleared itself up. Thank you again @jlverhagen
Ok. Just to make sure I have done everything properly. I started over with "weatheralerts" on my home assistant installation. (including using the updated package file "weatheralerts_1.yaml" from the github). A few days have passed and the original log errors seem to have come back. Should I send you my "weatheralerts_1.yaml" also? I will be posting the logs shortly.
Thank you @jlverhagen for any help you can provide.
I just caught another possible issue on my end. The sensor were called weatheralerts_1 but my actual file yaml file was still "weatheralerts.yaml". Maybe this could have been causing my log issues (I don't think so though. I have now renamed the yaml to "weatheralerts_1.yaml". Lets see if the log get filled again over the next few days. Previous to this change (I'm not sure the change matters). The logs are below: LOGS.txt
I have also attached the weatheralerts_1.yaml (wasn't sure if you needed it) It begins at the line:
2022-07-06 20:00:15 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{% if not is_state('sensor.weatheralerts_1', 'unavailable') and not is_state('sensor.weatheralerts_1', 'unknown') and is_state('sensor.weatheralerts_1_alert_1', 'on') or (is_number(states('sensor.weatheralerts_1')) and (states('sensor.weatheralerts_1')|int > 0)) %} {{ states.sensor.weatheralerts_1.attributes.alerts[0].id }} weatheralerts_1.txt
Just dropping back in here to see if anyone can help with the above. I have begun a home assistant thread about this at the address linked below:
@jlverhagen just dropping back in here to leave the above link.
It does look like one of the checks that were added earlier this year isn't fully working as intended and resulting in these errors. An additional logic check or a change to the existing checks would be needed to possibly eliminate the errors. I know the logged errors are a nuisance. My official recommendation, for now, is to add a logger filter to your Home Assistant configuration.yaml file to filter these errors from going into your log file.
If you don't have a logger:
section in your configuration.yaml file, add this to your configuration.yaml:
logger:
filters:
homeassistant.helpers.template_entity:
- "weatheralerts"
homeassistant.helpers.template:
- "weatheralerts"
If you already have a logger:
section, just add the filters to the existing logger section in the configuration.yaml file. These filters will prevent the weatheralerts template related errors from being logged to the log file.
The current yaml package will be mostly, if not completely, deprecated and not needed with the next release. Much of the info in the yaml package template sensors is being moved into the integration and included in the main weather alert sensor. And some of the logic and template sensor data will be moved directly into the automations, and the automations will be turned into blueprints.
The main sticking point to getting the next release finished is finding a way to accurately track alerts and which specific alerts have triggered notifications to prevent repeat notifications for the same alerts when the National Weather Service weather alerts API decides it wants to be flaky for a little while.
Thank you for your response @jlverhagen What you have given me is very helpful. I understand on things taken time to correct so no issues there. It was just making hard for me to track down things I could possibly fix with such a large amount of entries existing within the logs.
I do have a logger section but didn't know what to put in there just yet, I am still very new to home assistant. Thank you for this again.
Wow, that's awesome with regards to the yaml package. You are very talented. Thank you for what you have created for others. It is nice to be able to hear speech about the nws alerts using the google homes I have through the house.
Ahh, I understand with regards to duplicate notifications. Yeah, I've noticed that a few times in the last bit. I couldn't figure out if the NWS was just changing the alert slightly and reposting or if it was duplicates due to flakiness.
Thank you again @jlverhagen for your help here. If you want to close this, that's no problem or if it helps you remember stuff we can leave it open. Thank you again @jlverhagen!
Hello @jlverhagen
Just wanted to see if you could help me a bit more with the logger and removing the errors showing.
I have the following in my logger
default: error
logs:
homeassistant.core: warning
homeassistant.loader: error
homeassistant.components.recorder: error # to spot db issues
homeassistant.config_entries: error
homeassistant.setup: error
homeassistant.components.roku: critical
homeassistant.helpers.entity: critical
homeassistant.components.automation: error
homeassistant.components.waze_travel_time: error
homeassistant.components.statistics.sensor: critical
homeassistant.components.nws: error
homeassistant.helpers.event: critical
bellows: error
zigpy: error
homeassistant.components.zha.core: error
# homeassistant.components.hassio: debug
# homeassistant.components.cast: debug
# pychromecast: debug
# homeassistant.components.sonos: debug
# pysonos: info
filters:
homeassistant.helpers.template_entity:
- "weatheralerts"
homeassistant.helpers.template:
- "weatheralerts"
pychromecast.socket_client:
- "Heartbeat timeout, resetting connection"
- "Error reading from socket"
- "Error communicating with socket, resetting connection"
- "Failed to connect to service ServiceInfo"
This morning, I got the following error:
Logger: homeassistant.components.template.template_entity Source: components/template/template_entity.py:173 Integration: Template (documentation, issues) First occurred: 2:15:21 AM (92 occurrences) Last logged: 7:15:01 AM
TemplateError('UndefinedError: list object has no element 0') while processing template 'Template("{% if not is_state('sensor.weatheralerts_1', 'unavailable') and not is_state('sensor.weatheralerts_1', 'unknown') and is_state('sensor.weatheralerts_1_alert_1', 'on') or (is_number(states('sensor.weatheralerts_1')) and (states('sensor.weatheralerts_1')|int > 0)) %} {{ states.sensor.weatheralerts_1.attributes.alerts[0].title }} {% else %} None {% endif %}")' for attribute 'display_title' in entity 'sensor.weatheralerts_1_alert_1'
TemplateError('UndefinedError: list object has no element 0') while processing template 'Template("{% if not is_state('sensor.weatheralerts_1', 'unavailable') and not is_state('sensor.weatheralerts_1', 'unknown') and is_state('sensor.weatheralerts_1_alert_1', 'on') or (is_number(states('sensor.weatheralerts_1')) and (states('sensor.weatheralerts_1')|int > 0)) %} {{ states.sensor.weatheralerts_1.attributes.alerts[0].zoneid }} {% else %} None {% endif %}")' for attribute 'alert_zoneid' in entity 'sensor.weatheralerts_1_alert_1'
TemplateError('UndefinedError: list object has no element 0') while processing template 'Template("{% if not is_state('sensor.weatheralerts_1', 'unavailable') and not is_state('sensor.weatheralerts_1', 'unknown') and is_state('sensor.weatheralerts_1_alert_1', 'on') or (is_number(states('sensor.weatheralerts_1')) and (states('sensor.weatheralerts_1')|int > 0)) %} {% if states.sensor.weatheralerts_1.attributes.alerts[0].NWSheadline != "null" %} {{ states.sensor.weatheralerts_1.attributes.alerts[0].NWSheadline | regex_replace('[\'','') | regex_replace('\']','') }}
{% endif %}
{{ states.sensor.weatheralerts_1.attributes.alerts[0].description | regex_replace('\n\n','
') | regex_replace('\n',' ') | regex_replace('*','\n') | regex_replace(' ','\n\n') }} ') | regex_replace('\n',' ') | regex_replace('*','\n
{% if states.sensor.weatheralerts_1.attributes.alerts[0].instruction != None %} {{ states.sensor.weatheralerts_1.attributes.alerts[0].instruction | regex_replace('\n\n','
','\n\n') }}
{% endif %}
Where : {{ state_attr('sensor.weatheralerts_1', 'friendly_name') }}
Effective: {{ states.sensor.weatheralerts_1.attributes.alerts[0].effective }} {%- if states.sensor.weatheralerts_1.attributes.alerts[0].ends != None %}
Ends: {{ states.sensor.weatheralerts_1.attributes.alerts[0].ends }} {%- endif %}
Expires: {{ states.sensor.weatheralerts_1.attributes.alerts[0].expires }} {% else %} None {% endif %}")' for attribute 'display_message' in entity 'sensor.weatheralerts_1_alert_1'
TemplateError('UndefinedError: list object has no element 0') while processing template 'Template("{% if not is_state('sensor.weatheralerts_1', 'unavailable') and not is_state('sensor.weatheralerts_1', 'unknown') and is_state('sensor.weatheralerts_1_alert_1', 'on') or (is_number(states('sensor.weatheralerts_1')) and (states('sensor.weatheralerts_1')|int > 0)) %} Attention!!! Weather alert for {{ state_attr('sensor.weatheralerts_1', 'friendly_name') }}. A {{ states.sensor.weatheralerts_1.attributes.alerts[0].title }}. {{ states.sensor.weatheralerts_1.attributes.alerts[0].NWSheadline | regex_replace('[\'','') | regex_replace('\']','') | capitalize }}. {% else %} None {% endif %}")' for attribute 'spoken_title' in entity 'sensor.weatheralerts_1_alert_1'
TemplateError('UndefinedError: list object has no element 0') while processing template 'Template("{% if not is_state('sensor.weatheralerts_1', 'unavailable') and not is_state('sensor.weatheralerts_1', 'unknown') and is_state('sensor.weatheralerts_1_alert_1', 'on') or (is_number(states('sensor.weatheralerts_1')) and (states('sensor.weatheralerts_1')|int > 0)) %} {{ states.sensor.weatheralerts_1.attributes.alerts[0].description | regex_replace('\n\n','
') | regex_replace('\n',' ') | regex_replace('*','\n') | regex_replace(' ','\n\n') }} {% if states.sensor.weatheralerts_1.attributes.alerts[0].instruction != None %} {{ states.sensor.weatheralerts_1.attributes.alerts[0].instruction | regex_replace('\n\n',' ') | regex_replace('\n',' ') | regex_replace('*','\n
','\n\n') }} {% endif %} {% else %} None {% endif %}")' for attribute 'spoken_message' in entity 'sensor.weatheralerts_1_alert_1'
In the filters section in configuration.yaml add this:
homeassistant.components.template.template_entity:
- "weatheralerts"
I got the homeassistant.components.template.template_entity part from the Logger: line of the error log you posted. That will be the part of Home Assistant that is catching and logging the error and can be used to filter out errors.
@jlverhagen Thank you for responding to this and helping me hide some of these. I really do appreciate it.
Version of the custom_component
v0.1.2
Describe the bug Huge number of errors in Home Assistant log when there are no active alerts for my area. Just checking to make sure this is working properly. I have been getting alerts and this was the first instance I have seen in my area with no alerts. (First few days of having this installed, we had a air quality alerts). When this alert went away and our area had no alerts, the errors were produced in the log. Is there a way to supress these if this is not really a fixable situation?
Log