Dilbert66 / esphome-dsckeybus

Esphome custom configuration for interfacing to a DSC POWERSERIES alarm system
195 stars 37 forks source link

Unavailable "Arm Home" option #139

Closed mgiamberardino closed 2 months ago

mgiamberardino commented 2 months ago

Hi @Dilbert66

I built the board a few weeks ago. I'm having all the sensors and can manage the alarm from HA. Great work!

But I'm having an small issue that I'm kind of solving but not entirely and I'd like to get it right.

If I use the alarm_control_panel created when adding the esphome device as the source of my alarm_control_panel card in my dashboard I'm only able to arm away but arm_home is not available to select as option.

https://github.com/user-attachments/assets/8c6b721c-26e4-40f5-b1fd-f2d2487a9315

"Armar ausente" is "Arm Away" "Armar en casa" is "Arm Home"

The only way I can Arm Home is by creating a new alarm control panel in my configuration.yaml:

alarm_control_panel:
  - platform: template
    panels:
      safe_alarm_panel:
        name: "Alarm Panel"
        unique_id: alarm_custom_1
        value_template: "{{ states('sensor.dsc_alarm_partition_1_status_ps_1') }}"
        code_arm_required: false

        arm_away:
          - service: esphome.dsc_alarm_alarm_arm_away

        arm_home:
          - service: esphome.dsc_alarm_alarm_arm_home

        arm_night:
          - service: esphome.dsc_alarm_alarm_arm_night
            data_template:
              code: '{{code}}' #if you didnt set it in the yaml, then send the code here

        disarm:
          - service: esphome.dsc_alarm_alarm_disarm
            data_template:
              code: '{{code}}' 

This works and now I can arm home and arm away. And also I'm able to disarm. But I still use dsc_alarm_alarm_panel entities for sensor status. The only problem is that when ps_1 gets unavailable is messing around with the safe_alarm_panel status.

This is my esphome yaml config:

esphome:
  name: dsc-alarm
  friendly_name: DSC Alarm

esp8266:
  board: esp01_1m

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

ota:
  - platform: esphome
    password: ---

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

  ap:
    ssid: "Dsc-Alarm Fallback Hotspot"
    password: ---

captive_portal:

  #for documentation see project at https://github.com/Dilbert66/esphome-dsckeybus
substitutions:
  name: "dscalarm" 
  friendlyName: "DSC Alarm"
  panelId: DSCAlarm  

dsc_alarm_panel:
  id: $panelId
  #you can enter a list of user codes mapped to their names for display in armed/disarmed event messages
  usercodes: "1:John,2:Sally,3:Bob" #

  #Only comes into effect if a password prompt occurs when arming eg. night mode
  accesscode: !secret access_code 

  #used to select the default partition associated with the alarm panel messages
  defaultpartition: "1" 

  maxzones: "32" # maximum amount of zones your system supports

  # dsc debug level: 0 = off, 1 = minimal, 2 = all packets shown on console  3 =  + serial port debugging
  dscdebuglevel: "2"  

  #zone expander addresses:
  # 9  - zones 9-16
  # 10 - zones 17-24
  # 11 - zones 25-32
  # 12 - zones 33-40 (for systems with 64 zone support)
  # 13 - zones 41-48 (for systems with 64 zone support)
  # 14 - zones 49-56 (for systems with 64 zone support)
  # 16 - zones 57-64 (for systems with 64 zone support)  
  expanderaddr1: "0" # 1st zone expander emulator address to use . Set to 0 to disable. 
  expanderaddr2: "0" # 2nd expander emulator address to use . Set to 0 to disable. 

  ##ESP32 Pins
  # dscclockpin: "22"
  # dscreadpin: "21"
  # dscwritepin: "18"

  ##ESP8266 Pins
  dscclockpin: "5"
  dscreadpin: "4"
  dscwritepin: "15" 

  clean_build: "false" #default is false.  set to true if getting duplication errors in linking step.  

external_components:
  - source: github://Dilbert66/esphome-components@main 
    components: [dsc_alarm_panel,binary_sensor,text_sensor] 
    refresh: 10min

#you can remove/disable this section if you don't want your panel time updated automatically  
interval:
  - interval: 7200s
    then:
      - lambda: |-
          $panelId->set_panel_time();

logger:
  level: debug

time:
  - platform: sntp

binary_sensor:
### zone setup ###
# zone status open/close for each zone 
# zone id code = z+zone number  
  - platform: template
    id_code: z1
    name: "Living M (z1)"
    device_class: motion
    publish_initial_state: true        

  - platform: template
    id_code: z2
    name: "Cocina M (z2)"
    device_class: motion
    publish_initial_state: true         

  - platform: template
    id_code: z3  
    name: "Oficina M (z3)"
    device_class: motion
    publish_initial_state: true         

  - platform: template
    id_code: z4  
    name: "Suite M (z4)"
    device_class: motion
    publish_initial_state: true         

  - platform: template
    id_code: z5
    name: "Dormitorio Zaia M (z5)"
    device_class: motion
    publish_initial_state: true         

  - platform: template
    id_code: z6  
    name: "Dormitorio Lihuen M (z6)"
    device_class: motion
    publish_initial_state: true         

  - platform: template
    id_code: z7  
    name: "Oficina P (z7)"
    device_class: window
    publish_initial_state: true         

  - platform: template
    id_code: z8  
    name: "Living P (z8)"
    device_class: window
    publish_initial_state: true        

  - platform: template
    id_code: z9
    name: "Cocina P (z9)"
    device_class: window
    publish_initial_state: true        

  - platform: template
    id_code: z10  
    name: "Comedor P (z10)"
    device_class: window
    publish_initial_state: true        

  - platform: template
    id_code: z11  
    name: "Lavadero/Toilette P (z11)"
    device_class: window
    publish_initial_state: true        

  - platform: template
    id_code: z12  
    name: "Dormitorio Lihuen P (z12)"
    device_class: window
    publish_initial_state: true

  - platform: template
    id_code: z13
    name: "Dormitorio Zaia P (z13)"
    device_class: window
    publish_initial_state: true        

  - platform: template
    id_code: z14  
    name: "Suite P (z14)"
    device_class: window
    publish_initial_state: true

  - platform: template
    id_code: z15
    name: "Baño Suite P (z15)"
    device_class: window
    publish_initial_state: true

  - platform: template
    id_code: z16
    name: "Baño Secundario P (z16)"
    device_class: window
    publish_initial_state: true

  - platform: template
    id_code: z18
    name: "Puerta Entrada (z18)"
    device_class: door
    publish_initial_state: true

### non zone sensors ###
# partition ready indicators
# ready id code = rdy_ + partition number
  - platform: template
    id_code: rdy_1  
    name: "Partition 1 Ready (rdy_1)"
    publish_initial_state: true        

# partition arm indicators
# arm id code = arm_ + partition number
  - platform: template
    id_code: arm_1  
    name: "Partition 1 Armed (arm_1)"
    publish_initial_state: true        

# panel trouble status indicator
# trouble id code = tr
  - platform: template
    id_code: tr  
    name: "Trouble Status (tr)"
    device_class: problem
    publish_initial_state: true        

# bat id code = bat
# panel battery status indicator
  - platform: template
    id_code: bat  
    name: "Battery Status (bat)"
    device_class: problem
    publish_initial_state: true        

# ac id code = ac
# panel AC power indicator
  - platform: template
    id_code: ac  
    name: "AC Status (ac)"
    device_class: plug
    publish_initial_state: true        

# partition fire alarm indicators
# fire id code = fa_ + partition number  
  - platform: template
    id_code: fa_1  
    device_class: smoke
    name: "Fire partition 1 Status (fa_1)"
    publish_initial_state: true        

# partition in alarm indicators
# alarm id code = al_ + partition number  
  - platform: template
    id_code: al_1  
    name: "partition 1 Alarm Status (al_1)"
    publish_initial_state: true        

# relay PGM channels. Will show the state of the activate relay channel on/off
# relay id code = r + channel number
  - platform: template
    id_code: r1  
    name: "PGM 1 (r1)"
    publish_initial_state: true        

  - platform: template
    id_code: r2  
    name: "PGM 2 (r2)"
    publish_initial_state: true        

  - platform: template
    id_code: r3  
    name: "PGM 3 (r3)"
    publish_initial_state: true        

  - platform: template
    id_code: r4  
    name: "PGM 4 (r4)"
    publish_initial_state: true        

text_sensor:
# general system status online/disconnected 
# system status id code = ss
  - platform: template
    id_code: ss  
    name: "System Status (ss)"
    icon: "mdi:shield"

# battery level status for wireless channels, tamper , in alarm, etc for individual zones
# zone status id code = zs    
  - platform: template
    id_code: zs  
    name: "zone status (zs)"
    icon: "mdi:shield"  

# partition status ie ready/not ready, triggered, etc
# partition status id code = ps_ + partition number   
  - platform: template
    id_code: ps_1  
    name: "Partition 1 Status (ps_1)"
    icon: "mdi:shield"  

# more verbose message regarding the partition status. ie zones open, bypassed, etc
# partition message id code = msg_ + partition number    
  - platform: template
    id_code: msg_1  
    name: "Partition 1 Msg (msg_1)"
    icon: "mdi:alert-box"

# virtual lcd keypad line1 and line2 messages for each partition   
# partition line1 id code = ln1_ + partition number
# partition line2 id code = ln2_ + partition number
# partition 1
  - platform: template
    id_code: ln1_1  
    name: "line1 Partition 1 (ln1_1)"
    icon: "mdi:alert-box"

  - platform: template
    id_code: ln2_1  
    name: "line2 Partition 1 (ln2_1)"
    icon: "mdi:alert-box"  

# generic event messages from panel
# panel event id code = evt
  - platform: template
    id_code: evt  
    name: "event (evt)"
    icon: "mdi:alert-box" 

# partition beeps
# beeps id code = bp_ + partition number
  - platform: template
    id_code: bp_1  
    name: "beeps (bp_1)"
    icon: "mdi:alert-box" 

 # panel trouble messages  
 # panel msg id code = tr_msg
  - platform: template
    id_code: tr_msg  
    name: "Trouble Msg (tr_msg)" 
    icon: "mdi:alert-box"

switch:
    #shows status of connection status to panel.  You can disconnect before upload using the switch.
  - platform: template
    name: "Connection"
    id: connection_status_switch
    lambda: |-
      return dsc.keybusConnected;
    icon: "mdi:shield-link-variant"
    turn_on_action:
      - switch.toggle: restart_switch
    turn_off_action:
      - lambda: |-
          disconnectKeybus();

  - platform: restart
    id: restart_switch

  - platform: safe_mode
    name: "Safe Mode" 

alarm_control_panel:
  - platform: template
    name: "Alarm Panel"
    codes: 
      - ---

I'm wondering if there is a way to get the arm_home, etc working from the original alarm entity.

Thanks

Dilbert66 commented 2 months ago

Ok, the first issue is that you must have an older configuration for an alarm panel in your yaml since you cannot simply add an esp device to an alarm panel.

As to the unavailable status for ps_1, I suggest you use the "dev" branch code instead of the main. There are many enhancements there including the ps_1 status to show "disarmed" instead of unavalable when zones are open but not armed.

mgiamberardino commented 2 months ago

Ok, the first issue is that you must have an older configuration for an alarm panel in your yaml since you cannot simply add an esp device to an alarm panel.

Ohh. I see. Could you point me to some newer example of configuration?

As to the unavailable status for ps_1, I suggest you use the "dev" branch code instead of the main. There are many enhancements there including the ps_1 status to show "disarmed" instead of unavalable when zones are open but not armed.

Oh. Ok. I'll give it a try.

Thanks for the quick response!

Dilbert66 commented 2 months ago

Sorry, I'm confused. you already have a working configuration since you indicated that when you added the displayed config in your yaml, it worked ok?

mgiamberardino commented 2 months ago

Yes. The yaml I shared is working. I think I found the issue. I was adding an alarm_control_panel item in the esphome configuration and if I'm not wrong what you're suggesting is just add the the component in the configuration.yaml file, right?

Without adding the alarm_control_panel in the configuration.yaml and just using the one from esphome configuration is not allowing me to arm home.

BTW. Is the dev branch generating a bigger build? When switching to esphome_components@dev is failing to put it into the device memory.

Dilbert66 commented 2 months ago

Yes, do not use the "alarm_control_panel" in the esphome config. It will not work. Also, yes, the dev branch is larger. Try it without the "alarm_control_panel". If it still doesnt work, then you can go back to using the main branch or use an ESP32 board instead, which is much more powerful.

mgiamberardino commented 2 months ago

Thanks man! It worked. Thanks for que quick response and kudos for the project.

Bought you a coffee. Enjoy it!