vwout / hass-zkaccess_c3

C3 Access Control Panel integration for Home Assistant
GNU General Public License v3.0
5 stars 1 forks source link

Zkteco c3-400 homeassistant #1

Closed stepsolar closed 1 year ago

stepsolar commented 1 year ago

Would it be possible to use the C3-400 card with homeassistant ? Thank you

vwout commented 1 year ago

Hi @stepsolar, not with this library (since it is written in Lua), but I ported it to Python for this reason in vwout/zkaccess-c3-lua.

Additionally, I am currently developing a plugin for HomeAssistant. This can be found here, in my development branch: vwout/home-assistant-core/tree/add-zkaccess-c3-integration/homeassistant/components/zkaccess_c3

When you copy the folder zkaccess_c3 and its contents to the custom_components folder of your HA installation, you can add a C3 panel via the ‘Add Integration’ wizard.

The integration is brand new, so might contain issues and limitations. Let me know what you encounter (but please create issues on my home-assistant fork :P).

stepsolar commented 1 year ago

Thanks a lot, I'll try it tomorrow and let you know how it works. For me the main function it serves is to be able to open the door, but I have already understood that it does something else as well.

stepsolar commented 1 year ago

Hi, sorry but I can't contact you in other ways, I have a problem I copied the zkaccess_c3 folder to custom_componed I restarted but I can't find anything in the 'Add Integration' wizard. What am I doing wrong? Thank you

vwout commented 1 year ago

When you installed the folder zkaccess_c3 to config\custom_components and restarted HA that part is correct. When restarting, the log should state: "[homeassistant.loader] We found a custom integration zkaccess_c3 which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant".

You log probably also has this error: "[homeassistant.loader] The custom integration 'zkaccess_c3' does not have a version key in the manifest file and was blocked from loading. See https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions for more details", which is because my development is created as 'core component'.

To make this work as custom component, add something like "version": "0.0.1", to manifest.json, e.g.:

{
  "domain": "zkaccess_c3",
  "name": "C3 Access Control Panel",
  "version": "0.0.1",
  "after_dependencies": ["network"],
...
stepsolar commented 1 year ago

Hi, where do I enter the IP and password of the C3-400? Screenshot_2023-06-22-20-24-06-813-edit_io homeassistant companion android

vwout commented 1 year ago

Right, I guess labels are missing since I don't have translations yet (except English). The order of input items are:

I don't know yet how password authentication is handled on the device. So there is no field to set a password yet. Would you be in the position to either remove the password, or Wireshark the communication with the panel while connecting to it from one of the ZKTeco tools?

stepsolar commented 1 year ago

With the zkteco software I can change the password I don't think I can delete it, I'll try tomorrow.

stepsolar commented 1 year ago

This project doesn't work for c3-400 but I noticed they put password for setup, hope it will help for your project https://github.com/icarome/zk_teco

vwout commented 1 year ago

Thanks, I will have a look, set a password and try this on my C3-200. When it works, I will add it to this library and use that in the HA component.

stepsolar commented 1 year ago

hi, i removed the password from the c3-400 i tried your project entering ip, port, and name i click enter but nothing happens, configuration example:

Am I writing it correctly? Thank you

vwout commented 1 year ago

Looks good to me. Do you have a Python environment (>3.7) or Docker available?

What is the result when you clone this repository (zkaccess-c3-py) execute the command C3_GetDeviceParam.py 192.168.2.205?

stepsolar commented 1 year ago

I think I can use Python as well if I don't know it well. I know Docker but it is not installed in my machine where homeassistant is installed. But why in homeassistant the configuration is not successful? The card works correctly with the zkteco software that I have installed on my Windows PC.

vwout commented 1 year ago

I don't know why HA is not working, also the plugin is not verbose on its logging. The HA component uses my zkaccess-c3-py library. The command C3_GetDeviceParam.py outputs all traffic as part of debug output, which might provide a hint regarding why its not working.

I at least discovered that the authentication is different than the ZKT (ZEM*) panels supported by the library of fananimi/pyzk.

stepsolar commented 1 year ago

on the linux machine where homeassistant runs I installed "zkaccess-c3-py" the result is below, now how do I run the commands? I'm no expert but I'll try. Thank you

root@root:~# pip show zkaccess-c3 Name: zkaccess-c3 Version: 0.0.5 Summary: A native Python library for communicating with the ZKAccess C3 Access Control Panels. Home-page: Author: Author-email: Vwout vwout@users.noreply.github.com License: Location: /usr/local/lib/python3.9/dist-packages Requires: Required-by:

stepsolar commented 1 year ago

root@root:~# python3 C3_GetDeviceParam.py 192.168.2.205 Connecting to 192.168.2.205 Sending: aa01760000e02655 Receiving header: aa01c90100 Receiving payload: f313d955 Connection to 192.168.2.205 failed: Error -13 received in reply: Command error: This command is not available

vwout commented 1 year ago

That's quite a fundamental error. Two questions:

stepsolar commented 1 year ago

firmware version AC Ver 4.3.4 Apr 27 2017

stepsolar commented 1 year ago

I don't quite understand the second question, what should I do?

vwout commented 1 year ago

I don't quite understand the second question, what should I do? Forget about it :)

I did some additional testing with ZKAccess 3.5 desktop software instead of the ZKAccess 5.3 web interface. I modified the session initiation and added password support in a9dbed871ef1eae9f84b0512bd744f35aefe84f4. This updates are not released to pypi, but only committed to this repository. If you clone the repo, I'm curious to see whether C3_GetDeviceParam.py works on your device now.

stepsolar commented 1 year ago

root@ilmarchese:~# python3 C3_GetDeviceParam.py 192.168.2.205 Connecting to 192.168.2.205 Sending: aa01760400fefefefe467755 Receiving header: aa01c90100 Receiving payload: f313d955 Connection to 192.168.2.205 failed: Error -13 received in reply: Command error: This command is not available

stepsolar commented 1 year ago

I cloned the entire c3 folder in /usr/local/lib/python3.9/dist-packages/ I reboot

vwout commented 1 year ago

Ok, that's unexpected. The only way to get to know how it is supposed to work is to capture the traffic between the ZKAccess application and the C3 panel.

A way to do that is to install Wireshark. When capturing traffic, you can filter the traffic to the panel with the expression ip.addr == 192.168.2.205 (see e.g. https://www.redhat.com/sysadmin/introduction-wireshark). You can export the traffic via File->Export Specified Packets. Be sure to apply the filter, otherwise you will share all you network traffic :) Oh, and if you apply a password, don't set one that you want to keep secret, since it'll be exposed in almost plain text.

vwout commented 1 year ago

Thanks! Your C3 seems to use a variant of the protocol. I'll have a look on how to include this in the library.

vwout commented 1 year ago

Your C3 does not seem to use sessions (a session id and a message counter). Commit 1208713b8e1282c122d448f2e6e3764aadd1d43b implements at potential solution. I can't test this since my panel does not accept this (I'm on firmware AC Ver 4.1.9 4609-03 Apr 7 2016, so not that much different). Maybe this works :crossed_fingers:

stepsolar commented 1 year ago

root@root:~# python3 C3_GetDeviceParam.py 192.168.2.205 Connecting to 192.168.2.205 Sending: aa01760400fefefefe467755 Receiving header: aa01c90100 Receiving payload: f313d955 Connection attempt with session to 192.168.2.205 failed: Error -13 received in reply: Command error: This command is not available Sending: aa01010000503c55 Receiving header: aa01c80000 Receiving payload: 800255 Connected without session Sending: aa01042e007e53657269616c4e756d6265722c4c6f636b436f756e742c417578496e436f756e742c4175784f7574436f756e742a9d55 Receiving header: aa01c84800 Receiving payload: 7e53657269616c4e756d6265723d444447383133303031363039323230303430312c4c6f636b436f756e743d342c417578496e436f756e743d342c4175784f7574436f756e743d34c6be55 Retrieving configuration parameters from 192.168.2.205 failed: Data received with invalid session ID Device:

stepsolar commented 1 year ago

How do you like the result?

vwout commented 1 year ago

I like it a lot, it means the solution works. I only missed handling of data without session, which has been corrected in c84ba3723c321f3b4095ebfcaf1f3330a1677131.

stepsolar commented 1 year ago

root@ilmarchese:~# python3 C3_GetDeviceParam.py 192.168.2.205 Connecting to 192.168.2.205 Sending: aa01760400fefefefe467755 Receiving header: aa01c90100 Receiving payload: f313d955 Connection attempt with session to 192.168.2.205 failed: Error -13 received in reply: Command error: This command is not available Sending: aa01010000503c55 Receiving header: aa01c80000 Receiving payload: 800255 Connected without session Sending: aa01042e007e53657269616c4e756d6265722c4c6f636b436f756e742c417578496e436f756e742c4175784f7574436f756e742a9d55 Receiving header: aa01c84800 Receiving payload: 7e53657269616c4e756d6265723d444447383133303031363039323230303430312c4c6f636b436f756e743d342c417578496e436f756e743d342c4175784f7574436f756e743d34c6be55 Device:

stepsolar commented 1 year ago

i'm trying to understand the changes you made to your code but i'm having a hard time, from wireshark how did you find CONNECT_SESSION_LESS = 0x01? now on homeassistant it should work?

vwout commented 1 year ago

now on homeassistant it should work?

Not yet, I first need to release this library in PyPi. I'll do some cleaning up and release it soon.

Regarding my changes: The message send to the C3 panel (according to the protocol described in https://github.com/vwout/zkaccess-c3-py#protocol) differs between the different panels. My panel corresponds to what I described in the readme so far. The ZKAccess software send the following command:

aa 01 76 04 00 fe fe fe fe 46 77 55

This is a startbyte (aa), version indicator (01) and connect command (76) followed by the data length (4) and data (fefefefe), with finally the checksum en stop byte. The response to this command is a reply that contains a session id, in this case 05d8 (in little endian encoding):

aa 00 c8 04 00 d8 05 fe fe a3 09 55

What I see in your traffic log is that the ZKAccess software sends a different command to start a 'session':

aa 01 01 00 00 50 3c 55

The command is 01 instead of 76 and no data is send with the command. The response from the C3 panel also does not contain any session identifier, just the command acknowledge (c8) and no data:

aa 01 c8 00 00 80 02 55

When I try command 01 on my panel it accepts it, but further commands fail without session data. So what the library does now is attempt to initiate a session and when it fails try a connection without session.

stepsolar commented 1 year ago

Hi, I have seen the updates. I also downloaded everything on homeassistant, which now lets me complete the configuration but the identities are all unavailable. What can I do?

stepsolar commented 1 year ago

Questo errore ha avuto origine da un'integrazione personalizzata.

Logger: custom_components.zkaccess_c3.coordinator Source: custom_components/zkaccess_c3/coordinator.py:124 Integration: C3 Access Control Panel First occurred: 09:08:45 (2 occurrences) Last logged: 10:46:42

Unexpected error fetching Zkaccess C3 @ 192.168.2.205:4370 data: index out of range Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/zkaccess_c3/coordinator.py", line 124, in _async_update_data logs = self.c3_panel.get_rt_log() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/c3/core.py", line 392, in get_rt_log message, message_length = self._send_receive(consts.Command.RTLOG) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/c3/core.py", line 154, in _send_receive receive_data, bytes_received = self._receive() ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/c3/core.py", line 131, in _receive message = self._get_message(header + payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/c3/core.py", line 67, in _get_message if data[-1] == consts.C3_MESSAGE_END:


IndexError: index out of range
stepsolar commented 1 year ago

Questo errore ha avuto origine da un'integrazione personalizzata.

Logger: custom_components.zkaccess_c3.coordinator Source: custom_components/zkaccess_c3/coordinator.py:136 Integration: C3 Access Control Panel First occurred: 09:09:00 (5637 occurrences) Last logged: 11:30:12

Realtime log update failed: [Errno 32] Broken pipe

stepsolar commented 1 year ago

Questo errore ha avuto origine da un'integrazione personalizzata.

Logger: custom_components.zkaccess_c3.coordinator Source: custom_components/zkaccess_c3/coordinator.py:140 Integration: C3 Access Control Panel First occurred: 09:09:00 (5637 occurrences) Last logged: 11:30:12

Unexpected error fetching Zkaccess C3 @ 192.168.2.205:4370 data: [Errno 32] Broken pipe Traceback (most recent call last): File "/config/custom_components/zkaccess_c3/coordinator.py", line 124, in _async_update_data logs = self.c3_panel.get_rt_log() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/c3/core.py", line 392, in get_rt_log message, message_length = self._send_receive(consts.Command.RTLOG) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/c3/core.py", line 152, in _send_receive bytes_written = self._send(command, data) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/c3/core.py", line 118, in _send bytes_written = self._sock.send(message) ^^^^^^^^^^^^^^^^^^^^^^^^ BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/zkaccess_c3/coordinator.py", line 140, in _async_update_data self.c3_panel.disconnect() File "/usr/local/lib/python3.11/site-packages/c3/core.py", line 355, in disconnect self._send_receive(consts.Command.DISCONNECT) File "/usr/local/lib/python3.11/site-packages/c3/core.py", line 152, in _send_receive bytes_written = self._send(command, data) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/c3/core.py", line 118, in _send bytes_written = self._sock.send(message) ^^^^^^^^^^^^^^^^^^^^^^^^ BrokenPipeError: [Errno 32] Broken pipe

stepsolar commented 1 year ago

`0000 ec b1 d7 2d 6c 20 00 17 61 c6 2c 8f 08 00 45 00 ...-l ..a.,...E. 0010 03 c8 cc 19 40 00 40 06 e4 8a c0 a8 02 cd c0 a8 ....@.@......... 0020 02 6e 11 12 d0 ea 1d 29 23 52 03 5f 6a 78 50 18 .n.....)#R._jxP. 0030 16 d0 db 28 00 00 aa 01 c8 98 03 75 73 65 72 3d ...(.......user= 0040 31 2c 43 61 72 64 4e 6f 3d 69 31 2c 50 69 6e 3d 1,CardNo=i1,Pin= 0050 69 32 2c 50 61 73 73 77 6f 72 64 3d 73 33 2c 47 i2,Password=s3,G 0060 72 6f 75 70 3d 69 34 2c 53 74 61 72 74 54 69 6d roup=i4,StartTim 0070 65 3d 69 35 2c 45 6e 64 54 69 6d 65 3d 69 36 2c e=i5,EndTime=i6, 0080 53 75 70 65 72 41 75 74 68 6f 72 69 7a 65 3d 69 SuperAuthorize=i 0090 37 0a 75 73 65 72 61 75 74 68 6f 72 69 7a 65 3d 7.userauthorize= 00a0 32 2c 50 69 6e 3d 69 31 2c 41 75 74 68 6f 72 69 2,Pin=i1,Authori 00b0 7a 65 54 69 6d 65 7a 6f 6e 65 49 64 3d 69 32 2c zeTimezoneId=i2, 00c0 41 75 74 68 6f 72 69 7a 65 44 6f 6f 72 49 64 3d AuthorizeDoorId= 00d0 69 33 0a 68 6f 6c 69 64 61 79 3d 33 2c 48 6f 6c i3.holiday=3,Hol 00e0 69 64 61 79 3d 69 31 2c 48 6f 6c 69 64 61 79 54 iday=i1,HolidayT 00f0 79 70 65 3d 69 32 2c 4c 6f 6f 70 3d 69 33 0a 74 ype=i2,Loop=i3.t 0100 69 6d 65 7a 6f 6e 65 3d 34 2c 54 69 6d 65 7a 6f imezone=4,Timezo 0110 6e 65 49 64 3d 69 31 2c 53 75 6e 54 69 6d 65 31 neId=i1,SunTime1 0120 3d 69 32 2c 53 75 6e 54 69 6d 65 32 3d 69 33 2c =i2,SunTime2=i3, 0130 53 75 6e 54 69 6d 65 33 3d 69 34 2c 4d 6f 6e 54 SunTime3=i4,MonT 0140 69 6d 65 31 3d 69 35 2c 4d 6f 6e 54 69 6d 65 32 ime1=i5,MonTime2 0150 3d 69 36 2c 4d 6f 6e 54 69 6d 65 33 3d 69 37 2c =i6,MonTime3=i7, 0160 54 75 65 54 69 6d 65 31 3d 69 38 2c 54 75 65 54 TueTime1=i8,TueT 0170 69 6d 65 32 3d 69 39 2c 54 75 65 54 69 6d 65 33 ime2=i9,TueTime3 0180 3d 69 31 30 2c 57 65 64 54 69 6d 65 31 3d 69 31 =i10,WedTime1=i1 0190 31 2c 57 65 64 54 69 6d 65 32 3d 69 31 32 2c 57 1,WedTime2=i12,W 01a0 65 64 54 69 6d 65 33 3d 69 31 33 2c 54 68 75 54 edTime3=i13,ThuT 01b0 69 6d 65 31 3d 69 31 34 2c 54 68 75 54 69 6d 65 ime1=i14,ThuTime 01c0 32 3d 69 31 35 2c 54 68 75 54 69 6d 65 33 3d 69 2=i15,ThuTime3=i 01d0 31 36 2c 46 72 69 54 69 6d 65 31 3d 69 31 37 2c 16,FriTime1=i17, 01e0 46 72 69 54 69 6d 65 32 3d 69 31 38 2c 46 72 69 FriTime2=i18,Fri 01f0 54 69 6d 65 33 3d 69 31 39 2c 53 61 74 54 69 6d Time3=i19,SatTim 0200 65 31 3d 69 32 30 2c 53 61 74 54 69 6d 65 32 3d e1=i20,SatTime2= 0210 69 32 31 2c 53 61 74 54 69 6d 65 33 3d 69 32 32 i21,SatTime3=i22 0220 2c 48 6f 6c 31 54 69 6d 65 31 3d 69 32 33 2c 48 ,Hol1Time1=i23,H 0230 6f 6c 31 54 69 6d 65 32 3d 69 32 34 2c 48 6f 6c ol1Time2=i24,Hol 0240 31 54 69 6d 65 33 3d 69 32 35 2c 48 6f 6c 32 54 1Time3=i25,Hol2T 0250 69 6d 65 31 3d 69 32 36 2c 48 6f 6c 32 54 69 6d ime1=i26,Hol2Tim 0260 65 32 3d 69 32 37 2c 48 6f 6c 32 54 69 6d 65 33 e2=i27,Hol2Time3 0270 3d 69 32 38 2c 48 6f 6c 33 54 69 6d 65 31 3d 69 =i28,Hol3Time1=i 0280 32 39 2c 48 6f 6c 33 54 69 6d 65 32 3d 69 33 30 29,Hol3Time2=i30 0290 2c 48 6f 6c 33 54 69 6d 65 33 3d 69 33 31 0a 74 ,Hol3Time3=i31.t 02a0 72 61 6e 73 61 63 74 69 6f 6e 3d 35 2c 43 61 72 ransaction=5,Car 02b0 64 6e 6f 3d 69 31 2c 50 69 6e 3d 69 32 2c 56 65 dno=i1,Pin=i2,Ve 02c0 72 69 66 69 65 64 3d 69 33 2c 44 6f 6f 72 49 44 rified=i3,DoorID 02d0 3d 69 34 2c 45 76 65 6e 74 54 79 70 65 3d 69 35 =i4,EventType=i5 02e0 2c 49 6e 4f 75 74 53 74 61 74 65 3d 69 36 2c 54 ,InOutState=i6,T 02f0 69 6d 65 5f 73 65 63 6f 6e 64 3d 69 37 0a 66 69 ime_second=i7.fi 0300 72 73 74 63 61 72 64 3d 36 2c 50 69 6e 3d 69 31 rstcard=6,Pin=i1 0310 2c 44 6f 6f 72 49 44 3d 69 32 2c 54 69 6d 65 7a ,DoorID=i2,Timez 0320 6f 6e 65 49 44 3d 69 33 0a 6d 75 6c 74 69 6d 63 oneID=i3.multimc 0330 61 72 64 3d 37 2c 49 6e 64 65 78 3d 69 31 2c 44 ard=7,Index=i1,D 0340 6f 6f 72 49 64 3d 69 32 2c 47 72 6f 75 70 31 3d oorId=i2,Group1= 0350 69 33 2c 47 72 6f 75 70 32 3d 69 34 2c 47 72 6f i3,Group2=i4,Gro 0360 75 70 33 3d 69 35 2c 47 72 6f 75 70 34 3d 69 36 up3=i5,Group4=i6 0370 2c 47 72 6f 75 70 35 3d 69 37 0a 69 6e 6f 75 74 ,Group5=i7.inout 0380 66 75 6e 3d 38 2c 49 6e 64 65 78 3d 69 31 2c 45 fun=8,Index=i1,E 0390 76 65 6e 74 54 79 70 65 3d 69 32 2c 49 6e 41 64 ventType=i2,InAd 03a0 64 72 3d 69 33 2c 4f 75 74 54 79 70 65 3d 69 34 dr=i3,OutType=i4 03b0 2c 4f 75 74 41 64 64 72 3d 69 35 2c 4f 75 74 54 ,OutAddr=i5,OutT 03c0 69 6d 65 3d 69 36 2c 52 65 73 65 72 76 65 64 3d ime=i6,Reserved= 03d0 69 37 0a 9b 08 55 i7...U

ì±×-l aÆ,EÈÌ@@äÀ¨ÍÀ¨nÐê)#R_jxPÐÛ(ªÈuser=1,CardNo=i1,Pin=i2,Password=s3,Group=i4,StartTime=i5,EndTime=i6,SuperAuthorize=i7 userauthorize=2,Pin=i1,AuthorizeTimezoneId=i2,AuthorizeDoorId=i3 holiday=3,Holiday=i1,HolidayType=i2,Loop=i3 timezone=4,TimezoneId=i1,SunTime1=i2,SunTime2=i3,SunTime3=i4,MonTime1=i5,MonTime2=i6,MonTime3=i7,TueTime1=i8,TueTime2=i9,TueTime3=i10,WedTime1=i11,WedTime2=i12,WedTime3=i13,ThuTime1=i14,ThuTime2=i15,ThuTime3=i16,FriTime1=i17,FriTime2=i18,FriTime3=i19,SatTime1=i20,SatTime2=i21,SatTime3=i22,Hol1Time1=i23,Hol1Time2=i24,Hol1Time3=i25,Hol2Time1=i26,Hol2Time2=i27,Hol2Time3=i28,Hol3Time1=i29,Hol3Time2=i30,Hol3Time3=i31 transaction=5,Cardno=i1,Pin=i2,Verified=i3,DoorID=i4,EventType=i5,InOutState=i6,Time_second=i7 firstcard=6,Pin=i1,DoorID=i2,TimezoneID=i3 multimcard=7,Index=i1,DoorId=i2,Group1=i3,Group2=i4,Group3=i5,Group4=i6,Group5=i7 inoutfun=8,Index=i1,EventType=i2,InAddr=i3,OutType=i4,OutAddr=i5,OutTime=i6,Reserved=i7 U

0000 00 17 61 c6 2c 8f ec b1 d7 2d 6c 20 08 00 45 00 0010 00 35 62 cc 40 00 80 06 00 00 c0 a8 02 6e c0 a8 0020 02 cd d1 58 11 12 ec e8 89 f1 38 1c 00 03 50 18 0030 20 14 86 b3 00 00 aa 01 05 05 00 01 01 01 03 00 0040 f5 a3 55

`

vwout commented 1 year ago

The errors show that no (or incomplete) data is received:

if data[-1] == consts.C3_MESSAGE_END:
~~~~^^^^
IndexError: index out of range

That fact that it crashes on that is a bug, I will fix that, but it does not resolve the issue. The connection between your homeassistant installation and the C3 panel is lost (BrokenPipeError: [Errno 32] Broken pipe). Is there a WiFi connection between the two?

I will improve the connection handling, but if the connection is bad, it will not give very good results. Do you have earlier logs fro HA, e.g. directly after startup? I would expect either the entities to be created, or an error to be logged.

Regarding you message dump, please upload the pcap log, this way the data is not easily readable and your selection starts in the middle of a session, so is incomplete.

stepsolar commented 1 year ago

Entities are created, but are unavailable. The connection is not on WiFi.

stepsolar commented 1 year ago

now works

vwout commented 1 year ago

Thanks for the confirmation, great that it works!

I will look into the root causes for the errors you noticed, it might also be that the session-less connection of your C3 triggers some corner cases, that on its turn cause connection drop-outs.

stepsolar commented 1 year ago

In homeassistant I still received errors that I am attaching, and I noticed that sometimes the entities become unavailable and I have to reload the integration. Yes, it's great that it works, I've been waiting for a genius like you for years. Thanks for your creation. It must be inserted as an official integration on homeassistant. I will continue to follow your updates.

stepsolar commented 1 year ago

Questo errore ha avuto origine da un'integrazione personalizzata.

Logger: custom_components.zkaccess_c3.coordinator Source: custom_components/zkaccess_c3/coordinator.py:124 Integration: C3 Access Control Panel First occurred: 11:17:06 (25 occurrences) Last logged: 20:01:26

Unexpected error fetching Zkaccess C3 @ 192.168.2.201:4371 data: 7 is not a valid VerificationMode Unexpected error fetching Zkaccess C3 @ 192.168.2.205:4370 data: 7 is not a valid VerificationMode Unexpected error fetching Zkaccess C3 @ 192.168.2.202:4372 data: 7 is not a valid VerificationMode Unexpected error fetching Zkaccess C3 @ 192.168.2.211:4370 data: 7 is not a valid VerificationMode Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/zkaccess_c3/coordinator.py", line 124, in _async_update_data logs = self.c3_panel.get_rt_log() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/c3/core.py", line 403, in get_rt_log records.append(rtlog.EventRecord.from_bytes(log_message)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/c3/rtlog.py", line 156, in from_bytes record.verified = consts.VerificationMode(data[8]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/enum.py", line 711, in call return cls.new(cls, value) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/enum.py", line 1128, in new raise ve_exc ValueError: 7 is not a valid VerificationMode

stepsolar commented 1 year ago

Questo errore ha avuto origine da un'integrazione personalizzata.

Logger: custom_components.zkaccess_c3.coordinator Source: helpers/update_coordinator.py:229 Integration: C3 Access Control Panel First occurred: 14:31:14 (1 occurrences) Last logged: 14:31:14

Timeout fetching Zkaccess C3 @ 192.168.2.208:4370 data

vwout commented 1 year ago

FYI, the custom integration has its own repo now. It can be used as custom repository in HACS. When there is broader interest, I'll add it to the default store of HACS. For now closing this issue. Just create a new issue when needed.