Pollen (again) but for the UK

There are very many pollen threads on the community but I couldn’t find a decent one providing pollen count for the UK. Tado introduced an air quality report some time ago and a quick poke around their web app revealed the API calls to get the data.

Simple authenticated rest call to get the JSON plus some template sensors to get the air quality for today plus pollen levels for today, tomorrow and the after. They also provide pollution levels in the json response but would be easy enough to add these as additional sensors.

You’ll need your tado home ID, lat & long plus your tado username and password

sensor:
  - platform: rest
    # API call to get air quality
    # Result goes into outdoorQuality attribute in JSON format
    name: TadoAir
    verify_ssl: true
    scan_interval: 1800
    resource: https://acme.tado.com/v1/homes/XXX/airComfort?latitude=XXX1&longitude=XXXX&username=XXXXX&password=XXXXXXXXXXXXXXXXXX
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json
    method: GET
    json_attributes:
      - roomMessages
      - outdoorQuality
    value_template: 'Tado airComfort'

  # Enumerate JSON to populate various template sensors
  - platform: template
    sensors:
      air_quality:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["aqi"]["level"]  | capitalize }}'
        friendly_name: "Air Quality"
        icon_template: mdi:air-filter

      # Pollen sensors
      air_pollen_level:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["dominant"]["level"]  | capitalize }}'
        friendly_name: "Pollen Level"
        icon_template: mdi:flower

      air_pollen_level_grass:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["types"][0]["forecast"][0]["level"] | capitalize }}'
        friendly_name: "Pollen Level Grass"
        icon_template: mdi:flower

      air_pollen_level_grass_tomorrow:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["types"][0]["forecast"][1]["level"] | capitalize  }}'
        friendly_name: "Pollen Level Grass Tomorrow"
        icon_template: mdi:flower

      air_pollen_level_weed:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["types"][1]["forecast"][0]["level"] | capitalize  }}'
        friendly_name: "Pollen Level Weed"
        icon_template: mdi:sprout

      air_pollen_level_weed_tomorrow:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["types"][1]["forecast"][1]["level"] | capitalize  }}'
        friendly_name: "Pollen Level Weed Tomorrow"
        icon_template: mdi:sprout

      air_pollen_level_tree:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["types"][2]["forecast"][0]["level"] | capitalize  }}'
        friendly_name: "Pollen Level Tree"
        icon_template: mdi:tree

      air_pollen_level_tree_tomorrow:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["types"][2]["forecast"][1]["level"]  | capitalize }}'
        friendly_name: "Pollen Level Tree Tomorrow"
        icon_template: mdi:tree


4 Likes

Great piece of work - many thanks!

I’ve set up a tado account to try this but I get "User is not authorized to access this resource with an explicit deny" when I try the GET.

Where do I find the Home ID, I’ve tried the name of “Home” in settings ?

EDIT: looking at the API I think you need devices set up for this to work ?

you can find out your home ID by issuing the rest call

https://my.tado.com/api/v2/me?username=XXXXXX&password=XXXX

the value will be under [“homes”][0][“id”]

Not sure what other Tado kit you need for this to work. I’m fully bought into the system with boiler control and TRVs

That worked, I’ve got no devices, thanks

@drillbit This has stopped working for me, is it stiil working for you ?

Yes - still working for me. Possibly stopped working for you if you don’t have any Tado kit

I’m trying to use this as Tado seems to have a better Pollen prediction than anything else I can find.
The code above works fine, but the API call seems to return data that’s a day old. Today (Sat) it returns info for Today, Sat and Sun whereas it should be Today, Sun and Mon.

So, using this API I get:

Today (Medium), Sat (Medium), Sun (High)

With the phone app I get:

Today (Medium), Sun (High), Mon (High)

It looks like it’s the API, not your code as the raw API results match this. Any ideas?

Just in case anyone is interested, I raised a change for the Node-Red tado client to include the detailed pollen info and it’s been added into the latest release. This seems to match what is shown in the Tado app and should now be easy to use this to create/update entities in Hass.

Thanks for this. I can confirm that this Tado API rest sensor code is still mostly working. Really helpful in the absence of an official API or documentation for Tado API v1.

I made a few fixes/changes.

  1. the capitalisation in the template was causing values with NONE to come through as Unknown. I think as these level values are now coming through from Tado in capitals, this part of the template is unneccesary.
  2. I didn’t see the point in adding roomMessages to the TadoAir sensor attributes. This part of the JSON and associated values are not needed for any of the outdoor air quality data from Tado.
  3. I corrected some of the templates because I felt based on looking at the data coming back in the JSON, 0 actually appears to be yesterdays date, 1 has a date matching todays date and 2 had a date matching tomorrows date. I’m unsure as to why Tado send the data in this way.
  4. I changed the MD icons so that grass had a grass icon instead of flower, and pollen level has a pollen icon.
## credit to drillbit from HA forums for the template work
  - platform: rest
    # API call to get air quality
    # Result goes into outdoorQuality attribute in JSON format
    name: TadoAir
    scan_interval: 1800
    resource: !secret tado_rest_resource
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json
    json_attributes:
      - outdoorQuality
    value_template: 'Tado airComfort'

  # Enumerate JSON to populate various template sensors
  - platform: template
    sensors:
      air_quality:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["aqi"]["level"]}}'
        friendly_name: "Air Quality"
        icon_template: mdi:air-filter

      # Pollen sensors
      air_pollen_level:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["dominant"]["level"]}}'
        friendly_name: "Pollen Level"
        icon_template: mdi:flower-pollen

      air_pollen_level_grass:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["types"][0]["forecast"][1]["level"]}}'
        friendly_name: "Pollen Level Grass"
        icon_template: mdi:grass

      air_pollen_level_grass_tomorrow:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["types"][0]["forecast"][2]["level"]}}'
        friendly_name: "Pollen Level Grass Tomorrow"
        icon_template: mdi:grass

      air_pollen_level_weed:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["types"][1]["forecast"][1]["level"]}}'
        friendly_name: "Pollen Level Weed"
        icon_template: mdi:sprout

      air_pollen_level_weed_tomorrow:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["types"][1]["forecast"][2]["level"]}}'
        friendly_name: "Pollen Level Weed Tomorrow"
        icon_template: mdi:sprout

      air_pollen_level_tree:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["types"][2]["forecast"][1]["level"]}}'
        friendly_name: "Pollen Level Tree"
        icon_template: mdi:tree

      air_pollen_level_tree_tomorrow:
        value_template: '{{ states.sensor.tadoair.attributes["outdoorQuality"]["pollens"]["types"][2]["forecast"][2]["level"]}}'
        friendly_name: "Pollen Level Tree Tomorrow"
        icon_template: mdi:tree

Is this still working for you? I’m just getting Unknown’s in the outdoorQuality fields :frowning:

Yeah the template is also throwing up an error for me. Perhaps Tado has changed the structure of the JSON, I haven’t had a chance to check yet. Let me know here if you find anything.

EDIT: Made a quick GET request to Tado’s restful API, the API is returning UNKNOWN in those fields too. Updating the get request to use Tado’s API v2 with the following URL returns an error with title “current user is not allowed access to this resource”

https://my.tado.com/api/v2/homes/12467/airQuality?

tried the headers airQuality, airComfort, outdoorQuality and all of them return the same error. perhaps someone else will find the right GET request for a newer version of the API (such as V2) assuming pollen is still something available to users of the web app or mobile app. I can get airComfort, but it no longer contains pollen in API v2. My guess is they’ve stopped paying for the external API that they were using to get aqi, pollens and pollutants for the outdoorQuality values in V1 of their API.

API (at least v1) has the outdoorquality and pollen returned in the json data but UNKNOWN. Given that the pollen stats and AQI no longer appear in the mobile or web apps, I suspect they’ve removed this feature

Yeah, shame. At least hay fever season is over.