ESPHome alarm panel without alarmcode in yaml

I’ve seen a lot of projects that put their alarm code into their yaml which I wanted to avoid since I want to be able to easily change it and have multiple. So I use Alarmo instead of the regular since this does support multiple different codes on the hass side.

esphome:
  name: alarm-panel
  friendly_name: alarm-panel
  on_boot:
    priority: 200  
    then:
      - wait_until:  
          condition:
            wifi.connected: 
          timeout: 5s

esp8266:
  board: d1_mini

logger:

api:
  # password: !secret api_password
  encryption:
    key: !secret api_encryption_key

ota:
  password: !secret ota_pass

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

captive_portal:

web_server:
  port: 80
  include_internal: True

i2c:
  sda: D3
  scl: D2
  frequency: 400kHz

text_sensor:
  - platform: homeassistant
    entity_id: alarm_control_panel.alarmo
    name: "Alarm"
    id: ha_alarm
  - platform: template
    name: "Keypad code"
    id: keypad_text
    internal: true
  - platform: template
    name: "Keypad display code"
    id: keypad_display_text
    internal: true
    filters:
    # fix this
    - substitute:
      - "1 -> *"
      - "2 -> *"
      - "3 -> *"
      - "4 -> *"
      - "5 -> *"
      - "6 -> *"
      - "7 -> *"
      - "8 -> *"
      - "9 -> *"
      - "0 -> *"

display:
  - platform: lcd_pcf8574
    dimensions: 20x4
    address: 0x27
    update_interval: 0.1s
    lambda: |-
      it.printf("Alarm: %s", id(ha_alarm).state.c_str());
      it.printf(0, 1, "Code: %s", id(keypad_display_text).state.c_str());

pcf8574:
  - id: 'pcf8574_hub'
    address: 0x3C
    pcf8575: false

matrix_keypad:
  id: alarm_keypad
  # has_diodes: False
  keys: "123A456B789C*0#D"
  # keys: "123456789*0#"
  # https://learn.adafruit.com/matrix-keypad/pinouts
  # 3x4 Matrix Keypad (PID 3845)
  # 1  c2  7
  # 2  r1  6
  # 3  c1  5
  # 4  r4  4 
  # 5  c3  3 
  # 6  r3  2 
  # 7  r2  1

  columns:
    - pin:
        pcf8574: pcf8574_hub
        number: 0
        mode: INPUT
        inverted: False
    - pin:
        pcf8574: pcf8574_hub
        number: 1
        mode: INPUT
        inverted: False
    - pin:
        pcf8574: pcf8574_hub
        number: 2
        mode: INPUT
        inverted: False
    - pin:
        pcf8574: pcf8574_hub
        number: 3
        mode: INPUT
        inverted: False  
  rows:
    - pin:
        pcf8574: pcf8574_hub
        number: 4
        mode: OUTPUT
        inverted: False
    - pin:
        pcf8574: pcf8574_hub
        number: 5
        mode: OUTPUT
        inverted: False        
    - pin:
        pcf8574: pcf8574_hub
        number: 6
        mode: OUTPUT
        inverted: False
    - pin:
        pcf8574: pcf8574_hub
        number: 7
        mode: OUTPUT
        inverted: False


key_collector:
  - id: alarm_code_reader
    source_id: alarm_keypad
    min_length: 4
    max_length: 8
    end_keys: "#"
    end_key_required: True
    back_keys: "B"
    clear_keys: "C"
    allowed_keys: "0123456789A"
    timeout: 15s
    on_progress:
      then:
        - text_sensor.template.publish:
            id: keypad_text
            state: !lambda "return x.c_str();" 
        - text_sensor.template.publish:
            id: keypad_display_text
            state: !lambda "return x.c_str();" 
        - if: 
            condition: 
              lambda: |-
                return id(keypad_text).state.back() == 'A';
            then:
              - logger.log: "Arming"
              - homeassistant.service:
                  service: alarmo.arm
                  data:
                    entity_id: alarm_control_panel.alarmo
              - lambda: |-
                  id(alarm_code_reader).clear();
    on_result:
      then:
        - text_sensor.template.publish:
            id: keypad_text
            state: !lambda "return x.c_str();" 
        - homeassistant.service:
            service: alarmo.disarm
            data:
              code: !lambda  |-
                return x.c_str();
              entity_id: alarm_control_panel.alarmo
1 Like

great project i try to introduce alarm panel alarmo on my esp32 s3box3 but i am not good at yaml editing