0家居助理的空气质量

我最近写了关于如何在Home Assistant中显示垃圾箱收集信息的文章, 我的下一个项目是获取一些空气质量信息. 幸运的是,我有一个“ Tado”帐户,这意味着我可以从他们的帐户中提取此信息 API 使用以下代码


Much of the inform­a­tion for this was taken from a thread on the home assist­ant for­ums, but I was able to add pol­lu­tion as well as pol­len inform­a­tion, and I also had to tweak the code to resolve an issue with “none” being treated as “unknown” rather than as a string of text. Lots of cred­it to Drillbit on the for­ums though.

Tado帐户详细信息

  • You will need some inform­a­tion for your Tado account
  • Vis­it https://my.tado.com/api/v2/me?用户名=you@emailaddress.tld&密码=您的密码
  • Near the top of the out­put you need the numer­ic ID that is lis­ted under homes: 0: ID:
  • 下一个, 去 https://www.latlong.net/ and loc­ate your home and make a note of the lat­it­ude and longitude
  • Next vis­it https://acme.tado.com/v1/homes/您的家庭编号/空中舒适?纬度=12.34&经度=12.34&用户名=你的邮件&密码=your-pass­word 确保加载

家庭助理代码

  • Add the fol­low­ing code to your configuration.yaml
    传感器:
     - 平台: 休息
       # API 致电获取空气质量
       # Result goes into outdoorQuality attribute in JSON format
       name: TadoAir
       verify_ssl: true
       scan_interval: 1800
       资源: https://acme.tado.com/v1/homes/您的家庭编号/空中舒适?纬度=12.34&经度=12.34&用户名=你的邮件&密码=你的密码
       头:
         用户代理: Home Assistant
         Content-Type: application/json
       method: GET
       json_attributes:
         - roomMessages
         - outdoorQuality
       value_template: 'Tado air Comfort'
    
     # 枚举JSON以填充各种模板传感器
     - 平台: template
       sensors:
         空气质量:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["这里"]["等级"] | 大写 }}'
           friendly_name: "空气质量"
           icon_template: MDI:air-filter
           unique_id: "空气质量"
    
         # Pollen sensors
         air_pollen_level:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["花粉"]["主导的"]["等级"] | 大写 }}'
           friendly_name: "花粉水平"
           icon_template: MDI:flower
           unique_id: "花粉水平"
    
         air_pollen_level_grass:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["花粉"]["类型"][0]["预报"][0]["等级"] | 大写 }}.'
           friendly_name: "草花粉"
           icon_template: MDI:flower
           unique_id: "grass_pollen_level"
    
         air_pollen_level_grass_tomorrow:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["花粉"]["类型"][0]["预报"][1]["等级"] | 大写  }}.'
           friendly_name: "草花粉托莫。"
           icon_template: MDI:flower
           unique_id: "grass_pollen_level_tomorrow"
    
         air_pollen_level_weed:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["花粉"]["类型"][1]["预报"][0]["等级"] | 大写  }}.'
           friendly_name: "植物花粉"
           icon_template: MDI:sprout
           unique_id: "plant_pollen_level"
    
         air_pollen_level_weed_tomorrow:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["花粉"]["类型"][1]["预报"][1]["等级"] | 大写  }}.'
           friendly_name: "植物花粉托莫。"
           icon_template: MDI:sprout
           unique_id: "plant_pollen_level_tomorrow"
    
         air_pollen_level_tree:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["花粉"]["类型"][2]["预报"][0]["等级"] | 大写  }}.'
           friendly_name: "花粉 "
           icon_template: MDI:tree
           unique_id: "tree_pollen_level"
    
         air_pollen_level_tree_tomorrow:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["花粉"]["类型"][2]["预报"][1]["等级"] | 大写 }}.'
           friendly_name: "树花粉托莫。"
           icon_template: MDI:tree
           unique_id: "tree_pollen_level_tomorrow"
    
         air_pollution_level_pm10:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["污染物"][0]["等级"] | 大写 }}: {{ States.sensor.tadoair.attributes["户外品质"]["污染物"][0]["专注"]["值"]}}μg/m³'
           friendly_name: "下午 10"
           icon_template: MDI:tree
           unique_id: "污染_pm10"
    
         air_pollution_level_pm25:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["污染物"][1]["等级"] | 大写 }}: {{ States.sensor.tadoair.attributes["户外品质"]["污染物"][1]["专注"]["值"]}}μg/m³'
           friendly_name: "下午 2.5"
           icon_template: MDI:tree
           unique_id: "污染_pm25"
    
         air_pollution_level_ozone:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["污染物"][2]["等级"] | 大写 }}: {{ States.sensor.tadoair.attributes["户外品质"]["污染物"][2]["专注"]["值"]}}ppb'
           friendly_name: "臭氧"
           icon_template: MDI:tree
           unique_id: "污染臭氧"
    
         air_pollution_level_sulphur:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["污染物"][3]["等级"] | 大写 }}: {{ States.sensor.tadoair.attributes["户外品质"]["污染物"][3]["专注"]["值"]}}ppb'
           friendly_name: "二氧化硫"
           icon_template: MDI:tree
           unique_id: "污染_硫"
    
         air_pollution_level_carbon:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["污染物"][4]["等级"] | 大写 }}: {{ States.sensor.tadoair.attributes["户外品质"]["污染物"][4]["专注"]["值"]}}ppb'
           friendly_name: "一氧化碳"
           icon_template: MDI:tree
           unique_id: "污染碳"
    
         空气_污染_水平_氮:
           value_template: “{{ States.sensor.tadoair.attributes["户外品质"]["污染物"][5]["等级"] | 大写 }}: {{ States.sensor.tadoair.attributes["户外品质"]["污染物"][5]["专注"]["值"]}}ppb'
           friendly_name: "二氧化氮"
           icon_template: MDI:tree
           unique_id: "污染氮"
    

有你自己的一些想法? 下面放纵自己通过评论! 如果您想订阅,请使用菜单上的订阅链接右上方. 您还可以通过使用下面的链接社会分享这与你的朋友. 干杯.

发表评论