Skip to content

Commit

Permalink
Skip switch LED if netled_reuse is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba2k2 committed Sep 7, 2023
1 parent 2531178 commit 5d59669
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions upk2esphome/parts/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ def generate(yr: YamlResult, config: ConfigData, opts: Opts):
}
invert(switch, rl_inv)

if led_pin is not None and netled_reuse:
yr.warn(
f"Skipping LED {i} on pin P{led_pin} - shared status LED is enabled"
)
led_pin = None

if led_pin is not None:
yr.log(f" - LED {i}: pin P{led_pin}")
output = {
Expand Down
34 changes: 34 additions & 0 deletions upk2esphome/tests/plug_netled_reuse_led1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"bt1_lv": 0,
"bt1_pin": 10,
"bt1_type": 0,
"ch1_stat": 2,
"ch_cddpid1": 9,
"ch_dpid1": 1,
"ch_num": 1,
"chip_type": 0,
"crc": 8,
"ele_fun_en": 1,
"ele_pin": 7,
"ffc_select": 1,
"jv": "1.0.4",
"led1_lv": 0,
"led1_pin": 23,
"lose_vol": 90,
"module": "CB2S",
"net_trig": 4,
"netled1_lv": 0,
"netled1_pin": 8,
"netled_reuse": 1,
"over_cur": 25000,
"over_vol": 270,
"reset_t": 3,
"resistor": 1,
"rl1_lv": 1,
"rl1_pin": 26,
"rl1_type": 0,
"sel_pin_lv": 1,
"sel_pin_pin": 24,
"vi_pin": 6,
"vol_def": 1
}

0 comments on commit 5d59669

Please sign in to comment.