Closed philbert2k closed 1 year ago
If both events have the same headline wording then you will see that both events have the same spoken_desc since that is where the spoken_desc comes from.
It may have been two separate events with the same wording in the headline.
Did you only see that once or on every alert?
I have a test entry now that has 4 events and none of the spoken_desc's are the same.
I see it for every alert that has spoken_desc.
I'm looking at the raw API data from NWS and it seems like there are two fields, "headline" and "NWSheadline" .... The duplicate info shows only on "NWSheadline." I came to notice this issue because I have a template card that only shows certain events, here is a screenshot followed by the code. Also attaching the raw API output I captured as well.
Captured API: txz173-heat.txt txz173-heatair.txt
Code for card above:
{% if states.sensor.wx_alerts.state != 0 %}
{% if states.sensor.wx_alerts.state != '1'%}The National Weather Service has issued the following{%endif%}{% if states.sensor.wx_alerts.state == '1'%}The National Weather Service has issued a{%endif%}
{%- for wxalert in state_attr('sensor.wx_alerts', 'title').split('\n\n-\n\n') %}
{% for line in wxalert.split(' - ') %}
{% if line.strip() == "Severe Thunderstorm Watch" %}<ha-alert alert-type="warning" title="Severe T-Storm Watch">{{ state_attr('sensor.wx_testalerts', 'spoken_desc')}}</ha-alert>{%endif%}
{% if line.strip() == "Severe Thunderstorm Warning" %}<ha-alert alert-type="error" title="Severe T-Storm Warning">{{ state_attr('sensor.wx_testalerts', 'expires')}}</ha-alert>{%endif%}
{% if line.strip() == "Tornado Watch" %}<ha-alert alert-type="warning" title="Tornado Watch">{{ state_attr('sensor.wx_testalerts', 'spoken_desc')}}</ha-alert>{%endif%}
{% if line.strip() == "Tornado Warning" %}<ha-alert alert-type="error" title="Tornado Warning">{{ state_attr('sensor.wx_testalerts', 'expires')}}</ha-alert>{%endif%}
{% if line.strip() == "Heat Advisory" %}<ha-alert alert-type="warning" title="Heat Advisory">{{ state_attr('sensor.wx_alerts', 'spoken_desc')}}</ha-alert>{%endif%}
{% if line.strip() == "Excessive Heat Warning" %}<ha-alert alert-type="error" title="Excessive Heat Warning">{{ state_attr('sensor.wx_alerts', 'spoken_desc')}}</ha-alert>{%endif%}
{% if line.strip() == "Air Quality Alert" %}<ha-alert alert-type="info" title="Air Quality Alert">{{ state_attr('sensor.wx_alerts', 'spoken_desc')}}</ha-alert>{%endif%}
{% if line.strip() == "Special Weather Statement" %}<ha-alert alert-type="info" title="Special WX Statement">{{ state_attr('sensor.wx_alerts', 'spoken_desc')}}</ha-alert>{%endif%}
{% endfor %}
{%- endfor %}
{% else %} No Active Weather Alerts
{% endif %}
I see why it's doing it but i'm not sure what to do about it.
I'm not sure the headline should be the long description contained in the "headline" but should be the potentially shorter info in 'NWSHeadline".
But I think that the info in "headline" might be more useful.
But i've never really noticed any issues with the way it is no either before you mentioned it, either.
Let me think about it.
I see why it's doing it but i'm not sure what to do about it.
I'm not sure the headline should be the long description contained in the "headline" but should be the potentially shorter info in 'NWSHeadline".
But I think that the info in "headline" might be more useful.
But i've never really noticed any issues with the way it is no either before you mentioned it, either.
Let me think about it.
I see why it's doing it but i'm not sure what to do about it.
I'm not sure the headline should be the long description contained in the "headline" but should be the potentially shorter info in 'NWSHeadline".
But I think that the info in "headline" might be more useful.
But i've never really noticed any issues with the way it is no either before you mentioned it, either.
Let me think about it.
Sounds good. I'd be more than happy to help with feedback or ideas..... The weird thing is it worked fine for me and then just all of a sudden.... I do dev work as well but just getting my feet wet with Python and my left toe is just getting wet with HA type dev stuff.
Hi @finity69x2 ! Just wanted to check in and see if you had any updates on this one? Kind of forgot about this until recently.
Let's just keep it real... :)
I doubt I'll ever do anything with this so I'm just going to close this.
Sorry.
If you REALLY need the additional info from the headline (vs NWSHeadline) then you can pull the raw data from the NWS alerts website and get the entire raw data set by setting up a REST sensor.
That's actually the way I used to do it before the integration was created. And I still have that REST sensor set up on my system just for troubleshooting if needed even tho I never really look at it.
here is the example yaml code for that sensor if you want to try it:
sensor:
- platform: rest
resource: https://api.weather.gov/alerts/active?zone=<YOUR,CODES,HERE>
name: NWS Alert Event Raw
value_template: >
{% if value_json.features[0] is defined %}
{{ value_json['features'][0]['properties'].event }}
{% else %}
None
{% endif %}
json_attributes:
- features
headers:
User-Agent: Homeassistant
Accept: application/geo+json
scan_interval: 60
I am not sure if this is expected behavior or if there is an issue, but,..... I have two events, and both events have a spoken_desc attribute. Instead of spliting the attribute for each event, it's listing the same attribute for both, showing both. If you need it, I have both the output generated by the sensor state and the raw nws api output. Example below.
Code:
{{ state_attr('sensor.wx_alerts', 'spoken_desc')}}
Result: