JTK – Notes and Ramblings Things we have found …

12/23/2018

Seneye Home on the Pi

Filed under: General,Home Automation — taing @ 6:15 pm

The Seneye Home normally wants to be connected to a Windows PC to log its reading to the cloud. Naturally, I see no reason for the cloud to be involved. {Insert rant about unnecessary cloud connections for home devices here} Fortunately, Seneye has released at least a partial API for reading on a Raspberry Pi.

https://github.com/seneye/SUDDriver

There is a handy page describing compiling and testing the samples from the above: https://raspberrypidiyblog.wordpress.com/2018/01/17/seneye-suddriver-raspberrypi/

Compiling the code required I change line 464 of linux/hid.c from:

tmp = (hid_device_info*)malloc(sizeof(struct hid_device_info));

to

tmp = (struct hid_device_info *)malloc(sizeof(struct hid_device_info));

Over at https://doughall.me/2017/06/30/seneyemqttpt1/ is a discussion on using Python on the Pi to get the device readings. His code can be found at https://github.com/dhallgb/Seneye-MQTT.

Following these instructions I installed python modules pprint, pyusb, paho-mqtt and bitstring(not mentioned but required) using pip install. It was necessary to update the 10-local.rules file to indicate the correct idVendor and idProduct: idVendor=24f7 and idProduct=2204. These need to be in hex in the udev files. They are in decimal in the python source.

I have also updated the python script to not use bitstring and to use struct instead.

def mungReadings(p):
   s = {}
   scrap, scrap, TS, flag1, flag2, scrap, pH, NH3, thermo, scrap  = unpack('<BBLBBHHHL46s', p)
   s['InWater']=bool(flag1 & 0b00000100)
   s['SlideNotFitted']=bool(flag1 & 0b00001000)
   s['SlideExpired']=bool(flag1 & 0b00010000)
   s['pH']=float(pH)/100   # divided by 100
   s['NH3']=float(NH3)/1000  # divided by 1000
   s['Temp']=float(thermo)/1000 # divided by 1000
   j = json.dumps(s, ensure_ascii=False)
   return(j)

Still working on how to register a Seneye slide without the Windows PC. From the Seneye SUDDriver wiki:

Slide codes are retrieved from an API hosted on the seneye cloud. In order to use it, your account will need activating to allow permission. You can request access to this by E-mail by asking for “SUD Developer Access” and we will send you the terms and conditions to be sent to you for agreement.

https://github.com/seneye/SUDDriver/wiki/Activating-a-seneye-slide-for-your-SUD#retrieving-a-slide-code

2/6/2016

Openhab zwave

Filed under: General,Home Automation — taing @ 11:44 pm

I added the zwave binding:
sudo apt-get install openhab-addon-binding-zwave

For the Aeon Labs Z-Stick Series 2 which appears as /dev/ttyUSB0 I had to add the openhab user to the dialout group:
sudo adduser openhab dialout

To bind devices I used Habmin – https://github.com/cdjackson/HABmin. I chose the complied release version – https://github.com/cdjackson/HABmin/releases. The alternative is to install source from the git and compile.

So far I have linked a RadioThermostat CT-80 with Z-wave interface and a Aoetec Home Energy Meter(2nd edition).

For the HEM it was necessary to set the mode properly for periodic updates.

The RadioThermostat only sends changes and only works in “dumb” mode when using zwave. I have not yet been able to read the humidity from the thermostat. The definition in the openhab zwave binding is imcomplete.

Radio Thermostat WiFi Module : http://ndgeek.com/ct-50/RTCOAWiFIAPIV1_3.pdf. The radio module I had was very unreliable and disconnected frequently. I did find some interesting discussions on using the WiFi module with Openhab – https://community.openhab.org/t/binding-radio-thermostat/5480 & https://community.openhab.org/t/how-to-return-current-temp-from-my-thermostat/3141

Radio Thermostat zwave Module: http://products.z-wavealliance.org/MarketCertification/File?folder=&filename=MarketCertificationFiles/1046/RTZW-02_module_IB_9jun14.pdf. The Openhab wiki does have some good examples for the zwave interface – https://community.openhab.org/t/collection-of-working-z-wave-configs/1407

Aoetec Home Energy Meter(2nd edition): https://docs.google.com/viewer?a=v&pid=forums&srcid=MDM3NTIwMDUwMTA4OTkyOTEwNDQBMTc2Mjg0MjUxOTM5MzgwNTU2ODABYXZNMEo0RUZVcllKATAuMQEBdjI.

iPhone Locator for Openhab

Filed under: General,Home Automation — taing @ 5:00 pm

This is based on the work by many others.

Firstly, pyicloud – https://github.com/picklepete/pyicloud

For this you need:
sudo apt-get install python-pip
sudo apt-get install python-dev libffi-dev
sudo pip install pyopenssl ndg-httpsclient pyasn1
sudo pip install pyicloud

As the pyicloud documentation mentions, the first time you use this you will get a message from Apple letting you know your iCloud account was accessed.

To test I created location.py :
from pyicloud import PyiCloudService
api = PyiCloudService('myaccount@icloud.com','password')
print(api.devices)
print(api.devices[1])
print(api.devices[1].location())

python location.py

The second part of this is iphone-locator-bridge

I modified this a bit for my specific site. The includes changing the openhab items defined, passing back the actual longitude/latitude and distance and only running on demand.

I found the POST syntax in the original was giving me issues so I converted to the GET syntax:
url = '%s/CMD?%s=%s' % (gConfigurationOH['ohserver'], gConfigurationOH['ohitemdist'], dist)

It was necessary to add complete path info for the log file and the config file in roder for these to be found correctly when the script is called by an Openhab executeCommandLine().

The iPhone and home locations are then plotted on Google Maps using the info found at https://github.com/openhab/openhab/wiki/GoogleMap.

4/3/2015

HomeAutomation

Filed under: General,Home Automation — taing @ 6:27 pm

Raspberry Pi with Rasbian

MQTT

Updated 2/2016

wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list
sudo apt-get update
sudo apt-get install mosquitto mosquitto-clients libmosquitto-dev

wiringPi

(from http://wiringpi.com/download-and-install/)
For the first time: git clone git://git.drogon.net/wiringPi
For updates:
cd wiringPi
git pull origin

To Build:
cd wiringPi
./build

Java 8

sudo su
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get purge openjdk* (to remove previously installed lower versions)
apt-get install oracle-java8-installer
exit

OpenHab

(from https://github.com/openhab/openhab/wiki/Linux—OS-X)
Add repo signature: wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add -
Add sources to list: echo "deb http://dl.bintray.com/openhab/apt-repo stable main" | sudo tee /etc/apt/sources.list.d/openhab.list
Update apt data and install:
sudo apt-get update
sudo apt-get install openhab-runtime

Install optional Addons:
sudo apt-cache search openhab
sudo apt-get install openhab-addon-binding-xy

Gateway code

start with the code from https://github.com/abouillot/HomeAutomation/tree/master/piGateway

git clone https://github.com/abouillot/HomeAutomation
cd ~/HomeAutomation/piGateway
g++ Gateway.c rfm69.cpp -o Gateway -lwiringPi -lmosquitto -DRASPBERRY -DDEBUG

« Newer Posts

Powered by WordPress