-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalysis.txt
101 lines (64 loc) · 3.99 KB
/
analysis.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
These are timings (skipping any headers) from a lirc file that is known to work:
+427 -460
+460 -427
+460 -1248
+460 -460
+427 -1281
+460 -427
+460 -427
+460 -427
+427 -1314
+427 -1281
+460 -427
it defines on time and off time in microseconds
I had a document that said the long pause was a zero and short was one, but that didn't produce the right numbers for me
First eight bits of the above should produce:
00101000
(this is the first byte sent by any Fujitsu payload we're working with)
So each bit is represented as an on and off pulse.
427 on, 460 off is a binary one
460 on, 1248 off is a binary zero
Looking at the byte again:
00101000
That is hex 0x28 but when you develop codes for the unit they start with 0x14. The byte order is reversed.
The value is SENT little-endian, but the codes we assemble are big-endian (I may have had this backwards in my code and the endian-ness functions have the wrong names--I'll try to confirm the terminology and fix it. One way or another we have to reverse the byte order.
The broadlink python library expects the pulse timings as an integer--the integer is multiplied by broadlink's internal tick length to product a pulse of a certain length. e.g. for a pulse width of 420 microseconds you would divide by the pulse width (32.84) and round it to get 13. I am still not sure how the internal tick length is arrived at. Sources:
https://www.reddit.com/r/homeassistant/comments/pl03cj/add_custom_codes_to_broadlink/
https://github.com/mjg59/python-broadlink/blob/master/protocol.md#sending-data
(I really don't understand the 269/8192 but...it works.)
So we can generate hex codes based on my [previous work](https://github.com/mattjm/Fujitsu_IR/) and [dabram's excellent work](http://old.ercoupe.com/audio/FujitsuIR.pdf) (a copy of the PDF is in this GH repo in case it ever disappears from the web). Then we just need to turn them into timings
At a high level, to translate the the Fujitsu hex codes into timings used by broadlink:
Convert each byte from big-endian to little-endian (e.g. the first value, 14, would read as 28). The bytes are still _sent_ in the same order.
Break hex values into binary
each one gets the pulse value above
each zero gets the pulse value above
THEN these have to be converted to broadlink format.
broadlink does the pulse timing as the number of ticks, where the tick value is 269/8192 or 32.84
So divide the pulse duration by 32.84, encode in hex, and that's the broadlink value. There is some leading and trailing stuff that has to be added for Broadlink to parse the data packet.
pseudocode:
fujitsuhexcode = 'deadbeef'
bigendiancode = bigendconvert(fujitsuhexcode)
# create pulses from binary....
for time in list:
broadlinkpulse = time/32.84
broadlinkcode.append(broadlinkpulse)
Implemented (poorly) in broadfromhexcode.py. Note this code is only tested to work with Fujitsu style hex codes. There is no expectation it should work for anything else. The output is the base64 encoded string that goes in a remote file for Home Assistant's SmartIR integration.
genfujitsuhex.py will generate hex codes based on the different settings.
#1-8: same with every command
#9: temp and change or on. least significant bit needs to be 1 for the machine to turn on. example. 11100000 = E0. No turn on. 11100001=E1. Turns on.
#10: mode hot/cold. and timer. Timer not implemented--always disabled.
#11: swing and fan
#12-14: timer
#heat high 60: 14 63 00 10 10 fe 09 30 || 00 04 01 00 00 00 20 ab
# 1 2 3 4 5 6 7 8 || 9 10 11 12 13 14 15 16
# known codes from captures (little-endian)
existing_codes = [
'28c60008087f900c80200000000004d5',
'28c60008087f900c88200000000004d9', # heat auto 60
'28c60008087f900c00208000000004d5', # heat high 60
'28c60008087f900c08208000000004d9', # heat high 62
'28c60008087f900c04208000000004d1', # heat high 64
'28c60008087f900c0280800000000476', #cool high 68
'28c60008087f900c07800000000004f3',# cool auto 88
'28c60008087f900c8780000000000473'# cool ON
]