generated from esphome/esphome-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esphome-razer-nommo-pro-speaker-controller.yaml
708 lines (664 loc) · 22.5 KB
/
esphome-razer-nommo-pro-speaker-controller.yaml
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
# These substitutions allow the end user to override certain values
substitutions:
name: "razer-nommo-pro-controller"
device_name: rz_spk_ctl
speaker_mac: 00:00:00:00:00:00 # CHANGE ME
esphome:
name: "${name}"
# Automatically add the mac address to the name
# so you can use a single firmware for all devices
#name_add_mac_suffix: true
# This will allow for (future) project identification,
# configuration and updates.
project:
name: esphome.razer-nommo-pro-speaker-controller
version: "1.1"
on_boot:
then:
- lambda: "id(blue_led).turn_on();"
esp32:
board: esp32doit-devkit-v1
# To be able to get logs from the device via serial and api.
logger:
# API is a requirement of the dashboard import.
api:
# CHANGE ME
# OTA is required for Over-the-Air updating
ota:
# CHANGE ME
# This should point to the public location of this yaml file.
dashboard_import:
package_import_url: github://d-rez/esphome-razer-nommo-pro-speaker-control/d-rez/esphome-razer-nommo-pro-speaker-controller.yaml@main
wifi:
# Set up a wifi access point using the device name above
ap:
password: "beatrice"
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device.
captive_portal:
##########################################################
# Sets up the improv via serial client for Wi-Fi provisioning.
# Handy if your device has a usb port for the user to add credentials when they first get it.
improv_serial:
# BLE Protocol reverse-engineering details now live in https://github.com/d-rez/esphome-razer-nommo-pro-speaker-control/blob/main/razer-ble-protocol-reverse-engineering.md
text_sensor:
- platform: template
name: "${device_name}_uptime_human"
id: uptime_human
entity_category: diagnostic
icon: mdi:clock-start
time:
- platform: homeassistant
id: homeassistant_time
esp32_ble_tracker:
output:
- id: blue_led
platform: gpio
pin: GPIO2
# Using output.gpio here because status_led component does not clear errored state once BLE device is disconnected i.e. using the ble_client switch
remote_receiver:
pin:
number: GPIO18 # CHANGE ME (if needed)
inverted: true
mode:
input: true
pullup: false
ble_client:
- mac_address: "${speaker_mac}"
id: nommo_tv
on_connect:
then:
- lambda: |-
ESP_LOGD("ble_client_lambda", "Connected to BLE device");
id(nommo_ble_status).publish_state(true);
id(blue_led).turn_off(); // signal device connected
- delay: 3s # fails to execute ble_write if done too soon after connecting
- ble_client.ble_write:
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: [0x01, 0x00, 0xfc, 0x02, 0xc0, 0x48] # request settings (0xc0)
- delay: 500ms
- ble_client.ble_write:
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: [0x01, 0x00, 0xfc, 0x02, 0xcc, 0x48] # request volumes (0xcc)
on_disconnect:
then:
- lambda: |-
ESP_LOGD("ble_client_lambda", "Disconnected from BLE device");
id(nommo_ble_status).publish_state(false);
id(blue_led).turn_on(); // signal device disconnected
switch:
- platform: ble_client
ble_client_id: nommo_tv
name: "${device_name}_nommo_enable_control"
- platform: template
name: "${device_name}_nommo_power"
icon: mdi:power
turn_on_action:
ble_client.ble_write:
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: [0x01, 0x00, 0xfc, 0x03, 0xc6, 0x48, 0x01]
turn_off_action:
ble_client.ble_write:
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: [0x01, 0x00, 0xfc, 0x03, 0xc6, 0x48, 0x00]
lambda: !lambda |-
return id(nommo_power_state).state;
- platform: template
name: "${device_name}_nommo_mute"
id: nommo_mute_switch
icon: mdi:volume-mute
turn_on_action:
ble_client.ble_write:
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: [0x01, 0x00, 0xfc, 0x03, 0xc1, 0x48, 0x00]
turn_off_action:
ble_client.ble_write:
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: [0x01, 0x00, 0xfc, 0x03, 0xc1, 0x48, 0x01]
lambda: !lambda |-
return id(nommo_muted_state).state;
- platform: template
name: "${device_name}_nommo_auto_poweroff"
icon: mdi:timer-outline
turn_on_action:
ble_client.ble_write:
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: [0x01, 0x00, 0xfc, 0x03, 0xc3, 0x48, 0x01]
turn_off_action:
ble_client.ble_write:
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: [0x01, 0x00, 0xfc, 0x03, 0xc3, 0x48, 0x00]
lambda: !lambda |-
return id(nommo_auto_poweroff_state).state;
binary_sensor:
- platform: status
name: "${device_name}_status"
- platform: template
id: nommo_power_state
- platform: template
id: nommo_muted_state
- platform: template
id: nommo_ble_status
name: "${device_name}_nommo_ble_status"
device_class: connectivity
entity_category: diagnostic
- platform: template
id: nommo_eq_dolby
on_state:
then:
- component.update: nommo_eq
- platform: template
id: nommo_auto_poweroff_state
- platform: remote_receiver
id: ir_remote_volup
lg:
# 04FB 02FD
data: 0x20DF40BF
nbits: 32
on_press:
then:
if:
condition:
- binary_sensor.is_on: nommo_power_state
then:
lambda: |-
auto call = id(nommo_volume).make_call();
float v = id(nommo_volume).state + 0.05;
if (v>1) {
v = 1;
}
call.set_value(v);
call.perform();
- platform: remote_receiver
id: ir_remote_voldn
lg:
# 04FB 03FC
data: 0x20DFC03F
nbits: 32
on_press:
then:
if:
condition:
- binary_sensor.is_on: nommo_power_state
then:
lambda: |-
auto call = id(nommo_volume).make_call();
float v = id(nommo_volume).state - 0.05;
if (v<0) {
v = 0;
}
call.set_value(v);
call.perform();
- platform: remote_receiver
id: ir_remote_mute
lg:
# 04FB 09F6
data: 0x20DF906F
nbits: 32
on_press:
then:
if:
condition:
- binary_sensor.is_on: nommo_power_state
then:
switch.toggle: nommo_mute_switch
globals:
- id: nommo_eq_bands
type: float[8]
restore_value: no
initial_value: "{0,0,0,0,0,0,0,0}"
- id: nommo_eq_bands_modified
type: bool[8]
restore_value: no
initial_value: "{false,false,false,false,false,false,false,false}"
number:
- platform: template
name: "${device_name}_nommo_volume"
id: nommo_volume
min_value: 0
max_value: 1
step: 0.01
icon: 'mdi:volume-high'
set_action:
if:
condition:
- binary_sensor.is_on: nommo_power_state
then:
- script.execute:
id: nommo_vol_write_ble
volume: !lambda "return x;"
lambda: |-
return id(nommo_volume_raw).state;
- platform: template
name: "${device_name}_nommo_bass_volume"
id: bass_volume
min_value: 0
max_value: 1
step: 0.01
icon: 'mdi:tune'
set_action:
- ble_client.ble_write:
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: !lambda |-
// x coming from home assistant media_player will be in 0..1 range, speaker expects 0..100
return {0x01, 0x00, 0xfc, 0x03, 0xc7, 0x48, uint8_t(x*100)};
lambda: |-
return id(bass_volume_raw).state;
# EQ bands below
- platform: template
name: "${device_name}_nommo_eq_band_60hz"
id: nommo_eq_band_60hz
min_value: -9
max_value: 9
step: 0.18
unit_of_measurement: "dB"
icon: "mdi:tune-vertical"
set_action:
- lambda: |-
id(nommo_eq_bands)[0] = x;
id(nommo_eq_bands_modified)[0] = true;
- script.execute: nommo_eq_bands_write_ble
lambda: |-
return id(nommo_eq_band_60hz_raw).state;
- platform: template
name: "${device_name}_nommo_eq_band_250hz"
id: nommo_eq_band_250hz
min_value: -9
max_value: 9
step: 0.18
unit_of_measurement: "dB"
icon: "mdi:tune-vertical"
set_action:
- lambda: |-
id(nommo_eq_bands)[1] = x;
id(nommo_eq_bands_modified)[1] = true;
- script.execute: nommo_eq_bands_write_ble
lambda: |-
return id(nommo_eq_band_250hz_raw).state;
- platform: template
name: "${device_name}_nommo_eq_band_500hz"
id: nommo_eq_band_500hz
min_value: -9
max_value: 9
step: 0.18
unit_of_measurement: "dB"
icon: "mdi:tune-vertical"
set_action:
- lambda: |-
id(nommo_eq_bands)[2] = x;
id(nommo_eq_bands_modified)[20] = true;
- script.execute: nommo_eq_bands_write_ble
lambda: |-
return id(nommo_eq_band_500hz_raw).state;
- platform: template
name: "${device_name}_nommo_eq_band_1khz"
id: nommo_eq_band_1khz
min_value: -9
max_value: 9
step: 0.18
unit_of_measurement: "dB"
icon: "mdi:tune-vertical"
set_action:
- lambda: |-
id(nommo_eq_bands)[3] = x;
id(nommo_eq_bands_modified)[3] = true;
- script.execute: nommo_eq_bands_write_ble
lambda: |-
return id(nommo_eq_band_1khz_raw).state;
- platform: template
name: "${device_name}_nommo_eq_band_2khz"
id: nommo_eq_band_2khz
min_value: -9
max_value: 9
step: 0.18
unit_of_measurement: "dB"
icon: "mdi:tune-vertical"
set_action:
- lambda: |-
id(nommo_eq_bands)[4] = x;
id(nommo_eq_bands_modified)[4] = true;
- script.execute: nommo_eq_bands_write_ble
lambda: |-
return id(nommo_eq_band_2khz_raw).state;
- platform: template
name: "${device_name}_nommo_eq_band_4khz"
id: nommo_eq_band_4khz
min_value: -9
max_value: 9
step: 0.18
unit_of_measurement: "dB"
icon: "mdi:tune-vertical"
set_action:
- lambda: |-
id(nommo_eq_bands)[5] = x;
id(nommo_eq_bands_modified)[5] = true;
- script.execute: nommo_eq_bands_write_ble
lambda: |-
return id(nommo_eq_band_4khz_raw).state;
- platform: template
name: "${device_name}_nommo_eq_band_8khz"
id: nommo_eq_band_8khz
min_value: -9
max_value: 9
step: 0.18
unit_of_measurement: "dB"
icon: "mdi:tune-vertical"
set_action:
- lambda: |-
id(nommo_eq_bands)[6] = x;
id(nommo_eq_bands_modified)[6] = true;
- script.execute: nommo_eq_bands_write_ble
lambda: |-
return id(nommo_eq_band_8khz_raw).state;
- platform: template
name: "${device_name}_nommo_eq_band_16khz"
id: nommo_eq_band_16khz
min_value: -9
max_value: 9
step: 0.18
unit_of_measurement: "dB"
icon: "mdi:tune-vertical"
set_action:
- lambda: |-
id(nommo_eq_bands)[7] = x;
id(nommo_eq_bands_modified)[7] = true;
- script.execute: nommo_eq_bands_write_ble
lambda: |-
return id(nommo_eq_band_16khz_raw).state;
script:
- id: nommo_eq_bands_write_ble
mode: restart
then:
- delay: 100ms
- ble_client.ble_write:
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: !lambda |-
// Speaker expects -9dB to be 0x00 and +9dB to be 0x64 which effectively means a 0.18 dB step for each 0x01 increase
// It also expects all values at once so let's call this as a script and keep the band # and value of last call in lambdas to avoid too much code duplication
return {0x01, 0x00, 0xfc, 0x0a, 0xd3, 0x48,
uint8_t(((id(nommo_eq_bands_modified)[0]==true?id(nommo_eq_bands)[0]:id(nommo_eq_band_60hz_raw).state)+9.0)/0.18),
uint8_t(((id(nommo_eq_bands_modified)[1]==true?id(nommo_eq_bands)[1]:id(nommo_eq_band_250hz_raw).state)+9.0)/0.18),
uint8_t(((id(nommo_eq_bands_modified)[2]==true?id(nommo_eq_bands)[2]:id(nommo_eq_band_500hz_raw).state)+9.0)/0.18),
uint8_t(((id(nommo_eq_bands_modified)[3]==true?id(nommo_eq_bands)[3]:id(nommo_eq_band_1khz_raw).state)+9.0)/0.18),
uint8_t(((id(nommo_eq_bands_modified)[4]==true?id(nommo_eq_bands)[4]:id(nommo_eq_band_2khz_raw).state)+9.0)/0.18),
uint8_t(((id(nommo_eq_bands_modified)[5]==true?id(nommo_eq_bands)[5]:id(nommo_eq_band_4khz_raw).state)+9.0)/0.18),
uint8_t(((id(nommo_eq_bands_modified)[6]==true?id(nommo_eq_bands)[6]:id(nommo_eq_band_8khz_raw).state)+9.0)/0.18),
uint8_t(((id(nommo_eq_bands_modified)[7]==true?id(nommo_eq_bands)[7]:id(nommo_eq_band_16khz_raw).state)+9.0)/0.18)
};
- lambda: "for (int i=0; i<8; i++) { id(nommo_eq_bands_modified)[i] = false; }"
- id: nommo_vol_write_ble
mode: restart
parameters:
volume: float
then:
- delay: 100ms
- ble_client.ble_write:
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: !lambda |-
// x coming from home assistant media_player will be in 0..1 range, speaker expects 0..100
return {0x01, 0x00, 0xfc, 0x03, 0xc8, 0x48, uint8_t(volume*100)};
sensor:
- platform: wifi_signal
name: "${device_name}_rssi"
update_interval: 5min
- platform: uptime
id: uptime_sensor
name: "${device_name}_uptime"
update_interval: 5min
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m " : "") +
(to_string(seconds) + "s")
).c_str();
- platform: template
id: nommo_eq_raw
on_value:
then:
- component.update: nommo_eq
- platform: template
id: nommo_source_raw
on_value:
then:
- component.update: nommo_source
- platform: template
id: bass_volume_raw
filters:
# x coming from home assistant media_player will be in 0..1 range, speaker expects 0..100
- multiply: 0.01
on_value:
then:
- component.update: bass_volume
- platform: template
id: nommo_volume_raw
filters:
# x coming from home assistant media_player will be in 0..1 range, speaker expects 0..100
- multiply: 0.01
on_value:
then:
- component.update: nommo_volume
- platform: template
id: nommo_eq_band_60hz_raw
filters:
# Speaker expects -9dB to be 0x00 and +9dB to be 0x64 which effectively means a 0.18 dB step for each 0x01 increase
- multiply: 0.18
- offset: -9.0
on_value:
then:
- component.update: nommo_eq_band_60hz
- platform: template
id: nommo_eq_band_250hz_raw
filters:
# Speaker expects -9dB to be 0x00 and +9dB to be 0x64 which effectively means a 0.18 dB step for each 0x01 increase
- multiply: 0.18
- offset: -9.0
on_value:
then:
- component.update: nommo_eq_band_250hz
- platform: template
id: nommo_eq_band_500hz_raw
filters:
# Speaker expects -9dB to be 0x00 and +9dB to be 0x64 which effectively means a 0.18 dB step for each 0x01 increase
- multiply: 0.18
- offset: -9.0
on_value:
then:
- component.update: nommo_eq_band_500hz
- platform: template
id: nommo_eq_band_1khz_raw
filters:
# Speaker expects -9dB to be 0x00 and +9dB to be 0x64 which effectively means a 0.18 dB step for each 0x01 increase
- multiply: 0.18
- offset: -9.0
on_value:
then:
- component.update: nommo_eq_band_1khz
- platform: template
id: nommo_eq_band_2khz_raw
filters:
# Speaker expects -9dB to be 0x00 and +9dB to be 0x64 which effectively means a 0.18 dB step for each 0x01 increase
- multiply: 0.18
- offset: -9.0
on_value:
then:
- component.update: nommo_eq_band_2khz
- platform: template
id: nommo_eq_band_4khz_raw
filters:
# Speaker expects -9dB to be 0x00 and +9dB to be 0x64 which effectively means a 0.18 dB step for each 0x01 increase
- multiply: 0.18
- offset: -9.0
on_value:
then:
- component.update: nommo_eq_band_4khz
- platform: template
id: nommo_eq_band_8khz_raw
filters:
# Speaker expects -9dB to be 0x00 and +9dB to be 0x64 which effectively means a 0.18 dB step for each 0x01 increase
- multiply: 0.18
- offset: -9.0
on_value:
then:
- component.update: nommo_eq_band_8khz
- platform: template
id: nommo_eq_band_16khz_raw
filters:
# Speaker expects -9dB to be 0x00 and +9dB to be 0x64 which effectively means a 0.18 dB step for each 0x01 increase
- multiply: 0.18
- offset: -9.0
on_value:
then:
- component.update: nommo_eq_band_16khz
- platform: ble_client
ble_client_id: nommo_tv
id: nommo_ble_notification
type: characteristic
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: '43484152-2dab-3141-6972-6f6861424c45'
notify: true
lambda: |-
if (x.size() < 4) { return {}; } // don't care about smaller packets (if any)
if (x[3] == 0xCC) {
id(nommo_volume_raw).publish_state(x[5]);
id(bass_volume_raw).publish_state(x[6]);
id(nommo_eq_band_60hz_raw).publish_state(x[8]);
id(nommo_eq_band_250hz_raw).publish_state(x[9]);
id(nommo_eq_band_500hz_raw).publish_state(x[10]);
id(nommo_eq_band_1khz_raw).publish_state(x[11]);
id(nommo_eq_band_2khz_raw).publish_state(x[12]);
id(nommo_eq_band_4khz_raw).publish_state(x[13]);
id(nommo_eq_band_8khz_raw).publish_state(x[14]);
id(nommo_eq_band_16khz_raw).publish_state(x[15]);
}
else if (x[3] == 0xC0) {
id(nommo_power_state).publish_state(x[10]);
id(nommo_muted_state).publish_state(!x[6]);
id(nommo_eq_dolby).publish_state(x[7]);
id(nommo_eq_raw).publish_state(x[8]);
id(nommo_source_raw).publish_state(x[5]);
id(nommo_auto_poweroff_state).publish_state(x[9]);
}
return {};
select:
- platform: template
name: "${device_name}_nommo_source"
id: nommo_source
icon: mdi:import
lambda: |-
if (id(nommo_source_raw).state==0x01) {
return {"Optical"};
} else if (id(nommo_source_raw).state==0x02) {
return {"Analog"};
} else if (id(nommo_source_raw).state==0x03) {
return {"Bluetooth"};
} else if (id(nommo_source_raw).state==0x04) {
return {"USB"};
} else {
return {};
}
options:
- Optical
- Analog
- Bluetooth
- USB
set_action:
ble_client.ble_write:
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: !lambda |-
uint8_t src = 0;
(x=="Optical" && (src = 0x01)) || (x=="Analog" && (src = 0x02)) || (x=="Bluetooth" && (src = 0x03)) || (x=="USB" && (src=0x04));
return {0x01, 0x00, 0xfc, 0x03, 0xc5, 0x48, src};
- platform: template
name: "${device_name}_nommo_eq"
id: nommo_eq
icon: 'mdi:equalizer'
lambda: |-
if (id(nommo_eq_raw).state==0) {
return {"THX"};
}
char buffer[14];
if (id(nommo_eq_raw).state==0x01) {
sprintf(buffer, "%s%s", id(nommo_eq_dolby).state?"Dolby ":"", "Game");
} else if (id(nommo_eq_raw).state==0x02) {
sprintf(buffer, "%s%s", id(nommo_eq_dolby).state?"Dolby ":"", "Music");
} else if (id(nommo_eq_raw).state==0x03) {
sprintf(buffer, "%s%s", id(nommo_eq_dolby).state?"Dolby ":"", "Movie");
} else if (id(nommo_eq_raw).state==0x0a) {
sprintf(buffer, "Custom EQ");
}
return {buffer};
options:
- Dolby Game
- Dolby Music
- Dolby Movie
- THX
- Game
- Music
- Movie
- Custom EQ
set_action:
# Need to update both Dolby and EQ bytes using 2 separate writes
- ble_client.ble_write:
# EQ state
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: !lambda |-
uint8_t eq = 0; // 0 is THX
if (x=="Dolby Game" || x=="Game") {
eq = 0x01;
} else if (x=="Dolby Music" || x=="Music") {
eq = 0x02;
} else if (x=="Dolby Movie" || x=="Movie") {
eq = 0x03;
} else if (x=="Custom EQ") {
eq = 0x0a;
} // else == 0 so THX
return {0x01, 0x00, 0xfc, 0x03, 0xc4, 0x48, eq};
- ble_client.ble_write:
# Dolby state
id: nommo_tv
service_uuid: '5052494d-2dab-0341-6972-6f6861424c45'
characteristic_uuid: "43484152-2dab-3241-6972-6f6861424c45"
value: !lambda |-
uint8_t dolby = 0;
if (x=="Dolby Game" || x=="Dolby Music" || x=="Dolby Movie" ) {
dolby = 0x01;
}
return {0x01, 0x00, 0xfc, 0x03, 0xc2, 0x48, dolby};