Add ESPHome YAML to README
This commit is contained in:
169
README.md
169
README.md
@@ -1,3 +1,172 @@
|
|||||||
# aciremote
|
# aciremote
|
||||||
|
|
||||||
ESPhome remote for AC Infinity wired fan, using USB-C connector
|
ESPhome remote for AC Infinity wired fan, using USB-C connector
|
||||||
|
|
||||||
|
# ESPHome configuration
|
||||||
|
|
||||||
|
```
|
||||||
|
esphome:
|
||||||
|
name: aci-fan
|
||||||
|
friendly_name: aci-fan
|
||||||
|
|
||||||
|
esp32:
|
||||||
|
variant: esp32c6
|
||||||
|
framework:
|
||||||
|
type: esp-idf
|
||||||
|
|
||||||
|
logger:
|
||||||
|
|
||||||
|
api:
|
||||||
|
encryption:
|
||||||
|
key: *********************************************
|
||||||
|
|
||||||
|
ota:
|
||||||
|
- platform: esphome
|
||||||
|
|
||||||
|
wifi:
|
||||||
|
ssid: !secret wifi_ssid
|
||||||
|
password: !secret wifi_password
|
||||||
|
ap:
|
||||||
|
ssid: aci-fan Fallback Hotspot
|
||||||
|
password: **************
|
||||||
|
|
||||||
|
captive_portal:
|
||||||
|
|
||||||
|
script:
|
||||||
|
- id: handle_fan_change
|
||||||
|
then:
|
||||||
|
- lambda: |
|
||||||
|
float level = (id(fan_speed).state?id(fan_speed).speed:0) / 20.0;
|
||||||
|
esphome::light::LightState* ids[] = {id(led1), id(led2), id(led3), id(led4)};
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
float brightness = level * 4 - i;
|
||||||
|
if (brightness < 0)
|
||||||
|
brightness = 0;
|
||||||
|
if (brightness > 1)
|
||||||
|
brightness = 1;
|
||||||
|
ids[i]->turn_on().set_brightness(brightness).perform();
|
||||||
|
}
|
||||||
|
|
||||||
|
output:
|
||||||
|
- platform: ledc
|
||||||
|
pin: GPIO19
|
||||||
|
id: fan_pwm
|
||||||
|
inverted: true
|
||||||
|
frequency: 4882Hz
|
||||||
|
min_power: "0.1"
|
||||||
|
zero_means_zero: true
|
||||||
|
- platform: ledc
|
||||||
|
pin: GPIO20
|
||||||
|
id: led_led1
|
||||||
|
frequency: 4882Hz
|
||||||
|
- platform: ledc
|
||||||
|
pin: GPIO21
|
||||||
|
id: led_led2
|
||||||
|
frequency: 4882Hz
|
||||||
|
- platform: ledc
|
||||||
|
pin: GPIO22
|
||||||
|
id: led_led3
|
||||||
|
frequency: 4882Hz
|
||||||
|
- platform: ledc
|
||||||
|
pin: GPIO23
|
||||||
|
id: led_led4
|
||||||
|
frequency: 4882Hz
|
||||||
|
|
||||||
|
light:
|
||||||
|
- platform: monochromatic
|
||||||
|
id: led1
|
||||||
|
output: led_led1
|
||||||
|
internal: true
|
||||||
|
default_transition_length: 0s
|
||||||
|
- platform: monochromatic
|
||||||
|
id: led2
|
||||||
|
output: led_led2
|
||||||
|
internal: true
|
||||||
|
default_transition_length: 0s
|
||||||
|
- platform: monochromatic
|
||||||
|
id: led3
|
||||||
|
output: led_led3
|
||||||
|
internal: true
|
||||||
|
default_transition_length: 0s
|
||||||
|
- platform: monochromatic
|
||||||
|
id: led4
|
||||||
|
output: led_led4
|
||||||
|
internal: true
|
||||||
|
default_transition_length: 0s
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- platform: pulse_counter
|
||||||
|
name: "Fan RPM"
|
||||||
|
pin: GPIO18
|
||||||
|
id: fan_rpm
|
||||||
|
device_class: speed
|
||||||
|
unit_of_measurement: RPM
|
||||||
|
filters:
|
||||||
|
- multiply: 0.33333333333333
|
||||||
|
accuracy_decimals: 0
|
||||||
|
update_interval: 5s
|
||||||
|
|
||||||
|
fan:
|
||||||
|
- platform: speed
|
||||||
|
name: Fan Speed
|
||||||
|
id: fan_speed
|
||||||
|
output: fan_pwm
|
||||||
|
speed_count: 20
|
||||||
|
restore_mode: RESTORE_DEFAULT_ON
|
||||||
|
on_speed_set:
|
||||||
|
- then:
|
||||||
|
- script.execute: handle_fan_change
|
||||||
|
on_state:
|
||||||
|
- then:
|
||||||
|
- script.execute: handle_fan_change
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
name: Up
|
||||||
|
id: button_up
|
||||||
|
internal: true
|
||||||
|
pin:
|
||||||
|
number: GPIO0
|
||||||
|
inverted: true
|
||||||
|
mode:
|
||||||
|
input: true
|
||||||
|
pullup: true
|
||||||
|
on_press:
|
||||||
|
- then:
|
||||||
|
- lambda: |
|
||||||
|
if (id(fan_speed).state) {
|
||||||
|
id(fan_speed).turn_on().set_speed(id(fan_speed).speed + 1).perform();
|
||||||
|
} else {
|
||||||
|
id(fan_speed).turn_on().set_speed(1).perform();
|
||||||
|
}
|
||||||
|
filters:
|
||||||
|
- delayed_on: 50ms
|
||||||
|
- autorepeat:
|
||||||
|
delay: 500ms
|
||||||
|
time_off: 100ms
|
||||||
|
time_on: 150ms
|
||||||
|
- platform: gpio
|
||||||
|
name: Down
|
||||||
|
id: button_down
|
||||||
|
internal: true
|
||||||
|
pin:
|
||||||
|
number: GPIO1
|
||||||
|
inverted: true
|
||||||
|
mode:
|
||||||
|
input: true
|
||||||
|
pullup: true
|
||||||
|
on_press:
|
||||||
|
- then:
|
||||||
|
- lambda: |
|
||||||
|
int current_speed = id(fan_speed).speed;
|
||||||
|
if (current_speed > 1) {
|
||||||
|
id(fan_speed).turn_on().set_speed(current_speed - 1).perform();
|
||||||
|
} else {
|
||||||
|
id(fan_speed).turn_off().perform();
|
||||||
|
}
|
||||||
|
filters:
|
||||||
|
- delayed_on: 50ms
|
||||||
|
- autorepeat:
|
||||||
|
delay: 500ms
|
||||||
|
time_off: 100ms
|
||||||
|
time_on: 150ms
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user