Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Alexa Skill (for not only switching lights)


Alex

Question

Between the years I had some few seconds to learn about NodeJS, Alexa Skills and Fibaro API.

 

I was able to create a Skill for Alexa to communicate with Fibaro HC2 (HCL should work also).

For now it is written and configured for German language but can easily adopted to any other language.

 

Disadvantages so far:

The Fibaro Box must be available via internet by any port forwarded to HTTP port 80 only (unless you are creating a proxy in between). Dyndns and IPv4 are useful...

The skill cannot get certificated and set up easily.

For using it an Alexa Skill must be created manually and the code and all other options (like intents list, custom slots and utterances) must be pasted manually.

Some smaller changes in the code is needed too (abbreviations, url, port, authentication).

Also Alexa is responding only after asking for the keyword (like fibaro, house ore something like this). While using the Alexa Smart Home Skill it is not possible to have more usage than other already existing skills (like HABridge).

 

 

Advantages/Possibilities (just some examples):

- You are able to set temperature for a special period of time

- You can get and set status of global variables

- You can change up to two lights at once or all lights in one or two rooms at once

- You can call scenes

- You can get status information about open/closed doors, open/closed windows, bot at once, turned on lights

- Status information about wall plugs (turned on or off and power consumption)

- Change roller shutters status (with proper words like shut down instead of shut off).

 

If anybody might be interested he can ask me for the code.

I am going to publish it somewhere (maybe Github) in the next days if anybody else might get interested in this.

 

Also code is still not perfect. There might be a couple of bugs and it might get written better.

But it was my first time I was writing anything for Alexa and with Nodejs (don't know why I have chosen this language).

 

Also I would like to know some more ideas what could be done additional.

Also I am interested if anybody has some improvements (like communicating via home.fibaro.com).

 

 

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • I will post it tomorrow (hope I will find some time).

    But you can already start configuration.

    An AWS account will be needed.

     

    There you must create a custom skill and name it however you want.

    Next step would be to create an empty lambda function:

    Please login or register to see this link.

    Also you have to set up a dyndns account and port forwarding to your fibaro controller.

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Feel free to edit it, use it, improve it:

    Please login or register to see this link.

     

    I am glad if anybody is willing to help me with this.

    Link to comment
    Share on other sites

    • 0

    The topic has been moved from "

    Please login or register to see this link.

    " to "

    Please login or register to see this link.

    ".

     

    Temat został przeniesiony z "

    Please login or register to see this link.

    " do "

    Please login or register to see this link.

    ".

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Sorry you are right, I forgot something to update ;)

    Link to comment
    Share on other sites

    • 0

    Hi Alex, i am not sure if i have configured something wrong. but when i test with AWS developer tool and call something like "Turn EntranceLight on" it appears to always be sending the turnOff command. and the json response is saying :

     

    your help on this would be very much appreciated.

     

          "name": "SwitchIntent",
          "slots": {
            "Status": {
              "name": "Status",
              "value": "turn on"
            },
            "Device": {
              "name": "Device",
              "value": "entranceLight"
            },
            "Yesno": {
              "name": "Yesno"

     

    2017-02-12T15:34:27.958Z bd600d07-f138-11e6-a07f-dd9e860771c1 Called getJsonDataFromFibaro
    2017-02-12T15:34:29.100Z bd600d07-f138-11e6-a07f-dd9e860771c1 Result: [{"id":20,"name":"Dining Light","roomID":1,"type":"com.fibaro.multilevelSwitch","baseType":"com.fibaro.binarySwitch","enabled":true,"visible":true,"isPlugin":false,"parentId":69,"remoteGatewayId":0,"viewXml":false,"configXml":false,"interfaces":["deviceGrouping","fibaroFirmwareUpdate","levelChange","light","power","zwave","zwave
    2017-02-12T15:34:29.101Z bd600d07-f138-11e6-a07f-dd9e860771c1 Sending HTTP request to: /api/callAction?deviceID=148&name=turnOff

    Edited by chrisdunn43
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • There is a small bug in the english slot file named "slot_toggles.txt".

    The "value" at "Status" should be "on" only, without the "turn".

    Can you remove all the "turn*", "switch*" and "move*" words? This should help.

     

    Edited by Alex
    Link to comment
    Share on other sites

    • 0

    Hi Alex, I ended up updating the Toggles with just on and off and had the same outcome. After looking at index.js and outputting to console statusValue is being returned as "on" and the if statement below on line 871 says  if (statusValue==STATE_RESPONSES.On)    when i changed this to  if (statusValue=="on") it will then work and turn on light and by default your code will set turnoff as default.

     

    I appreciate any assistance to see what could be causing my issue

     

    this is the request being sent when using statusValue==STATE_RESPONSES.On {
      "session": {
        "sessionId": "SessionId.1bd58cc7-8822-4298-b25b-dc38839e9f43",
        "application": {
          "applicationId": "amzn1.ask.skill.c25f29ad-d208-4995-bf7b-ef77c396bac6"
        },
        "attributes": {},
        "user": {
          "userId": "amzn1.ask.account.AFVCM3UCZIBZQDP6LQQSDJNUIW73CKJE7V2YCMDUS7GO5QV4SULJKXV7AKRIIATYNLXZDE55FERRWSEV4MF5JFQC7AEDQMJO2ZSDRFGPSPR45BOHDEW6IW2NCPJ6AAGSDXS7CH5LAUKJHONKMQGPXDM2QBVLVNHSGX5J3QWIQZ7EA34AFDL4FPR7OVULTVXHNU47R2M43A2X7TA"
        },
        "new": false
      },
      "request": {
        "type": "IntentRequest",
        "requestId": "EdwRequestId.e7d72ceb-8838-474a-b270-795ff1dc69c8",
        "locale": "en-US",
        "timestamp": "2017-02-15T14:28:15Z",
        "intent": {
          "name": "SwitchIntent",
          "slots": {
            "Status": {
              "name": "Status",
              "value": "on"
            },
            "Device": {
              "name": "Device",
              "value": "entranceLight"
            },
            "Yesno": {
              "name": "Yesno"
            }
          }
        }
      },
      "version": "1.0"
    }

     

     

     

     

    and the response

     

    {
      "version": "1.0",
      "response": {
        "outputSpeech": {
          "type": "PlainText",
          "text": "Device switched off."
        },
        "reprompt": {
          "outputSpeech": {
            "type": "PlainText",
            "text": "Pleae tell me what to do or ask me a question."
          }
        },
        "shouldEndSession": false
      },
      "sessionAttributes": {}
    }

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Thanks for showing this.

    There will be a fix in Github in a couple of minutes.

    This is just a case sensitive bug at this place, I forgot it there.

    Also I did not find this because in German language file I am using "on", the English one has it written as "On".

     

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...