Atmo, Alexa skill for weather stations & Amazon Echo, ...

Apple HomeKit (Siri), Amazon Alexa, Google Assistant
lroguet
Posts: 8
Joined: 07 May 2016, 09:27
Location: Stockholm, Sweden
Contact:

Atmo, Alexa skill for weather stations & Amazon Echo, ...

Post by lroguet » 07 May 2016, 09:41

Hi there,

I'm implementing an Alexa skill for Netatmo weather stations (https://github.com/lroguet/amzn-alexa-skill-netatmo) and I'm using the getstationsdata api which, in my opinion (correct me if I'm wrong) could be improved slightly.

The skill makes it possible, for example, for someone to ask for the temperature measured by a given module. To do so the user would say "Alexa, ask Netatmo to give me the temperature indoors." (where indoors is the name of a module, the base station in my case) or "Alexa, ask Netatmo for the temperature reported by the module called the kids bedroom.", ... Alexa would reply: "The module named the kids bedroom reports a temperature of 19 degrees."

It all works fine already (so go ahead and setup the skill for your home if you have an Amazon Echo) but I had to write some stupid code to handle the fact that the base station is not a module and its data live outside of the modules array (see below, I pasted the documentation response example). To look up the temperature by module name I have to use 2 patterns since I don't know if the user asks for the base station or an additional module. Please note that this is not only true for temperature since the skill in the end will support all measurements...

Code: Select all

var pattern = "[ body.devices[?module_name==`" + moduleName + "`].dashboard_data.temperature, body.devices[].modules[?module_name==`" + moduleName + "`].dashboard_data.temperature | [] ] | []";
var result = JMESPATH.search(data, pattern);
Am I doing something wrong? Wouldn't it make sense to treat the base station as a module like the other ones?

Code: Select all

{
  "body": {
    "devices": [
      {
        "_id": "70:ee:50:00:00:14",
        "co2_calibrating": false,
        "firmware": 91,
        "last_status_store": 1441872001,
        "last_upgrade": 1440507643,
        "module_name": "ind",
        "modules": [
          {
            "_id": "05:00:00:00:00:14",
            "module_name": "Pluie",
            "type": "NAModule3",
            "firmware": 91,
            "last_message": 1437990885,
            "last_seen": 1437990885,
            "rf_status": 40,
            "battery_vp": 4103,
            "dashboard_data": {
              "time_utc": 1437990885,
              "Rain": 0.101
            },
            "data_type": [
              "Rain"
            ]
          },
          {
            "_id": "03:00:00:00:00:14",
            "module_name": "Inter",
            "type": "NAModule4",
            "firmware": 91,
            "last_message": 1437991542,
            "last_seen": 1437991541,
            "rf_status": 72,
            "battery_vp": 44568,
            "dashboard_data": {
              "time_utc": 1437991550,
              "Noise": 10,
              "Temperature": 40.2,
              "Humidity": 23,
              "date_max_temp": 1437991547,
              "date_min_temp": 1437991549,
              "min_temp": -31.7,
              "max_temp": 46.9
            },
            "data_type": [
              "Temperature",
              "CO2",
              "Humidity"
            ]
          },
          {
            "_id": "02:00:00:00:00:14",
            "module_name": "out",
            "type": "NAModule1",
            "firmware": 91,
            "last_message": 1441872001,
            "last_seen": 1441868401,
            "rf_status": 143,
            "battery_vp": 31188,
            "dashboard_data": {
              "time_utc": 1441872001,
              "Temperature": 3.2,
              "Humidity": 60,
              "date_max_temp": 1441851001,
              "date_min_temp": 1441863001,
              "min_temp": -39.5,
              "max_temp": 79.5
            },
            "data_type": [
              "Temperature",
              "Humidity"
            ]
          },
          {
            "_id": "06:00:00:00:00:14",
            "module_name": "wind",
            "type": "NAModule2",
            "firmware": 91,
            "last_message": 1441872001,
            "last_seen": 1441868401,
            "rf_status": 143,
            "battery_vp": 31188,
            "dashboard_data": {
              "WindAngle": 155,
              "WindStrength": 25,
              "GustAngle": 156,
              "GustStrength": 35,
              "time_utc": 1441872001,
              "WindHistoric": [
                {
                  "WindStrength": 25,
                  "WindAngle": 155,
                  "time_utc": 1441868401
                },
                {
                  "WindStrength": 25,
                  "WindAngle": 155,
                  "time_utc": 1441869001
                },
                {
                  "WindStrength": 25,
                  "WindAngle": 155,
                  "time_utc": 1441869601
                },
                {
                  "WindStrength": 25,
                  "WindAngle": 155,
                  "time_utc": 1441870201
                },
                {
                  "WindStrength": 25,
                  "WindAngle": 155,
                  "time_utc": 1441870801
                },
                {
                  "WindStrength": 25,
                  "WindAngle": 155,
                  "time_utc": 1441871402
                },
                {
                  "WindStrength": 25,
                  "WindAngle": 155,
                  "time_utc": 1441872001
                }
              ],
              "date_max_wind_str": 1441836001,
              "max_wind_angle": 156,
              "max_wind_str": 35
            },
            "data_type": [
              "Wind"
            ]
          }
        ],
        "place": {
          "altitude": 30.478512648583,
          "city": "Saint-Denis",
          "country": "FR",
          "improveLocProposed": true,
          "location": [
            2.384033203125,
            48.936934954094
          ],
          "timezone": "Europe\/Paris"
        },
        "station_name": "Station",
        "type": "NAMain",
        "wifi_status": 109,
        "dashboard_data": {
          "AbsolutePressure": 929.4,
          "time_utc": 1441872001,
          "Noise": 110,
          "Temperature": 3.2,
          "Humidity": 60,
          "Pressure": 929.4,
          "CO2": 4852,
          "date_max_temp": 1441850941,
          "date_min_temp": 1441862941,
          "min_temp": -39.5,
          "max_temp": 79.5
        },
        "data_type": [
          "Temperature",
          "CO2",
          "Humidity",
          "Noise",
          "Pressure"
        ]
      }
    ],
    "user": {
      "mail": "toto@netatmo.com",
      "administrative": {
        "reg_locale": "en-US",
        "lang": "en-US",
        "unit": 1,
        "windunit": 1,
        "pressureunit": 1,
        "feel_like_algo": 1
      }
    }
  },
  "status": "ok",
  "time_exec": 0.36015892028809,
  "time_server": 1441872018
}
Last edited by lroguet on 31 Oct 2016, 10:30, edited 4 times in total.

lroguet
Posts: 8
Joined: 07 May 2016, 09:27
Location: Stockholm, Sweden
Contact:

Re: Amazon Echo, Alexa & response from the getstationsdata a

Post by lroguet » 07 May 2016, 10:01

To add to my previous post, just listing all names requires 2 patterns.

Code: Select all

function getSpeechForListDevicesIntent(data) {

    var pattern = "[ body.devices[].modules[].module_name, body.devices[].module_name ] | []";
    var result = JMESPATH.search(data, pattern);
    
    return "You can retrieve weather data from the following modules: " + result.join(", ") + ".";

}

Fawnlake1
Posts: 12
Joined: 22 Jan 2016, 12:20
Location: Stavanger, Norway

Re: Amazon Echo, Alexa & response from the getstationsdata a

Post by Fawnlake1 » 31 May 2016, 21:59

Hi,

I wish I could answer your query!, but I simply wanted to say that this is great and I really am anxious for this to work. We are a NetAtmo & Echo addicted expat family in Norway and look forward to seeing this in action... let me know if I could assist in any testing capacity.
Best regards \ Med vennlig hilsen,

Jeff

Sandnes, Norway
Proud owner of 2 Indoor Modules, Outdoor Module, Anemometer & Rain Gauge

lroguet
Posts: 8
Joined: 07 May 2016, 09:27
Location: Stockholm, Sweden
Contact:

Re: Amazon Echo, Alexa & response from the getstationsdata a

Post by lroguet » 14 Sep 2016, 14:57

Fawnlake1 wrote:Hi,

I wish I could answer your query!, but I simply wanted to say that this is great and I really am anxious for this to work. We are a NetAtmo & Echo addicted expat family in Norway and look forward to seeing this in action... let me know if I could assist in any testing capacity.
Just to inform you that the skill is pretty much completed (working at home for me) and is going through the certification process.

lroguet
Posts: 8
Joined: 07 May 2016, 09:27
Location: Stockholm, Sweden
Contact:

Re: Amazon Echo, Alexa & response from the getstationsdata a

Post by lroguet » 19 Sep 2016, 14:13

And it's now generally available in your Alexa companion app.

zuko3984
Posts: 5
Joined: 23 Oct 2016, 01:41

Re: Amazon Echo, Alexa & response from the getstationsdata a

Post by zuko3984 » 23 Oct 2016, 01:44

Having some trouble getting this to work. I enable the skill then it says i have to link my Netatmo account. every time i try to link my account i get an error message "Unable to link your skill Please try again later"
If i check in the user setting in my Netatmo account the Amazon Alexa weather station is listed under My Third Party Apps.
It just wont link the account in the alexa app.
Any idea what i can do to get this to work.

Thanks

Claire G
Posts: 27
Joined: 25 Jan 2016, 17:04

Re: Amazon Echo, Alexa & response from the getstationsdata a

Post by Claire G » 24 Oct 2016, 11:27

Hi there,

Thanks for posting in the forum, I'd be happy to help :)
Could you please let us know if your issue is happening with the Weather Station skill built by lrogut or the Thermostat skill (official Netatmo skill) available in the skill store?

Thanks!
Claire - Proudly part of the Netatmo Team

zuko3984
Posts: 5
Joined: 23 Oct 2016, 01:41

Re: Amazon Echo, Alexa & response from the getstationsdata a

Post by zuko3984 » 24 Oct 2016, 19:55

I'm having trouble with the skill built by lrogut. I have the weather station and the only official skill built by Netatmo is for the thermostat which i do not have.

thanks for any help.

zuko3984
Posts: 5
Joined: 23 Oct 2016, 01:41

Re: Amazon Echo, Alexa & response from the getstationsdata a

Post by zuko3984 » 24 Oct 2016, 23:21

Got it working. Had to use a regular computer to enable the skill and authorize it instead of doing it through the alexa app on my phone.

zuko3984
Posts: 5
Joined: 23 Oct 2016, 01:41

Re: Amazon Echo, Alexa & response from the getstationsdata a

Post by zuko3984 » 24 Oct 2016, 23:27

So it works now but when i ask for the temperature it gives me the temperature in Celsius but it calls it Fahrenheit. So for example it will say the temperature is 22.8 degrees Fahrenheit when the temperature is actually 73.04 Fahrenheit.

Post Reply

Return to “Voice assistants”