PLUGIN: Broadlink RM Interface

@cybrmage

I’ve been looking at the Broadlink references - noting they may also be in error:
GitHub - mjg59/python-broadlink: Python module for controlling Broadlink RM2/3 (Pro) remote controls, A1 sensor platforms and SP2/3 smartplugs
Broadlink smart home devices complete protocol hack | by Ipsum Domus | Smart Home DIY

In your plugin ver1.16 there are potentially a few problems:

-- line 982
-- using the hash here will give the incorrect result as tables/arrays start at one
for i = 0, #dPacket do[/code]
The hash is used in this manner in a variety of locations.

The refs seem to indicate these entries are not required. Also if they were; the msb value of 0x00 is missing 
[code]-- lines 930 to 937
			[0x00] = string.char(0x5a),  -- public flag

			[0x01] = string.char(0xa5),  -- lsb 64bit
			[0x02] = string.char(0xaa),
			[0x03] = string.char(0x55),
			[0x04] = string.char(0x5a),
			[0x05] = string.char(0xa5),
			[0x06] = string.char(0xaa),
			[0x07] = string.char(0x55),  -- msb-1 64bit

Unsure why this is set to 0x0d? I believe it’s meant to be the msb of the port number.

-- line 961 [0x1d] = string.char(0x0d),

Entries don’t appear to match the references, which off course may be incorrect as well.

-- lines 942 to949 [0x0c] = string.char(DATE.year - (math.floor(DATE.year/256) * 256)), [0x0d] = string.char(math.floor(DATE.year/256)), [0x0e] = string.char(DATE.sec), [0x0f] = string.char(DATE.min), [0x10] = string.char(DATE.hour), [0x11] = string.char(DATE.day), [0x12] = string.char((DATE.wday - 1)), [0x13] = string.char(DATE.month),

References indicate a minus sign be introduced at some stage eg -3600 vs 3600. Noting that the JavaScript getTimezoneOffset, as used in the one of the refs, returns the offset as a negative number.

-- line 923 local tzOffset = os.difftime(os.time(localdate), os.time(utcdate)) / 3600