Giter Club home page Giter Club logo

air-visual-card's Introduction

Air Visual Card

example

This is a Home Assistant Lovelace card that uses the AirVisual Sensor to provide air quality index (AQI) data and creates a card like the ones found on AirVisual website. Requires the AirVisual Sensor to be setup. Tested with Yahoo and Darksky Weather component.

Features

  • Card colors and icons change depending on AQI level

Options

Name Type Default Description
air_pollution_level string Optional Name of the Air Pollution Level sensor created by Airvisual component. If sensor does not exist, do not add this config value.
air_quality_index string Optional Name of the Air Quality Index sensor created by Airvisual component. If sensor does not exist, do not add this config value.
main_pollutant string Optional Name of the Main Pollutant sensor created by Airvisual component. If sensor does not exist, do not add this config value.
temp string Optional Name of the temperature sensor or weather entity, such as 'weather.yweather' or 'sensor.yweather_temperature'
country string Optional Name of the country that Airvisual is collecting AQI data from.
city string Optional Name of the city that AirVisual is collecting AQI data from.
icons string Optional The local directory where the .svg files are located. For example, 'icons: "/hacsfiles/air-visual-card"' is appropriate if this plugin is installed using HACS. If left blank, icons will be loaded from Jsdeliver CDN.
hide_title boolean Optional Set to true if you want to hide the title that includes the city name and weather. Useful for minimalists or those using dark themes.
hide_face boolean Optional Set to true if you want to hide the face icon.
weather string Optional If temp field does not use a weather entity (such as 'sensor.yweather_temperature'), this attribute allows you to specify a weather state for displaying the appropiate icon on the card.

HACS Installation

  1. Open the HACS on your Home Assistant instance.
  2. Open the Plugins section and click on the Air Visual Card.
  3. Click on Install, then click on "Add to Lovelace"

Manual Installation

  1. Download the AirVisual Card
  2. Place the file in your config/www folder
  3. Include the card code in the Resources section of your ui-lovelace-card.yaml like below:
resources:
  - url: /local/air-visual-card.js
    type: js
  1. Optional: If you wish to store the Airvisual icons locally, then download the icons here.

  2. Save the icons in a directory in Home Assistant, such as ''/local/icons/aqi_icons"

  3. Update the card configuration in ui-lovelace.yaml to include the following (use directory name in step #7):

     icons: "/local/icons/aqi_icons"

Instructions

  1. Install the AirVisual sensor and confirm AQI, APL, and Main Pollutant sensors are created, like below.

sensors

  1. Write configuration for the card and list your AirVisual sensors. MAKE SUREAn examples is provided below:

Direct editing within the YAML files (ui-lovelace.yaml)

  - type: 'custom:air-visual-card'
    air_pollution_level: sensor.use_the_actual_name_of_your_sensor_not_this_example
    air_quality_index: sensor.use_the_actual_name_of_your_sensor_not_this_example
    main_pollutant: sensor.use_the_actual_name_of_your_sensor_not_this_example
    temp: weather.use_the_actual_name_of_your_weather_entity_not_this_example
    city: 'San Francisco'

Adding via the Lovelace UI Card Configuration

type: 'custom:air-visual-card'
air_pollution_level: sensor.use_the_actual_name_of_your_sensor_not_this_example
air_quality_index: sensor.use_the_actual_name_of_your_sensor_not_this_example
city: Moscow
main_pollutant: sensor.use_the_actual_name_of_your_sensor_not_this_example
temp: weather.use_the_actual_name_of_your_weather_entity_not_this_example
  1. Refresh Lovelace to load the card.

FAQ

  • The card doesn't show the temperature properly.

    Let me know which weather provider you are using and I'll try to fix the issue. I have only tested with the Yahoo! Weather component. Optionally, if you create a template sensor that reports the temperature as its state, you can use that sensor as for the temp config.

  • This card doesn't work in Fully Kiosk Browser on Amazon Fire tablets. Why?

    This card uses a new CSS function, CSS Grid Layout, which was implemented in October 2018, and isn't compatible with browsers using old versions of Android WebView. That's my guess anyways.

  • The card is showing the word 'unavailable' instead of the AQI data!

    Most likely your Airvisual key expired (it has a one-year expiration) and needs to be recreated. Delete and recreate a new key on airvisual.com and save the key in your HA config file.

Support

I am studying programming as a hobby and this is my first set of Home Assistant projects. Unfortunately, I know nothing about Javascript and relied on studying other Lovelace custom cards to write this. Suggestions are welcome but no promises if I can fix anything! If you're familiar with CSS, then you can edit the CSS style in the .js file directly.

Credits

air-visual-card's People

Contributors

bradleyford avatar dnguyen800 avatar jeremywillans avatar mariusthvdb avatar rubengargar avatar scstraus avatar swampen avatar yuvalabou avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.