89 lines
2.0 KiB
YAML
89 lines
2.0 KiB
YAML
---
|
|
select:
|
|
- platform: template
|
|
name: "PD Modus"
|
|
id: pd_voltage
|
|
optimistic: true
|
|
options:
|
|
- "Off"
|
|
- "5V"
|
|
- "9V"
|
|
- "12V"
|
|
- "15V"
|
|
- "20V"
|
|
initial_option: "Off"
|
|
on_value:
|
|
then:
|
|
- logger.log:
|
|
format: "Voltage set: %s (index %d)"
|
|
args: ["x.c_str()", "i"]
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return (id(pd_voltage).active_index() == 0);
|
|
then:
|
|
- logger.log: "Off"
|
|
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return (id(pd_voltage).active_index() == 1);
|
|
then:
|
|
- logger.log: "5V"
|
|
- output.turn_on: pd_cfg1
|
|
- output.turn_off: pd_cfg2
|
|
- output.turn_off: pd_cfg3
|
|
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return (id(pd_voltage).active_index() == 2);
|
|
then:
|
|
- logger.log: "9V"
|
|
- output.turn_off: pd_cfg1
|
|
- output.turn_off: pd_cfg2
|
|
- output.turn_off: pd_cfg3
|
|
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return (id(pd_voltage).active_index() == 3);
|
|
then:
|
|
- logger.log: "12V"
|
|
- output.turn_off: pd_cfg1
|
|
- output.turn_off: pd_cfg2
|
|
- output.turn_on: pd_cfg3
|
|
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return (id(pd_voltage).active_index() == 4);
|
|
then:
|
|
- logger.log: "15V"
|
|
- output.turn_off: pd_cfg1
|
|
- output.turn_on: pd_cfg2
|
|
- output.turn_on: pd_cfg3
|
|
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return (id(pd_voltage).active_index() == 5);
|
|
then:
|
|
- logger.log: "20V"
|
|
- output.turn_off: pd_cfg1
|
|
- output.turn_on: pd_cfg2
|
|
- output.turn_off: pd_cfg3
|
|
|
|
|
|
output:
|
|
- platform: gpio
|
|
pin: ${pin_pd_cfg1}
|
|
id: pd_cfg1
|
|
- platform: gpio
|
|
pin: ${pin_pd_cfg2}
|
|
id: pd_cfg2
|
|
- platform: gpio
|
|
pin: ${pin_pd_cfg3}
|
|
id: pd_cfg3
|
|
|