Hello all,
I connected shelly 2.5 wtih esphome on board to my shutter.
I’m trying to achieve automation where my shutter will be closing on 20% and will be opening on 80% of overall position on certain hours. So far it works with schedule but it fully opens or fully close. I’m using momentary switches - when i push up or down it goes in disered direction, another push stops movement of shutter. My esphome code looks like this:
substitutions:
devicename: shelly_25
pin_led1: GPIO0
pin_button1: GPIO2
pin_relay1: GPIO4
pin_switch2n: GPIO13
pin_sda: GPIO12
pin_switch1n: GPIO5
pin_scl: GPIO14
pin_relay2: GPIO15
pin_ade7953: GPIO16
pin_temp: A0
location: Salon
open_duration: 20sec
open_switch: switch1
open_relay: relay2
open_sensor: current_b
open_time: '0 0 8 * * MON-FRI'
open_time_weekend: '0 0 9 * * SUN-SAT'
close_duration: 19sec
close_switch: switch2
close_relay: relay1
close_sensor: current_a
esphome:
name: roleta2-salon
platform: ESP8266
board: modwifi
wifi:
ssid: XXX
password: XXX
power_save_mode: none
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: XXX
password: XXX
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: XXX
time:
- platform: homeassistant
id: homeassistant_time
on_time:
- cron: '0 0 21 * * *'
then:
if:
condition:
switch.is_off: ignore_schedule
then:
cover.close: rolladen
- cron: ${open_time}
then:
if:
condition:
switch.is_off: ignore_schedule
then:
cover.open: rolladen
- cron: ${open_time_weekend}
then:
if:
condition:
switch.is_off: ignore_schedule
then:
cover.open: rolladen
i2c:
sda: ${pin_sda}
scl: ${pin_scl}
sun:
latitude: XXX
longitude: XXX
on_sunset:
- then:
if:
condition:
switch.is_off: ignore_schedule
then:
cover.close: rolladen
sensor:
- platform: ade7953
irq_pin: GPIO16
voltage:
name: Shelly Voltage
filters:
- throttle: 5s
current_a:
name: Shelly Current B
id: "current_b"
internal: true
current_b:
name: Shelly Current A
id: "current_a"
internal: true
active_power_a:
name: Shelly Active Power B
id: shelly_active_power_b
internal: true
filters:
- multiply: -1
active_power_b:
name: Shelly Active Power A
id: shelly_active_power_a
internal: true
filters:
- multiply: -1
update_interval: 0.5s
# NTC Temperature
- platform: ntc
sensor: temp_resistance_reading
name: "Shelly Temperature"
calibration:
b_constant: 3350
reference_resistance: 10kOhm
reference_temperature: 298.15K
- platform: resistance
id: temp_resistance_reading
sensor: temp_analog_reading
configuration: DOWNSTREAM
resistor: 32kOhm
- platform: adc
id: temp_analog_reading
pin: ${pin_temp}
- platform: uptime
name: Uptime Sensor
- platform: wifi_signal
name: "WiFi Signal Sensor"
switch:
- platform: gpio
pin: ${pin_relay1}
name: "Relay #1"
internal: true
id: relay1
interlock: &interlock_group [relay1, relay2]
- platform: gpio
pin: ${pin_relay2}
name: "Relay #2"
internal: true
id: relay2
interlock: *interlock_group
- platform: template
id: block_control
name: "${location} Block Control"
optimistic: true
- platform: template
id: ignore_schedule
name: "${location} Ignore Schedule"
optimistic: true
binary_sensor:
- platform: gpio
pin: ${pin_switch1n}
name: "Switch #1"
internal: true
id: switch1
on_press:
then:
- lambda: |
if (id(rolladen).current_operation == COVER_OPERATION_IDLE) {
// Cover is idle, check current state and open cover.
id(rolladen).make_call().set_command_open().perform();
}
else {
// Cover is opening/closing. Stop it.
id(rolladen).make_call().set_command_stop().perform();
}
- platform: gpio
pin: ${pin_switch2n}
name: "Switch #2"
internal: true
id: switch2
on_press:
then:
- lambda: |
if (id(rolladen).current_operation == COVER_OPERATION_IDLE) {
// Cover is idle, check current state and close cover.
id(rolladen).make_call().set_command_close().perform();
}
else {
// Cover is opening/closing. Stop it.
id(rolladen).make_call().set_command_stop().perform();
}
cover:
- platform: current_based
name: "${location} Rolladen"
id: rolladen
open_action:
- switch.turn_on: ${open_relay}
open_duration: ${open_duration}
open_sensor: ${open_sensor}
open_moving_current_threshold: 0.5
close_action:
- switch.turn_on: ${close_relay}
close_duration: ${close_duration}
close_sensor: ${close_sensor}
close_moving_current_threshold: 0.5
start_sensing_delay: 1s
stop_action:
- switch.turn_off: ${open_relay}
- switch.turn_off: ${close_relay}
Thank You in advance for help or any info!