ESPHome API: Message type serialization

I’m looking at the ESPHome API documentation at Protocol Details - ESPHome Developer Documentation

I’m confused about the specification for the message type, it shows here that it’s encoded as a VarInt, but that the values are up to 65535. How would that be possible when a VarInt provides 7 bits of data per byte? Shouldn’t the values go up to 16383? Under “Common Elements” it’s described as a 16-bit unsigned value.

I feel one of these details is wrong, but I’m not sure which one.

I am not much into ESPHome, but 2^16 = 65536 possibilities and unsigned means it goes from 0 to 65535. Signed would be -32768 to 32767.

Regarding the 7 bits out of 8 for data, then I just think the last bit is a parity bit, which will give 16384 for data.

The disparity between those 2 numbers is due to the view.
If you are looking at the data you can transport in varint, then it will be 14bits, but you need to actually transport all 16bits to get the data to the destination.