Dilbert66 / esphome-vistaECP

This is an implementation of an ESPHOME custom component and ESP Library to interface directly to a Safewatch/Honeywell/Ademco Vista 15/20 alarm system using the ECP interface and very inexpensive ESP8266/ESP32 modules .
GNU Lesser General Public License v2.1
131 stars 21 forks source link

Vista 25IT - Strange behavior on the bus #84

Closed lorenzodeveloper closed 1 year ago

lorenzodeveloper commented 1 year ago

Ciao Alain, Thank you very much for your effort! This project is amazing!

I currently have an Ademco Vista 25IT, that so far seems to be the italian version of the Vista 20SEa, with the following list of devices:

I followed the doc you wrote and assembled the ground isolated version of the circuit using a pair of 100kohm + 5.1kohm in parallel to make the 4.7kohm resistors (actually 4.85252 kohm) and a pair of 220ohm + 1kohm in parallel to make the 180 ohm resistor. Used ESP8266 wemos D1 R2. (pin mapping is the same of your example). (I used the 4N35 optocouplers)

Zones/addresses:

I'm not sure about the keypad address, looking at the manual, it seems that it should be at address 31, but I'm really not sure about it. The address I set on the yaml file is 36. lrr is set to true. (don't have one)

I made the following changes to the code to make it work with my panel:

// Italian language adaptation in vistaAlarm.h // hoping it is appreciated, here are the translations...

    const char *const FAULT = "APERT";
    const char *const BYPAS = "ESCL.";
    const char *const ALARM = "ALARM";
    const char *const FIRE = "INCEND";
    const char *const CHECK = "VERIF";
    const char *const CLOSED = "CLOSED"; //not used
    const char *const OPEN = "OPEN"; //not used
    const char *const ARMED = "INSERIM.";

    const char *const HITSTAR = "SPENTO Premi* e ";
    const char *const HITSTAR_ALT = "Premere *"; // sometimes it is displayed like this

...

    if (strstr(vista.statusFlags.prompt, HITSTAR) || strstr(vista.statusFlags.prompt, HITSTAR_ALT))
          vista.write('*');

// Status processing in vista.cpp I need to discard messages that contain only zeroes otherwise I'm not able to retrieve anything from the panel

void Vista::processStatus(char cbuf[], int *idx)
{
    // Before the for loop, discard only 00 packets
    bool onlyZeroes = true;
    for (int x = 0; x <= 10; x++)
    {
        if (cbuf[x] != 0)
        {
            onlyZeroes = false;
            break;
        }
    }
    if (onlyZeroes)
        return;
...

I plugged it to the bus and it works, I can read the bus and send commands to the panel.

The problem is that sometimes I get a lot of false positives, specially when I bypass a zone. This results in wrong reporting of the panel status (Alarm flag, Armed status, Bypassed zones reset, ...)

image image

After a brief investigation I found out that this is because these messages that are sometimes sent to the panel (not sent together)

[..:..:..][I][CMD:432]: 31 C3 0A 00 00 00 00 00 00 00 00 00 00 
or
[..:..:..][I][CMD:432]: B1 0D 6B 00 00 00 00 00 00 00 00 00 00 
or (most of the times)
[..:..:..][I][CMD:432]: 0E 00 00 00 00 00 00 00 00 00 00 00 00 

Only zeroes example

// Filtered out the "sending state C for sensor XYZ"

[16:07:02][I][CMD:436]: FB 02 20 82 61 00 00 00 00 00 00 00 00 
[16:07:02][I][EXT:436]: 00 24 03 D9 00 00 00 00 00 00 00 00 74 
[16:07:03][I][CMD:436]: 27 00 1C 18 00 00 00 00 00 00 00 00 00 
[16:07:03][I][CMD:436]: 00 00 00 00 00 00 00 00 00 00 00 00 00 
[16:07:05][I][CMD:436]: FE 65 72 20 20 00 00 00 00 00 00 00 00 
[16:07:05][I][INFO:696]: Prompt: SPENTO ZONE ESC                              //bypass is on on zone 10 that is not working
[16:07:05][I][INFO:697]: Prompt:  Si puo' inser  
[16:07:05][I][INFO:698]: Beeps: 0

[16:07:05][D][DEBUG:886]: ac=1,batt status = 0,systemflag=1,lightbat status=0,trouble=0
[16:07:10][D][DEBUG:566]: 30 second time check
[16:07:14][I][CMD:436]: 27 00 1C 18 00 00 00 00 00 00 00 00 00 
[16:07:14][I][CMD:436]: 00 00 00 00 00 00 00 00 00 00 00 00 00 
[16:07:16][I][CMD:436]: FE 65 72 20 20 00 00 00 00 00 00 00 00 
[16:07:16][I][INFO:696]: Prompt: SPENTO ZONE ESC                             //bypass is on on zone 10 that is not working
[16:07:16][I][INFO:697]: Prompt:  Si puo' inser  
[16:07:16][I][INFO:698]: Beeps: 0

Some other interesting logs

// Filtered out the "sending state C for sensor XYZ"

[16:10:55][I][CMD:436]: 27 00 1C 18 00 00 00 00 00 00 00 00 00 
[16:10:56][I][CMD:436]: 00 00 00 00 00 00 00 00 00 00 00 00 00 
[16:10:57][I][CMD:436]: FE 65 72 20 20 00 00 00 00 00 00 00 00 
[16:10:57][I][INFO:696]: Prompt: SPENTO ZONE ESC 
[16:10:57][I][INFO:697]: Prompt:  Si puo' inser  
[16:10:57][I][INFO:698]: Beeps: 0

[16:10:57][D][DEBUG:886]: ac=1,batt status = 0,systemflag=1,lightbat status=0,trouble=0
[16:11:06][I][CMD:436]: 27 00 1C 18 00 00 00 00 00 00 00 00 00 
[16:11:07][I][CMD:436]: 00 00 00 00 00 00 00 00 00 00 00 00 00 
[16:11:08][I][CMD:436]: FE 65 72 20 20 00 00 00 00 00 00 00 00 
[16:11:08][I][INFO:696]: Prompt: SPENTO ZONE ESC 
[16:11:08][I][INFO:697]: Prompt:  Si puo' inser  
[16:11:08][I][INFO:698]: Beeps: 0

[16:11:08][D][DEBUG:886]: ac=1,batt status = 0,systemflag=1,lightbat status=0,trouble=0
[16:11:09][D][DEBUG:566]: 30 second time check
[16:11:17][I][CMD:436]: FB 02 25 81 5D 00 00 00 00 00 00 00 00 
[16:11:18][I][CMD:436]: 27 00 1C 18 00 00 00 00 00 00 00 00 00 
[16:11:18][I][CMD:436]: B1 0D 6B 00 00 00 00 00 00 00 00 00 00 
[16:11:18][I][CMD:436]: FB 02 20 82 61 00 00 00 00 00 00 00 00 
[16:11:18][I][EXT:436]: 00 24 03 D9 00 00 00 00 00 00 00 00 74 
[16:11:20][I][CMD:436]: FE 65 72 20 20 00 00 00 00 00 00 00 00 
[16:11:20][I][INFO:696]: Prompt: SPENTO ZONE ESC 
[16:11:20][I][INFO:697]: Prompt:  Si puo' inser  
[16:11:20][I][INFO:698]: Beeps: 5

[16:11:20][D][text_sensor:067]: 'vistaalarm Beeps': Sending state '5'
[16:11:20][D][DEBUG:886]: ac=0,batt status = 0,systemflag=0,lightbat status=0,trouble=0
[16:11:20][D][text_sensor:067]: 'vistaalarm System Status': Sending state 'triggered'
[16:11:20][D][binary_sensor:036]: 'vistaalarm Fire': Sending state ON
[16:11:20][D][binary_sensor:036]: 'vistaalarm Trouble': Sending state ON
[16:11:20][D][binary_sensor:036]: 'vistaalarm AC': Sending state OFF
[16:11:20][D][binary_sensor:036]: 'vistaalarm Bypass': Sending state OFF
[16:11:20][D][binary_sensor:036]: 'vistaalarm Ready': Sending state OFF

[16:11:23][D][text_sensor:067]: 'vistaalarm System Status': Sending state 'triggered'
[16:11:25][D][text_sensor:067]: 'vistaalarm Beeps': Sending state '5'
[16:11:28][I][CMD:436]: FB 02 25 81 5D 00 00 00 00 00 00 00 00 
[16:11:28][I][EXT:436]: 00 21 40 9F 00 00 00 00 00 00 00 00 74 
[16:11:29][I][CMD:436]: 27 00 1C 18 00 00 00 00 00 00 00 00 00 
[16:11:29][I][CMD:436]: 00 00 00 00 00 00 00 00 00 00 00 00 00 
[16:11:31][I][CMD:436]: FE 65 72 20 20 00 00 00 00 00 00 00 00 
[16:11:31][I][INFO:696]: Prompt: SPENTO ZONE ESC 
[16:11:31][I][INFO:697]: Prompt:  Si puo' inser  
[16:11:31][I][INFO:698]: Beeps: 0

What can I do? Thank you in advance!

lorenzodeveloper commented 1 year ago

Just flashed it and so far it looks good! I tried to open and close very quickly the window and I'm not able to reproduce it! Seems ok at a first glance, here is a first log, I haven't noticed anything odd. Let me know if you notice something. serial_logs_esphome-web-fc535f_upload.txt

I'll keep an eye on it and let you know in case, but to me the issue can be closed as of now. Thank you!

Dilbert66 commented 1 year ago

Awesome! Looks ok so far. I dont see any of those extraneous bytes either so looks like they are getting filtered out ok. You can comment out the #define debug on line 12 of vista.h to stop the printing of those extra f1/ff commands that.

lorenzodeveloper commented 1 year ago

Ciao Alain, after a day I can confirm that the issue is finally gone, no weird behavior looking at the logbook, the AC flag and the other entities are ok :) Thank you very much for your work! Let me contribute and start drafting a wiki for the project, I would like to extend the README.md you have done and add a couple of things during these days. Thank you again.

lorenzodeveloper commented 1 year ago

Please check it when you have time, if you think this is ok, I can open a PR for the wiki. Thank you!

esphome-vistaECP.wiki.zip

(Quickly drafted, I hope everything is correct)

Dilbert66 commented 1 year ago

Hi Lorenzo, Nice. I'm not great on documentation so any assistance is always appreciated. I'll give you access to edit the wiki and readme's if you want. Please only update the dev version as I will be migrating dev to master in the near future once I clean up the vista20se multi partition changes.

lorenzodeveloper commented 1 year ago

Awesome, thanks! I will touch the README file only for now on dev branch. Afterwards please take your time to review it as I'm not a native english speaker and also I'm not 100% sure about some topics like the MQTT part, safety or the recommendation about ESP device to use (8266 vs 32)

lorenzodeveloper commented 1 year ago

Done! Added a lot of stuff and refactored the readme. I noticed too late that you added also the RF lookup in one of the yaml, so I didn't mention it. It might be worth it to add it though. I added "REVIEW COMMENT" and "TO BE CHECKED" comments for you for a better review. Of course feel free to remove what you don't like :) thank you!

Dilbert66 commented 1 year ago

Awesome. Thanks Lorenzo! I'm still tweaking a few things. The RF lookup is to allow users to add their sensor serial number, associated zone and the bit mask to isolate the loop. This was requested by user @rcmurphy for a vista250bpt. The mask is needed since loops sensors have 4 possible bits that can be used for indicating status. I don't know the selection logic. Either way, the mask makes is user selectable. This data will then be used by the library to control zone status independent of the panel open/clause messages. I don't have that added to the vista20se at this time. I need to finish adding the multi partition changes to that platform first.

As to the MQTT section, that needs to be revisited as well since HA has changed how sensors are setup in the HA config so I will update that.

I do recommended the ESP32 nowadays since it provides a lot ram and flash, as well as being dual core. With the ESP8266, i've hit some ram limits a few timez with some of my code so it's tight. Also, it seems to have more wifi dropouts then the ESP32 when using esphome. I've found the ESP32 much more solid and versatile.

Thanks again. I'll review it when I get a chance.

Dilbert66 commented 1 year ago

Oh, one more thing i've added in light of our discusssions is that I've split off the panel messages text config portion off the main include and placed it in a panelText.h file. I've then added a panelText_EN.h and a panelText_IT.h file. This way the user can select the one they want and rename it to panelText.h to replace the default one. This way we can keep local language custimizations separate. I havent pushed it. I'm also adding some changes to make the library work better when used in an arduino standalone script.

lorenzodeveloper commented 1 year ago

Great! I'll add the new definitions/steps in the next days. Thanks :)