New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No longer see 'forecast' in attributes of PirateWeather weather. entities #157
Comments
same here |
Thanks for using this integration and opening an issue! I was worried this would be a problem, but it's a change in HA and I'm not sure how to work around it without causing a ton of warnings. Two solutions here:
|
For me solution 2, creating a sensor, would be fine but I didn't understand how to get the forecast data. State: clear-night Attributes: temperature: 1.1 |
Thanks for the reply, first of all! And for being so willing to help us
out. I have the same issue as described by the last commenter. I actually
used discrete sensor templates before to extract certain forecast elements
so I’m fine with that approach. The problem is that they referenced the
forecast dict that used to be present as an attribute to the weather
entity, and it’s that forecast dict that’s no longer available. So those
sensors can’t go pick out the elements we’re looking for. Hopefully I’m
making some sense here :)
…On Tue, Dec 5, 2023 at 9:41 AM Ameglialuna ***@***.***> wrote:
For me solution 2, creating a sensor, would be fine but I didn't
understand how to get the forecasts data.
In developer tools I only see the following data, just like @pbohannon
<https://github.com/pbohannon>:
State:
clear-night
Attributes:
temperature: 1.1
temperature_unit: °C
humidity: 91
ozone: 306.07
pressure: 969.38
pressure_unit: hPa
wind_bearing: 355
wind_speed: 9.18
wind_speed_unit: km/h
visibility: 16.09
visibility_unit: km
precipitation_unit: mm
attribution: Powered by Pirate Weather
friendly_name: PirateWeather
supported_features: 3
—
Reply to this email directly, view it on GitHub
<#157 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKNN2S4BG4WBHK3AF3C2JJTYH5MDBAVCNFSM6AAAAABAGVXWYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBRGMYDCNBYGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I'm still confused as to what to do. I was using this YAML to draw a 48hr precip_probability graph (helps when hanging washing outside to dry) but of course it now doesn't work. Apex-charts can't call services, how would i use a template sensor to package up that data to display in the graph?
|
If the forecast data is not exposed via an entity attribute anymore, I
think we're going to have to use a two-step process to continue referencing
forecast data in our cards. You can get the data via calling the
get_forecast service, but I don't yet know how to take the return data from
a service, store it, and assign it to a helper or template sensor. I think
that it'll require doing something like building an automation that runs
hourly (or whenever, not sure the load concerns of repeated service calls),
calls the get_forecast service, stores the data, updates the template
sensor with that data. Will mess with it today and see if I can't get a
working example.
…On Thu, Dec 7, 2023 at 4:30 AM Martin Cross ***@***.***> wrote:
I'm still confused as to what to do. I was using this YAML to draw a 48hr
precip_probability graph (helps when hanging washing outside to dry) but of
course it now doesn't work. Apex-charts can't call services, how would i
use a template sensor to package up that data to display in the graph?
type: custom:apexcharts-card
graph_span: 50h
apex_config:
chart:
height: 150px
xaxis:
labels:
format: hht
span:
start: hour
offset: '-2h'
now:
show: true
label: Now
header:
show: true
title: Rain Probability
yaxis:
- max: 100
decimals: 0
apex_config:
tickAmount: 5
cache: false
series:
- entity: weather.pirateweather_home_hourly
stroke_width: 3
type: line
color: '#9fc5e8'
data_generator: |
return entity.attributes.forecast.map((record, index) => {
return [record.datetime, record.precipitation_probability];
});
—
Reply to this email directly, view it on GitHub
<#157 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKNN2S5SGQ5GX4IA66KNYHTYIGZEZAVCNFSM6AAAAABAGVXWYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBVGI2TSOJSGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I'm also interested in something like this as the weather card that I use is not updated to use the new get_forecast service. I followed the steps in the first link that @alexander0042 shared but it doesn't seem to work for my card. I'll share what I have setup in case it's useful to anyone. The code goes in a templates.yaml file and you need to include - trigger:
- platform: time_pattern
minutes: "/30"
action:
- service: weather.get_forecast
target:
entity_id: weather.pirateweather
data:
type: hourly
response_variable: hourly_forecast
- service: weather.get_forecast
target:
entity_id: weather.pirateweather
data:
type: daily
response_variable: daily_forecast
sensor:
- name: "Pirate Weather Hourly"
unique_id: pirateweather_hourly
state: "{{ states('weather.pirateweather') }}"
attributes:
temperature: "{{ state_attr('weather.pirateweather', 'temperature') }}"
temperature_unit: "{{ state_attr('weather.pirateweather', 'temperature_unit') }}"
humidity: "{{ state_attr('weather.pirateweather', 'humidity') }}"
pressure: "{{ state_attr('weather.pirateweather', 'pressure') }}"
pressure_unit: "{{ state_attr('weather.pirateweather', 'pressure_unit') }}"
wind_bearing: "{{ state_attr('weather.pirateweather', 'wind_bearing') }}"
wind_speed: "{{ state_attr('weather.pirateweather', 'wind_speed') }}"
wind_speed_unit: "{{ state_attr('weather.pirateweather', 'wind_speed_unit') }}"
visibility: "{{ state_attr('weather.pirateweather', 'visibility') }}"
visibility_unit: "{{ state_attr('weather.pirateweather', 'visibility_unit') }}"
forecast: "{{ hourly_forecast.forecast[:24] }}"
- name: "Pirate Weather Daily"
unique_id: pirateweather_daily
state: "{{ states('weather.pirateweather') }}"
attributes:
temperature: "{{ state_attr('weather.pirateweather', 'temperature') }}"
temperature_unit: "{{ state_attr('weather.pirateweather', 'temperature_unit') }}"
humidity: "{{ state_attr('weather.pirateweather', 'humidity') }}"
pressure: "{{ state_attr('weather.pirateweather', 'pressure') }}"
pressure_unit: "{{ state_attr('weather.pirateweather', 'pressure_unit') }}"
wind_bearing: "{{ state_attr('weather.pirateweather', 'wind_bearing') }}"
wind_speed: "{{ state_attr('weather.pirateweather', 'wind_speed') }}"
wind_speed_unit: "{{ state_attr('weather.pirateweather', 'wind_speed_unit') }}"
visibility: "{{ state_attr('weather.pirateweather', 'visibility') }}"
visibility_unit: "{{ state_attr('weather.pirateweather', 'visibility_unit') }}"
forecast: "{{ daily_forecast.forecast[:7] }}" |
What @Ameglialuna said - forecast is no longer available in the dropdown in the integration. Right now, for whatever reason, the PirateWeather integration is not working at all. I could use the forecast from Norwegian (complicated to parse) or National Weather Service (even more complicated to parse). What's the issue with HA? Something I can do to help? |
@cloneofghosts, what card are you trying to display this in? I tried it with a couple options and your syntax seems to be correct, since I'm seeing everything populate correctly. Only thing I haven't tested is the updating, but I should know if that's working in a couple hours |
@alexander0042 I'm using this card https://github.com/Makin-Things/platinum-weather-card. I don't have the error message handy at the moment but it was something along the lines of things needing to be a number. It's probably something to do with the card I'm using and nothing to do with the template. |
Hey Alexander,
Hope you don't mind what could be a slightly orthogonal way of stating the
'issue'. I'm more interested in accessing the data the integration
provides than one particular card's ability to display the data. More
specifically, I have about 20 template sensors that are broken because the
forecast attribute is no longer exposed directly; I have to work out a
service call each time to populate the sensors. Is this going to be
permanent behavior in your view due to the change in the way HA is handling
weather integrations? Or is there a path back to where we can use
state_attr to access the dictionaries provided by the forecast attribute?
Thanks!
…On Mon, Dec 11, 2023 at 8:37 AM Alexander Rey ***@***.***> wrote:
@cloneofghosts <https://github.com/cloneofghosts>, what card are you
trying to display this in? I tried it with a couple options and your syntax
seems to be correct, since I'm seeing everything populate correctly. Only
thing I haven't tested is the updating, but I should know if that's working
in a couple hours
—
Reply to this email directly, view it on GitHub
<#157 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKNN2SZPDMAIYCTTHZFTW4LYI4ZF7AVCNFSM6AAAAABAGVXWYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJQGQ2DMMBWGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@cloneofghosts Looked into platinum weather card and it seems to be a larger issue with it: Makin-Things/platinum-weather-card#90. It's doing some sort of funky manual attribute name parsing instead of indexing, and that's what's creating the issue here. @pbohannon, did you try using the template+service setup? That creates a new sensor with attributes that match the old one, and should work more or less the same. When I tested it I got a list that looked like the old one, so curious if that works for you? |
Thanks for the quick reply! I may have missed it if you referenced it or
just didn't look hard enough myself :) I'll try to get this going later
this evening, unless you happen to have a snippet and/or screenshot you're
willing to share? Thanks again!
…On Mon, Dec 11, 2023 at 9:19 AM Alexander Rey ***@***.***> wrote:
@cloneofghosts <https://github.com/cloneofghosts> Looked into platinum
weather card and it seems to be a larger issue with it:
Makin-Things/platinum-weather-card#90
<Makin-Things/platinum-weather-card#90>. It's
doing some sort of funky manual attribute name parsing instead of indexing,
and that's what's creating the issue here.
@pbohannon <https://github.com/pbohannon>, did you try using the
template+service setup? That creates a new sensor with attributes that
match the old one, and should work more or less the same. When I tested it
I got a list that looked like the old one, so curious if that works for you?
—
Reply to this email directly, view it on GitHub
<#157 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKNN2SZ4CEGNSCHZ6NZYZPLYI46BDAVCNFSM6AAAAABAGVXWYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJQGUYTSNRTGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Figured it was likely something with the card and nothing to do with the template. The dev doesn't seem to be particularly active anymore so I might have to switch to a new card. @pbohannon I've created a template which you can modify to suit your needs here #157 (comment). If you don't need the current data you can remove everything but the forecast attribute. |
I'm trying to use your template and am getting a hourly_forecast is undefined error. Any ideas why? |
@luberk8 I have the same template setup in my install and it's working for me without any issues. If you look at the template entity attributes does it show anything under forecast? The template is setup to refresh every 30 minutes so it could be that the data wasn't initialized when you tried to use it. |
Yeah, definitely something is wrong on my setup. I was just wondering if you had any ideas. The only attribute the sensor entity has is a "friendly name". Also changed the time interval to 1 min and waited 30 |
HA changed the service call to Here is a template I am using now in my
This results in a state with today's date formatted MM-DD-YYYY and the following attributes for today and tomorrow:
|
Ugh, good catch here. At least it should be an easy change, but still irritating to have to test everything again. I'll update my dev instance over to 2023.12 shortly and double check, then add a note to update the docs with this tempting stuff! |
I updated my templates to the following to get the daily/hourly forecast sensors using - trigger:
- platform: time_pattern
minutes: "/30"
action:
- service: weather.get_forecasts
data:
type: daily
target:
entity_id: weather.pirateweather
response_variable: daily
sensor:
- name: Pirate Weather Daily
unique_id: pirateweather_daily
state: "{{ daily['weather.pirateweather'].forecast[0].condition }}"
attributes:
forecast: "{{ daily['weather.pirateweather'].forecast }}"
- trigger:
- platform: time_pattern
minutes: "/30"
action:
- service: weather.get_forecasts
data:
type: hourly
target:
entity_id: weather.pirateweather
response_variable: hourly
sensor:
- name: Pirate Weather Hourly
unique_id: pirateweather_hourly
state: "{{ hourly['weather.pirateweather'].forecast[0].condition }}"
attributes:
forecast: "{{ hourly['weather.pirateweather'].forecast[:24] }}" I found this thread on the HA forums useful in getting this setup https://community.home-assistant.io/t/new-weather-forecast-template/622642/ |
Thank you for the fix @cloneofghosts and everyone else! Worked like a charm. |
I've went ahead and updated the HA documentation page with the template and some information regarding the change. I'm going to close this for now but if you're still having issues feel free to create a new issue. |
Describe the issue
Hi there - I'm reluctant to post this because I'm sure I'm missing something obvious, but I'm stuck. :) Since the recent update through HACS, and a recent upgrade to HA (versions input below), I can no longer access the forecast dict from within the weather entities. Typically I would use state_attrs('weather.pirateweather', 'forecast')[0] etc., but forecast simply doesn't appear as an attribute anymore. I did see a note in the HACS upgrade about a breaking change, but I can't seem to find that note anywhere as it probably contains the key. I've tried to read through the code itself as well as track down the "new way of doing things in HA" but still can't find anything obvious. Any ideas? Thanks very much!
FWIW, here are the attributes shown via Developer Tools:
friendly_name: pirateweather_templow_5d
weather.pirateweather
PirateWeather
cloudy temperature: 50
temperature_unit: °F
humidity: 94
ozone: 312.32
pressure: 29.65
pressure_unit: inHg
wind_bearing: 134
wind_speed: 8.99
wind_speed_unit: mph
visibility: 7.58
visibility_unit: mi
precipitation_unit: in
attribution: Powered by Pirate Weather
friendly_name: PirateWeather
supported_features: 3
Home Assistant version
2023.12.0b2
Integration version
1.3.4
Troubleshooting steps
The text was updated successfully, but these errors were encountered: