vanackej / risco-mqtt-local

Provide Risco alarm system integration to Home assistant using local TCP communication (no cloud required) and MQTT
MIT License
24 stars 11 forks source link

Device Doesnt Exists LightSys #21

Closed llambkin closed 2 years ago

llambkin commented 2 years ago

Here is my log output, the panel connects but stops discovery after saying device doesn't exists

Loading config from: /config/risco-mqtt.json 2/20/2022, 8:17:16 PM [info] autoConnect enabled, starting communication 2/20/2022, 8:17:16 PM [info] Connecting to mqtt server: mqtt://192.168.3.159:1883 2/20/2022, 8:17:16 PM [info] Connected on mqtt server: mqtt://192.168.3.159:1883 2/20/2022, 8:17:16 PM [info] Panel is not connected, waiting 2/20/2022, 8:17:17 PM [info] Panel info: LightSys/RP432, FW 5.93 2/20/2022, 8:17:17 PM [info] Panel options: 4 parts, 50 zones, 32 outputs, Pir Cam support: false 2/20/2022, 8:17:26 PM [warn] Command[7] Receipt of an error code: Device Doesn't Exists 2/20/2022, 8:17:26 PM [info] Output does not exists, stopping outputs discovery /app/node_modules/@vanackej/risco-lan-bridge/dist/RiscoComm.js:680 Item.Label = PLabels[j].trim(); ^ TypeError: Cannot read properties of undefined (reading 'trim') at RiscoComm. (/app/node_modules/@vanackej/risco-lan-bridge/dist/RiscoComm.js:680:45) at Generator.next () at fulfilled (/app/node_modules/tslib/tslib.js:114:62)

Configuration

The panel connects correctly through the official "cloud" app, so it does exist on my network and the panel does indeed have an internet connection.

llambkin commented 2 years ago

Here is my Debug log: 2/20/2022, 8:46:53 PM [debug] Command[1] Data Sent : OPULSE3? 2/20/2022, 8:46:53 PM [debug] Received data Buffer : [2,17,50,52,68,71,122,18,238,63,199,213,240,148,85,188,61,32,110,3] 2/20/2022, 8:46:53 PM [debug] Command[1] CRC Value : 966C 2/20/2022, 8:46:53 PM [debug] Command[1] CRC Ok 2/20/2022, 8:46:53 PM [debug] Command[1] Command response from Panel 2/20/2022, 8:46:53 PM [debug] Command[1] Emitting expected command response 2/20/2022, 8:46:53 PM [verbose] Command[1] Received data from panel: OPULSE3= 5 2/20/2022, 8:46:53 PM [debug] Command[1] SendCommand receive this response : OPULSE3= 5 2/20/2022, 8:46:53 PM [verbose] Command[2] Sending Command: OPULSE4? 2/20/2022, 8:46:53 PM [debug] Command[2] Writing command buffer to socket: [2,17,50,55,68,71,122,18,238,63,192,215,199,228,117,196,60,3] 2/20/2022, 8:46:53 PM [debug] Command[2] Data Sent : OPULSE4? 2/20/2022, 8:46:54 PM [debug] Received data Buffer : [2,17,50,55,68,71,122,18,238,63,192,213,240,148,85,176,57,82,105,3] 2/20/2022, 8:46:54 PM [debug] Command[2] CRC Value : 52DD 2/20/2022, 8:46:54 PM [debug] Command[2] CRC Ok 2/20/2022, 8:46:54 PM [debug] Command[2] Command response from Panel 2/20/2022, 8:46:54 PM [debug] Command[2] Emitting expected command response 2/20/2022, 8:46:54 PM [verbose] Command[2] Received data from panel: OPULSE4= 5 2/20/2022, 8:46:54 PM [debug] Command[2] SendCommand receive this response : OPULSE4= 5 2/20/2022, 8:46:54 PM [verbose] Command[3] Sending Command: OPULSE5? 2/20/2022, 8:46:54 PM [debug] Command[3] Writing command buffer to socket: [2,17,50,54,68,71,122,18,238,63,193,215,199,228,112,196,60,3] 2/20/2022, 8:46:54 PM [debug] Command[3] Data Sent : OPULSE5? 2/20/2022, 8:46:54 PM [debug] Received data Buffer : [2,17,50,54,68,71,122,18,238,63,193,213,240,144,85,188,58,39,107,3] 2/20/2022, 8:46:54 PM [debug] Command[3] CRC Value : 911F 2/20/2022, 8:46:54 PM [debug] Command[3] CRC Ok 2/20/2022, 8:46:54 PM [debug] Command[3] Command response from Panel 2/20/2022, 8:46:54 PM [debug] Command[3] Emitting expected command response 2/20/2022, 8:46:54 PM [verbose] Command[3] Received data from panel: OPULSE5= 1 2/20/2022, 8:46:54 PM [debug] Command[3] SendCommand receive this response : OPULSE5= 1 2/20/2022, 8:46:54 PM [verbose] Command[4] Sending Command: OPULSE6? 2/20/2022, 8:46:54 PM [debug] Command[4] Writing command buffer to socket: [2,17,50,49,68,71,122,18,238,63,194,215,199,146,122,192,61,3] 2/20/2022, 8:46:54 PM [debug] Command[4] Data Sent : OPULSE6? 2/20/2022, 8:46:54 PM [debug] Received data Buffer : [2,17,50,49,68,71,122,18,238,63,194,213,240,144,85,176,74,87,104,3] 2/20/2022, 8:46:54 PM [debug] Command[4] CRC Value : 5AAE 2/20/2022, 8:46:54 PM [debug] Command[4] CRC Ok 2/20/2022, 8:46:54 PM [debug] Command[4] Command response from Panel 2/20/2022, 8:46:54 PM [debug] Command[4] Emitting expected command response 2/20/2022, 8:46:54 PM [verbose] Command[4] Received data from panel: OPULSE6= 1 2/20/2022, 8:46:54 PM [debug] Command[4] SendCommand receive this response : OPULSE6= 1 2/20/2022, 8:46:54 PM [verbose] Command[5] Sending Command: OPULSE7? 2/20/2022, 8:46:54 PM [debug] Command[5] Writing command buffer to socket: [2,17,50,48,68,71,122,18,238,63,195,215,199,146,6,192,61,3] 2/20/2022, 8:46:54 PM [debug] Command[5] Data Sent : OPULSE7? 2/20/2022, 8:46:54 PM [debug] Received data Buffer : [2,17,50,48,68,71,122,18,238,63,195,213,240,148,85,188,50,32,110,3] 2/20/2022, 8:46:54 PM [debug] Command[5] CRC Value : 996C 2/20/2022, 8:46:54 PM [debug] Command[5] CRC Ok 2/20/2022, 8:46:54 PM [debug] Command[5] Command response from Panel 2/20/2022, 8:46:54 PM [debug] Command[5] Emitting expected command response 2/20/2022, 8:46:54 PM [verbose] Command[5] Received data from panel: OPULSE7= 5 2/20/2022, 8:46:54 PM [debug] Command[5] SendCommand receive this response : OPULSE7= 5 2/20/2022, 8:46:54 PM [verbose] Command[6] Sending Command: OPULSE8? 2/20/2022, 8:46:54 PM [debug] Command[6] Writing command buffer to socket: [2,17,50,51,68,71,122,18,238,63,204,215,199,146,115,183,61,3] 2/20/2022, 8:46:54 PM [debug] Command[6] Data Sent : OPULSE8? 2/20/2022, 8:46:54 PM [debug] Received data Buffer : [2,17,50,51,68,71,122,18,238,63,204,213,240,148,85,188,72,37,110,3] 2/20/2022, 8:46:54 PM [debug] Command[6] CRC Value : 9C3C 2/20/2022, 8:46:54 PM [debug] Command[6] CRC Ok 2/20/2022, 8:46:54 PM [debug] Command[6] Command response from Panel 2/20/2022, 8:46:54 PM [debug] Command[6] Emitting expected command response 2/20/2022, 8:46:54 PM [verbose] Command[6] Received data from panel: OPULSE8= 5 2/20/2022, 8:46:54 PM [debug] Command[6] SendCommand receive this response : OPULSE8= 5 2/20/2022, 8:46:54 PM [verbose] Command[7] Sending Command: OSTT9:16? 2/20/2022, 8:46:54 PM [debug] Command[7] Writing command buffer to socket: [2,17,50,50,68,68,123,10,151,67,206,217,230,158,85,196,62,34,31,3] 2/20/2022, 8:46:54 PM [debug] Command[7] Data Sent : OSTT9:16? 2/20/2022, 8:46:54 PM [debug] Received data Buffer : [2,17,50,50,69,38,22,73,132,76,177,220,3] 2/20/2022, 8:46:54 PM [debug] Command[7] CRC Value : 96E4 2/20/2022, 8:46:54 PM [debug] Command[7] CRC Ok 2/20/2022, 8:46:54 PM [debug] Command[7] Command response from Panel 2/20/2022, 8:46:54 PM [debug] Command[7] Emitting expected command response 2/20/2022, 8:46:54 PM [verbose] Command[7] Received data from panel: N19 2/20/2022, 8:46:54 PM [warn] Command[7] Receipt of an error code: Device Doesn't Exists 2/20/2022, 8:46:54 PM [debug] Command[7] SendCommand receive this response : N19 2/20/2022, 8:46:54 PM [info] Output does not exists, stopping outputs discovery 2/20/2022, 8:46:54 PM [debug] Retrieving the configuration of the Partitions. 2/20/2022, 8:46:54 PM [verbose] Command[8] Sending Command: PLBL1:4? 2/20/2022, 8:46:54 PM [debug] Command[8] Writing command buffer to socket: [2,17,50,61,91,91,109,18,151,75,206,220,239,182,116,199,77,46,3] 2/20/2022, 8:46:54 PM [debug] Command[8] Data Sent : PLBL1:4? 2/20/2022, 8:46:54 PM [debug] Received data Buffer : [2,17,50,61,91,91,109,18,151,75,206,220,237,236,35,236,101,54,104,52,193,25,175,164,83,189,127,230,231,123,190,3] 2/20/2022, 8:46:54 PM [debug] Command[8] CRC Value : 6F89 2/20/2022, 8:46:54 PM [debug] Command[8] CRC Ok 2/20/2022, 8:46:54 PM [debug] Command[8] Command response from Panel 2/20/2022, 8:46:54 PM [debug] Command[8] Emitting expected command response 2/20/2022, 8:46:54 PM [verbose] Command[8] Received data from panel: PLBL1:4=Main Entry
2/20/2022, 8:46:54 PM [debug] Command[8] SendCommand receive this response : PLBL
1:4=Main Entry
2/20/2022, 8:46:54 PM [verbose] Command[9] Sending Command: PSTT1:4? 2/20/2022, 8:46:54 PM [debug] Command[9] Writing command buffer to socket: [2,17,50,60,91,68,123,10,151,75,206,220,239,182,122,181,61,47,3] 2/20/2022, 8:46:54 PM [debug] Command[9] Data Sent : PSTT1:4? 2/20/2022, 8:46:54 PM [debug] Received data Buffer : [2,17,50,60,91,68,123,10,151,75,206,220,237,140,111,168,38,59,0,119,152,57,251,232,119,153,69,253,140,110,142,34,50,18,83,208,214,218,194,242,146,82,210,210,211,209,212,223,236,231,184,6,123,129,117,157,77,236,174,43,33,52,31,73,229,189,41,108,175,40,38,58,16,2,114,147,80,215,216,199,248,135,120,135,121,191,96,148,16,2,185,3] 2/20/2022, 8:46:54 PM [debug] Command[9] CRC Value : 16F1 2/20/2022, 8:46:54 PM [debug] Command[9] CRC Ok 2/20/2022, 8:46:54 PM [debug] Command[9] Command response from Panel 2/20/2022, 8:46:54 PM [debug] Command[9] Emitting expected command response 2/20/2022, 8:46:54 PM [verbose] Command[9] Received data from panel: PSTT1:4=--------R-E------ ----------------- ----------------- ----------------- 2/20/2022, 8:46:54 PM [debug] Command[9] Data type: Partition Status 2/20/2022, 8:46:54 PM [debug] Command[9] SendCommand receive this response : PSTT1:4=--------R-E------ ----------------- ----------------- ----------------- /app/node_modules/@vanackej/risco-lan-bridge/dist/RiscoComm.js:680 Item.Label = PLabels[j].trim(); ^ TypeError: Cannot read properties of undefined (reading 'trim') at RiscoComm. (/app/node_modules/@vanackej/risco-lan-bridge/dist/RiscoComm.js:680:45) at Generator.next () at fulfilled (/app/node_modules/tslib/tslib.js:114:62)

vanackej commented 2 years ago

Device Doesn't Exists error code is 'normal': The panel supports at most 14 outputs, but they are not all used. When the library get this error code during discovery, it just stops looking for more outputs.

The error you get is unrelated but is a real one. I fixed it. Should be available in the next release in a few days

vanackej commented 2 years ago

Can you try with 0.3.6 please ?

llambkin commented 2 years ago

Okay, now have updated to 0.3.7 and I can now see MQTT messages, but the zones don't self publish into the entities in HA. The only Entity I end up with is panel status.

The risco-lan-bridge wiki mentions: const RiscoTCPPanel = require('risco-lan-bridge'); as a command and sending: let RPanel = new RiscoTCPPanel.LightSys(Options); but I don't know if this applies to us as I don't see anywhere to send such commands.

Maybe this stuff is not self explanatory for me to understand.

vanackej commented 2 years ago

The wiki from the original forked library (https://github.com/TJForc/risco-lan-bridge/wiki) is not relevant anymore, as the codebase has been completly rewritten since the fork. As an HA addon user, you don't have to care for the underlying library usage. This library wraps it's usage and take care of bootstraping everything and associating library events to MQTT messages for HA.

The result of discovered zones / parts are logged at startup if log level is set at least to verbose

For exemples, here are my logs when starting the HA addon with verbose logs :

21/02/2022, 14:11:29 [verbose] [Panel => MQTT][Discovery] Alarm discovery payload
{
  "name": "risco-alarm-panel-1",
  "state_topic": "riscopanel/alarm/1/status",
  "unique_id": "risco-alarm-panel-1",
  "availability": {
    "topic": "riscopanel/alarm/status"
  },
  "command_topic": "riscopanel/alarm/1/set"
}
21/02/2022, 14:11:29 [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = GARAGE, HA name = Détecteur - GARAGE
21/02/2022, 14:11:29 [verbose] [Panel => MQTT][Discovery] Sensor discovery payload
{
  "availability": {
    "topic": "riscopanel/alarm/status"
  },
  "unique_id": "risco-alarm-panel-1-zone-1",
  "payload_on": "1",
  "payload_off": "0",
  "device_class": "motion",
  "qos": 1,
  "state_topic": "riscopanel/alarm/1/sensor/1/status",
  "json_attributes_topic": "riscopanel/alarm/1/sensor/1",
  "off_delay": 30,
  "name": "Détecteur - GARAGE"
}
21/02/2022, 14:11:29 [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = ENTREE, HA name = Détecteur - ENTREE
21/02/2022, 14:11:29 [verbose] [Panel => MQTT][Discovery] Sensor discovery payload
{
  "availability": {
    "topic": "riscopanel/alarm/status"
  },
  "unique_id": "risco-alarm-panel-1-zone-2",
  "payload_on": "1",
  "payload_off": "0",
  "device_class": "motion",
  "qos": 1,
  "state_topic": "riscopanel/alarm/1/sensor/2/status",
  "json_attributes_topic": "riscopanel/alarm/1/sensor/2",
  "off_delay": 30,
  "name": "Détecteur - ENTREE"
}
21/02/2022, 14:11:29 [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = SALLE A MANGER, HA name = Détecteur - SALLE A MANGER
21/02/2022, 14:11:29 [verbose] [Panel => MQTT][Discovery] Sensor discovery payload
{
  "availability": {
    "topic": "riscopanel/alarm/status"
  },
  "unique_id": "risco-alarm-panel-1-zone-3",
  "payload_on": "1",
  "payload_off": "0",
  "device_class": "motion",
  "qos": 1,
  "state_topic": "riscopanel/alarm/1/sensor/3/status",
  "json_attributes_topic": "riscopanel/alarm/1/sensor/3",
  "off_delay": 30,
  "name": "Détecteur - SALLE A MANGER"
}
21/02/2022, 14:11:29 [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = SALON, HA name = Détecteur - SALON
21/02/2022, 14:11:29 [verbose] [Panel => MQTT][Discovery] Sensor discovery payload
{
  "availability": {
    "topic": "riscopanel/alarm/status"
  },
  "unique_id": "risco-alarm-panel-1-zone-4",
  "payload_on": "1",
  "payload_off": "0",
  "device_class": "motion",
  "qos": 1,
  "state_topic": "riscopanel/alarm/1/sensor/4/status",
  "json_attributes_topic": "riscopanel/alarm/1/sensor/4",
  "off_delay": 30,
  "name": "Détecteur - SALON"
}
21/02/2022, 14:11:29 [info] Subscribing to Home assistant commands topics
21/02/2022, 14:11:29 [info] Subscribe on riscopanel/alarm/1/set topic
21/02/2022, 14:11:29 [verbose] [Panel => MQTT] Published alarm online
21/02/2022, 14:11:29 [info] Publishing initial partitions and zones state to Home assistant
21/02/2022, 14:11:29 [info] [Panel => MQTT] Published alarm status disarmed on partition 1
21/02/2022, 14:11:29 [verbose] [Panel => MQTT] Published sensor status 0 on zone GARAGE
21/02/2022, 14:11:29 [verbose] [Panel => MQTT] Published sensor status 0 on zone ENTREE
21/02/2022, 14:11:29 [verbose] [Panel => MQTT] Published sensor status 0 on zone SALLE A MANGER
21/02/2022, 14:11:29 [verbose] [Panel => MQTT] Published sensor status 0 on zone SALON
21/02/2022, 14:11:29 [info] Initialization completed

If you need support understanding what happens, please always attach logs in debug level (or at least verbose)

llambkin commented 2 years ago

Okay, Cool. So I have to copy paste the dumped details from my logs into the config json to have the zones show up as entities?

llambkin commented 2 years ago

Here is my Verbose log: { "name": "risco-alarm-panel-1", "state_topic": "riscopanel/alarm/1/status", "unique_id": "risco-alarm-panel-1", "availability": { "topic": "riscopanel/alarm/status" }, "command_topic": "riscopanel/alarm/1/set" } 2/21/2022, 9:32:06 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Entrance PIR, HA name = Sensor - Entrance PIR 2/21/2022, 9:32:06 PM [verbose] [Panel => MQTT][Discovery] Sensor discovery payload { "availability": { "topic": "riscopanel/alarm/status" }, "unique_id": "risco-alarm-panel-1-zone-1", "payload_on": "1", "payload_off": "0", "device_class": "motion", "qos": 1, "state_topic": "riscopanel/alarm/1/sensor/1/status", "json_attributes_topic": "riscopanel/alarm/1/sensor/1", "off_delay": 30, "name": "Sensor - Entrance PIR" } 2/21/2022, 9:32:06 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Living, HA name = Sensor - Living 2/21/2022, 9:32:06 PM [verbose] [Panel => MQTT][Discovery] Sensor discovery payload { "availability": { "topic": "riscopanel/alarm/status" }, "unique_id": "risco-alarm-panel-1-zone-2", "payload_on": "1", "payload_off": "0", "device_class": "motion", "qos": 1, "state_topic": "riscopanel/alarm/1/sensor/2/status", "json_attributes_topic": "riscopanel/alarm/1/sensor/2", "off_delay": 30, "name": "Sensor - Living" } 2/21/2022, 9:32:06 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Hallway, HA name = Sensor - Hallway 2/21/2022, 9:32:06 PM [verbose] [Panel => MQTT][Discovery] Sensor discovery payload { "availability": { "topic": "riscopanel/alarm/status" }, "unique_id": "risco-alarm-panel-1-zone-3", "payload_on": "1", "payload_off": "0", "device_class": "motion", "qos": 1, "state_topic": "riscopanel/alarm/1/sensor/3/status", "json_attributes_topic": "riscopanel/alarm/1/sensor/3", "off_delay": 30, "name": "Sensor - Hallway" } 2/21/2022, 9:32:06 PM [info] Subscribing to Home assistant commands topics 2/21/2022, 9:32:06 PM [info] Subscribe on riscopanel/alarm/1/set topic 2/21/2022, 9:32:06 PM [verbose] [Panel => MQTT] Published alarm online 2/21/2022, 9:32:06 PM [info] Publishing initial partitions and zones state to Home assistant 2/21/2022, 9:32:06 PM [info] [Panel => MQTT] Published alarm status disarmed on partition 1 2/21/2022, 9:32:06 PM [verbose] [Panel => MQTT] Published sensor status 0 on zone Entrance PIR 2/21/2022, 9:32:06 PM [verbose] [Panel => MQTT] Published sensor status 0 on zone Living 2/21/2022, 9:32:06 PM [verbose] [Panel => MQTT] Published sensor status 0 on zone Hallway 2/21/2022, 9:32:06 PM [info] Initialization completed 2/21/2022, 9:32:06 PM [verbose] System initialization completed.

vanackej commented 2 years ago

And, so everything seems ok. No you don't have anything to do as long as MQTT discovery is enabled in Home assistant Have you checked directly on your MQTT that messages are properly published ? Have you check that MQTT discovery is enabled in HA ? https://www.home-assistant.io/docs/mqtt/discovery/

Then your entities should be visible in HA MQTT integration : image

llambkin commented 2 years ago

I can see the published entities in MQTT explorer, but they are coming up in different areas, one is published under "riscopanel" and the other is being published under homeassistant/risco-alarm-panel

I have obviously done something wrong here....

Here is my config json: { "log": "verbose", "panel": { "panelIp": "192.168.1.230", "panelPort": 1000, "panelPassword": 5678, "panelId": "0001", "watchDogInterval": 10000, "Disable_RiscoCloud": true, "SocketMode": "direct", "autoDiscover": true }, "mqtt": { "url": "mqtt://192.168.3.159:1883", "username": "liam", "password": "P11emmp11e" }, "zones": { "default": { "off_delay": 30, "name_prefix": "Sensor - " }, "GARAGE": { "off_delay": 0, "device_class": "garage_door", "name": "Garage Door", "name_prefix": "" } } }

image

llambkin commented 2 years ago

MQTT discovery is working just fine, as my 3D printers discover just fine through MQTT discovery using the repetier server addon.

vanackej commented 2 years ago

No, everything is ok in your mqtt explorer. On hierarchy is for discovery info, the other part is for entities values updates. The issue must be somewhere in your HA setup

Le lun. 21 févr. 2022 à 14:55, Liam Lambkin @.***> a écrit :

MQTT discovery is working just fine, as my 3D printers discover just fine through MQTT discovery using the repetier server addon.

— Reply to this email directly, view it on GitHub https://github.com/vanackej/risco-mqtt-local/issues/21#issuecomment-1046905780, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECPHPN42Z2RNZQY2UUV4LU4I75TANCNFSM5O4K7LNA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were assigned.Message ID: @.***>

llambkin commented 2 years ago

Thankyou for your help. Great work with this addon, I will do some further digging as to why it is not discovering properly.

llambkin commented 2 years ago

Okay, you can close this issue. I got it going, modified my MQTT addon, and it now shows the sensors it discovered. image