Error: Extension weather not defined to type CompressorPlant

#1

I have a type defined as follows:

entity type CompressorPlant mixes GeoPoint, MetricEvaluatable, WeatherAware schema name 'COMPRESSOR_PLANT' { ... }

I’m trying to now use the WeatherAware type to get the closest weather station information.

I’ve loaded some data into the type (which includes lat/long data) and try:

CompressorPlant.refreshWeatherStations()

This results in:

error / message: Extension weather not defined to type CompressorPlant

What am I missing here? am I taking the right approach to using WeatherAware type?

0 Likes

#2

In addition to the mixin you also need to include the @weather annotation on the type. The @weather maps type fields to input required by the weather service so it can determine the correct weather station. For example:

@weather(countryName="countryName",
         countryAbbr="countryAbbr",
         zipcode="zipcode",
         latitude='latitude',
         longitude='longitude')
entity type MyDevice mixes WeatherAware schema name 'MYDEV' {...}
0 Likes

#3

Hi Scott,

Thanks - that got me further…

are ALL the fields countryName, countryAbbr, and zipcode absolutely required?

In the data provided by customer, the zipcode would be a Canadian Postal Code, if it exists. However, these locations are in the middle of nowhere… I’m not sure they have proper addresses (I’ll have to ask).

Right now, I have defined the annotation as follows:

@weather(countryName="countryName",
         countryAbbr="countryAbbr",
         latitude='lat',
         longitude='long')

(… note that zipcode is missing in the above)

With that above, I’m getting this error as reported by refreshWeatherStationStatus():

Invalid expression null. Error message is 'Empty expression.'. Time range [null, null]

if zipcode is absolutely required, are there any known limitations (such as US Addresses only)? Further, if we are providing lat/long, why is zipcode even required? The latter is less precise than actual latitude/longitude, is it not?

0 Likes

#4

Well, I answered my own question.

zipcode is required

Canada Postal Codes are supported. An example of a postal code in Canada might be “L3R 1E3” or “L3R-1E3”… but what worked for me is “L3R1E3” … no space/dash.

0 Likes