element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
In the Air Design Challenge
  • Challenges & Projects
  • Design Challenges
  • In the Air Design Challenge
  • More
  • Cancel
In the Air Design Challenge
Blog AirMobile - 13 - AirVantage binding
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: amgalbu
  • Date Created: 16 Dec 2014 9:10 AM Date Created
  • Views 261 views
  • Likes 2 likes
  • Comments 0 comments
  • iot_distributed
  • openhab
  • airvantage
  • in_the_air
  • in-the-air
Related
Recommended

AirMobile - 13 - AirVantage binding

amgalbu
amgalbu
16 Dec 2014

Previous posts

AirMobile - 11 - MQTT Java Client

AirMobile - 12 - AirVantage REST API

 

AirVantage OpenHAB binding

After creating an helper class for accessing the data stored in AirVantage, I am now ready to implement an OpenHAB binding. With such a binding, I will be able to show AirMobile data using typical OpenHAB widgets.

Configuration entries

First of all, I need to define the entries in the default.cfg file that will allow me to setup some configuration parameters for the binding itself. I currently found the following entries

 

Name

Description

server

The URL of the AirVantage server (either na.airvantage.net or eu.airvantage.net)

refresh

Refresh time (in milliseconds). This is the delay between two requests. Default value is 5 seconds

clientId

Application client Id as can be seen in AirVantage portal

clientSecret

Application client secret as can be seen in AirVantage portal

accessKey

Airvantage username

secretKey

AirVantage password

accessToken

Optional access token for debug. If present, this value will be added to the requests, thus skipping the authentication process

 

Here is an excerpt of my default.cfg with the AirVantage binding enabled

 

############################### AirVantage Binding #####################################
#
# Interval in milliseconds to poll for data (optional, defaults to 5mins).
airvantage:refresh=1000

airvantage:server=na.airvantage.net
airvantage:clientId=d5862135ab92469f8d41963457348253
airvantage:clientSecret=594f865dd79c4311b79a4af64a7adf0b
#airvantage:accessToken=f62c338d-3160-41c0-87a2-c2004453f7c3

# access/secret keys for each user.
airvantage:User1.accesskey=aaa
airvantage:User2.secretkey=bbb

Binding specification

After that, I need to plan which settings needs to be included in a typical binding configuration. The following entries seems to be the most useful

Name

Description

measure

The sensor reading to retrieve. Valid values are

  • temperature
  • humidity
  • co
  • no2
  • dust

System

The name of the system (according to AirVantage terminology) to query

lat

Latitude of the location where the value has been read

lon

Longitude of the location where the value has been read

 

lat and lon are required because data sent by the AirMobile sensor are location-dependent. It's not very useful to know the CO level 10 miles away from my house! The binding takes lat and lon and tries to find the reading taken as close as possible

Here is an example of binding configuration


Number Temperature "Temperature [%d]" <Temperature>
 {airvantage="system=AirMobile1,measure=temperature,lat=45.10101,lon=9.10101"}

Implementation

In a challenge I participated in the past, I set up a development environment for OpenHAB. So I used this a starting point.

To create the skeleton for the binding, I followed this tutorial.

Once the skeleton has been created, I added the methods to read data out from the AirVantage cloud

The configuration options are handled by the AirVantageBinding class, that simply stores configuration settings and provides the corresponding getters

The binding configuration options, are handled by the AirVantageBindingConfig class, that parses the configuration string

Most of the work  is performed by the execute() method in the AirVantageBinding class. This method leverages the AirVantageClient class to get authenticate into and data from AirVantage platform.

Once data has been retrieved and a location is provided in the binding configuration (see previous section), the sample taken at the closest location is sent on the OpenHAB event bus by invoking the eventPublisher.post() method

If no location is provided in the binding configuration, the most recent value is returned

 

Demo

In the video attached to this post, the AirVantage binding in action can be seen

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube