Created At

Jun 14, 2019

Last Update

Jul 01, 2019

Platforms

HC 2

Views

329

Download

23

Device features

Periodic reports on air quality for a defined location. Be warned about the smog conditions at your place instantly.

Advantages for everyone

  • Automatic status update. Custom interval value for update queries. Manual update is also available (via button).
  • May use "interpolation mode" (enabled by default in Lua scene). Airly gives you an option to calculate estimated values for any location near their stations, to see more then just what is exactly measured by the station.
  • You may select the language used for Airly messages. Polish and English are supported.
  • Colors to visualize Smog description. This will work on PC only. The mobile app does not interpret HTML tags.
  • Icon color is changing according to air quality measured. The colors are in correspondence with Airly recommendations.
  • One of three different air quality indexes from Airly might be selected. Airly supports: "AIRLY_CAQI", "CAQI" and "PIJP". Each may have different levels, descriptions, and pieces of advice.
  • Customizable location for reports. The location might be read automatically from your Home Center box or it might be set as a fixed one.
  • Data retrieved from Airly are stored in a global variable. The variable might be used to trigger another scene.

Advantages for geeks

  • Using the newest API 2.0.
  • Missing pieces of data from Airly are properly detected and do not stop the device from working.
  • No label "flickering" ("50%" → "missing data" → "52%", e.g.) on data updates. Changes on any update are reported once.
  • Clear information about the license (MIT). Make any changes you want, distribute, sell or whatever. Just include my name and the copywrite information.
  • Easy to change labels content, data grouping within labels, etc. (data selectors within one config variable labelConfig).
  • Source code easy to maintain and develop: rich debug information; separation of acquisition, extraction and data presentation, etc.

Installation

  1. Import the virtual device and create a new Lua scene with the code provided in the file.
  2. Add device icons and update their IDs in the virtual device main loop.
  3. Replace 'xxx...x' with the key you can get from Airly free of charge.
  4. Start the Lua scene manually (just for the first time).
  5. (optional) Customize: update interval, display language, labels content and many more (see details below).

Configuration

Read comments in Lua scene and VD main loop. 
Each configuration parameter is described there in details.

Zip file content

  • Virtual device: "Airly Status".
  • Lua scene for grabbing data from Airly: "Airly Status scraper".
  • Nine device icons to visualize air quality.
  • Screenshots.

FAQ

How can I get Airly API key?

Get one from developer.airly.eu. When you register an account within that website you will get your free API key.

How to upload/add device icons?

  1. Open (any) virtual device configuration page.
  2. Press "Change icon".
  3. Press "Select file" (in the bottom), choose file, then confirm with "Add" button (even lower).

Please make sure to execute step 1 properly. Icons in Home Center are divided into 4 categories. If your icons are placed not in the "virtual device collection", they will not be visible for the device.

How can I get an icon ID?

  1. Open (any) virtual device configuration page.
  2. Press "Change icon".
  3. Right click on the icon you want to get an ID. Select "Open graphics in a new tab". The address should be like: "http://hc2/fibaro/n_vicons/User1003.png". 1003 is your ID in this case.

How can I change the language for all displayed information?

  1. Change config variable in Lua scene. Only "pl" and "en" messages are supported by Airly API.
  2. Update display name of each label.
  3. Update labels content (if needed) by editing labelConfig variable in VD main loop. There is the same string formatting as for the Lua print function.

4 Comments,  Want to add comment please login
Da54c20566015cb188b16106e0cb981e

Sure. The device stores all retrieved data in a global variable. You can create very simple Lua scene on any condition and action you like. For detecting high pollution you could do: --[[ %% properties %% events %% globals AirlyStatus --]] local data = json.decode(fibaro:getGlobalValue("AirlyStatus")) if data.action == nil and data.indexes.AIRLY_CAQI.value > 75 then fibaro:debug("Very bad air") -- send push here or anything you need... end

9b3ad57e3aa52a515af31d525aa57a3b

A może wysyłać push kiedy wykryje, że smog jest wysoki ?

Da54c20566015cb188b16106e0cb981e

The mobile app does not interpret HTML tags. If you prefer to have nice labels over there you need to neglect to have line breaks and colors with the desktop app. To achieve that simply replace labelConfig variable with this one: local labelConfig = { Index = { "%.0f", {"I:"..INDEX_TYPE..":v"} }, Smog = { "%s", {"I:"..INDEX_TYPE..":metaDescription"} }, Description = { "%s", {"I:"..INDEX_TYPE..":description"} }, Advice = { "%s", {"I:"..INDEX_TYPE..":advice"} }, PM1 = { "%.0f µg/m³ (%.0f%%)", {"V:PM1:v", "S:PM1:percent"} }, PM10 = { "%.0f µg/m³ (%.0f%%)", {"V:PM10:v", "S:PM10:percent"} }, PM25 = { "%.0f µg/m³ (%.0f%%)", {"V:PM25:v", "S:PM25:percent"} }, Weather = {"%.1f °C %.0f hPa %.0f %%", {"V:TEMPERATURE:v", "V:PRESSURE:v", "V:HUMIDITY:v"}, empty = "--" }, Station = { "%s (ID: %d)", {"N:sponsor:name", "N:id"}, empty = "--" }, Address = { "%s %s", {"N:address:displayAddress1", "N:address:displayAddress2"}, empty = "--" }, Distance = { "%d m", {"N:distance"} }, UpdateTime = {"%s (pobrano %s)", {"tillDateTime", "nowTimeOnly"} }, }

084ede70c5609c8c1b9494496c120b30

Działa pięknie tylko na telefonie w apce wyświetla dziwne znaki.

Load more comments