1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import yaml
- DELAY_RESEND = 488400
- DELAY_HOLD_1 = 39800
- DELAY_HOLD_N = 95200
- PREAMBLE = 9000
- PREPAUSE = 4400
- PREHOLD = 2200
- SIGNAL = 500
- PAUSE_1 = 1700
- PAUSE_0 = 600
- rgbButtonsSingle = {
- "on": 0x407F807F,
- "off": 0x407F40BF,
- "candle": 0x407F8877,
- "warm white": 0x407F6897,
- "white": 0x407F50AF,
- "cold white": 0x407FC03F,
- "night": 0x407F48B7,
- "sleep": 0x407FE817,
- "reading": 0x407FD02F,
- "yoga": 0x407F20DF,
- "morning": 0x407FC837,
- "color wheel": 0x407F18E7,
- "random": 0x407F30CF,
- "evening": 0x407FA05F,
- "trees": 0x407F28D7,
- "water": 0x407F9867,
- "fire": 0x407FB04F,
- "hearts": 0x407F609F,
- }
- rgbButtonsRepeat = {
- "saturate": 0x407F58A7,
- "lighter": 0x407FF00F,
- "blue": 0x407FA857,
- "red": 0x407F708F,
- "orange": 0x407FE01F,
- "green": 0x407F10EF,
- }
- def ir_send_rgb(value):
- irSignal = [0] * 67
- irRepeatDelay = DELAY_RESEND
-
- irSignal[0] = PREAMBLE
- irSignal[1] = -PREPAUSE
- irSignal[2] = SIGNAL
-
- for i in range(32):
- irSignal[65-i*2] = -PAUSE_1 if value & 1<<i else -PAUSE_0
- irSignal[66-i*2] = SIGNAL
- return irSignal
- data = {
- 'button': [
- {
- 'platform': "template",
- 'name': key,
- 'on_press': [
- {
- 'remote_transmitter.transmit_raw': {
- 'code': ir_send_rgb(value),
- 'carrier_frequency': 38_000,
- 'repeat': {
- 'times': 3,
- 'wait_time': "0.5s",
- },
- }
- }
- ]
- } for key, value in rgbButtonsSingle.items()
- ] + [
- {
- 'platform': "template",
- 'name': key,
- 'on_press': [
- {
- 'remote_transmitter.transmit_raw': {
- 'code': ir_send_rgb(value),
- 'carrier_frequency': 38_000,
- 'repeat': {
- 'times': 5,
- 'wait_time': "0.5s",
- },
- }
- }
- ]
- } for key, value in rgbButtonsRepeat.items()
- ]
- }
- with open('data.yaml', 'w') as outfile:
- yaml.dump(data, outfile, default_flow_style=None)
|