ESP8266 into existing alarm DSC System

@Dilbert66, I just recompiled the yaml file without changing anything, only hoping to center the keypad. The keypad section as well as sensor information were all gone. Did I do something wrong?

Edit: I never used any local .js or .css file.

Try it again. I had a bad config on the last file. Just recompile and it will pick up the latest version.

Yep, it is back and keypad centered. Many thanks.

@Dilbert66 , I noticed that you have removed ‘Standalone-Telegram-Keypad-Example’ from your repository. Never mind, I downloaded and still running it on my WT32-ETH01. However, is it possible to reuse the .css, .js of that keypad in your latest esphome-component repository? The keypad of that example was so beautifully designed!

1 Like

I had considered it but the effort required was much more extensive then just using my lovelace component that was already built as a litelement web component which just needed a few tweaks. The requirement I had with this new version was having no dependencies on external libraries and have all css inlined with the code. The example above uses external javascript/css/font files that would need to be converted and inlined or create a persistent littlefs partition to host the files on the esp. Also it has a reliance on external libraries jquery/bootstrap/font awsome that need to be converted to litelement.

It’s all doable but will take more time and effort then I have right now. The goal was to have a standalone keypad and I have that with the current implementation. At some point I might do it but I don’t want to spend too much time on this project right now. One thing with having a persistent partition would be the capability of having the page customized on the fly controlled with either uploaded configs or parameters set from the component itself like I did with the Arduino virtualkeypad.

I’m currently looking at bringing the telegram component to esphome. When I do that, I’ll probably add the littlefs partition as well.
I’ve made the original virtualkeypad repository pulic again for reference.

Edit: Actually instead of converting it to a web component, I might instead use the
v1 format of straight javascript which will allow it to work with a lesser amount of modifications. That would be a quicker convrersion and less time consuming approach. The static css and fonts will still need to be inlined as a flash constant but that isnt too much of an issue.

Great! Now it works me too :slight_smile:

A few words of comment, because it took me some time to run the Alarm-Panel. My HA installation runs on Proxmox and when I go into the HA thru Samba my directory tree looks like on the screen below:

image

In my case, the following should be added to “resources” in “settings – > dashboards”: /hacsfiles/alarm-keypad-card/alarm-keypad-card.js
Only now you add a new card (you can choose anything), go to the code editor, delete everything that is there and paste the code “Panel card example lovelace configuration” from Dilbert66’s github. Finally, you change the entities in the code to those you have in your system - depending on what names you have given to your system in DscAlarm.yaml, syntax of yours entities may differ from the starting Dilbert66 configuration.

Hi All.
I configured an ESP32 with my DSC1864 panel and everything (arming, disarming) works well except for the HA Virtual Keypad. I cannot get it to display anything in the screen block.
I started with a ESP8266 before and had the same issue. I copied the *.mp3 files and *.js file into the config/www/ directory and also added /local/alarm-keypad-card.js/id=1 in the dashboard resources (even changed the ID number after the various attempts) - no success.
Could you please have a quick look at the attached yaml files and log files to see if you can spot something that I missed.
Thanks in advance.

The Blank Keypad

The lovelace.yaml

type: custom:alarm-keypad-card
title: DSCALARM_ESPHOME
unique_id: dsc1
disp_line1: sensor.dscalarm_line1
disp_line2: sensor.dscalarm_line2
service_type: esphome
service: dscalarm_alarm_keypress_partition
status_A: READY
status_B: ARMED
status_C: TROUBLE
status_D: AC
status_E: ''
status_F: ''
status_G: ''
status_H: ''
sensor_A: binary_sensor.dscalarm_partition_1_ready
sensor_B: binary_sensor.dscalarm_partition_1_armed
sensor_C: binary_sensor.dscalarm_trouble_status
sensor_D: binary_sensor.dscalarm_ac_status
sensor_E: ''
sensor_F: ''
sensor_G: ''
sensor_H: ''
button_A: STAY
button_B: AWAY
button_C: NIGHT
button_D:
button_E:
button_F: <
button_G: '>'
button_H: 
cmd_A:
  keys: S
  partition: 1
cmd_B:
  keys: W
  partition: 1  
cmd_C:
  keys: 'N'
  partition: 1
cmd_D:
  keys:
  partition: 1    
cmd_E:
  keys:
  partition: 1    
cmd_H:
  keys:
  partition: 1  
cmd_F:
  keys: <
  partition: 1
cmd_G:
  keys: '>'
  partition: 1
key_0:
  keys: '0'
  partition: 1
key_1:
  keys: '1'
  partition: 1
key_2:
  keys: '2'
  partition: 1
key_3:
  keys: '3'
  partition: 1
key_4:
  keys: '4'
  partition: 1
key_5:
  keys: '5'
  partition: 1
key_6:
  keys: '6'
  partition: 1
key_7:
  keys: '7'
  partition: 1
key_8:
  keys: '8'
  partition: 1
key_9:
  keys: '9'
  partition: 1
key_star:
  keys: '*'
  partition: 1
key_pound:
  keys: '#'
  partition: 1
text_1: BYPASS
text_2: SERV
text_3: ALARMS
text_4: CHIME
text_5: CODES
text_6: FUNC
text_7: OUTP
text_8: PROG
text_9: NIGHT
text_star: SELECT
text_pound: ENTER
text_0: ''  
beep: sensor.dscalarm_beeps
scale: 1
view_pad: true
view_display: true
view_status: true
view_status_2: false
view_bottom: true
button_left: false

dscalarm.yaml

#for documentation see project at https://github.com/Dilbert66/esphome-dsckeybus
substitutions:
  name: "dscalarm" #unique network name
  friendlyName: "dscalarm" #friendly name for this device
  panelId: dscalarm  #used as the service variable name.
  
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:user1,2:user2,3:user3" #
  
  #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: "64" # 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 or first time install of this yaml file  


# Enable Home Assistant API

esp32: 
  board: nodemcu-32s
  framework: 
    type: arduino
    version: 2.0.9

#esp8266:    
  #board: d1_mini
  #framework:
    #version: recommended 

#location of alarm panel code.  You can use the github release version  or 
#copy the code to directory "my_components" in your main esphome directory          
external_components:
  - source: github://Dilbert66/esphome-components@main #uncomment to use github repository
  #- source:  my_components #uncomment to use local directory 
    components: [dsc_alarm_panel,binary_sensor,text_sensor] 
    refresh: 10min
  
esphome:
  name: $name
  friendly_name: $friendlyName

  platformio_options:
    build_flags: 
        - "-Wl,-Map,output.map"  
  

#ESP32 only .  Syncs the time with the panel every 7200 seconds ( 2hours)
interval:
  - interval: 7200s
    then:
      - lambda: |-
          $panelId->set_panel_time();
  
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  manual_ip:
    static_ip: 192.168.0.x
    gateway: 192.168.0.1
    subnet: 255.255.255.0
  
  ap:
    ssid: "$name"
    password: !secret wifi_password

logger:
  baud_rate: 115200
  level: DEBUG

api:
   #password: !secret api_password  
   encryption:
    key: !secret encryption_key
    
    
#exmple mqtt setup. Replaces api
#mqtt:
 # broker: 192.168.2.175
  #port: 1883
  #username: mqttuser
  #password: mqttuser
  #discovery_prefix: "homeassistant"
  #ssl_fingerprints:
   # - 0ce84a11a63779b30119724776ecf4703de083b5      
   

ota:
   safe_mode: True
   on_begin:
       switch.turn_off: connection_status_switch   
   
status_led:
  pin:
    number: GPIO2
    inverted: no
  
time:
 - platform: sntp


################################################################################
# Edit binary and text sensors below to suit your alarm setup. 
# The id code is entered using the "id_code:" tag.  Alternatively you can
# add the id code in round brackets  at the end of the sensor name: eg. (z1)
# You can safely add or remove any sensors as needed.

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

  - platform: template
    id_code: z2
    name: "Entrance Door (z2)"
    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        

  - platform: template
    id_code: rdy_2  
    name: "Partition 2 Ready (rdy_2)"    
    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        

  - platform: template
    id_code: arm_2  
    name: "Partition 2 Armed (arm_2)"   
    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        
    
  - platform: template
    id_code: fa_2  
    device_class: smoke
    name: "Fire partition 2 Status (fa_2)"  
    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        
    
  - platform: template
    id_code: al_2  
    name: "partition 2 Alarm Status (al_2)"  
    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"

  - platform: template
    id_code: ps_2  
    name: "Partition 2 Status (ps_2)" 
    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"

  - platform: template
    id_code: msg_2  
    name: "Partition 2 Msg (msg_2)"
    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"  

# partition 2
  - platform: template
    id_code: ln1_2  
    name: "line1 partition 2 (ln1_2)"
    icon: "mdi:alert-box"

  - platform: template
    id_code: ln2_2  
    name: "line2 partition 2 (ln2_2)"
    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" 

  - platform: template
    id_code: bp_2  
    name: "partition 2 beeps (bp_2)"
    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"

# this sensor below is optional - example use of pin d8 as a zone trigger pin for the emulated zone expander  
# this emulates the hardware connection for a pc5108 board. Use a pull down/pull up resistor.  Adjust logic accordingly for the correct logic output. ie invert
 # - platform: gpio  
 #   pin: D8
 #   device_class: window
 #   on_press:       #pin high=on(open), pin low=off(closed)
 #     - lambda: |-
 #         dsc.setZoneFault(17,1);  #set zone 17 as open
 #   on_release:
 #     - lambda: |-
 #         dsc.setZoneFault(17,0);  #set zone 17 as closed
 


 # end of panel sensor setup - no need to edit anything below.
##########################################################################################
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: |-
          alarm_panel::disconnectKeybus();

  - platform: restart
    id: restart_switch
    
  - platform: safe_mode
    name: "Safe Mode" 

@bafana001 Not sure I am right but if you use sensor.dscalarm_line1 in the ui-lovelace.yaml, the name under id_code ln1_1 should be only “line1” instead of “line1 Partition 1 (ln1_1)”. In your case HA simply generates an entity named sensor.dscalarm_line1_partition_1_ln1_1 of which your ui-lovelace.yaml is not addressing! You can browser the entity list in HA to see what name HA/ESPHome assigned to the entities. The same applies to all other binary sensors and text sensors defined in your dscalarm.yaml file.

Thank you for your response @wkchick .

I used the HA Developer Tools and the entity sensor.dscalarm_line1_partition_1_ln1_1 and sensor.dscalarm_line2_partition_1_ln2_1 did produce the correct results for partition 1 lines 1 and 2. Changing the “name:” field seemingly only changes the description.

The name field is used by esphome to create a unique id to reference the sensors. That is what you need to reference in the lovelace.yaml. That document was done a long time ago for a previous version of the application. As wkchick indicated, you just need to find your relevent sensors id’s and use those instead of the ones in the sample yaml.

Thank you @Dilbert66 and @wkchick . It all makes sense now - I made the changes and it all works now.

My board has been working well so far.
I have updated HA and ESPHome to the latest version (HA: 2023.12.4/ ESPHome: 2023.12.5) and it stopped working. I didn’t have time to dig into it so I just wen back to the Vmware snapshot I took before the upgrade. I did upgrade the ESP Device when I was on the latest version. Now I see this message I open the LOG window of the esp device:

WARNING GPIO2 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See Frequently Asked Questions — ESPHome

Any ideas? I will call my friend google of course but I just wanted to drop this in here just in case.

I’m now running:
HA: 2023.4.1
ESPHome: 2023.3.2

That’s just a warning and not an issue. That would not impact the operation. I don’t see any issues with the latest esphome. Just stating it stopped working is not very usefull info. Post logs.

Yes sorry I was in a hurry and didn’t take the time to troubleshoot or get the error messages. I will put the updated snapshot and get back with more details.

Hi all. I have been using this interface without issues for quite some time and it has been amazing.

I have a slightly unrelated issue that I was hoping one of the DSC experts on this forum can give me some advice with:

My house was struck by lightning which resulted in the circuit breaker in my DB tripping. After restoring the power my alarm powered up, but the keypad shows the yellow trouble light and beeps for about 2 seconds every 2 seconds repeatedly. Pressing *2 to view a fault code does nothing and it just keeps beeping until I silence the beep with the # key after which the keypad is unresponsive. Looking at my HA interface “system status” shows “offline” and all other status cards show “unknown”.

The alarm powers up and all sensors power up from the board so the power supply side of the alarm must be OK, but nothing else works.

So far I have powered down the board and disconnected the battery for a few hours with the hopes that the alarm will reset, but didn’t help. Powering the alarm from ac or battery (respectively) alone does not make any difference. Disconnecting all of the sensors and powering the alarm also doesn’t make a difference. My AC transformer outputs around 16.5 volts, the aux DC output is around 13.5 volts.

My questions:

Has anyone perhaps experienced this fault light/beep combo?
Is there a way to do a hard reset or restore to factory settings to reset the alarm?
Any other fault finding steps that I can take?
Is my alarm dead?

It is a DSC PC1808 alarm with a PK5516 LED (non-lcd) keypad.

Any advice will be greatly appreciated.

Try removing the esp or powering it down to see if that solves the issue. A bad esp device could cause issues on the panel bus and cause the problem you have

1 Like

Thank you for the very quick response. I forgot to mention that I powered down the esp without disconnecting it during my testing, which didn’t make a difference. I will comletely disconnect it in the morning to see if it helps.

If it’s a panel bus issue could it be that the keypad could be damaged? Problem is if I disconnect both the keypad and esp there will be no way to test if the system is working.

I disconnected the ESP and the problem was solved. Thank you for the advice @Dilbert66 you were spot on. I’m very grateful that I don’t have to replace my alarm board. Reflashing the esp didn’t work so I will need to replace it to control the system from HA again.

Strangely the esp still seems to work fine as it powers up and connects to the wifi and HA without issues. Must be only the comms pins that have failed or something.

The issue is most likely the transistor on the tx line and not the esp. replace it and see.

1 Like

It was indeed the transistor. Replaced it and everything is back to normal. Thanks @Dilbert66 you’re truly an expert.