Hello Dirk,
I must admit that I am a bit cut-off the improvements of the past years (I use the latest code, but still a very early yaml file (added below for reference).
In https://www.mikrocontroller.net/topic/458856#8056425 there is a recent development, that allows a faster connection and this way does not require the permanent connection anymore, whilst still ensuring very rapid reaction.
am meisten hat beim connect ausgemacht, dass man nicht wartet. das
schloss scheint hier nicht nach dem BT-standard zu arbeiten, und liefert
nach dem connect keine Meldung dass man mit weiteren Befehlen loslegen
könnte. Damit läuft das in ein timeout, es machen die BT-libraries aber
erst nach 10sec Timeout (oder höher) weiter.
Das ausschlaggebende war dann der lib mitzugeben dass man keinen
Response erwartet, explizit beim connect.
From command to lock moving it takes 2 seconds.
It would be great if we could have this in the esphome version as well.
esphome:
name: esphome-eqiva-lock-hintertuer
friendly_name: Eqiva Hintertuer
esp32:
board: esp32dev
framework:
type: esp-idf
# Uncomment below for ESP32-C3 if you have unexpected reboots when encrypting data
# sdkconfig_options:
# CONFIG_BOOTLOADER_WDT_TIME_MS: "60000"
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "/gpvP8+BDJuyMBhFE="
ota:
- platform: esphome
password: ""
web_server:
include_internal: true
local: false
port: 80
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Eqiva-Wemos-Hintertuer"
password: "x"
# Activate scan only after wifi connect, see https://github.com/esphome/issues/issues/2941#issuecomment-1842369092
on_connect:
- esp32_ble_tracker.start_scan:
continuous: true
- eqiva_key_ble.connect:
mac_address: !lambda 'return id(mac_address).state;'
user_id: !lambda 'return id(user_id).state;'
user_key: !lambda 'return id(user_key).state;'
on_disconnect:
- esp32_ble_tracker.stop_scan:
#button, number and text input for pairing and setting mac/user_id/user-key via UI
button:
- platform: template
id: ble_settings
name: BLE Settings _Save_
icon: "mdi:content-save"
on_press:
- eqiva_key_ble.connect:
mac_address: !lambda 'return id(mac_address).state;'
user_id: !lambda 'return id(user_id).state;'
user_key: !lambda 'return id(user_key).state;'
- platform: template
id: ble_disconnect
name: BLE Settings _Disconnect_
icon: "mdi:clear"
on_press:
- eqiva_key_ble.disconnect:
- platform: template
id: ble_pair
name: BLE Pair _Start_
icon: "mdi:check-underline"
on_press:
- eqiva_key_ble.pair:
card_key: !lambda 'return id(card_key).state;'
mac_address: !lambda 'return id(mac_address).state;'
- platform: template
id: lock_settings
name: Lock Settings _Apply_
icon: "mdi:check-underline"
on_press:
- eqiva_key_ble.settings:
turn_left: !lambda 'return id(direction).state == "Left";'
key_horizontal: !lambda 'return id(position).state == "Horizontal";'
lock_turns: !lambda 'return atoi(id(turns).state.c_str());'
- platform: restart
name: "Hintertür Controller Restart"
number:
- platform: template
mode: box
name: BLE Settings User ID
id: user_id
max_value: 7
min_value: 0
step: 1
optimistic: true
restore_value: true
text:
- platform: template
mode: text
name: BLE Settings Mac Address
id: mac_address
optimistic: true
restore_value: true
- platform: template
mode: text
name: BLE Settings User Key
id: user_key
optimistic: true
restore_value: true
- platform: template
mode: text
name: BLE Pair Card Key
id: card_key
optimistic: true
select:
- platform: template
name: Lock Settings Close Direction
id: direction
options:
- "Left"
- "Right"
optimistic: true
- platform: template
name: Lock Settings Key Position
id: position
options:
- "Vertical"
- "Horizontal"
optimistic: true
- platform: template
name: Lock Settings Turns
id: turns
options:
- "1"
- "2"
- "3"
- "4"
optimistic: true
captive_portal:
external_components:
source: github://digaus/esphome-components-eqiva
# use refresh when you do not get latest version
# refresh: 0s
esp32_ble_tracker:
scan_parameters:
interval: 320ms
window: 200ms
active: true
eqiva_ble:
eqiva_key_ble:
id: key_ble
# Below can left empty because we connect in wifi on_connect
# mac_address: 00:12:
# user_id: 0
# user_key: x
text_sensor:
- platform: eqiva_key_ble
mac_address:
name: "Mac Address"
lock_status:
name: "Lock Status"
id: lock_status
low_battery:
name: "Low Battery"
lock_ble_state:
name: "Lock BLE State"
user_id:
name: "User ID"
user_key:
name: "User Key"
# on_raw_value:
# then: Do stuff on state change (!lambda "return x")
# Call status every 4 minutes because lock seems to disconnect after 5 minutes of inactivity
# need to watch battery consumption, could also do some other time or present based approaches
time:
- platform: sntp
# ...
on_time:
# Every 4 minutes
- seconds: 0
minutes: /4
then:
- eqiva_key_ble.status:
# Make Fallensensor available
binary_sensor:
- platform: homeassistant
name: "Hintertuer"
entity_id: binary_sensor.eg_flur_reed_hintertuer_geschlossen
id: Hintertuer_status
# Lock component for HA, can also create two locks and use connect service to connect/control two different locks
# One ESP per lock is still recommended
lock:
- platform: template
name: "Hintertür"
lambda: |-
if (id(Hintertuer_status).state) {
return LOCK_STATE_UNLOCKED;
} else {
return LOCK_STATE_LOCKED;
}
lock_action:
- eqiva_key_ble.lock:
unlock_action:
- eqiva_key_ble.unlock:
open_action:
- eqiva_key_ble.open:
Hello Dirk,
I must admit that I am a bit cut-off the improvements of the past years (I use the latest code, but still a very early yaml file (added below for reference).
In https://www.mikrocontroller.net/topic/458856#8056425 there is a recent development, that allows a faster connection and this way does not require the permanent connection anymore, whilst still ensuring very rapid reaction.
From command to lock moving it takes 2 seconds.
It would be great if we could have this in the esphome version as well.