digaus / esphome-components-eqiva

Other
23 stars 10 forks source link

[BUG?] Homeassistant configuration incorrect.. #3

Closed wes1993 closed 9 months ago

wes1993 commented 9 months ago

Hello, I have copied the example for the Homeassistant part of the configuration but i have this errors:

Invalid config for 'lock.template' at configuration.yaml, line 65: required key 'lock' not provided
Invalid config for 'lock.template' at configuration.yaml, line 65: required key 'unlock' not provided
Invalid config for 'lock.template' at configuration.yaml, line 65: required key 'value_template' not provided
Invalid config for 'lock.template' at configuration.yaml, line 67: 'lambda' is an invalid option for 'lock.template', check: lambda
Invalid config for 'lock.template' at configuration.yaml, line 78: 'lock_action' is an invalid option for 'lock.template', check: lock_action
Invalid config for 'lock.template' at configuration.yaml, line 80: 'unlock_action' is an invalid option for 'lock.template', check: unlock_action
Invalid config for 'lock.template' at configuration.yaml, line 82: 'open_action' is an invalid option for 'lock.template', check: open_action

I have successfully configured the lock and paired also, i think i miss something but don't know what...

ESP Home Config:

esphome:
  name: portablindata
  friendly_name: portablindata

esp32:
  board: esp32dev
  framework:
    type: esp-idf

web_server:
  include_internal: true
  # needs to be false due to a bug: https://github.com/esphome/issues/issues/5188
  local: false 
  port: 80

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: Hidden

ota:
  password: Hidden

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # We only start BLE scan after WiFi connected, see https://github.com/esphome/issues/issues/2941#issuecomment-1842369092
  on_connect:
    - esp32_ble_tracker.start_scan:
       continuous: true
    # Use below to apply saved input parameters
    - 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:

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Portablindata Fallback Hotspot"
    password: "MMSgAGzQx0Pu"

# 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;' 

  - 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());'

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

external_components:
  source: github://digaus/esphome-components-eqiva
  # use refresh when you do not get latest version
  # refresh: 0s

eqiva_key_ble:
  id: key_ble

esp32_ble_tracker:
   scan_parameters:
    window: 300ms
    # We do not start scan initialy, see https://github.com/esphome/issues/issues/2941#issuecomment-1842369092
    continuous: false

# used for discovering the lock and get the mac_address, check logger for it
eqiva_ble:

text_sensor: 
  - platform: eqiva_key_ble
    mac_address: 
      name: "Mac Address"
    lock_status:
      id: lock_status
      name: "Lock Status"
    low_battery:
      name: "Low Battery"
    lock_ble_state:
      name: "Lock BLE State"
    user_id:
      name: "User ID"
    user_key:
      name: "User Key"

time:
  - platform: sntp
    on_time:
      # Every 4 minutes
      - seconds: 0
        minutes: /4
        then:
          - eqiva_key_ble.status:
captive_portal:

And in the screen the sensors in HA:

image

I hope in your reply and thanks a lot for all your works!!!

Best Regards Stefano

wes1993 commented 9 months ago

My bad, solved the issue