refactor
This commit is contained in:
parent
c62f0319e6
commit
e60b96d6e5
38 changed files with 1348 additions and 0 deletions
59
devices/athom-bulb.yaml
Normal file
59
devices/athom-bulb.yaml
Normal file
|
@ -0,0 +1,59 @@
|
|||
substitutions:
|
||||
light_restore_mode: RESTORE_DEFAULT_ON
|
||||
color_interlock: 'true'
|
||||
|
||||
esphome:
|
||||
board: esp8285
|
||||
platform: ESP8266
|
||||
name: ${hostname}
|
||||
build_path: ./build/${hostname}
|
||||
#on_boot:
|
||||
# then:
|
||||
# - script.execute: fast_boot_script
|
||||
|
||||
packages:
|
||||
base: !include ../common/base.yaml
|
||||
basicSensors: !include ../common/basicSensors.yaml
|
||||
|
||||
output:
|
||||
- platform: esp8266_pwm
|
||||
id: red_output
|
||||
pin: GPIO4
|
||||
min_power: 0.000499
|
||||
max_power: 1
|
||||
- platform: esp8266_pwm
|
||||
id: green_output
|
||||
pin: GPIO12
|
||||
min_power: 0.000499
|
||||
max_power: 1
|
||||
- platform: esp8266_pwm
|
||||
id: blue_output
|
||||
pin: GPIO14
|
||||
min_power: 0.000499
|
||||
max_power: 1
|
||||
- platform: esp8266_pwm
|
||||
id: warm_white_output
|
||||
pin: GPIO13
|
||||
min_power: 0.000499
|
||||
max_power: 1
|
||||
- platform: esp8266_pwm
|
||||
id: white_output
|
||||
pin: GPIO5
|
||||
min_power: 0.000499
|
||||
max_power: 1
|
||||
|
||||
|
||||
light:
|
||||
- platform: rgbww
|
||||
id: light1
|
||||
name: "${friendly_name} Bulb"
|
||||
restore_mode: ${light_restore_mode}
|
||||
red: red_output
|
||||
green: green_output
|
||||
blue: blue_output
|
||||
warm_white: warm_white_output
|
||||
cold_white: white_output
|
||||
cold_white_color_temperature: 6000 K
|
||||
warm_white_color_temperature: 3000 K
|
||||
color_interlock: ${color_interlock}
|
||||
effects: !include ../common/lightEffects.yaml
|
310
devices/localbytes-plug.yaml
Normal file
310
devices/localbytes-plug.yaml
Normal file
|
@ -0,0 +1,310 @@
|
|||
# Largely based off this:
|
||||
#https://github.com/JamesSwift/localbytes-plug-pm/blob/main/localbytes-plug-pm.yaml
|
||||
substitutions:
|
||||
# Icon
|
||||
main_icon: "power-socket-uk"
|
||||
default_state: "RESTORE_DEFAULT_OFF"
|
||||
|
||||
esphome:
|
||||
name: ${hostname}
|
||||
build_path: ./build/${hostname}
|
||||
friendly_name: ${friendly_name}
|
||||
|
||||
wifi:
|
||||
output_power: 18db
|
||||
power_save_mode: light
|
||||
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
restore_from_flash: true
|
||||
|
||||
packages:
|
||||
base: !include ../common/base.yaml
|
||||
basicSensors: !include ../common/basicSensors.yaml
|
||||
|
||||
globals:
|
||||
- id: voltage_multiply
|
||||
type: float
|
||||
restore_value: true
|
||||
initial_value: "0.3"
|
||||
|
||||
- id: power_multiply
|
||||
type: float
|
||||
restore_value: true
|
||||
initial_value: "0.133"
|
||||
|
||||
- id: current_multiply
|
||||
type: float
|
||||
restore_value: true
|
||||
initial_value: "0.805"
|
||||
|
||||
api:
|
||||
services:
|
||||
- service: calibrate_voltage
|
||||
variables:
|
||||
actual_value: float
|
||||
then:
|
||||
- lambda: |-
|
||||
id(voltage_multiply) = actual_value / id(voltage).raw_state;
|
||||
- number.set:
|
||||
id: voltage_factor
|
||||
value: !lambda "return id(voltage_multiply);"
|
||||
|
||||
- service: calibrate_power
|
||||
variables:
|
||||
actual_value: float
|
||||
then:
|
||||
- lambda: |-
|
||||
id(power_multiply) = actual_value / id(power).raw_state;
|
||||
- number.set:
|
||||
id: power_factor
|
||||
value: !lambda "return id(power_multiply);"
|
||||
|
||||
- service: calibrate_current
|
||||
variables:
|
||||
actual_value: float
|
||||
then:
|
||||
- lambda: |-
|
||||
id(current_multiply) = actual_value / id(current).raw_state;
|
||||
- number.set:
|
||||
id: current_factor
|
||||
value: !lambda "return id(current_multiply);"
|
||||
|
||||
sensor:
|
||||
# Power Monitoring
|
||||
- platform: hlw8012
|
||||
sel_pin:
|
||||
number: GPIO12
|
||||
inverted: true
|
||||
cf_pin: GPIO4
|
||||
cf1_pin: GPIO5
|
||||
change_mode_every: 3
|
||||
update_interval: 6s
|
||||
|
||||
voltage:
|
||||
name: "Voltage"
|
||||
id: voltage
|
||||
unit_of_measurement: V
|
||||
accuracy_decimals: 1
|
||||
filters:
|
||||
- lambda: return x * id(voltage_multiply);
|
||||
|
||||
power:
|
||||
name: "Power"
|
||||
id: power
|
||||
unit_of_measurement: W
|
||||
accuracy_decimals: 0
|
||||
filters:
|
||||
- lambda: return x * id(power_multiply);
|
||||
|
||||
current:
|
||||
name: "Current"
|
||||
id: current
|
||||
unit_of_measurement: A
|
||||
accuracy_decimals: 3
|
||||
filters:
|
||||
- lambda: return x * id(current_multiply);
|
||||
|
||||
# Total daily energy sensor
|
||||
- platform: total_daily_energy
|
||||
name: "Daily Energy"
|
||||
power_id: power
|
||||
filters:
|
||||
# Multiplication factor from W to kW is 0.001
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
|
||||
|
||||
# Make calibration factor data readable/setable from home assistant
|
||||
number:
|
||||
- platform: template
|
||||
name: "Voltage Calibration Factor"
|
||||
id: voltage_factor
|
||||
icon: "mdi:sine-wave"
|
||||
min_value: 0
|
||||
max_value: 10
|
||||
step: 0.001
|
||||
entity_category: diagnostic
|
||||
mode: box
|
||||
lambda: |-
|
||||
return id(voltage_multiply);
|
||||
set_action:
|
||||
lambda: |-
|
||||
id(voltage_multiply) = x;
|
||||
|
||||
- platform: template
|
||||
name: "Power Calibration Factor"
|
||||
id: power_factor
|
||||
icon: "mdi:flash"
|
||||
min_value: 0
|
||||
max_value: 10
|
||||
step: 0.001
|
||||
entity_category: diagnostic
|
||||
mode: box
|
||||
lambda: |-
|
||||
return id(power_multiply);
|
||||
set_action:
|
||||
lambda: |-
|
||||
id(power_multiply) = x;
|
||||
|
||||
- platform: template
|
||||
name: "Current Calibration Factor"
|
||||
id: current_factor
|
||||
icon: "mdi:current-ac"
|
||||
min_value: 0
|
||||
max_value: 10
|
||||
step: 0.001
|
||||
entity_category: diagnostic
|
||||
mode: box
|
||||
lambda: |-
|
||||
return id(current_multiply);
|
||||
set_action:
|
||||
lambda: |-
|
||||
id(current_multiply) = x;
|
||||
|
||||
# Relay State LED
|
||||
output:
|
||||
- platform: esp8266_pwm
|
||||
id: state_led
|
||||
pin:
|
||||
number: GPIO13
|
||||
inverted: true
|
||||
|
||||
light:
|
||||
- platform: binary
|
||||
output: state_led
|
||||
id: led
|
||||
|
||||
binary_sensor:
|
||||
# Push Button (Toggles Relay When Pressed)
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO3
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
name: "Button"
|
||||
on_click:
|
||||
|
||||
- max_length: 1s
|
||||
then:
|
||||
if:
|
||||
condition:
|
||||
switch.is_off: disable_button
|
||||
then:
|
||||
switch.toggle: relay
|
||||
|
||||
- min_length: 1.5s
|
||||
max_length: 5s
|
||||
then:
|
||||
switch.toggle: disable_led
|
||||
|
||||
- min_length: 8s
|
||||
max_length: 12s
|
||||
then:
|
||||
switch.toggle: disable_button
|
||||
|
||||
|
||||
switch:
|
||||
# Relay (As Switch)
|
||||
- platform: gpio
|
||||
name: ""
|
||||
icon: "mdi:${main_icon}"
|
||||
pin: GPIO14
|
||||
id: relay
|
||||
restore_mode: "${default_state}"
|
||||
on_turn_on:
|
||||
if:
|
||||
condition:
|
||||
switch.is_off: disable_led
|
||||
then:
|
||||
light.turn_on:
|
||||
id: led
|
||||
on_turn_off:
|
||||
- light.turn_off:
|
||||
id: led
|
||||
|
||||
- platform: template
|
||||
name: "Disable LED"
|
||||
id: disable_led
|
||||
icon: "mdi:led-variant-off"
|
||||
restore_mode: "${default_state}"
|
||||
optimistic: true
|
||||
on_turn_on:
|
||||
#Flash twice
|
||||
- light.turn_off: led
|
||||
- delay: 0.1s
|
||||
- light.turn_on: led
|
||||
- delay: 0.1s
|
||||
- light.turn_off: led
|
||||
- delay: 0.1s
|
||||
- light.turn_on: led
|
||||
- delay: 0.1s
|
||||
#Final state
|
||||
- light.turn_off: led
|
||||
on_turn_off:
|
||||
#Flash twice
|
||||
- light.turn_on: led
|
||||
- delay: 0.1s
|
||||
- light.turn_off: led
|
||||
- delay: 0.1s
|
||||
- light.turn_on: led
|
||||
- delay: 0.1s
|
||||
- light.turn_off: led
|
||||
- delay: 0.7s
|
||||
#Final state
|
||||
- if:
|
||||
condition:
|
||||
switch.is_on: relay
|
||||
then:
|
||||
light.turn_on: led
|
||||
|
||||
|
||||
|
||||
- platform: template
|
||||
name: "Disable Button"
|
||||
id: disable_button
|
||||
icon: "mdi:toggle-switch-off-outline"
|
||||
restore_mode: "${default_state}"
|
||||
optimistic: true
|
||||
on_turn_on:
|
||||
#Flash thrice
|
||||
- light.turn_off: led
|
||||
- delay: 0.15s
|
||||
- light.turn_on: led
|
||||
- delay: 0.15s
|
||||
- light.turn_off: led
|
||||
- delay: 0.15s
|
||||
- light.turn_on: led
|
||||
- delay: 0.15s
|
||||
- light.turn_off: led
|
||||
- delay: 0.15s
|
||||
- light.turn_on: led
|
||||
- delay: 0.15s
|
||||
#Final state
|
||||
- if:
|
||||
condition:
|
||||
switch.is_off: relay
|
||||
then:
|
||||
light.turn_off: led
|
||||
on_turn_off:
|
||||
#Flash thrice
|
||||
- light.turn_on: led
|
||||
- delay: 0.15s
|
||||
- light.turn_off: led
|
||||
- delay: 0.15s
|
||||
- light.turn_on: led
|
||||
- delay: 0.15s
|
||||
- light.turn_off: led
|
||||
- delay: 0.15s
|
||||
- light.turn_on: led
|
||||
- delay: 0.15s
|
||||
- light.turn_off: led
|
||||
- delay: 0.7s
|
||||
#Final state
|
||||
- if:
|
||||
condition:
|
||||
switch.is_on: relay
|
||||
then:
|
||||
light.turn_on: led
|
||||
|
||||
|
13
devices/nodemcu.yaml
Normal file
13
devices/nodemcu.yaml
Normal file
|
@ -0,0 +1,13 @@
|
|||
substitutions:
|
||||
|
||||
esphome:
|
||||
name: ${hostname}
|
||||
build_path: ./build/${hostname}
|
||||
friendly_name: ${friendly_name}
|
||||
|
||||
esp32:
|
||||
board: nodemcu-32s
|
||||
|
||||
packages:
|
||||
base: !include ../common/base.yaml
|
||||
basicSensors: !include ../common/basicSensors.yaml
|
47
devices/sonoff-basic.yaml
Normal file
47
devices/sonoff-basic.yaml
Normal file
|
@ -0,0 +1,47 @@
|
|||
substitutions:
|
||||
button_action: sonoff_button_toggle_relay
|
||||
relay_on_action: nullScript
|
||||
relay_off_action: nullScript
|
||||
|
||||
esphome:
|
||||
board: esp8285
|
||||
platform: ESP8266
|
||||
name: ${hostname}
|
||||
build_path: ./build/${hostname}
|
||||
|
||||
packages:
|
||||
base: !include ../common/base.yaml
|
||||
basicSensors: !include ../common/basicSensors.yaml
|
||||
|
||||
switch:
|
||||
- platform: gpio
|
||||
name: "${friendly_name} Relay"
|
||||
id: relay
|
||||
pin: GPIO12
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
on_turn_on:
|
||||
then:
|
||||
- script.execute: "${relay_on_action}"
|
||||
on_turn_off:
|
||||
then:
|
||||
- script.execute: "${relay_off_action}"
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO0
|
||||
mode: INPUT_PULLUP
|
||||
inverted: True
|
||||
name: "${friendly_name} Button"
|
||||
on_press:
|
||||
then:
|
||||
- script.execute: "${button_action}"
|
||||
|
||||
|
||||
script:
|
||||
- id: sonoff_button_toggle_relay
|
||||
then:
|
||||
- switch.toggle: relay
|
||||
- id: nullScript
|
||||
then:
|
||||
|
95
devices/sonoff-t3.yaml
Normal file
95
devices/sonoff-t3.yaml
Normal file
|
@ -0,0 +1,95 @@
|
|||
substitutions:
|
||||
touchpad1_action: sonoff_t3_toggle_relay_1
|
||||
touchpad2_action: sonoff_t3_toggle_relay_2
|
||||
touchpad3_action: sonoff_t3_toggle_relay_3
|
||||
|
||||
esphome:
|
||||
board: esp01_1m
|
||||
platform: ESP8266
|
||||
name: ${hostname}
|
||||
build_path: ./build/${hostname}
|
||||
|
||||
packages:
|
||||
base: !include ../common/base.yaml
|
||||
basicSensors: !include ../common/basicSensors.yaml
|
||||
|
||||
output:
|
||||
- platform: esp8266_pwm
|
||||
id: blue_led
|
||||
pin: GPIO13
|
||||
inverted: True
|
||||
|
||||
switch:
|
||||
- platform: gpio
|
||||
name: "${friendly_name} Relay 1"
|
||||
id: relay_1
|
||||
pin: GPIO12
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
- platform: gpio
|
||||
name: "${friendly_name} Relay 2"
|
||||
id: relay_2
|
||||
pin: GPIO5
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
- platform: gpio
|
||||
name: "${friendly_name} Relay 3"
|
||||
id: relay_3
|
||||
pin: GPIO4
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO0
|
||||
mode: INPUT_PULLUP
|
||||
inverted: True
|
||||
name: "${friendly_name} Touchpad 1"
|
||||
on_press:
|
||||
then:
|
||||
- output.turn_on: blue_led
|
||||
- script.execute: "${touchpad1_action}"
|
||||
on_release:
|
||||
then:
|
||||
- output.turn_off: blue_led
|
||||
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO9
|
||||
mode: INPUT_PULLUP
|
||||
inverted: True
|
||||
name: "${friendly_name} Touchpad 2"
|
||||
on_press:
|
||||
then:
|
||||
- output.turn_on: blue_led
|
||||
- script.execute: "${touchpad2_action}"
|
||||
on_release:
|
||||
then:
|
||||
- output.turn_off: blue_led
|
||||
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO10
|
||||
mode: INPUT_PULLUP
|
||||
inverted: True
|
||||
name: "${friendly_name} Touchpad 3"
|
||||
on_press:
|
||||
then:
|
||||
- output.turn_on: blue_led
|
||||
- script.execute: "${touchpad3_action}"
|
||||
on_release:
|
||||
then:
|
||||
- output.turn_off: blue_led
|
||||
|
||||
script:
|
||||
- id: sonoff_t3_toggle_relay_1
|
||||
then:
|
||||
- switch.toggle: relay_1
|
||||
- id: sonoff_t3_toggle_relay_2
|
||||
then:
|
||||
- switch.toggle: relay_2
|
||||
- id: sonoff_t3_toggle_relay_3
|
||||
then:
|
||||
- switch.toggle: relay_3
|
||||
- id: sonoff_t3_toggle_relay_1_and_3
|
||||
then:
|
||||
- switch.toggle: relay_1
|
||||
- switch.toggle: relay_3
|
Loading…
Add table
Add a link
Reference in a new issue