New Sure Petcare Binding for Cat/Pet Flap

Interesting, it looks like this is a slightly different hardware version. I’m happy to fix it today.
Would you be able to send me the full JSON reply from the topology call for testing?
I.e.: the string returned after “updating topology cache”. Feel free to remove any personal information, but please leave the document complete.
2020-04-28 15:55:58.085 [DEBUG] [nal.handler.SurePetcareBridgeHandler] - Login successful, updating topology cache
2020-04-28 15:55:58.289 [DEBUG] [etcare.internal.SurePetcareAPIHelper] - API execution successful, response: {“data”:{"devic …

Bastian, can you try this latest version please:

Works great for me !!
Thank you very much.

Hi Rene. Im still having the same warning.

020-05-02 11:46:40.630 [hingStatusInfoChangedEvent] - 'surepetcare:bridge:b7576a0f' changed from UNINITIALIZED to INITIALIZING

==> /var/log/openhab2/openhab.log <==

2020-05-02 11:46:40.653 [DEBUG] [nal.handler.SurePetcareBridgeHandler] - Initializing Sure Petcare bridge handler.

==> /var/log/openhab2/events.log <==

2020-05-02 11:46:40.661 [hingStatusInfoChangedEvent] - 'surepetcare:bridge:b7576a0f' changed from INITIALIZING to UNKNOWN

==> /var/log/openhab2/openhab.log <==

2020-05-02 11:46:40.660 [DEBUG] [nal.handler.SurePetcareBridgeHandler] - Login to SurePetcare API with username:

2020-05-02 11:46:40.671 [DEBUG] [etcare.internal.SurePetcareAPIHelper] - current MAC address: 

2020-05-02 11:46:41.533 [DEBUG] [etcare.internal.SurePetcareAPIHelper] - Login successful, token: 

2020-05-02 11:46:41.546 [DEBUG] [nal.handler.SurePetcareBridgeHandler] - Login successful, updating topology cache

==> /var/log/openhab2/events.log <==


2020-05-02 11:46:42.411 [DEBUG] [etcare.internal.SurePetcareAPIHelper] - API execution successful, response: {"data":{"devices":[{"id":58192,"product_id":1,"household_id":2948,"name":"Uhli","serial_number":","mac_address":"","version":"MTAwNjc=","created_at":"2017-08-17T07:55:49+00:00","updated_at":"2020-05-02T09:39:02+00:00","control":{"led_mode":0,"pairing_mode":0},"status":{"led_mode":0,"pairing_mode":0,"version":{"device":{"hardware":3,"firmware":2.43}},"online":true}},{"id":68233,"parent_device_id":58192,"product_id":3,"household_id":2948,"name":"Vratca","mac_address":"4BA553FEFF3980D8","index":0,"version":"NTM2NQ==","created_at":"2018-01-23T15:39:13+00:00","updated_at":"2020-05-02T09:10:45+00:00","control":{"curfew":{"enabled":false,"lock_time":"23:00","unlock_time":"01:00"},"locking":0,"fast_polling":true},"parent":{"id":58192,"product_id":1,"household_id":2948,"name":"Uhli","serial_number":"H001-0058192","mac_address":"0000D8803970862E","version":"MTAwNjc=","created_at":"2017-08-17T07:55:49+00:00","updated_at":"2020-05-02T09:39:02+00:00"},"status":{"battery":5.415,"locking":{"mode":0},"version":{"lcd":{"hardware":1,"firmware":1},"rf":{"hardware":4,"firmware":0.16}},"learn_mode":false,"online":false,"signal":{"device_rssi":-35,"hub_rssi":-35}},"tags":[{"id":3281,"index":0,"version":"MQ==","created_at":"2018-01-23T15:39:34+00:00","updated_at":"2020-03-11T14:44:07+00:00"},{"id":3282,"index":1,"version":"MQ==","created_at":"2018-01-23T15:39:34+00:00","updated_at":"2020-03-11T14:44:07+00:00"},{"id":3283,"index":2,"version":"MQ==","created_at":"2018-01-23T15:39:35+00:00","updated_at":"2020-03-11T14:44:07+00:00"},{"id":12731,"index":3,"version":"MQ==","created_at":"2018-08-09T14:55:53+00:00","updated_at":"2020-03-11T14:44:07+00:00"}]}],"households":[{"id":2948,"name":"Mrvar","share_code":"u4u8tvV1D91N","timezone_id":340,"version":"Mg==","created_at":"2018-01-23T15:25:20+00:00","updated_at":"2018-01-23T15:25:21+00:00","invites":[{"id":2018,"code":"","email_address":"","creator_user_id":3737,"owner":false,"write":true,"status":0,"version":"MQ==","created_at":"2018-02-05T23:39:13+00:00","updated_at":"2018-02-05T23:39:36+00:00","user":{"creator":{"id":3737,"name":""}}}],"users":[{"id":3737,"owner":true,"write":true,"version":"MQ==","created_at":"2018-01-23T15:25:20+00:00","updated_at":"2018-01-29T08:07:31+00:00","user":{"id":3737,"name":""}}]}],"pets":[{"id":6381,"name":"Misa","gender":0,"weight":"1","comments":"","household_id":2948,"species_id":1,"tag_id":3281,"version":"NA==","created_at":"2018-01-23T15:39:34+00:00","updated_at":"2020-04-23T20:47:05+00:00","position":{"tag_id":3281,"device_id":68233,"where":1,"since":"2020-05-02T08:18:55+00:00"},"status":{"activity":{"tag_id":3281,"device_id":68233,"where":1,"since":"2020-05-02T08:18:55+00:00"}}},{"id":6382,"name":"Zuzu","gender":0,"weight":"1","comments":"","household_id":2948,"species_id":1,"tag_id":3282,"version":"NA==","created_at":"2018-01-23T15:39:34+00:00","updated_at":"2020-04-23T20:47:41+00:00","position":{"tag_id":3282,"device_id":68233,"where":1,"since":"2020-05-01T23:23:08+00:00"},"status":{"activity":{"tag_id":3282,"device_id":68233,"where":1,"since":"2020-05-01T23:23:08+00:00"}}},{"id":6383,"name":"Kepek","gender":1,"weight":"NaN","household_id":2948,"species_id":1,"tag_id":3283,"version":"Mw==","created_at":"2018-01-23T15:39:35+00:00","updated_at":"2018-01-23T15:41:52+00:00","position":{"tag_id":3283,"device_id":68233,"where":1,"since":"2020-05-02T04:23:56+00:00"},"status":{"activity":{"tag_id":3283,"device_id":68233,"where":1,"since":"2020-05-02T04:23:56+00:00"}}},{"id":17072,"name":"Belka","gender":0,"household_id":2948,"species_id":1,"tag_id":12731,"version":"Mg==","created_at":"2018-08-09T14:55:53+00:00","updated_at":"2018-08-09T15:02:06+00:00","position":{"tag_id":12731,"device_id":68233,"where":1,"since":"2020-05-02T08:18:55+00:00"},"status":{"activity":{"tag_id":12731,"device_id":68233,"where":1,"since":"2020-05-02T08:18:55+00:00"}}}],"photos":[],"tags":[{"id":3281,"tag":"705.060002133831","version":"MQ==","created_at":"2018-01-23T15:39:34+00:00","updated_at":"2020-03-11T12:50:47+00:00","supported_product_ids":[3,4,6,8]},{"id":3282,"tag":"705.100000031597","version":"MQ==","created_at":"2018-01-23T15:39:34+00:00","updated_at":"2020-03-11T13:25:59+00:00","supported_product_ids":[3,4,6,8]},{"id":3283,"tag":"705.035000002060","version":"MQ==","created_at":"2018-01-23T15:39:35+00:00","updated_at":"2020-03-11T13:25:59+00:00","supported_product_ids":[3,4,6,8]},{"id":12731,"tag":"705.100000092733","version":"MQ==","created_at":"2018-08-09T14:55:53+00:00","updated_at":"2020-03-11T13:25:57+00:00","supported_product_ids":[3,4,6,8]}],"user":{"id":3737,"email_address":"","first_name":"","last_name":"","country_id":200,"language_id":37,"marketing_opt_in":true,"terms_accepted":false,"weight_units":0,"time_format":0,"version":"NQ==","created_at":"2018-01-23T15:23:38+00:00","updated_at":"2019-03-16T14:23:32+00:00","notifications":{"device_status":true,"animal_movement":true,"intruder_movements":true,"new_device_pet":true,"household_management":true,"photos":true,"low_battery":true,"curfew":true,"feeding_activity":true}}}}

2020-05-02 11:46:42.523 [WARN ] [etcare.internal.SurePetcareAPIHelper] - Exception caught during topology cache update: java.lang.NumberFormatException

2020-05-02 11:46:42.525 [DEBUG] [nal.handler.SurePetcareBridgeHandler] - Cache update successful, setting bridge status to ONLINE

==> /var/log/openhab2/events.log <==

2020-05-02 11:46:42.529 [hingStatusInfoChangedEvent] - 'surepetcare:bridge:b7576a0f' changed from UNKNOWN to ONLINE

==> /var/log/openhab2/openhab.log <==

2020-05-02 11:46:42.529 [DEBUG] [nal.handler.SurePetcareBridgeHandler] - Updating 0 connected things

2020-05-02 11:46:42.533 [DEBUG] [nal.handler.SurePetcareBridgeHandler] - Bridge topology polling job every 36000 seconds

2020-05-02 11:46:42.537 [DEBUG] [nal.handler.SurePetcareBridgeHandler] - Pet status polling job every 300 seconds

==> /var/log/openhab2/events.log <==

2020-05-02 11:46:42.595 [.ItemChannelLinkAddedEvent] - Link 'surepetcare_bridge_b7576a0f_online-surepetcare:bridge:b7576a0f:online' has been added.

2020-05-02 11:46:42.609 [vent.ItemStateChangedEvent] - surepetcare_bridge_b7576a0f_online changed from NULL to ON
020-05-02 12:06:44.174 [DEBUG] [etcare.internal.SurePetcareAPIHelper] - API execution successful, response: {"data":[{"id":6381,"name":"Misa","gender":0,"weight":"1","comments":"","household_id":2948,"species_id":1,"tag_id":3281,"version":"NA==","created_at":"2018-01-23T15:39:34+00:00","updated_at":"2020-04-23T20:47:05+00:00","status":{"activity":{"tag_id":3281,"device_id":68233,"where":1,"since":"2020-05-02T08:18:55+00:00"}}},{"id":6382,"name":"Zuzu","gender":0,"weight":"1","comments":"","household_id":2948,"species_id":1,"tag_id":3282,"version":"NA==","created_at":"2018-01-23T15:39:34+00:00","updated_at":"2020-04-23T20:47:41+00:00","status":{"activity":{"tag_id":3282,"device_id":68233,"where":1,"since":"2020-05-01T23:23:08+00:00"}}},{"id":6383,"name":"Kepek","gender":1,"weight":"NaN","household_id":2948,"species_id":1,"tag_id":3283,"version":"Mw==","created_at":"2018-01-23T15:39:35+00:00","updated_at":"2018-01-23T15:41:52+00:00","status":{"activity":{"tag_id":3283,"device_id":68233,"where":1,"since":"2020-05-02T04:23:56+00:00"}}},{"id":17072,"name":"Belka","gender":0,"household_id":2948,"species_id":1,"tag_id":12731,"version":"Mg==","created_at":"2018-08-09T14:55:53+00:00","updated_at":"2018-08-09T15:02:06+00:00","status":{"activity":{"tag_id":12731,"device_id":68233,"where":1,"since":"2020-05-02T08:18:55+00:00"}}}]}

2020-05-02 12:06:44.185 [WARN ] [etcare.internal.SurePetcareAPIHelper] - Exception caught during pet status update: java.lang.NumberFormatException

2020-05-02 12:06:44.188 [DEBUG] [nal.handler.SurePetcareBridgeHandler] - Updating pet status for: 6405b830

2020-05-02 12:06:44.192 [DEBUG] [ternal.handler.SurePetcarePetHandler] - Trying to update unknown pet: 6405b830

Thanks. I’m just having a look if I can reproduce with your JSON.

Hi Rene,
thanks a lot for your effort. I did also successfully add your binding to my household.
I wanted to add all the things manually and struggled a bit with your example .things:

Bridge surepetcare:bridge:bridge1 "Demo API Bridge" @ "SurePetcare" [ username="<USERNAME>", password="<PASSWORD>", refreshIntervalTopology=36000, refreshIntervalStatus=300 ]
{
  Thing household     12345  "My Household" @ "SurePetcare"
  Thing hubDevice     123456 "My SurePetcare Hub" @ "SurePetcare Devices"
  Thing flapDevice    123456 "My Backdoor Cat Flap" @ "SurePetcare Devices"
  Thing feederDevice  123456 "My Pet Feeder" @ "SurePetcare Devices"
  Thing pet           12345  "My Cat" @ "SurePetcare Pets"
}

Maybe you should add a comment, that the digit in the end (12345) is a fixed number used for identification of every device and cannot be selected at own will. I used the automatic discovery function to figure out the id for every device (is there a way to obtain this number without the discovery function?). If you enter something else, the Thing is still shown as online, but all items pointing to that Thing have the value NULL.
Thing surepetcare:household:bridge1:28553 "Home" @ "SurePetcare"

Thanks again and keep up the good work!
Morten

Hi,

there is no easy way to get those ids i know of… one can use postman app and login in to the api and check the JSON for those ids…

Or as i did… started the automatic discovery scan… checked the logs (maybe turn on debug mode) for those ids,

[DEBUG] [iscovery.SurePetcareDiscoveryService] - Discovered pet: Test Chip
[INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'surepetcare:pet:THINGID:YOURPETID

and deleted the things from the inbox… then i created the .things file with those things…

Hope this helps

/Holger

Hi,

First of all, thanks for developing this add-on! I’m really looking forward to your PR being accepted soon.

I have tried the latest snapshot you’ve provided org.openhab.binding.surepetcare-2.5.5-SNAPSHOT.jar and have configured the things and items manually, but get an error when openhab tries to initialize the API bridge:

2020-05-05 17:13:23.448 [hingStatusInfoChangedEvent] - 'surepetcare:bridge:bridge1' changed from UNINITIALIZED (HANDLER_INITIALIZING_ERROR): java.lang.NumberFormatException: Expected an int but was 2491083182 at line 1 column 33 path $.data.user.id to UNINITIALIZED

I’ve checked if the ID is correct, but it is. This is a recently created account. I have more accounts in my household, they seem to be in the 22xxx range of IDs. So it seems like they’ve switched to using integers greater than signed 32 bits somewhat recently.

Is this something you could take a look at? Thanks in advance!

I’ve had a look at the data types and changed the ids from integers to longs. Hopefully that should resolve this issue. Please could you do a test for me with the following build:
https://drive.google.com/file/d/14NqXo2hqHADYCTUIiLRKz-LkICfkOlsv/view?usp=sharing

1 Like

That indeed seems to fix it. It is now connecting without errors and my configured things started working straight away. I will test it more extensively in the coming days. Thanks a lot!

2 Likes

@scherer
Hi Rene, still no joy for me. Did you find out something?

I like to try this binding with my cat door. Are the config/settings collected/documented somewhere?
I have fond the Bridge and thing just above, but what about the cannels?

Best regards
Ola

Hi Ola,

the readme of this binding can be found here https://github.com/renescherer/openhab2-addons/tree/feature/surepetcare_binding/bundles/org.openhab.binding.surepetcare

But keep in mind, this binding is still in review, and channels can change in future versions…

@scherer
Thanks for creating this binding. I implemented the binding and everything is working fine. Thanks to you I can start my Roborock vaccum cleaner now when my cat leaves the house, less hassle for her and myself :wink:

1 Like

I get the message:

UNINITIALIZED - HANDLER_INITIALIZING_ERROR java.lang.NumberFormatException: Expected an int but was 2491097522 at line 1 column 33 path $.data.user.id

I use
org.openhab.binding.surepetcare-2.5.5-SNAPSHOT.jar

now works after deleting the temporary files and restarting

Hi guys,

I’m now getting this error having Openhab on the newest stable version. It’s already happening since quite some time actually.

2020-11-17 17:31:45.636 [WARN ] [core.thing.internal.ThingManagerImpl] - Initializing handler for thing 'surepetcare:bridge:bridge1' takes more than 5000ms.
2020-11-17 17:31:50.884 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.surepetcare.internal.handler.SurePetcareBridgeHandler@1261ef9': null
java.lang.NullPointerException: null
        at org.openhab.binding.surepetcare.internal.handler.SurePetcareDeviceHandler.updateThingCurfews(SurePetcareDeviceHandler.java:180) ~[?:?]
        at org.openhab.binding.surepetcare.internal.handler.SurePetcareDeviceHandler.updateThing(SurePetcareDeviceHandler.java:141) ~[?:?]
        at org.openhab.binding.surepetcare.internal.handler.SurePetcareBridgeHandler.updateThings(SurePetcareBridgeHandler.java:214) ~[?:?]
        at org.openhab.binding.surepetcare.internal.handler.SurePetcareBridgeHandler.initialize(SurePetcareBridgeHandler.java:87) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_265]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_265]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_265]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_265]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_265]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_265]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_265]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_265]

Any help is appreciated.

Any plans to port this to Openhab 3?

Nice! I hope that the code eventually gets merged in to the main GitHub repository for openhab.