Connected Devices/QA/Tips and Tricks
Contents
- 1 Hardware devices
- 2 Programming language
- 3 Projects
- 3.1 Project Link
- 3.2 Project Vaani
- 3.2.1 Dev environment on mac
- 3.2.1.1 Prerequisites
- 3.2.1.2 Vaani version OpenHAB
- 3.2.1.2.1 OpenHAB background info
- 3.2.1.2.2 IDE setup
- 3.2.1.2.3 Troubleshooting Errors
- 3.2.1.2.3.1 Issues with CodeHaus downloads
- 3.2.1.2.3.2 Plugin execution not covered by lifecycle configuration: org.eclipse.tycho
- 3.2.1.2.3.3 Project 'org.openhab.binding.smarthomatic' is missing required source folder: 'src-gen/main/java'
- 3.2.1.2.3.4 The import with org.openhab.binding.smarthomatic.internal.packetData cannot be resolved
- 3.2.1.2.3.5 Missing Constraint: Import-Package: org.eclipse.smarthome.io.voice.tts; version="0.0.0"
- 3.2.1.2.4 setting up pocketsphinx with OpenHAB
- 3.2.1.2.5 Building smarthome
- 3.2.1.2.6 Building OpenHAB distributions
- 3.2.2 Misc setup
- 3.2.1 Dev environment on mac
- 3.3 Project Sensor Web
- 3.4 Project Smart Home
- 3.5 Project SmartTV
- 3.6 Project WebVR
- 3.7 Project Flyweb
- 4 Misc Info Resources
Hardware devices
Hue
NOTE:
- currently only the colored lights works with link project
- A19 has 2 different bulb types, Lux and one that states white & colored. Lux is white and dimmable only.
- be sure to get the 2nd generation (should be 1st generation compatible) ie. Philips 456194 Hue White and Color Ambiance Starter Kit, A19 Starter, Standard Packaging
- There's another white only kit, don't get that one yet. ($75 w/ 2 bulbs)
- The hubs from both the Color kit and the white only are the same hub models. You can get a colored light to work on the white starter package. If you get the wrong kit, you just need to get the right bulb.
setup
- be sure to download the app on your iphone or android device and setup the hub.
adding a new light
- on the iphone : -> go to settings -> my lights -> +connect new lights.
- Make sure the light is near the Hue Hub; ZigBee spec for linking is that the devices need to be within 30 centimeters of the hub.
Raspberry Pi 2
- Highly recommended to have a heatsink for your raspberry pi. Certain Raspberry Pi sets such as complete kits from Vilros will include heat sinks.
Version Check
Make sure you are on jessie and not wheezy; you can do this by :
more /etc/apt/sources.list
- If you see wheezy, then it's wheezy. If it says jessie somewhere, then it's jessie.
Upgrading from Wheezy
There's 2 ways :
1. let the system upgrade:
sudo nano /etc/apt/sources.list change wheezy with jessie sudo apt-get update && sudo apt-get dist-upgrade
2. reinstall the OS. There's 2 ways to do this. NOOBs or using an image; NOOBs is probably easier for most people.
- If you're going to do this on a mac, I suggest using Apple-Pi Baker:
- if you reformat the card, make sure you use FAT16, or FAT32; 64 MB or higher might end up formatting in exFAT which won't work; it also has to be formatted to have a bootable MBR (Master boot record)
- Note : Apple-Pi Baker will format like this with the format button so you don't have to worry about making these settings; SDFormatter won't by default
Steps for install
One and Done task : https://oneanddone.mozilla.org/tasks/158/
post install
Make sure your libs are up to date
sudo apt-get update && sudo apt-get dist-upgrade
setting a password
You may also want to set a password on the device, if the noobs didn't ask for you to set one up: Menu -> preferences -> Raspberry Pi Configuration -> Password The user would be Pi
Reseting the Device
One and Done task : https://oneanddone.mozilla.org/tasks/160/
- tip: if you have a Mac and Apple-Pi-Baker, you can backup your image from the SDcard, and then restore from a frozen build which might be better than having to setup from scratch.
Raspberry Pi 3
See Raspberry Pi 2 section.
Programming language
Rust
uninstall any previous instances of rust
- sudo /usr/local/lib/rustlib/uninstall.sh
installing multirust
git clone https://github.com/brson/multirust ./build.sh sudo ./install.sh multirust default stable multirust update multirust override nightly-2016-03-07 multirust default nightly-2016-03-07
- First time use doesn't work without setting a default
- foxbox won't compile using stable.
- override will over ride to a build
- default will make it the default build
creating rust so that it cross compiles on pi:
choice 1
- you most likely don't have to do this, using fabrice's tool is probably better
git clone https://github.com/raspberrypi/tools.git ~/Projects/pi-tools export PATH=~/Projects/pi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:$PATH git clone http://github.com/rust-lang/rust.git cd rust rustc -V git reset --hard 998a6720b sudo ./configure --target=armv7-unknown-linux-gnueabihf --prefix=$HOME/Projects/pi-rust && make && make install
Choice 2: the better choice
- Use ubuntu 15.10 ; doesn't seem to work on 14.10?
- git clone https://github.com/fabricedesre/rustpi2
- read and follow : https://github.com/fabricedesre/rustpi2#usage
Projects
Project Link
Using a Fabrice Build
- Raspberry pi needs a lib updated : sudo apt-get install libupnp-dev
- use a browser and download a build : builds can be downloaded from here : https://people.mozilla.org/~fdesre/foxbox/
- after downloading the build, extract it and run ./foxbox
Compiling
- Compiling for the Raspberry pi requires cross compilation to the raspberry pi.
- it's recommended to use a Ubuntu 15.10 for now if you're going to compile for yourself
REST API
Https is turned on now, the following will only work for regular http. To turn https off, make sure you supply with --disable-tls parameter when running foxbox.
check to see if it's up :
curl -X GET --url http://<ipaddress of machine with foxbox>:3000 --head
create an account:
curl -X POST -d @credentials.txt http://localhost:3000/users/setup
The credentials.txt should be a text file that contains the following format:
{ "email":"<email address>" "username":"<username>" "password":"<password>" }
Note: Make sure to use double quotes and not single quotes.
logging in:
- NOTE: you can encode the <user>:<password> here : http://www.opinionatedgeek.com/dotnet/tools/base64encode/
- be sure to include the :
curl -X POST -H "Authorization: Basic <<64bit encoding of <user>:<password>>" http://192.168.1.102:3000/users/login
Listing Device services available :
curl -X GET -H "Authorization: Bearer <token result from logging in>" http://192.168.1.102:3000/services/list
This would also give you a list of devices and the device id.
Device State
Get the state of a Hue bulb : curl -X GET -H "Authorization: Bearer <token>" http://192.168.1.102:3000/services/<device id>/state
Change State of the Device
curl -X PUT -H "Authorization: Bearer <token>" http://192.168.1.102:3000/services/<device id>/state -d <json of change of state> ex. for Hue: curl -X PUT -H "Authorization: Bearer <token>" http://192.168.1.102:3000/services/<device id>/state -d '{"on":"false"}'
For Hue:
- red : '{"on":true, "hue":0, "sat":1, "val":0.5}'
- greenish (not very green) : '{"on":true, "hue":120, "sat":1, "val":0.5}'
- blue : '{"on":true, "hue":240, "sat":1, "val":0.5}'
- off : '{"on":false}'
Note:
- it's using HSL, here's an online hslpicker: http://hslpicker.com/
- ignore the last value a, as the light doesn't use it at this time. ie keep the value of A on the website at 1. val = value and is synonymous to lightness. See wiki for background : https://en.wikipedia.org/wiki/HSL_and_HSV
Project Vaani
Dev environment on mac
Prerequisites
installing homebrew on mac
- see instructions at http://brew.sh/
Installing Maven on Mac
brew install maven
Installing Gradle on Mac
brew install gradle
installing bison on mac
brew install bison
installing swig on mac
Note: you can probably skip this step as it's done in the pocketsphinx script : https://github.com/mozilla/smarthome/blob/vaani/setup_pocketsphinx.sh
brew install swig
Vaani version OpenHAB
OpenHAB background info
- It may help to understand the openhab architecture : https://github.com/openhab/openhab/wiki
- mary-tts and net-speech-api are in the installations for the orchestrator
- You can pull and compile all of them by compiling in this order "smarthome", "openhab-core", "openhab2-addons", "openhab", "openhab-distro", and running: mvn install in each directory; it's better to setup the IDE. The openhab-distro is where the distributions will compile; you can run mvn install clean to clean and install and with the -DskipTests=true to skip tests.
- NOTE: OpenHAB 1.4 packaged everything together with a Designer and Runtime; for 2.0, Designer and Runtime are a package part of Eclipse
IDE setup
- new instructions are listed here : https://github.com/mozilla/openhab-distro/blob/vaani/docs/sources/development/ide.md
Troubleshooting Errors
Issues with CodeHaus downloads
From Codehuas:
Now that Codehaus no longer serves up Maven repositories, you will need to change your configuration. If your configuration is not updated and you slam our redirector, then you may be served invalid JAR files with status 200 to encourage you to update your configuration. Making Maven Work settings.xml In ~/.m2/settings.xml you can update the URL to be used for specific repositories. For example: <repositories> <repository> <id>codehaus-mule-repo</id> <name>codehaus-mule-repo</name> <url> https://repository-master.mulesoft.org/nexus/content/groups/public/ </url> <layout>default</layout> </repository> </repositories>
I believe the repo we want is : https://oss.sonatype.org/content/repositories/snapshots
Plugin execution not covered by lifecycle configuration: org.eclipse.tycho
- select the error and hit command 1. This should bring up the "Discover new m2e connectors"
- select finish
- Make sure Tycho Configurator is selected. ( uncheck Groovy-Eclipse if it's listed )
- not sure why there's some error with downloading Groovy-Eclipse; It doesn't seem necessary. You can install it using the instructions listed here : http://groovy.jmiguel.eu/groovy.codehaus.org/Install+Groovy-Eclipse+Plugin%3Fprint=1.html
- if you are having issues with Tycho install, here are two solutions :
- ) Install Tycho m2e connector manually using Help -> Install New Software. You can use the following update site: "http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-tycho/0.8.0/N/LATEST/"; Do not forget to update your project: Select the package "org.eclipse.om2m" -> right click -> maven -> update Project.
- ) Make a test with Eclipse Luna RCP and Rap developers using Window -> Preferences -> maven -> discovery -> open catalog. Then find and install tycho.
Project 'org.openhab.binding.smarthomatic' is missing required source folder: 'src-gen/main/java'
- the reason is because we're missing a PR : https://github.com/mozilla/openhab/issues/2
- fetch and cherry pick the PR listed in the issue.
- turn off all building automatically settings ( ie make sure that you uncheck build automatically after cleaning and in the menu setting)
- refresh the whole project ( select all the files and hit F5 )
- clean the whole project
- run the setup steps again
- then build the whole project again
The import with org.openhab.binding.smarthomatic.internal.packetData cannot be resolved
- verify that you have the openhab2-addons repo
- if refreshing, cleaning, and rebuilding doesn't do the trick, you can try quitting out of the Eclipse, and rm ~/.m2 and then try rebuilding again.
- if that doesn't work try mvn install method and then go back to eclipse once everything is compiled.
Missing Constraint: Import-Package: org.eclipse.smarthome.io.voice.tts; version="0.0.0"
- right click ( or control click) on the org.eclipse.smarthome.io.voice -> select Build Path -> and select "Use as Source Folder"
- Within the "run configurations..." dialog, select plugins and org.eclipse.smarthome.io.voice with default start-level and default auto-start; do the same for any other packages it's complaining about.
setting up pocketsphinx with OpenHAB
- pocketsphinx should install now with the Mozilla Vaani version. See IDE setup.
- Troubleshooting:
- if you get an error regarding the native-lib-loader-2.1.3.jar file missing, download the jar file from http://search.maven.org/remotecontent?filepath=org/scijava/native-lib-loader/2.1.3/native-lib-loader-2.1.3.jar and place it here : <smarthome directory>/bundles/io/org.eclipse.smarthome.io.voice/lib/native-lib-loader-2.1.3.jar
Building smarthome
- see https://github.com/mozilla/smarthome/#3-building-with-maven for build and distribution location.
- if you're showing errors:
- do a clean without rebuilding
- run the setup
- close out of the application
- do mvn install in the following git hub repos in the following order : smarthome, OpenHAB-addons, OpenHAB-core, OpenHAB, OpenHAB-distro.
- reopen the Eclipse app and then retry building.
Troubleshooting issues with the Designer
- control-click on the app
- from the context menu select "Show Package Contents"
- go into the Contents folder
- open the Info.plist file in a text editor
- search for <key>Eclipse</key>
- add and save the file:
<string>--launcher.ini</string><string>$APP_PACKAGE/Contents/Eclipse/SmartHome-Designer.ini</string>
- close out of the plist and the open folders and launch the application.
(Taken from : https://github.com/eclipse/smarthome/issues/639 )
Building OpenHAB distributions
- You can pull and compile all of them by compiling in this order "smarthome", "openhab-core", "openhab2-addons", "openhab", "openhab-distro", and running: mvn install in each directory. The openhab-distro is where the distributions will compile; you can run mvn install clean to clean and install and with the -DskipTests=true to skip tests.
- The distributions will be moved to ~/.m2/repository/org/openhab/distro/ by default.
NOTE: sometimes running mvn clean install -U may help; -U forces an update on all cached files. If it still has issues, sometime deleting the .m2 cache may help ( https://github.com/openhab/openhab/issues/3879#issuecomment-174836411 ).
Misc setup
setting up audio on Rpi
One and done task : https://oneanddone.mozilla.org/tasks/162/
Setting up OpenHAB Client on Android
One and done task : https://oneanddone.mozilla.org/tasks/163/
Project Sensor Web
Project Smart Home
Project SmartTV
Project WebVR
Project Flyweb
Misc Info Resources
RESET API & CURL
- other useful information on REST API and curl :
free SSL encryption
python scripts for Raspberry Pi
- hue scripts : https://github.com/nhirata/hue_scripts
- note: python isn't my language, and I need to revisit cleaning the scripts. They were suppose to be a part of a cron job script that would react to data from fitbit; I stopped working on that exercise.
fitbit API
- https://github.com/nhirata/python-fitbit/commits/heartrate
- a fork from orcasgit/python-fitbit ; I modified it so it's easier to get the authentication going and made a small script to pull the data. Need to go back and clean up the scripts at some point; stopping the exercise for some other items.
Eclipse
- error when trying to save preferences on Mac:
- create the directory and make sure you can access it :
- sudo mkdir /Applications/Xcode.app/Contents/Developer/usr/etc
- sudo chown <user> /Applications/Xcode.app/Contents/Developer/usr/etc
- create the directory and make sure you can access it :