Assistance parsing state attributes

Can some kind developer assist me in parsing out these state attributes? I’m trying to pull today’s weather out of my weather sensor. This is what I got so far:

’{{states.weather.yweather.attributes.forecast}}'

[
    {
      "datetime": "13 Oct 2018",
      "temperature": 59,
      "templow": 46,
      "condition": "rainy"
    },
    {
      "datetime": "14 Oct 2018",
      "temperature": 62,
      "templow": 42,
      "condition": "cloudy"
    },
    {
      "datetime": "15 Oct 2018",
      "temperature": 72,
      "templow": 53,
      "condition": "lightning-rainy"
    },
    {
      "datetime": "16 Oct 2018",
      "temperature": 63,
      "templow": 50,
      "condition": "lightning-rainy"
    },
    {
      "datetime": "17 Oct 2018",
      "temperature": 61,
      "templow": 46,
      "condition": "sunny"
    },
    {
      "datetime": "18 Oct 2018",
      "temperature": 55,
      "templow": 41,
      "condition": "sunny"
    },
    {
      "datetime": "19 Oct 2018",
      "temperature": 61,
      "templow": 41,
      "condition": "cloudy"
    },
    {
      "datetime": "20 Oct 2018",
      "temperature": 61,
      "templow": 47,
      "condition": "cloudy"
    },
    {
      "datetime": "21 Oct 2018",
      "temperature": 64,
      "templow": 49,
      "condition": "cloudy"
    },
    {
      "datetime": "22 Oct 2018",
      "temperature": 64,
      "templow": 46,
      "condition": "cloudy"
    }
  ]

What I want to do is pull out today’s weather forecast (the first entry in the list or alternatively by parsing today’s date) and use the “temperature”, “templow”, and “condition” values.

Any tips or advice on how to do this?

{{ state_attr('weather.yweather', 'forecast')[0].temperature }}

etc.

2 Likes

Hmm, I can’t seem to get that to pass the config check, errors on syntax. Here’s the whole action I’m trying:

  action:
  - data_template:
      title: Today's weather
      message: '{{ state_attr('weather.yweather', 'forecast')[0].temperature }}'
      data:
        device: myiphone
    service: notify.mypushover

The outermost quotes should be double quotes.

1 Like

That did the trick!

Thank you both!

1 Like