GithubHelp home page GithubHelp logo

johnvey / smartthings-hd-powerview Goto Github PK

View Code? Open in Web Editor NEW
15.0 7.0 47.0 412 KB

Hunter Douglas PowerView bridge for SmartThings

License: GNU General Public License v3.0

Groovy 100.00%
smartthings hunter-douglas-blinds iot http

smartthings-hd-powerview's Introduction

Hunter Douglas PowerView Hub bridge for SmartThings

Overview

This project implements a SmartApp and device handlers to allow you to directly communicate with the PowerView hub on your local network and do the following:

  • auto-discover registered shades
  • auto-discover configured scenes
  • set/monitor the shade level
  • set/monitor the vanes level
  • monitor battery level
  • execute scenes

The benefit of using this is that there is no requirement for the default PowerView Account web service or other middlemen like IFTTT--your SmartThings hub will communicate directly with the PowerView hub. Note: due to the way SmartThings works, a connection to the ST cloud is still required.

This project currently does not support:

  • reading/editing rooms
  • modifying schedules set in PV
  • editing scenes
  • reading/editing scene collections
  • managing PowerView Connect settings

This is primarily for Hunter Douglas Silhouette shades so there is both the vane and shade control. Other shades will likely work, though there will be extraneous functionality that may throw errors. Relying on scenes is likely the easiest way forward in this case.

Screenshots

The shade control panel. Note that the primary action (top circle) is for toggling the vanes on and off. The brightness control is for the shade. The device handler should refresh its state every minute in the background. The "refresh" tile is there if you need to know the state immediately.

screen1

The scene control panel. This is implemented as a momentary switch and there is no state tracking info, i.e., the "Recently" tab will always be empty.

screen1

Installation

This requires you to log in to the SmartThings web-based IDE to add a custom SmartApp and two custom device handlers.

  1. Register the following custom components (see tutorial for SmartApps and device handlers):

    1. Install the Hunter Douglas PowerView SmartApp from this repo: owner=johnvey, name=smartthings-hd-powerview, branch=master
    2. Install the Hunter Douglas PowerView Shade device handler from this repo
    3. Install the Hunter Douglas PowerView Scene device handler from this repo
  2. Add the newly registered SmartApp via Automation > SmartApps > Add a SmartApp > My Apps section

  3. Open the app

    screen1

  4. Enter the IP address of your PowerView hub, click "Done"

    screen1

  5. Wait for the app to discover your shades and scenes

    screen1 screen1

  6. Choose the shades you want to control via SmartThings

    screen1

  7. Choose the scenes you want to control via SmartThings

    screen1

Implementation Details

The PowerView hub is a very simple HTTP server. I've documented the API that I've been able to sniff from a hub at Rev. 1, SubRev. 1, Build 847:

Hunter Douglas PowerView HTTP API

The structure of this SmartThings handler is:

  • 1 SmartApp that handles the initial setup and discovery of the connected shades and configured scenes
  • 1 device handler instance for each shade
  • 1 device handler instance for each scene

Gen 2 hub compatibility

Some updates have been made that makes portions of this work with a gen 2 hub. Further investigations are still required to confirm full compatibility. See the Github issue for details.

SmartThings Programming Errata

Programming these handlers was markedly cumbersome due to the poor quality of the documentation. Here are some tips that I wish I knew before I had started:

Tip 1: There are several incantations to have your ST hub communicate directly with a device on your LAN.

This is the most reliable method that I had found:

  1. instantiate your own HubAction() instance
  2. use the HubAction(map requestConfig, string deviceID, map options) signature
  3. provide an explicit callback function if you need to parse the response
  4. use a unique identifier for the device ID, not some kind of hash of the MAC address (the official docs cover this multiple times but the forums are rife with misinformation)
sendRequest(method, path, body=null, callbackFn=null) {
    def host = '192.168.1.123:4567'
    def contentType = 'application/json'
    def deviceId = '18d11666-14de-4a46-9492-86a147ef0e3b'
    def hubAction = new physicalgraph.device.HubAction(
        [
            method: method,
            path: path,
            HOST: host,
            headers: [
                'HOST': host, // yes, it is required here and above
                'Content-Type': contentType
            ],
            body: body
        ],
        deviceId,
        [
            callback: callbackFn
        ]
    )
    log.debug("sendRequest: ${method} ${host}${path}")
    return hubAction
}

Note that this implementation generally requires that you invoke this from a device event, i.e., if the ST framework was the caller that initiated this invocation somewhere up in your call tree. If you decide to invoke this via a timer, e.g. runEvery1Minute(), then you must invoke via the sendHubCommand() method. See example.

Tip 2: If you are connecting your GitHub project directly to the ST IDE, make sure your source code file name matches the name field in the metadata declaration exactly.

If you fail to do this, attempting to use the "Update from repo" functionality will fail with no further explanation. Official doc mention.

Tip 3: Direct embed of a dynamicPage() inside of the top-level preferences() block for a SmartApp doesn't work.

Instead of something like

preferences {
    dynamicPage(...)
}

use a separate function like:

preferences {
    page(name: "singlePagePref")
}
def singlePagePref() {
    return dynamicPage() {...}
}

Tip 4: You can use many of the other Groovy language features.

You can use import to bring in other functionality that makes programming in ST more palatable. For example, I wanted to declare a top-scope "enum", but ran into the sandboxing that ST uses via a class wrapper around your SmartApp. The solution to this was to use the @Field decorator to effectively hoist my defs out of the default scope.

smartthings-hd-powerview's People

Contributors

johnvey avatar rossc719g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

smartthings-hd-powerview's Issues

Alexa can't set variable brightness on shades

@johnvey, thanks for the PowerView integration. I am able to control individual shade from ST to Alexa. However, I notice Alexa can not set the % of how high or low the shade will be. It will open and close fully by saying “Turn on and off” with Alexa. However, saying “Set shades to 40%” will have no result. Is there something else I need to do for Alexa to control the % of opening and closing of the shades?

Originally: https://community.smartthings.com/t/release-hunter-douglas-powerview-hub-integration/105388/69

Something Went Wrong Error

Hi, I followed your instructions and installed the SmartApp and Device Handler on my SmartThing account. When I try to add the App on my mobile device, the App does find the Hub and also shows all the "Available Shades" and "Linked Scenes", however the "Scene Collections" does not show anything and it shows "Searching for installed scene collections..". When I try to click on "Done" then the App shows an error "Something went wrong. Please try to install the SmartApp again"

I am using the latest SmartThings App. Can you give me some guidance on what I may be doing wrong?

Thank you,

Kia

Shades not displaying the correct open/close position.

All the shades (no matter they are open or close with the ST) will show V. Closed. The way it shows open or close is by looking at the %. It will show 100% (the main screen still show V. Closed) when it is opened and 0% when it is closed, is it the way it supposed to work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.