I would really love to help. I know a good bit of python. But every time I sit down and try to look through code to understand it, I’m immediately lost. HA even has some pretty good documentation, but I just can’t get this stuff through my head.
@peterl Have you had a chance to take a look at moving the pets to a switch? I really want to move over to this before they lock us all out with a firmware update!
Hey,
thanks for this project. But i need help.
I setup Pet Local Hub as Addon in Home Assistant and setup a DNS rewrite in my local DNS Server.
On first start it hast connected so the Cloud service and downloaded “pethubconfig” i can see here i have “Firmware”: “2.43”.
If i do a Post request to https://hub.api.surehub.io/api/credentials i get a response from Pet Local Hub with the credentials. I can see this request in Pet Local Hubs logs too.
I also can see in my DNS Server (AdGuard), that the Hub is requesting pool.ntp.org and hub.api.surehub.io but the Hub isn’t connecting. The Hub is alternating blinking with red ears and i can’t so any connecting try in Pet Local Hubs logs.
If i delete the DNS entry it instant connects to the Cloud Service.
Thanks.
Currently on vacation, but will be looking into it when I get back.
Are you doing the DNS poison to point hub.api.surehub.io
to your local stack? As the credentials and MQTT needs to be running locally.
Did you follow the instructions at: Setup PetHubLocal | Pet Hub Local
@peterl I have exactly the same issue as @it-guy92. All looks fine, no evidence in the logs - but the hub stays offline with red-flashing ears.
In a wireshark trace I took I see everything runs smooth until the Hub sends the TLSv1.2 “Client Hello” to the server on the already opened TCP connection. Right after this message the PetHubLocal server closes the TCP connection. So the Hub does not even get that far to communicate with the PHL.
I’ve opened a GitHub issue with some screenshots: https://github.com/PetHubLocal/pethublocal/issues/3
Hoping for a solution after the Sure Petcare server desaster the last 2 days. And hopefully they do not do weird things to my hub meanwhile after this big server update mess as I need to reconnect to the cloud now due to this …
GRRRRR @ SurePet’s email. wtf guys
What email ?
Dear Customer,
We are sorry to inform you that the Sure Petcare App service has been experiencing intermittent issues since the morning of the 26th of July. We now believe we have a fix for this instability and are working to restore the service within the next 24 hrs.
Please note that as a result of our efforts to restore a stable service:
- Data collected on pet activity, feeding and drinking since the morning of July 26 until now will no longer be available and appear as a small gap in your app’s history.
- Any product settings or changes you made in the application since the morning of the 26th of July may not show correctly in the app.
We have not made this decision lightly but want to ensure that we are able to support you in looking after your pets.
If you are currently experiencing problems accessing your app, and would like to manage your pet’s permissions in the meantime, you can do so by following these instructions:
Pet Door Connect:
Use the button display, to lock or unlock your door. This will override anything you have set in the app.Cat Flap Connect:
Press and release the “add a pet” button. The catches will drop, and you can remove the batteries. This will free the access in and out of the home.Your satisfaction is very important to us. Should you have any further questions, please contact our customer services. Our team will be happy to assist you further. For updates on the situation, please visit our community page.
Sure Petcare
Reading between the lines, something went wrong and they restored a backup.
My personal pet peeve is they turned off replies on their “it is back up tweet”. That is the sign of poor social media comms person who knows they are going to get slated.
Poor form IMHO.
Regarding the connectivity issue above: It’s limited to the HA app. I’ve spent the evening spinning up an Ubuntu VM with a manual installation and that works!
This project is really awesome! Thanks a lot @peterl for this great reverse engineer work!
Moved from SurePet cloud to PetHubLocal within a day, including modifications of the HA UI.
I did some templates to:
- Calculate the battery percent (still under investigation if and how this fits, but 1.25V per cell is treated as 0%)
- Calculate a battery status (green, yellow, red)
- Calculate the binary status (inside, outside) of the cats out of the 4 CatFlap statuses “Outside”, “Lookedin”, “Inside”, “Lookedout”
To whom is interested:
- platform: template
sensors:
catflap_battery_percent:
friendly_name: CatFlap_Battery
value_template: '{{ min((((states("sensor.wintergarten_battery") |float - 5) *100)/1.3) |int,100) }}'
catflap_battery_status:
friendly_name: CatFlap_Battery_Status
value_template: '{% if (states("sensor.catflap_battery_percent")|int >= 20 and states("sensor.catflap_battery_percent")|int <= 100) %}green{% elif (states("sensor.catflap_battery_percent")|int >= 10 and states("sensor.catflap_battery_percent")|int < 20) %}yellow{% elif (states("sensor.catflap_battery_percent")|int < 10) %}red{% endif %}'
cat_shadow_where:
friendly_name: Shadow_where
value_template: '{% if (states("sensor.shadow") == "Inside" or states("sensor.shadow") == "Lookedout") %}inside{% elif (states("sensor.shadow") == "Outside" or states("sensor.shadow") == "Lookedin") %}outside{% endif %}'
cat_rocket_where:
friendly_name: Rocket_where
value_template: '{% if (states("sensor.rocket") == "Inside" or states("sensor.rocket") == "Lookedout") %}inside{% elif (states("sensor.rocket") == "Outside" or states("sensor.rocket") == "Lookedin") %}outside{% endif %}'
Finally I did some automations for push messages when a cat leaves or enters home and for battery warnings (to replace this cloud feature also).
Waiting excited for new features like changing the cat status (inside / outside) manually (already discussed here) and to lock in a cat selective (supported by CatFlap Connect).
After this stupid outage, I can’t wait to switch over to this!
Yap! Thankfully Peter has mentioned his project in the Twitter shitstorm, so I found it. That was the 3rd time that their cloud went mad for >1day. Time to get rid of this !
My wife had locked the flap because one of our cats was on the way in with a … right afterwards the server died again. Fortunately she had homeoffice, so she could do the “door butler” for the cats. I hate products with dependency on “someone else’s computer” … one of the reasons for my rack with some R720 in my basement
The only thing which is not really clear to me: When I change the lock status (lock in or lock out) it still takes between 5-10 seconds before the lock is applied and the status is fed back to HA.
As all is local
HA MQTT → (LAN) → Hub → (Zigbee) → Flap → (Zigbee) → Hub → (LAN) → HA MQTT
that should be something which completely happens in 100-200ms … where is that freakin’ delay?
The delay is with the device itself and sometimes the hub sending the Zigbee frame.
I find if I am sending a lot it can take up to a few seconds to react. Then another second or so after changing until it actually sends the status update.
I have my whole house running via HA, automated pretty much everything which is automateable, 1800 lines of code in my configuration file, so I am not a total dumbhead; 51 years of age and tought myself a lot about this through learning from others, searching here for similar use cases etc. My Xiaomi devices are all rooted and operate locally. Really thankful to this community!
Yesterday, I was a victim of the sureflap desaster as well. My cat did headbanging in the morning trying desperately to get out as the flap is alway blocked over night, and by the time it was supposed to unblock again, our dear friends at Sure Petcare had their little incident. I love the flap, but the way they didn’t manage this major issue is telling.
So I want to go local with the flap as well, and I am confident I can install everything and get it to run. BUT in all embarrassment - how do I poison the DNS entry? My router is from my ISP which I do not want to fiddle with; would it be sufficient enough if I install the Adguard Add-on in HA, create the rule which will root the api call to my local HA machine?
Very embarrassing. Have done quite some elegant automations, but network management is certainly a new territory for me
Any help or hint would be hugely appreciated!
yes, but you still need to point your new DNS server (HA with AdGuard) on your ISP router.
In the end the end device must get your rewriting where you make this does not matter.
To poison DNS requires you to be running your own DNS server in your network. PiHole can be a great choice, if you’d like to also block ads. Once you have DNS setup, you’ll go into your router and manually set DNS to be the server(s) you have setup.
Keep in mind that there isn’t exactly feature parity yet, as you can’t set the pet’s state manually like you can in the app. But our resident wizard is working on it!
FYI @jacotec on the Battery Voltage:
Re-checking the javascript there is two functions, b
and p
, you just need to search for voltage in the code.
function b(t, e) {
o.Gb(1), o.tc("ngIf", t.voltage <= 4.8), o.Gb(1), o.tc("ngIf", t.voltage > 4.8 && t.voltage <= 5.1), o.Gb(1), o.tc("ngIf", t.voltage > 5.1 && t.voltage <= 5.4), o.Gb(1), o.tc("ngIf", t.voltage > 5.4 && t.voltage <= 5.6), o.Gb(1), o.tc("ngIf", t.voltage > 5.6)
or
function p(t, e) {
o.Gb(1), o.tc("ngIf", t.voltage <= 5), o.Gb(1), o.tc("ngIf", t.voltage > 5 && t.voltage <= 5.15), o.Gb(1), o.tc("ngIf", t.voltage > 5.15 && t.voltage <= 5.4), o.Gb(1), o.tc("ngIf", t.voltage > 5.4 && t.voltage <= 5.6), o.Gb(1), o.tc("ngIf", t.voltage > 5.6)
With the pseudocode for b
below:
if voltage <= 4.8 then empty
elif voltage > 4.8 and voltage <= 5.1 then 1 Bars
elif voltage > 5.1 and voltage <= 5.4 then 2 Bars
elif voltage > 5.4 and voltage <= 5.6 then 3 Bars
elif voltage > 5.6 then Full
All devices have either 4xAA (Cat Flap) or 4xC batteries in them so they should always report 1.5v x 4 aka Maximum 6v from the ADC.
One quirk of the Pet Door is it supports rechargeable batteries if you set on Custom Mode 2 so has a range 1.2v rather than 1.5v so a maximum of 4.8v rather than 6v, so I suspect b
is for the rechargeable pet door values and p
is for everything else.