ESP8266 into existing alarm DSC System

Right, thanks a lot for pointing this, after the integration setup completed I immediately got all the zones I’ve defined and see their status changing.

Still log on the esp-gateway is empty :rofl:

“Still log on the esp-gateway is empty”

I experienced the same before and don’t know why. Glad I have more than one (if you use PCB, you knew you have to make at least 5 pieces) ESPhome ‘dscalarm’ devices. Anyway I got the log on another so that I could post the log yesterday.

What’s most important that you got your binary_sensors and sensors in HA updated by your DSC security panel through the ESPhome ‘dscalarm’. Does it work in your case? If yes, you can probably forget about the log in the meantime.

This is the line in the dscalarm.yaml that controls logging verbosity. The default of 2 should give some traffic.

   DSCkeybus->debug=2; // 0 = off, 1 = status change data, 2 = + 05/27 packets, 3 = + all packets received
1 Like

I put even level 3 DSCkeybus->debug=3; // 0 = off, 1 = status change data, 2 = + 05/27 packets, 3 = + all packets received and silence in the logs.

Yes, I’ve done setup with PCBs for Wemos D1 Mini. This is really weird. I can read all sensor and I can send commands but nothing in the logs. I read logs wireless. I also found that I can not update the ESP wirelessly.

@wkchick, what was the difference between PCBs you’ve made that has no logs output? Mine resistors nominal was pretty close to required. I use 5v supply and its 5.001v actually.

There is a magic line in config cmdWaitTime - do you have 0 value?

Here is my yaml config:


# For documentation see project at https://github.com/Dilbert66/esphome-dsckeybus

substitutions:
  instance: "dsc-gateway"
  prefix: "DSC"
  somokeSensor: "Smoke"
  motionSensor: "Motion"
  accessCode: !secret access_code # Only comes into effect if a password prompt occurs when arming eg. night mode
  cmdWaitTime: "0" # milliseconds.  set how long to delay before accepting a new 05 cmd as valid to filter out intermittent short duration bogus commands that some panels send. default = 0



esphome:
  name: $instance
  includes:
    - dscKeybusInterface/

esp8266:
  board: d1_mini

logger:
  baud_rate: 0
  level: info

# Enable Home Assistant API
api:
  password: !secret api_password

ota:
  password: !secret ota_password
  safe_mode: True

status_led:
  pin:
    number: D4
    inverted: yes
  
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

captive_portal:

custom_component:
- lambda: |-
    auto DSCkeybus = new DSCkeybushome();
    
    DSCkeybus->accessCode="$accessCode";
    DSCkeybus->cmdWaitTime=$cmdWaitTime;
    DSCkeybus->debug=3; // 0 = off, 1 = status change data, 2 = + 05/27 packets, 3 = + all packets received
    
    DSCkeybus->onSystemStatusChange([&](std::string statusCode) {
      id(system_status).publish_state(statusCode);
    });
    DSCkeybus->onPartitionStatusChange([&](uint8_t partition,std::string statusCode) {
      switch(partition) {
        case 1: id(p1).publish_state(statusCode); break;
        case 2: id(p2).publish_state(statusCode); break;
      }
    });
    DSCkeybus->onPartitionMsgChange([&](uint8_t partition,std::string msg) {
      switch(partition) {
        case 1: id(m1).publish_state(msg); break;
        case 2: id(m2).publish_state(msg); break;
      }
    });
    DSCkeybus->onTroubleStatusChange([&](troubleStatus ts,bool open) {
        switch(ts) {
            case trStatus: id(tr).publish_state(open);break;
            case batStatus: id(bat).publish_state(open);break;
            case acStatus: id(ac).publish_state(open);break;
            case panicStatus: id(panic).publish_state(open);break;
            default: break;
        }
    });
    DSCkeybus->onFireStatusChange([&](uint8_t partition, bool open) {
      switch (partition) {
          case 1: id(f1).publish_state(open); break;
          case 2: id(f2).publish_state(open); break;
          case 3: id(f3).publish_state(open); break;
          case 4: id(f4).publish_state(open); break;
          case 5: id(f5).publish_state(open); break;
          case 6: id(f6).publish_state(open); break;
          case 7: id(f7).publish_state(open); break;
          case 8: id(f8).publish_state(open); break;
      }
    });
    DSCkeybus->onZoneStatusChange([&](uint8_t zone, bool open) {
      switch (zone) {
        case 1: id(z1).publish_state(open); break;
        case 2: id(z2).publish_state(open); break;
        case 3: id(z3).publish_state(open); break;
        case 4: id(z4).publish_state(open); break;
        case 5: id(z5).publish_state(open); break;
        case 6: id(z6).publish_state(open); break;
        case 7: id(z7).publish_state(open); break;
        case 8: id(z8).publish_state(open); break;
        case 9: id(z9).publish_state(open); break;
        case 10: id(z10).publish_state(open); break;
        case 12: id(z12).publish_state(open); break;
        case 13: id(z13).publish_state(open); break;
        case 14: id(z14).publish_state(open); break;
        case 15: id(z15).publish_state(open); break;
        case 16: id(z16).publish_state(open); break;
        case 17: id(z17).publish_state(open); break;
        case 18: id(z18).publish_state(open); break;
        case 19: id(z19).publish_state(open); break;
        case 20: id(z20).publish_state(open); break;
        case 21: id(z21).publish_state(open); break;
        case 22: id(z22).publish_state(open); break;
        case 23: id(z23).publish_state(open); break;
        case 24: id(z24).publish_state(open); break;
        case 25: id(z25).publish_state(open); break;
        case 26: id(z26).publish_state(open); break;
        case 27: id(z27).publish_state(open); break;
        case 28: id(z28).publish_state(open); break;
        case 29: id(z29).publish_state(open); break;
        case 30: id(z30).publish_state(open); break;
        case 31: id(z31).publish_state(open); break;
        case 32: id(z32).publish_state(open); break;
      }
    });
    DSCkeybus->onZoneAlarmChange([&](uint8_t zone, bool open) {
      switch (zone) {
        case 1: id(za1).publish_state(open); break;
        case 2: id(za2).publish_state(open); break;
        case 3: id(za3).publish_state(open); break;
        case 4: id(za4).publish_state(open); break;
        case 5: id(za5).publish_state(open); break;
        case 6: id(za6).publish_state(open); break;
        case 7: id(za7).publish_state(open); break;
        case 8: id(za8).publish_state(open); break;
        case 9: id(za9).publish_state(open); break;
        case 10: id(za10).publish_state(open); break;
        case 12: id(za12).publish_state(open); break;
        case 13: id(za13).publish_state(open); break;
        case 14: id(za14).publish_state(open); break;
        case 15: id(za15).publish_state(open); break;
        case 16: id(za16).publish_state(open); break;
        case 17: id(za17).publish_state(open); break;
        case 18: id(za18).publish_state(open); break;
        case 19: id(za19).publish_state(open); break;
        case 20: id(za20).publish_state(open); break;
        case 21: id(za21).publish_state(open); break;
        case 22: id(za22).publish_state(open); break;
        case 23: id(za23).publish_state(open); break;
        case 24: id(za24).publish_state(open); break;
        case 25: id(za25).publish_state(open); break;
        case 26: id(za26).publish_state(open); break;
        case 27: id(za27).publish_state(open); break;
        case 28: id(za28).publish_state(open); break;
        case 29: id(za29).publish_state(open); break;
        case 30: id(za30).publish_state(open); break;
        case 31: id(za31).publish_state(open); break;
        case 32: id(za32).publish_state(open); break;
      }
    });
    return {DSCkeybus};

binary_sensor:
    #zone status
  - platform: template
    id: z1
    name: "$prefix Alarm"
    device_class: connectivity
  - platform: template
    id: z2
    name: "$prefix $somokeSensor, zone 2"
    device_class: smoke
  - platform: template
    id: z3
    name: "$prefix $somokeSensor, zone 3"
    device_class: smoke
  - platform: template
    id: z4
    name: "$prefix $somokeSensor, zone 4"
    device_class: smoke
  - platform: template
    id: z5
    name: "$prefix $somokeSensor, zone 5"
    device_class: smoke
  - platform: template
    id: z6
    name: "$prefix $somokeSensor, zone 5"
    device_class: smoke
  - platform: template
    id: z7
    name: "$prefix $somokeSensor, zone 7"
    device_class: smoke
  - platform: template
    id: z8
    name: "$prefix $somokeSensor, zone 8"
    device_class: smoke
  - platform: template
    id: z9
    name: "$prefix $motionSensor, zone 9"
    device_class: motion
  - platform: template
    id: z10
    name: "$prefix $motionSensor, zone 10"
    device_class: motion
  - platform: template
    id: z11
    name: "$prefix $motionSensor, zone 11"
    device_class: motion
  - platform: template
    id: z12
    name: "$prefix $motionSensor, zone 12"
    device_class: motion
  - platform: template
    id: z13
    name: "$prefix $motionSensor, zone 13"
    device_class: motion
  - platform: template
    id: z14
    name: "$prefix $motionSensor, zone 14"
    device_class: motion
  - platform: template
    id: z15
    name: "$prefix $motionSensor, zone 15"
    device_class: motion
  - platform: template
    id: z16
    name: "$prefix $motionSensor, zone 16"
    device_class: motion
  - platform: template
    id: z17
    name: "$prefix $motionSensor, zone 17"
    device_class: motion
  - platform: template
    id: z18
    name: "$prefix $motionSensor, zone 18"
    device_class: motion
  - platform: template
    id: z19
    name: "$prefix $motionSensor, zone 19"
    device_class: motion
  - platform: template
    id: z20
    name: "$prefix $motionSensor, zone 20"
    device_class: motion
  - platform: template
    id: z21
    name: "$prefix $motionSensor, zone 21"
    device_class: motion
  - platform: template
    id: z22
    name: "$prefix $motionSensor, zone 22"
    device_class: motion
  - platform: template
    id: z23
    name: "$prefix $motionSensor, zone 23"
    device_class: motion
  - platform: template
    id: z24
    name: "$prefix $motionSensor, zone 24"
    device_class: motion
  - platform: template
    id: z25
    name: "$prefix $motionSensor, zone 25"
    device_class: motion
  - platform: template
    id: z26
    name: "$prefix $motionSensor, zone 26"
    device_class: motion
  - platform: template
    id: z27
    name: "$prefix $motionSensor, zone 27"
    device_class: motion
  - platform: template
    id: z28
    name: "$prefix $motionSensor, zone 28"
    device_class: motion
  - platform: template
    id: z29
    name: "$prefix $motionSensor, zone 29"
    device_class: motion
  - platform: template
    id: z30
    name: "$prefix $motionSensor, zone 30"
    device_class: motion
  - platform: template
    id: z31
    name: "$prefix $motionSensor, zone 31"
    device_class: motion
  - platform: template
    id: z32
    name: "$prefix $motionSensor, zone 32"
    device_class: motion
    
    #zone alarm status
  - platform: template
    id: za1
    name: "$prefix Alarm active!"
    device_class: connectivity
  - platform: template
    id: za2
    name: "$prefix $somokeSensor, zone 2 alarm"
    device_class: smoke
  - platform: template
    id: za3
    name: "$prefix $somokeSensor, zone 3 alarm"
    device_class: smoke
  - platform: template
    id: za4
    name: "$prefix $somokeSensor, zone 4 alarm"
    device_class: smoke
  - platform: template
    id: za5
    name: "$prefix $somokeSensor, zone 5 alarm"
    device_class: smoke
  - platform: template
    id: za6
    name: "$prefix $somokeSensor, zone 6 alarm"
    device_class: smoke
  - platform: template
    id: za7
    name: "$prefix $somokeSensor, zone 7 alarm"
    device_class: smoke
  - platform: template
    id: za8
    name: "$prefix $somokeSensor, zone 8 alarm"
    device_class: smoke
  - platform: template
    id: za9
    name: "$prefix $motionSensor, zone 9 alarm"
    device_class: motion
  - platform: template
    id: za10
    name: "$prefix $motionSensor, zone 10 alarm"
    device_class: motion
  - platform: template
    id: za11
    name: "$prefix $motionSensor, zone 11 alarm"
    device_class: motion
  - platform: template
    id: za12
    name: "$prefix $motionSensor, zone 12 alarm"
    device_class: motion
  - platform: template
    id: za13
    name: "$prefix $motionSensor, zone 13 alarm"
    device_class: motion
  - platform: template
    id: za14
    name: "$prefix $motionSensor, zone 14 alarm"
    device_class: motion
  - platform: template
    id: za15
    name: "$prefix $motionSensor, zone 15 alarm"
    device_class: motion
  - platform: template
    id: za16
    name: "$prefix $motionSensor, zone 16 alarm"
    device_class: motion
  - platform: template
    id: za17
    name: "$prefix $motionSensor, zone 17 alarm"
    device_class: motion
  - platform: template
    id: za18
    name: "$prefix $motionSensor, zone 18 alarm"
    device_class: motion
  - platform: template
    id: za19
    name: "$prefix $motionSensor, zone 19 alarm"
    device_class: motion
  - platform: template
    id: za20
    name: "$prefix $motionSensor, zone 20 alarm"
    device_class: motion
  - platform: template
    id: za21
    name: "$prefix $motionSensor, zone 21 alarm"
    device_class: motion
  - platform: template
    id: za22
    name: "$prefix $motionSensor, zone 22 alarm"
    device_class: motion
  - platform: template
    id: za23
    name: "$prefix $motionSensor, zone 23 alarm"
    device_class: motion
  - platform: template
    id: za24
    name: "$prefix $motionSensor, zone 24 alarm"
    device_class: motion
  - platform: template
    id: za25
    name: "$prefix $motionSensor, zone 25 alarm"
    device_class: motion
  - platform: template
    id: za26
    name: "$prefix $motionSensor, zone 26 alarm"
    device_class: motion
  - platform: template
    id: za27
    name: "$prefix $motionSensor, zone 27 alarm"
    device_class: motion
  - platform: template
    id: za28
    name: "$prefix $motionSensor, zone 28 alarm"
    device_class: motion
  - platform: template
    id: za29
    name: "$prefix $motionSensor, zone 29 alarm"
    device_class: motion
  - platform: template
    id: za30
    name: "$prefix $motionSensor, zone 30 alarm"
    device_class: motion
  - platform: template
    id: za31
    name: "$prefix $motionSensor, zone 31 alarm"
    device_class: motion
  - platform: template
    id: za32
    name: "$prefix $motionSensor, zone 32 alarm"
    device_class: motion
    
  - platform: template
    id: tr
    name: "$prefix Trouble Status"
    device_class: problem
  - platform: template
    id: bat
    name: "$prefix Battery Status"
    device_class: problem

  - platform: template
    id: ac
    name: "$prefix AC Status"
    device_class: plug

  - platform: template
    id: panic
    name: "$prefix Panic Status"
    device_class: safety
    
  - platform: template
    id: f1
    device_class: safety
    name: "$prefix Fire Alarm Status"
  - platform: template
    id: f2
    name: "$prefix $somokeSensor, 1st floor, Guest Room"
    device_class: smoke
  - platform: template
    id: f3
    name: "$prefix $somokeSensor, Basement, Burner"
    device_class: smoke
  - platform: template
    id: f4
    name: "$prefix $somokeSensor, Roof 1"
    device_class: smoke
  - platform: template
    id: f5
    name: "$prefix $somokeSensor, 2nd floor, Work Room"
    device_class: smoke
  - platform: template
    id: f6
    name: "$prefix $somokeSensor, Roof 2"
    device_class: smoke
  - platform: template
    id: f7
    name: "$prefix $somokeSensor, 2nd Floor, Children Room"
    device_class: smoke
  - platform: template
    id: f8
    name: "$prefix $somokeSensor, 1st floor, Kitcher"
    device_class: smoke



text_sensor:
  - platform: template
    id: system_status
    name: "$prefix System Status"
    icon: "mdi:shield"
  - platform: template
    id: p1
    name: "$prefix Partition 1 Status "
    icon: "mdi:shield"
  - platform: template
    id: p2
    name: "$prefix Partition 2 Status "
    icon: "mdi:shield"  
  - platform: template
    id: m1
    name: "$prefix Partition 1 Msg "
    icon: "mdi:alert-box"
  - platform: template
    id: m2
    name: "$prefix Partition 2 Msg "
    icon: "mdi:alert-box"

switch:
  - platform: template
    name: "$prefix 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

The cmdWaittime is not a critical value. I added that to correct an issue with an older dsc model that would intermittently send bogus 05 cmds on data switchover. Having a delay there solved the issue. This will have no visible effects on other systems.

It is very odd that you do not see any traffic data in the logs. What do you mean you cannot update wirelessly? Does it not start or does it fail part way through? If it fails part way through, you need to toggle the “Dscalarm connection” switch off in homeassistant. This stops the esp from capturing panel traffic and thus prevents it from affecting uploads

1 Like

@palivoda Sorry, I didn’t dig into it as I just need to update the HA sensors. I always update the ESPhome and seems after the update, the log appeared again.

As suggested by Dilbert66, I use 3.3V instead of the step-down regulator on the D1 mini ESP32. I had been using D1 mini (ESP8266) until this January.

If you’re using the ‘master’ branch, you must first switch off the ‘connection’ before you can update the ESP wirelessly. I found it is not necessary anymore after I switched to ‘new’ branch.

I just checked my yaml file and found my logger level is set to DEBUG instead of INFO. Did you try that?

1 Like

FYI, the “new” branch is my experimental version where I’m working on adding full LCD keypad emulation including all menus. You will also be able to fully program the panel using the virtual keypad. Right now, there is an issue with programming on some cmds that require long input values. This requires adding a new cmd processor to handle these in the backend.

Any issues and fixes, I do backport to the master version.

Can someone share a Lovelace panel code to arm/disarm specific partition?

title: Partition 2
type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: sensor.dsc_partition_2_msg
        secondary_info: last-changed
      - entity: sensor.dsc_partition_2_status
  - type: horizontal-stack
    cards:
      - type: button
        tap_action:
          action: call-service
          service: esphome.dsc_gateway_set_alarm_state
          service_data:
            partition: 2
            state: A
            code: '{{ states("input_number.security_pin_code") | int(0) }}'
          target: {}
        show_state: false
        show_icon: false
        name: Arm
        hold_action:
          action: more-info
      - type: button
        tap_action:
          action: call-service
          service: esphome.dsc_gateway_set_alarm_state
          service_data:
            partition: 2
            state: D
            code: '{{ states("input_number.security_pin_code") | int(0) }}'
          target: {}
        show_state: false
        show_icon: false
        name: Disarm

Here I have trouble passing PIN in to button automation - code: ‘{{ states(“input_number.security_pin_code”) | int(0) }}’

Thanks!
After DSCkeybus->debug=2, logger: level: DEBUG and switch to 3.3 volts - I can see logs.

Here is mine ESPHome verify output:

logger:
  baud_rate: 0
  level: DEBUG
  tx_buffer_size: 512
  deassert_rts_dtr: false
  hardware_uart: UART0
  logs: {}
  esp8266_store_log_strings_in_flash: true

Update: After install of latest ESPHome 2022.1.4 in HA I had more detailed logs that could show signal from any sensor. If you do not see logs output I would recommend to update the ESPHome first.

Fantastic! You’re almost there.

You have a much, much complicated alarm system. Mine is only one partition with 8 zones. I simply used custom-component provided by Dilbert66 to arm/disarm the security panel. Could not even fully understand your Lovelace.

Hm… custom component… can you share a link to the component? :slight_smile:

The Lovalace panel is a simple object status and 2 buttons to arm and disarm.
2022-02-09_210104

It’s on GitHub Dilbert66 under the ‘new’ branch.
https://github.com/Dilbert66/esphome-dsckeybus/tree/new

1 Like

Today I had a first smoke alarm after connected the ESP module. During alarm I was unable to reset it with keyboard and with HA - only with full power down of DSC panel and ESP8266 disconnect help. After reset if I reconnect ESP fire alarm triggers again. It looks the ESP id damaged. I replaced ESP module with another fresh one and all works again, but I found that most (except one) smoke sensors started to show status Unavailable. In the HA sensor history I see that there are two signals coming at the same time - ‘smoke not detected’ (that is expected) and then immediately ‘unavailable’. Motion sensors and arm/disarm commands are working fine. Has anyone seen such problem?
Any ideas why this could happen?

Please post logs so we can see what is going on. The logs should show the sequence of data from the panel and any sensor changes .

Hello Everyone!

First of all I would like to thank @Dilbert66 for the great job he did. And all group members. Without your comments and photos - I could understand nothing and do nothing ))))

The problem is that everything seems to be connected and should work, but in homeassistant the status is unknown and no signals / statuses are sent. The log is also empty…

I am new to ESP and electronics in general. Therefore, I will describe as much as possible in detail what I did. I would be very grateful for your help in solving the problem.

  • Bought lolin nodemcu v3

  • Set ESPhome в Homeassistant, added necessary files from the repository Dilbert66/esphome-dsckeybus

  • added in configuration.yaml desired lines

  • upload firmware to my nodemcu v3 from this file: note-eWP8ibvLCG.txt

  • i turn it on and it connects to wifi. I see in ESPhome like online.

  • I ordered a printed circuit board.

-soldered all the necessary elements, set the voltage to 3.3 volts, set the jumper to 3.3 volts (is the jumper installed correctly?): see photo

  • connected the appropriate wires to my dsc hs2016
  • nothing new appeared in homeassistant.
    I mean, there are sensors and objects themselves, but they do not change their status. And when I try to force a connection - it looks like this: Box

What could be wrong? How to diagnose a problem and find a solution? I would really appreciate any help/advice!

1 Like

Before even looking at home assistant itself, you MUST be seeing data traffic in the esphome logs window . Ensure you have the debug value set to 2. If you don’t see any traffic in the logs, that means your circuit is not wired correctly to the bus and you have a connection issue.

1 Like

Did you add your ESPhome in your HA integration?

Edited: Sorry, I didn’t aware you uploaded a video. Yep, you already add your dscalarm in your ESPhome HA integration.

1 Like

Hello @poltavcev, you did a great job on the PCB, looks great!. If you set the lm2596 with 3.3v then yes, the jumper is on the right position.

I saw your video and seems you have installed correctly ESPhome, however and as @Dilbert66 said, it seems that there are not trafic data between your NodeMCU and your alarm pannel. Check the connection, maybe there is a bad contact on the wires. Using the PCB there is no confusion on the wiring because they are labeled correctly.

1 Like

I notice that you wrote that you connected it to your DSC HS2016 alarm board. Isn’t that a DSC Neo series board?

In that case it wouldn’t work as only DSC Power boards are supported, according to the documentation on GitHub.

Mjac is correct! That’s a Neo system. It is not supported as it uses completely different bus protocol and assumed to be encrypted. I’ve never worked on one but that is what I’ve been told. I didnt catch that when I read your post.