Poseidon (Feelaqua)
Product ID = 8
The Poseidon / Felaqua is a fairly dumb device. The 4 feet have scales to detect weight changes and report values in a similar way to the feeder. Really there is only one message type which is the 1b
All the non-Pet Door devices have common messages
All the non Pet Door devices have a consistent messaging format with the message types 126 and 127.
| Type | Feeder | Cat Flap | Poseidon | Description |
|---|---|---|---|---|
00 |
Acknowledgement Command Message to Status Message | |||
01 |
Get Command Message to retrieve message state | |||
07 |
Set Time Command Message to set device time | |||
09 |
Device settings parameters | |||
0b |
0b Boot Status Message | |||
0c |
Battery Status Message | |||
10 |
10 Boot Status Message | |||
11 |
Tag Provision Command Message to Status Message | |||
12 |
Set Cat Flap Curfew Command message | |||
13 |
Cat Movement through cat flap status message | |||
17 |
17 Unknown message | |||
18 |
Feeding status message | |||
0d |
Cat Flap Curfew Status messages | |||
0d |
Zero Feeder Scales | |||
1b |
Drinking status message |
126 Messages
These are the status message where multiple messages can all be sent in a single payload from the device. Directly after the 126 the message length in hex, then the message type, and the payload. At the end of the payload an additional message can be sent. Again the length then message type until the end of the payload. The first byte after the timestamp is the same hub counter message as already talked about 0xx0 above. That is consistent for all messages.
This means a message can look like:
tttttttt 0010 126 0d 09 00 01 00 9f cc 42 59 0c 02 00 00 00
| | | | | --+-- -----+----- | +----------
| | | | | | | | +- Bowl Count = 2
| | | | | | | +--- SubType = C
| | | | | | +----------- Timestamp
| | | | | +-------------------- Counter
| | | | +---------------------------- Message Type
| | | +------------------------------- Length
| | +---------------------------------- Message Type 126
| +--------------------------------------- Hub Counter Status Message
+---------------------------------------------- Hub UTC Hex Timestamp
The above secnario the message is a single message length is 0d bytes long. The message type is a 09 and the payload is 00 01 00 9f cc 42 59 0c 02 00 00 00.
tttttttt 0xx0 126 0d 09 00 01 00 9f cc 42 59 0c 02 00 00 00 0d 09 00 02 00 9f cc 42 59 0a 88 13 00 00
Similar to the above, the first message is the same message above, the second message is also 0d bytes long and a message type 09 with the payload 00 02 00 9f cc 42 59 0a 88 13 00 00.
127 Messages
The 127 messages are command messages either sent from the cloud service to change something, such as locking the cat flap or provisioning a new tag to the device. Because they are command messages they will always be 1000, but they are a single message so do not include the length so you need to just know how long the message you want to send is and just start with the message type immedateily after 127 ie
tttttttt 1000 127 09 00 01 00 9f cc 42 59 0c 01 00 00 00
| | | | --+-- -----+----- | +----------
| | | | | | | +- Bowl Count = 1
| | | | | | +--- SubType = C
| | | | | +----------- Timestamp
| | | | +-------------------- Counter
| | | +---------------------------- Message Type
| | +------------------------------- Message Type 126
| +------------------------------------ Command Message
+------------------------------------------- Hub UTC Hex Timestamp
The above is setting the Bowl Count to 1.
Message Counter
Directly after the message type is a 00, then a two byte little endian byte counter which counts from 0 to 65534 before cycling back to 0. This is so the cloud knows the current state of the devices and if messages are lost as if the hub is offline or disconnected from the internet none of the messsages are retained. Typical messages:
There is also a send a retrive counter, which are generated and increment independently. As each end have their own sent counter
tttttttt 0xx0 126 09 01 00 01 00 9e cc 42 59 11 11 - Device Counter = 1
tttttttt 1000 127 01 00 02 f2 9e cc 42 59 11 11 - Cloud Counter = F202 = 61954
Message Timestamp
After the counter is a 4 byte timestamp of the event. This is used by the device to set the time of it, and report back the timestamp of the device if there is any skew. The time is stored in UTC, but instead of using the UTC Timestamp they have their own custom rolled timestamp using bitwise operators as shown below which bits are converted into numbers. This is calculated in function devicetimestamp in message.py
def devicetimestamp(hexts, time_zone, tz_format):
""" Convert device hex timestamp into something human readable """
timestamp_int = int.from_bytes(hexts, byteorder='little')
year = int(f'20{timestamp_int >> 26:02}') # Year - 6 Bits, prepending 20 for 4 digit year
month = timestamp_int >> 22 & 0xf # Month - 4 Bits
day = timestamp_int >> 17 & 0x1f # Day - 5 Bits
hour = timestamp_int >> 12 & 0x1f # Hour - 5 Bits
minute = timestamp_int >> 6 & 0x3f # Minute - 6 Bits
second = timestamp_int & 0x3f # Second - 6 Bits
Example Conversion
Using the example timestamp `9e cc 42 59`
9e cc 42 59 -> Little Endian -> 5942CC9E -> Integer = 1497549982
1497549982 -> Binary 01011001010000101100110010011110
First 6 Bits 010110 -> 22 Year, so prepent 20 to 2022.
Next 4 Bits 0101 -> 5 Month
Next 5 Bits 00001 -> 1 Day
Next 5 Bits 01100 -> 12 Hour
Next 6 Bits 110010 -> 50 Minute
Next 6 Bits 011110 -> 30 Second
UTC Time = 2022-05-01 12:50:30
And since this is UTC time, it needs to be converted into local time.
Acknowledgement
Message Type: 00
Message Length: 07
Every status message needs to be acknowledged back using a 127 and a message type of 00 once it has been processed by the other end. This is sent with the same send counter, but the timestamp of the sending host, and include the message type and two bytes of 00 ie 01 00 00 being acknowledged.
Hub to Cloud -> tttttttt 0xx0 126 07 01 00 02 11 9e cc 42 59 11 22 33 44 55
Cloud to Hub -> tttttttt 1000 127 00 00 02 11 9f cc 42 59 01 00 00
Get State
Message Type: 01
Message Length = N/A as Command only, and varaible length.
To retrieve the current status of a message type a 01 command message is sent to the device.
Cloud to Hub -> tttttttt 1000 127 01 00 01 00 9f cc 42 59 09 00 ff # Boot message 09
Cloud to Hub -> tttttttt 1000 127 01 00 02 00 9f cc 42 59 0b 00 # Unknown 0b
Cloud to Hub -> tttttttt 1000 127 01 00 03 00 9f cc 42 59 0c 00 # Battery state
Cloud to Hub -> tttttttt 1000 127 01 00 04 00 9f cc 42 59 0d 00 # Lock state
Cloud to Hub -> tttttttt 1000 127 01 00 05 00 9f cc 42 59 10 00 # Boot message 10
Cloud to Hub -> tttttttt 1000 127 01 00 06 00 9f cc 42 59 11 00 ff # Tag provisioned
Cloud to Hub -> tttttttt 1000 127 01 00 07 00 9f cc 42 59 12 00 # Curfew state
Cloud to Hub -> tttttttt 1000 127 01 00 08 00 9f cc 42 59 17 00 00 # Boot message 17
Cloud to Hub -> tttttttt 1000 127 01 00 09 00 9f cc 42 59 1b 00 # Water state
Set Device Time
Message Type: 07
Command message to set the time of the device in UTC. As all the time is in UTC the device timestamp value needs to be set to UTC time.
Cloud to Hub -> tttttttt 1000 127 01 00 01 00 9f cc 42 59 00 00 00 00 07 # Sets the device time to 2022-05-01 12:50:30
Device settings messages
Message Type: 09
Messages Length: 0d
This is used for setting device settings. Such as custom modes and bowl counts for the feeder. The sub-type messages vary depending on the device and have a byte after the timestamp for the sub-type, then little endian 4 byte word for the value of the sub-type.
Status 09 Example:
0d 09 00 01 00 9f cc 42 59 0c 02 00 00 00
| | --+-- -----+----- | -----+-----
| | | Bowl Count = 2
| | +--- SubType = C
| +---------------------------- Message Type
+------------------------------- Length
Boot Device Information
Message Type 0b
The boot device message length is 43 and the figured fields defined message
elif value[0] == 0x0b: # Status - Boot Device Information
frame_response.Operation = "DeviceInfo"
frame_response.Hardware = b2is(value[8:12])
frame_response.Firmware = b2is(value[12:16])
frame_response.EntityType = EntityType(value[64]).name
frame_response.Val1 = b2is(value[16:20]) # **TODO Some value
frame_response.HexTS = value[20:28].hex()
frame_response.SerialHex = value[36:45].hex() # **TODO Serial Number calc somehow
Battery Information
Message Type 0c
Message length = 18
The battery information in the message
The 4 byte word after the timestamp is the battery value with 3 decimal places of accuracy as reported in the app.
126 18 0c 00 01 00 9f cc 42 59 b8 14 00 00 dd 0c 00 00 25 01 00 00 00 00 00 00
b8 14 00 00 -> Hex 14B8 -> Decimal 5304 / 1000 -> Battery voltage 5.304
Code:
elif value[0] == 0x0c: # Status - Battery state for four bytes
frame_response.Operation = 'Battery'
battery = str(round(int(b2is(value[8:12])) / 1000, 4))
frame_response.Battery = battery
frame_response.Value2 = str(int(b2is(value[12:16]))) # **TODO Not sure what this value is.
frame_response.Value3 = str(int(b2is(value[16:20]))) # **TODO Or this one
frame_response.BatteryTime = devicetimestamp(value[20:24], time_zone, '') # **TODO Last time the time was set?
Some boot message
Message type: 10
Message length: 18
The Boot in the message No idea what is in the message.
Message 11 - Tag Provisioning
Message Length = 12
This is used to and and remove tags to the device. The Tag Calculation is completely different from the Pet Door as it is little endian. This is also used to set lock state on the Cat Flap on Tag 00.
Example Message:
126 12 11 00 01 00 9f cc 42 59 4a 2a 86 48 d7 f9 01 02 01 00
| --+-- -----+----- --------+-------- | | | +- Always 0
| | | | +---- Tag Offset starting with 1
| | | +------- Tag State, 02 = Normal
| | +---------- Tag Type `01` for FDX-B
| +-------------------- Tag Value
+---------------------------------------------------- Message Type 11
There are 2 types of tags:
- Tag
01is a FDX-B tag with the numberingxxx.xxxxxxxxxxdecimal value 3 + 10 digits - Tag
03is a HDX tag which is presented as 5 bytes of hexhhhhhhhhhh
FDX-B Tag Conversion:
4a 2a 86 48 d7 f9 -> Little endian hex F9D748862A4A -> Int 274703030037066
274703030037066 -> Binary 111110011101011101001000100001100010101001001010
First 10 Bytes are Country Code = 11111001110 = 999
38 Bytes are National Code = 1011101001000100001100010101001001010 = 100001000010
FDX-B Tag = 999.100001000010
HDX Tag:
11 22 33 44 55 00 -> Direct translation of the hex to the tag and the last byte is always 00
Tag State is either 02 for active/normal, 06 for disabled, or 03 if it is a CatFlap and the Tag is set to Keep In
Tag Offset starts at 1, and supports up to 32 aka 1f tags on the device. Tag Offset 0 is used on the Cat Flap to set door locking state.
Message 09 - Poseidon Command
The only command you can send is for the Posedion to start looking for tags.
1000 127 09 00 01 00 9f cc 42 59 0f 01 00 00 00 # Look for tags
1000 127 09 00 01 00 9f cc 42 59 0f 00 00 00 00 # Stop looking for tags
Message 1b - Poseidon drinking
Message Length - Variable
The message length is typically 1b when no tags have been detected, when a tag is detected then the last byte changes from 00 to the number of tags. So thus the message length also changes. Similar that there is a Drinking action, time spent drinking, from and to weights.
For the drinking action refer to the enum
- PoseidonState FeederState enums
Example Messages
Water Bowl Status update Action = 00
126 1b 1b 00 ea 04 9f cc 42 59 00 00 00 01 0c d2 ff ff 8f 6f fe ff cb 00 21 01 00 00 00
| --+-- -----+----- | --+-- | -----+----- -----+----- | --+-- +- Number of Tags
| | | | | | | +----------- Always 21-28 01
| | | | | | +------------------- Event counter
| | | | | +-------------------------- Scale To
| | | | +-------------------------------------- Scale From
| | | | +-------------------------------------- Scale From
| | | +---------------------------------------------- Always 01
| | +-------------------------------------------------- Time Drinking in Seconds
| +------------------------------------------------------- Drinking Action, water removed no tag
+------------------------------------------------------------------------------- Message 1b
Single Animal Drink - Action = 01 and Tag Count = 1
126 22 1b 00 bb 04 9f cc 42 59 01 0f 00 01 7e 36 00 00 7e 36 00 00 b6 00 23 01 00 00 01 4a 2a 86 48 d7 f9 01
| --+-- -----+----- | --+-- | -----+----- -----+----- | --+-- | --------+-------- +- Tag Type 01 = FDX-B
| | | | | | +----------- Tag FDX-B = 999.100001000010
| | | | | +---------------------- Number of Tags = 1
| | | | +----------------------------------------------- Scale To
| | | +----------------------------------------------------------- Scale From
| | +----------------------------------------------------------------------- Time Drinking in Seconds
| +---------------------------------------------------------------------------- Drinking Action, water removed with 1 tag
Two Animals Drink - Action = 01 and Tag Count = 2
126 29 1b 00 bb 04 9f cc 42 59 01 3c 00 01 87 61 01 00 6c 5d 01 00 0b 00 24 01 00 00 02 4a 2a 86 48 d7 f9 01 4a 2a 86 48 d7 f9 01
| --+-- -----+----- | --+-- | -----+----- -----+----- | --+-- | --------+-------- +- --------+-------- +- Tag 2 Type 01 = FDX-B
| | | +----------- Tag 2 FDX-B = 999.100001000010
| | +---------------------- Tag 1 Type 01 = FDX-B
| +-------------------------------- Tag 1 FDX-B = 999.100001000010
+------------------------------------------- Number of Tags = 2
Water Bowl removed, to weight goes to negative value.
126 1b 1b 00 e8 04 9f cc 42 59 02 00 00 01 b7 87 00 00 0c d2 ff ff ca 00 21 01 00 00 00
| --+-- -----+----- | --+-- | -----+----- -----+----- | --+-- +- Number of Tags
| | | | | | | +----------- Always 21-28 01
| | | | | | +------------------- Event counter
| | | | | +-------------------------- Scale To
| | | | +-------------------------------------- Scale From
| | | | +-------------------------------------- Scale From
| | | +---------------------------------------------- Always 01
| | +-------------------------------------------------- Time Drinking in Seconds
| +------------------------------------------------------- Drinking Action, water removed no tag
+------------------------------------------------------------------------------- Message 1b
Water Bowl Refilled, notice how from weight is 0.
126 1b 1b 00 3a 05 9f cc 42 59 03 00 00 01 00 00 00 00 fa 64 01 00 0b 00 24 01 00 00 00
| --+-- -----+----- | --+-- | -----+----- -----+----- | --+-- +- Number of Tags
| | | +-------------------------- Scale To
| | +-------------------------------------- Scale From
| +------------------------------------------------------- Drinking Action, Refilled
+------------------------------------------------------------------------------- Message 1b