Home Assistant Integration

I've started working on a Home Assistant ( https://home-assistant.io/ ) integration to allow the control of devices in Home Assistant from NEEO. I've only just started working on it (got my NEEO yesterday) so the functionality is very limited at the moment, only lights/switches/scenes can be controlled.

Use It

You can find it here: https://github.com/jakeblatchford/neeo-homeassistant

There are instructions in the repository and auto-discovery should make the setup of devices quite easy once you have configured the integration.

I'll be adding support for more device types and fixing the issues listed on the project readme. I'd be grateful if anyone can spot any obvious solutions to the problems noted, I've not written any NodeJS for about 5 years so I'm a bit rusty. Pull requests are welcome.

Why?

If you're interested in why I'm working on this read on. I've ended up using Home Assistant to tie together a wide range of different home automation products. Over the last few years I've built up my home automation and tried lots of different products, as a result I now have Philips Hue, IKEA Tradfri and LIFX smart bulbs, a wide range of Zigbee and Z-Wave sensors/sockets, Z-Wave USB controller, SmartThings Hub, Hue Hub, Tradfri Hub, Amazon Alexa, Google Home and a number of DIY devices using MQTT.

Home Assistant has allowed me to centralise control of all these devices into one place, and most of my setup is controllable by voice using Google Home and Alexa via Home Assistant. This project aims to allow control of the exhaustive list of Home Assistant supported devices from NEEO without having to add all the devices directly to NEEO.

Jake

Reply
37replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Great stuff!

    I run everything through Home Assistant (control it will Amazon Echos, Google Home, HomeKit/Homebridge etc.) so definitely want to be able to use the NEEO to control some things in Home Assistant. I'll be giving this a try later 😃

    Reply Like 1
  • …so I've set it up and it's running well apart from some switches. Not sure if that's a problem with this driver/plugin or the NEEO itself (as the software is all pretty new).

    Anyway thanks again for this!

    Reply Like
    • Jono Hunt If you don't mind sharing the logs from the script (it's very verbose about what's going on at the moment) I can try and work out why your switches aren't working.

      Reply Like
      • Jono Hunt
      • Jono_Hunt
      • 1 yr ago
      • Reported - view

      Jake Blatchford Sure, where can I find them?

      Also, it's now saying 'ERROR! ENV is not setup, no HA_URL', even though I haven't changed anything. I checked the .env file and it still shows the correct info. I edited then re-saved the file (just in case) but still won't start anymore because of this error message.

      And it would be nice (easier to edit) if the .env file wasn't a hidden file 🙂

      Reply Like
    • Jono Hunt If you grabbed the latest version of the repository I updated the .env format so the environmental variable for the Home Assistant URL is now "HA_URL" rather than just "URL", take a look at .env-sample to see.

       

      You can also pass the environmental settings directly when running the script.

      On Linux / OS X

      # HA_URL='http://homeassistant.example.org' node index.js

      On Windows

      SET HA_URL=http://homeassistant.example.org
      node index.js
      

      The log is output directly to the terminal window that you run the script in, if you're using anything to manage that process it's possible those messages will be swallowed, although they should appear in the same place that you saw the "ERROR! ENV is not setup" message.

      I went with the .env as it's a common nodejs standard but I can understand it's a bit of a pain if you're not familiar, I might move the config into a js file for ease of use.

      Reply Like
  • Thanks. I couldn't get the version I downloaded yesterday to work anymore, so trashed it, downloaded again (same version I think) and now works.

     

    So first I tested a 'regular' smart switch I have in Home Assistant. I created a recipe in NEEO with a POWER_TOGGLE and this works fine. Tap the button and it turns the switch on, tap again and it switches it off.

     

    I created a couple more recipes in NEEO, one that did POWER ON for the same switch, and another recipe that did POWER OFF for that switch. Neither of these would work. The log appears to be exactly the same for both these, so here's one version

    ReferenceError: setBrightnessState is not defined
        at module.exports.onButtonPressed (/home/pi/node_modules/neeo-homeassistant/controller.js:57:7)
        at Object.module.exports.trigger (/home/pi/node_modules/neeo-homeassistant/node_modules/neeo-sdk/lib/device/handler/button.js:6:30)
        at checkForFunction.then (/home/pi/node_modules/neeo-homeassistant/node_modules/neeo-sdk/lib/device/handler/RequestHandler.js:57:27)
        at tryCatcher (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/util.js:16:23)
        at Promise._settlePromiseFromHandler (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/promise.js:512:31)
        at Promise._settlePromise (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/promise.js:569:18)
        at Promise._settlePromiseCtx (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/promise.js:606:10)
        at Async._drainQueue (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/async.js:138:12)
        at Async._drainQueues (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/async.js:143:10)
        at Immediate.Async.drainQueues (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/async.js:17:14)
        at runCallback (timers.js:789:20)
        at tryOnImmediate (timers.js:751:5)
        at processImmediate [as _immediateCallback] (timers.js:722:5)

     

    Then I have some 'non regular' switches setup in Home Assistant, ones that run different scenes depending on whether they're switched on or off. Here's an example

    switch:
        living_room_lights:
          value_template: "{{ is_state('living_room_lights', 'on') }}"
          turn_on:
            - service: scene.turn_on
              entity_id: scene.living_room_lights_on
          turn_off:
            - service: scene.turn_on
              entity_id: scene.living_room_lights_off

     

    Again I created a POWER_TOGGLE recipe in NEEO. This worked at turning on the switch (activating 'scene.living_room_lights_on' in Home Assistant), but pressing again didn't turn off the switch (activate 'scene.living_room_lights_off').

    The log for toggling both times appears exactly the same (even though turning the switch on worked and turning the switch off didn't)

    calling service switch on entity switch.lounge_lights with action toggle
    Using options { method: 'POST',
      uri: 'https://MY_URL.duckdns.org/api/services/switch/toggle',
      body: { entity_id: 'switch.lounge_lights' },
      json: true,
      headers: { 'x-ha-access': 'HA_PASSWORD' } }
    service call successful
    

     

    I also created POWER ON and POWER OFF recipes for the same switch I have in Home Assistant and neither of these would work. Here's the log for those (both the same)

    ReferenceError: setBrightnessState is not defined
        at module.exports.onButtonPressed (/home/pi/node_modules/neeo-homeassistant/controller.js:54:7)
        at Object.module.exports.trigger (/home/pi/node_modules/neeo-homeassistant/node_modules/neeo-sdk/lib/device/handler/button.js:6:30)
        at checkForFunction.then (/home/pi/node_modules/neeo-homeassistant/node_modules/neeo-sdk/lib/device/handler/RequestHandler.js:57:27)
        at tryCatcher (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/util.js:16:23)
        at Promise._settlePromiseFromHandler (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/promise.js:512:31)
        at Promise._settlePromise (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/promise.js:569:18)
        at Promise._settlePromiseCtx (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/promise.js:606:10)
        at Async._drainQueue (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/async.js:138:12)
        at Async._drainQueues (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/async.js:143:10)
        at Immediate.Async.drainQueues (/home/pi/node_modules/neeo-homeassistant/node_modules/bluebird/js/release/async.js:17:14)
        at runCallback (timers.js:789:20)
        at tryOnImmediate (timers.js:751:5)
        at processImmediate [as _immediateCallback] (timers.js:722:5)
    Reply Like
    • Jono Hunt Ah I see what the problem is, I rearranged some things and forgot to update something. I've just pushed the fix up to github so your POWER ON / POWER OFF should work now.

      For your 'non regular' switch i'm not sure what to suggest for the toggle function as it just asks Home Assistant to toggle the state. As above the buttons specifically for ON/OFF should work now though.

      Reply Like
    • Jono Hunt how an earth did you get it running? i've install the dependencies and get an error in the neo-SDK

      /home/jamie/Neeo/node_modules/neeo-sdk/lib/device/brain/urlbuilder.js:6
      module.exports.buildBrainUrl = function(brain, baseUrl, brainport = DEFAULT_BRAIN_PORT) {
                                                                                                                 ^

      Reply Like
      • Jono Hunt
      • Jono_Hunt
      • 10 mths ago
      • Reported - view

      Jamie Burgess I installed the NEEO SDK Drivers from here https://planet.neeo.com/t/18kj94/howto-use-sdk-drivers-with-rasberrypi

      And then installed neeo-homeassistant with the instructions on the GitHub page.

       

      I installed it all under my pi user folder at /home/pi/ not the Home Assistant folder at /home/homeassistant/.homeassistant/

       

      Try making the path all lowercase (so /home/jamie/neeo/node_modules/neeo-sdk/lib/device/brain/, not /home/jamie/Neeo/node_modules/neeo-sdk/lib/device/brain/). And I take it you filled out your Home Assistant details in the .env file?

      Reply Like
    • yep - was the requirement to use Nodejs 6.x and above :/

      Reply Like
  • Yep that's fixed it now, thanks!

     

    Not to worry about the 'non regular' switches, I can live with them as they are 🙂

    Reply Like
  • …BTW, maybe you should add this to this page and this document.

    Reply Like
    • Jono Hunt I'd already added it to the document but not posted about it, done that now :)

      Reply Like 1
  • Jake Blatchford

    I tried to install to install your Home Assistant integration of Neeo and I'm getting the following error:

    (hass_venv) hass@kpi:~/.homeassistant/neeo-homeassistant$ node index.js
    /home/hass/.homeassistant/neeo-homeassistant/node_modules/neeo-sdk/lib/device/brain/urlbuilder.js:6
    module.exports.buildBrainUrl = function(brain, baseUrl, brainport = DEFAULT_BRAIN_PORT) {
                                                                      ^

    SyntaxError: Unexpected token =
        at exports.runInThisContext (vm.js:53:16)
        at Module._compile (module.js:373:25)
        at Object.Module._extensions..js (module.js:416:10)
        at Module.load (module.js:343:32)
        at Function.Module._load (module.js:300:12)
        at Module.require (module.js:353:17)
        at require (internal/module.js:12:17)
        at Object.<anonymous> (/home/hass/.homeassistant/neeo-homeassistant/node_modules/neeo-sdk/lib/recipe/index.js:7:20)
        at Module._compile (module.js:409:26)
        at Object.Module._extensions..js (module.js:416:10)
        at Module.load (module.js:343:32)
        at Function.Module._load (module.js:300:12)
        at Module.require (module.js:353:17)
        at require (internal/module.js:12:17)
        at Object.<anonymous> (/home/hass/.homeassistant/neeo-homeassistant/node_modules/neeo-sdk/lib/index.js:4:17)
        at Module._compile (module.js:409:26)
    (hass_venv) hass@kpi:~/.homeassistant/neeo-homeassistant$ hass --version
    0.54.0

    I don't know javascript so I have no idea what this means.  I installed the repo in my home assistant directory and ran "npm install" as the hass user with no errors.  I setup the .env file with my password and URL to HA.  I do use https on a non-standard port for HA so I'm not sure if that is part of the problem.

    Any assistance would be greatly appreciated.

    Galen Krokum

    Reply Like 1
    • Galen Krokum same issue- any resolution?

      Reply Like
  • Jake Blatchford Thank you! It works perfectly!

    Reply Like
  • I have a problem with this 😐

     

    It stopped working (error message: 'ERROR! ENV is not setup, no HA_URL'), so I trashed everything and then reinstalled from scratch. After reinstalling it worked fine…

    until I rebooted the RPi running it. At first it appeared fine:

    - discover one NEEO Brain...
    - Brain discovered: NEEO Lounge
    - Start server
    # READY! use the NEEO app to search for "Home Assistant".

     

    But after sending a command through NEEO to Home Assistant it stopped in Terminal with the same error message as before:

    ERROR! ENV is not setup, no HA_URL

     

    I checked the .env file and haven't changed anything since it was working previously (same HA_URL as before). Any idea how to fix this?

    Reply Like
    • Jono Hunt Have you re-run

      npm install

      since you started from scratch?

      Reply Like
      • Jono Hunt
      • Jono_Hunt
      • 11 mths ago
      • Reported - view

      Jake Blatchford Yes I have.

      In fact I've found that once the error occurs, if I delete the 'node_modules' folder that's created after running npm install originally. Then run npm install again (which recreates that folder, sub-folders and files), and then run node index.js it works again for me for a while.

      Reply Like
  • Yes, you HERO! Just ordered and have everything in HASS

    Reply Like
  • hey folks, just getting round to installing this - got 2 questions:

     1. not overly familiar with terminal, can someone help with installation (i mean i've managed to set up an advance HA set up, just not comfortable with the underlying OS)

    2. What is your best practice for exposing devices to NEEO - do you surface everything, or, do you create a bunch of scripts/scenes and just expose those to NEEO (seems a common challenge with exposing to top tier interfaces (floorplan, alexa etc)

    Reply Like
      • Jono Hunt
      • Jono_Hunt
      • 10 mths ago
      • 1
      • Reported - view

      Jamie Burgess For adding items to NEEO from Home Assistant I just added a few scripts, scenes etc. and created some recipes to run them (if I remember correctly).

      Reply Like 1
  • Does no one else have this problem? Still happens every time after my Raspberry Pi has been rebooted

    Always have to delete the folder at '/home/pi/node_modules/_neeo-homeassistant/node_modules', then run 'npm install' again to get it working.
     

    It's a shame, as it's really useful when it works 🙂

    Reply Like
      • Derek G
      • Derek_G
      • 9 mths ago
      • Reported - view

      Jono Hunt Did you set the variable in the .env file? The .env (which is hidden) should have a single line in it that shows:

      HA_URL=http://ipaddress.of.rasp.pi:8123

      If not, while in the '/home/pi/node_modules/_neeo-homeassistant/ ' directory, type:

      sudo nano .env

      Then hit [return] and enter or edit the HA_URL line above with the correct IP Address of your Raspberry Pi. 

      If you have already configured the .env file, make sure your Raspberry Pi isn't grabbing another IP Address after you're rebooting it. It should obviously be what you have listed in the .env file. (aka, make sure your Raspberry Pi is using a static IP, not a dynamic IP). To confirm the IP Address of the Raspberry Pi, type:

      ifconfig

      in your terminal session and see what is listed. All the above should do the trick!

      Reply Like
      • Jono Hunt
      • Jono_Hunt
      • 9 mths ago
      • Reported - view

      Derek G Yeah, I added my pi's URL in the .env file when I originally set it up (and haven't changed it).

      When I start it, it does run fine for a while, but any time I reboot the pi I get this problem. I can fix it for a while (as I said above) by deleting the folder at '/home/pi/node_modules/_neeo-homeassistant/node_modules', then running 'npm install' again. But every time I reboot I get the same problem 😐

      Reply Like
      • Derek G
      • Derek_G
      • 9 mths ago
      • Reported - view

      Jono Hunt It still sounds to me that it could be the static vs dynamic IP address. If you have a dynamic IP address, when you reboot the Pi it could grab a new (different) IP, which in turn would cause your .env file to be wrong.

      I understand you haven't changed the .env file since you set it up, but that's my point - if your Pi's IP address changed after the reboot, you have to change the .env file.

       

      Is your Raspberry Pi using a static IP address?

      (if you didn't manually set it as static, the answer is 'no' and it will be using dynamic). If that's the case, I can assist you setting it as static and then we can fix the .env without having to reinstall. Just let me know.

      Reply Like
      • Jono Hunt
      • Jono_Hunt
      • 9 mths ago
      • Reported - view

      Derek G Yeah, it has a static IP address, but I use a DuckDNS URL (https://MY_URL.duckdns.org) in the .env file.

      Maybe I should try using the static IP address instead of the DuckDNS URL? 🙂

      Reply Like
    • Jono Hunt yeah use the local IP. Also no need for the extra round trip.

       

      double check the permissions of the env file can be read by NEEO. And that something else isn’t updating it and locking it. Chown to the NEEO user you are running it as (depending if you are using systems or not)

      Reply Like
      • Derek G
      • Derek_G
      • 9 mths ago
      • Reported - view

      Jono Hunt Exactly what  Jamie Burgess said with regards to the external (DuckDNS) URL. Essentially you're telling the .env file to go out into the internet and then back into your house, no need for that. Keep it local using your internal IP address.

      Again, to find the IP Address of your Raspberry Pi, just type:

      ifconfig

      While connected via SSH. Then look for the "inet" number (should be either a 192.168.x.x or 10.0.x.x number). 

      Then plug that number into the .env file. It should look something like this:

      HA_URL=http://ipaddress.of.rasp.pi:8123

      Try that and then run node again to see if it gives an error.

      Reply Like
  • Thanks guys. I've tried a few variations using the static IP address of my pi (http://192.168.0.30:8123, http://192.168.0.30 , https://192.168.0.30:8123 , https://192.168.0.30 etc.).

    It wouldn't authenticate when just using the http URLs, and when trying the https URLs it gave errors saying that the SSL certificate (through Let's Encrypt) wasn't valid for that address (presumably as it's only valid for my DuckDNS URL).
     

    So I trashed  everything and started again. I installed Node.js 8 (was previously using 6), the NEEO SDK and neeo-homeassistant from scratch. And now managed to get it working with my DuckDNS URL, and no problems/crashes after restarting the pi.

    Maybe it didn't like the older version of Node.js I was using, and hopefully updating the NEEO SDK has helped. Anyway, I'm keeping my fingers crossed 🙂


    Out of interest how is everyone auto-starting neeo-homeassistant after Raspberry Pi reboots?

     

    Edit:
    Spoke too soon. Just rebooted the pi and getting the same error with neeo-homeassistant as before 😐

    Reply Like
      • Derek G
      • Derek_G
      • 9 mths ago
      • Reported - view

      Jono Hunt  

      I am using Node 6 with no issues, so that isn't it. I still think its with the .env, so let's dig deeper...

       

      1. How are you editing the .env file? (step by step - not just "Im editing in terminal" or similar)

      2. Post a screenshot of your .env file. 

      3. Why do you constantly reboot your Pi? Is there some app that requires this?

      Reply Like
      • Jono Hunt
      • Jono_Hunt
      • 9 mths ago
      • Reported - view

      Derek G I'm hoping I was being premature, as it now seems fine again.

      I'm now thinking one of the problems I've had is with then NEEO Brain and maybe not neeo-homeassistant. I was experiencing different errors this morning in macOS Terminal (where I'm activating neeo-homeassistant from to start running on the pi). I rebooted the NEEO Brain and now seems fine again (the brain and remote do seem to need rebooting now and then as the firmware doesn't seem rock solid yet).

       

      Derek G said:
      Why do you constantly reboot your Pi? Is there some app that requires this?

      I don't normally reboot often, but as I experienced the problems with neeo-homeassistant after restarting Home Assistant or rebooting the Raspberry Pi in the past I've been doing it when trying to troubleshoot this problem to see if it still happens again 😊

      Reply Like
  • …I don't suppose anyone made a Docker image of this did they?

    I seem to have better luck/experience running things in Docker containers if I've had problems in the past 🤓

    Reply Like
    • Jono Hunt you are in luck! :)

      This is my docker file. Place it with the other files of the integration

      FROM node:9.4.0
      RUN mkdir -p /usr/src/app
      WORKDIR /usr/src/app
      
      COPY package.json /usr/src/app
      RUN npm install
      
      COPY controller.js /usr/src/app
      COPY haservice.js /usr/src/app
      COPY index.js /usr/src/app
      CMD node index.js

      and this is my compose config

        ha-neeo-proxy:
          build: ./ha-neeo-proxy/neeo-homeassistant
          container_name: "ha-neeo-proxy"
          restart: always
          network_mode: "host"
          environment:
            - TZ=Europe/Stockholm
            - HA_URL=[url-to-ha-with-port]
            - HA_PASSWORD=[ha-password]
            - BRAINIP=[ip-to-brain]
          ports:
            - "6336:6336"

       

      Remember to conf the environment variables and to input the correct folder for the build folder (same folder where your docker file is)

      Reply Like 1
      • Jono Hunt
      • Jono_Hunt
      • 8 mths ago
      • Reported - view

      Anders Liljekvist Great, thanks a lot! I'll give this a try, see if I can get it running 👍

       

      Edit: Got it running and it’s working well. Thanks again!

      Reply Like
  • Since version 0.80 of HA the discovery of devices does not work anymore. Maybe a change in the API?

    Reply Like
reply to topic
Like12 Follow