Closed zsbobbob closed 2 years ago
That sounds a bit odd, looks like are you using a Pet Door by the message 110181
and "PetOffset": 1
As the messages are significantly different between the two as the cat flap sends the tag for the animal in the payload whereas the pet door sends a chip offset from the provisioned device, so then what I need to do is lookup by the tag map.
In tagmap table in pethublocal.db
sqlite database you should see
CREATE TABLE tagmap(mac_address TEXT, deviceindex INTEGER, tag TEXT, profile INTEGER, UNIQUE (mac_address, deviceindex) ON CONFLICT REPLACE );
INSERT INTO tagmap VALUES('50626FFEFF121F80',0,'xxxx',2);
INSERT INTO tagmap VALUES('50626FFEFF121F80',1,'xxxx',2);
Where the mac_address is the mac address of your pet door, then deviceindex
is the PetOffset
value (dammit I need to make them the same term as they are the same thing!) where each provisioned tag is a value in the memory registers from 91 - 309 in the dump:
if offset in range(91,309): #Provisioned tags
print("Register 91-309 - Provisioned Tags",messagerange)
op="Tag"
frameresponse.Operation=op
operation.append(op)
pet=round((int(offset)-84)/7)-1 #Calculate the pet number
tag = doorhextochip(value[4:]) #Calculate tag Number
frameresponse.PetOffset = pet
frameresponse.Tag = tag
Where the messages over mqtt are like:
messages/50626FFEFF121F80 610f5a39 02d0 132 153 91 7 00 00 00 00 00 00 00
The 91 is the register offset being the first provisioned device on the Pet Door, then the following 7 bytes is the tag value which I use the function doorhextochip
to convert it back into the correct number... and that could be the problem.
I suspect something has gone wrong with the creation of the database when parsing the tag index
values for the pet door into the tagmap
table. If you wanted to email me directly your start.json
I could see what was wrong, as the mkpetlocaldb.py
should have parsed the start.json
into the database using the index values.
Which also leads to this issue https://github.com/plambrechtsen/pethublocal/issues/7 where I haven't figured out the calculation of the non FDX-B tags such as HDX ones from the hex string into their stored value.
Hello, Thanks for the detailed explanation. I checked the tagmap table which is empty, so maybe something went wrong during the database import. I sent you the start.json via e-mail. Thanks your help in advance. Zsolt
Closing this as I think you are sorted now.
Yes, thanks for your help!
Hello,
First of all thanks for your great work. It was a brilliant idea to create a tool to use the pethub locally.
I successfully setup the docker version it has connected to the Hub, MQTT connection is working fine with the Home Assistant.
Only reporting of the movement which is not working properly, a cat and a dog who are using the door, but at both animal the messages is unknown animal.
Door : Parsed: {"device": "Bejarati ajto", "mac_address": "50626FFEFF121F80", "message": [{"MSG": "110181", "Operation": "PetMovement", "PetOffset": 1, "Animal": "Unknown", "Direction": "Inside_Already"}, {"Operation": ["PetMovement", "PetMovement"]}], "timestamp": "2021-09-09 17:02:03", "operation": "Status"}
I checked the database what was imported from pethub server, but seems the ID is correct.
Do you have any idea what can be wrong? Thank in advance