Hey all,
I finally have a working solution for my connected cat flap from Sure Petcare This soultion is not the very best way… but it works
I tried to do this with a binding, but havent success, so i stick with this ruels for now… maybe some Dev can create a binding in the future.
Note: I’m running on the latest Snapshot builds with JSR223 Rules and I’m using HABPanel…
If you are on another version of openHAB or if you are using BasicUI, you may need to adjust the following steps a bit…
This is for testing only… if you found bugs or find a better way to do things, please let me know in the comments.
You also nee to get you Auth token and need to insert it into the 3 jsr223 rules (explained below).
Look in Matrix Theme (outdated)
Look in Basic HABPanel widgets
This is what works so far:
- polls the main catflap data every 6 hours (there are not much changing)
- polls the pet location (and pet feeder data if available) every 5 minutes
- you can set the status of the cat through openHAB
- for now only 1 household is supported
- if you have multiple users in your sure petcare account, openhab shows which user set the cat status manually via sure petcare app (f.e. if you have pet sitters)
- otherwise the device name (where the cat entered/left the house) is shown
- map transform file to translate into your language
- device status of your Hub and Cat Flap and Pet Feeder devices
PLEASE NOTE!
This will only work if you are on openHAB version: 2.4M3, S1319, or newer
STEP 1.
Get the files from my GitHub Repository and add them to your openhab2-conf
folder.
keep the folder structure.
STEP 2.
log into openhab console and rund these commands:
openhab-cli console
log:set INFO jsr223.javascript
logout
STEP 3.
enter into openhab2-conf/scripts and make the script executeable
cd /etc/openhab2/scripts
chmod +x surehub.sh
STEP 4.
get your API Auth token:
click to show code
I’m using the postman app but you can also do this online at API Tester
then click TEST and in the Response -> Response Headers you have your token, everything after "Authorization: Bearer "
copy this and update the files:
- 001_surehub_start.js in Line 18
- 002_surehub_get_pet_location.js in Line 18
- 003_surehub_post_pet_location.js in Line 29
STEP 5.
go to PaperUI and install under Add-ons -> TRANSFORMATIONS -> JSONPath Transformation
go to PaperUI and install under Add-ons -> TRANSFORMATIONS -> MAP Transformation
STEP 6.
go to PaperUI and install under Add-ons -> MISC -> Rule Engine (Experimental)
STEP 7.
go to PaperUI -> Rules -> click the play button for the rule “Surehub START”
then take a look into your logs (frontail) and search for “Found Pet ID”
copy those IDs and insert them in the file 002_surehub_get_pet_location.js
around line 16
you also need to edit the url
string in line 22
STEP 8.
HABPanel code:
get the .json widgets from my GitHub Widget Repo and import them into your HABPanel
Thats it! Have fun with your cats data in openHAB.
Please also note that i’m not a developer… but i tried my best to get this working. If you have suggestions please let me know. Also feel free to create a PR HERE and HERE
If you like this addon to openHAB please let my know by clicking that heart button