Reading Seneye from USB

This is a project to read a Seneye from an SBC and write the data to a local hass.io instance.

Some links that may be useful.

This may be useful

http://answers.seneye.com/en/Seneye_Products/seneye_developer_information

@mark.grimes It would be great if you could take any notes in this thread.

I had a go with the official Seneye code and had to fix some minor errors so I put in a pull request to the manufacturers (https://github.com/seneye/SUDDriver/pull/1).
It now compiles fine but I didn’t have a device to test with, so the example program just exits out with “Select the device: (y to select) No device selected”.

The python project (https://github.com/dhallgb/Seneye-MQTT) might be easier to integrate into Hassio though since it already has MQTT functionality, and I would guess you’ll be able to find people to maintain it more easily.

1 Like

Thanks Mark

This is really helpful.

Would the next step be trying it as a HASS addon/ container

I think they are relatively easy to create

You should have terminal access via the Tor link I shared privately with you

Thanks

Sam

I’d like to try with a Seneye unit connected first, but a HASS container shortly afterwards. I’ve been looking into that and the interface to the Seneye has to be available on PyPi. I’ve not checked yet whether the Python project mentioned above is.

Having said that there might be a work around for development testing, but that would be a short term solution.

Came back to this after a few weeks away. This time I had a Seneye connected so thought I’d try the official Seneye C++ code first to check it all works. For reference:

Only required once if you get errors about missing include “curses.h” or similar

sudo apt-get install libncurses5-dev

(exact package name might be different depending on your Linux distro)

git clone https://github.com/seneye/SUDDriver.git
cd SUDDriver/Cpp
c++ main.cpp linux/hid.c -o SUDDriver -lcurses -ludev

Then running it gives me:

Select the device: (y to select)
1 )F50020C6587F71D9AEFE812318007021

So it appears to have recognised the device, but anything after that gives me either No device selected or unable to open device, then quits out and gives me a messed up terminal (so they don’t restore the terminal state after whatever changes they make for ncurses).

1 Like

I tried reading the Seneye with the Seneye-MQTT python code. Note that this was from an RPi that I had root access to (I’ll figure out running in a container later).

git clone https://github.com/dhallgb/Seneye-MQTT.git
cd Seneye-MQTT
sudo pip install paho-mqtt pyusb bitstring
python -O sudmqtt.py

and got

usb.core.USBError: [Errno 13] Access denied (insufficient permissions)

so I then tried with sudo and got

socket.gaierror: [Errno -2] Name or service not known

I spent a while playing with USB debugging tools to try and figure it out, but eventually realised it was the publishing to MQTT that was failing, not the device read. The line that specifies the MQTT broker hostname needs changing for your specific setup (sudmqtt.py line 12). I changed that to the IP address of the RPi running Home Assistant (after Sophie got the MQTT broker working) and the script runs and exits (it currently reads the device once, publishes and then exits). In another shell I ran:

mosquitto_sub -h 192.168.1.3 -d -t "raw/aquarium"

…to listen for messages on the raw/aquarium topic (set in line 13 of sudmqtt.py), ran the script again from the first shell and got:

Subscribed (mid: 1): 0
Client mosqsub/24328-ethoscope received PUBLISH (d0, q0, r0, m0, 'raw/aquarium', ... (96 bytes))
{"Temp": 0, "SlideExpired": false, "NH3": 0, "pH": 0, "SlideNotFitted": false, "InWater": false}

(the Seneye was sitting in a cup of water). So it all seems to work except that the readings are incorrect. Pretty sure the USB communication is working, so don’t know if it’s a hardware problem or parsing the sensor data incorrectly. I ran out of time to investigate further.

Note that this is further proof that the MQTT broker on hassio.local is working correctly, and that it is currently setup to allow anonymous access (at no point did I give either the Seneye python code or my mosquitto_sub command a username or password).

Tried again after 2 weeks away. I got the Seneye official code working, everything above is correct except that when running it you need sudo (as for the python code). When running that however I get "This device need to be connected to SCA or SWS" (SCA is Seneye Control Application, i.e. the PC software; and SWS is the Seneye Web Server). Tried with a Seneye Reef and it worked (other model was a Seneye Home). I’m guessing Seneye intentionally hobble the Home, but all the readings and controls work and look sensible for the Seneye Reef. The software isn’t great but it should be easy enough to modify for whatever needs you have.

Tried briefly with the Python code but it didn’t get the readings off correctly. Didn’t have time to investigate.

1 Like