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

Zone config override issue #23

Closed ob1w4nken0b1 closed 2 years ago

ob1w4nken0b1 commented 2 years ago

Hi, As I try to override config (e.g. "device class":"door" or "name": "xxxx") for a given zone, it changes it for several other random zones. I think it depends from zone label as I tried configuring several different zones (one at a time) and it does that only for some...for example if i configure it like this:

"zones": {
  "default": {
    "off_delay": 0,
    "name_prefix": "Sensor "
  },
  "Porta Ingresso": {
    "device_class": "door"
  }

it changes class to door for a bunch of other random zones

while if i configre it like this:

"zones": {
  "default": {
    "off_delay": 0,
    "name_prefix": "Sensor "
  },
  "Tamper SIR": {
    "device_class": "tamper"
  }

the configuration is fine and it doesnt change class to other zones. It does the same thing with "name"

let me know if u need logs for this

Configuration

markxroberts commented 2 years ago

I have seen this too. I updated entity names manually in Home Assistant. This was a one-time change. Here's my config.json excerpt:

    "Utility Door": { 
      "off_delay": 0, 
      "device_class": "door", 
      "name": "Utility door", 
      "name_prefix": "" 
    },
     "Utility Window": { 
      "off_delay": 0, 
      "device_class": "window", 
      "name": "Utility window", 
      "name_prefix": "" 
    },
    "Kitchen LH Window": { 
      "off_delay": 0, 
      "device_class": "window", 
      "name": "Kitchen small window", 
      "name_prefix": "" 
    },
    "Kitchen RH Window": { 
      "off_delay": 0, 
      "device_class": "window", 
      "name": "Kitchen large window", 
      "name_prefix": ""
    },
    "Kitchen Patio Dr": { 
      "off_delay": 0, 
      "device_class": "door", 
      "name": "Kitchen patio door", 
      "name_prefix": "" 
    },

In Home Assistant, the next 3 sensors in "window" class are called "Utility window". The next correctly named entry is Kitchen patio door. These are zones 10, 11, 12, 13. The empty "name_prefix" line is also not updated. All sensors retain the default "sensor" prefix.

The error reoccurs later:

config.json:

    "Plum Bed Window": { 
      "off_delay": 0, 
      "device_class": "window", 
      "name": "Plum bedroom window", 
      "name_prefix": "" 
    },
    "Landing window": { 
      "off_delay": 0, 
      "device_class": "window", 
      "name": "Landing window", 
      "name_prefix": "" 
    },
    "Oak Bed Window": { 
      "off_delay": 0, 
      "device_class": "window", 
      "name": "Oak bedroom window", 
      "name_prefix": "" 
    },

Landing window is also represented in HA as Plum bed window, but Oak bed window is correctly named. These are zones 20, 21, 22.

vanackej commented 2 years ago

@ob1w4nken0b1 Can you post your debugs logs, including json config logs and MQTT discovery payload logs ?

ob1w4nken0b1 commented 2 years ago

@ob1w4nken0b1 Can you post your debugs logs, including json config logs and MQTT discovery payload logs ?

Yep! Here they are... deleted

And here's the resulting mess lol...but i saw that you can already see it from mqtt discovery payload logs (for example sensor 8 took same name of sensor 7, sensor 9 took the same class of sensor 8, some sensors I didn't override took class or name from others)

deleted

(again logs are from separate docker image but the addon has the exact same behavior)

vanackej commented 2 years ago

As I try to override config (e.g. "device class":"door" or "name": "xxxx") for a given zone, it changes it for several other random zones. I think it depends from zone label as I tried configuring several different zones (one at a time) and it does that only for some...for example if i configure it like this:

"zones": {
  "default": {
    "off_delay": 0,
    "name_prefix": "Sensor "
  },
  "Porta Ingresso": {
    "device_class": "door"
  }

it changes class to door for a bunch of other random zones

@ob1w4nken0b1 In the provided exemple, you have overriden every zone, so I can't track the problem. I need a log using configuration from your initial issue as quoted

ob1w4nken0b1 commented 2 years ago

There are several zones not overridden that have taken wrong name and class, and a lot of overridden zones that have taken wrong name and class the same way. (e.g. zone 2 took name and class from zone 1, zone 6 took name and class from zone 7 ecc).

However let me redo the test then i'll post logs

ob1w4nken0b1 commented 2 years ago

Ok so in ths log you can see that despite having overridden only zone 8 ("porta ingresso") with "device_class":"door", it gave the same device class to all the zones coming after 8 in the log.

deleted

with "device_class" and "name" it does the same as you can see in previous logs even if zones are overridden...other attributes might be affected too but i haven't tested

ob1w4nken0b1 commented 2 years ago

Update: looking at the first log i posted i think i have better understood the issue... Seems like when the program encounters an overridden zone, it just keeps applying the same overrided configs to all the zones coming after that until he finds a new override, and then starts again applying that to all zones coming after.

vanackej commented 2 years ago

Yeah I also spotted the problem. Currently testing the fix

markxroberts commented 2 years ago

That's not the case with my first example. I put in an override for all of them. The first 2 aren't really overrides. The first 'proper' override is ignored, as is the second... It's only followed again when the device class changes.

ob1w4nken0b1 commented 2 years ago

That's not the case with my first example. I put in an override for all of them. The first 2 aren't really overrides. The first 'proper' override is ignored, as is the second... It's only followed again when the device class changes.

it goes on applying overridden configs to the increasing zone number, doesnt matter the order you provided in the config. e.g. if zone 8 has ooverrides then it applies em to 9, 10, 11 until for example zone 12 has overrides and then starts again with 13, 14 etc.

As a confirm...if like in my first post i override only my last zone number, no other zones are mistakenly overridden

markxroberts commented 2 years ago

Yes, understand that. My first example doesn't fit with that, though. Zones are all listed in ascending numerical order. I have overrides for nearly all zones, including all 5 in the first example. Subsequent overrides are ignored until the change in device type. The second example does fit with your theory!

markxroberts commented 2 years ago

This hasn't completely solved the problem for me. config.json as in earlier post. Zone labels for Kitchen LH window and kitchen RH window remain uncorrected.

2/25/2022, 6:50:48 PM [info] Connected on mqtt server: mqtt://192.168.3.81:1883
2/25/2022, 6:50:48 PM [info] Panel is not connected, waiting
2/25/2022, 6:50:53 PM [warn] Command[1] 'RMT=1317' Timeout
2/25/2022, 6:50:58 PM [warn] Command[1] 'RMT=1317' Timeout
2/25/2022, 6:51:03 PM [warn] Command[1] 'RMT=1317' Timeout
2/25/2022, 6:51:05 PM [warn] Command[1] Command response was unexpected, ignoring. Data[ACK]
2/25/2022, 6:51:06 PM [info] Panel info: LightSys/RP432, FW 5.93
2/25/2022, 6:51:06 PM [info] Panel options: 4 parts, 50 zones, 32 outputs, Pir Cam support: false
2/25/2022, 6:51:06 PM [info] Starting devices discovery
2/25/2022, 6:51:06 PM [info] Retrieving System Information
2/25/2022, 6:51:06 PM [info] Retrieving zones configuration
2/25/2022, 6:51:45 PM [info] Retrieving outputs configuration
2/25/2022, 6:51:48 PM [warn] Command[42] Receipt of an error code: Device Doesn't Exists
2/25/2022, 6:51:48 PM [warn] Got error while fetching output 7 data: N19
2/25/2022, 6:51:48 PM [info] Output 7 does not exists, stopping outputs discovery
2/25/2022, 6:51:48 PM [info] Retrieving partitions configuration
2/25/2022, 6:51:48 PM [info] Panel and MQTT communications are ready
2/25/2022, 6:51:48 PM [info] Publishing Home Assistant discovery info
2/25/2022, 6:51:48 PM [info] [Panel => MQTT][Discovery] Published alarm_control_panel to HA on partition 1
2/25/2022, 6:51:48 PM [info] [Panel => MQTT][Discovery] Published alarm_control_panel to HA on partition 2
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Front Door, HA name = Front door
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Hall PIR, HA name = Hall PIR
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Kitchen PIR, HA name = Kitchen PIR
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Lounge PIR, HA name = Lounge PIR
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Grnd Flr Bath, HA name = Downstairs bathroom window
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Study PIR, HA name = Study PIR
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Study Window, HA name = Study window
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Utility Door, HA name = Utility door
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Utility Window, HA name = Utility window
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Kitchen LH Wndow, HA name = Kitchen LH Wndow
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Kitchen RH Wndow, HA name = Kitchen RH Wndow
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Kitchen Patio Dr, HA name = Kitchen patio door
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Lounge Patio Dr, HA name = Lounge patio door
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Landing PIR, HA name = Landing PIR
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = M Bed PIR, HA name = Master bedroom PIR
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = 1st Flr Bath, HA name = Main bathroom window
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Plum Bed Window, HA name = Plum bedroom window
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Landing Window, HA name = Landing Window
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Oak Bed Window, HA name = Oak bedroom window
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Beach Bed Window, HA name = Beach bedroom window
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = M Bed French, HA name = Master bedroom patio door
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Dining PIR, HA name = Dining room PIR
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Dining Windows, HA name = Dining room windows
2/25/2022, 6:51:49 PM [info] [Panel => MQTT][Discovery] Published binary_sensor to HA: Zone label = Garage Door, HA name = Garage door
2/25/2022, 6:51:49 PM [info] Publishing initial partitions and zones state to Home assistant
2/25/2022, 6:51:49 PM [info] [Panel => MQTT] Published alarm status disarmed on partition 1
2/25/2022, 6:51:49 PM [info] [Panel => MQTT] Published alarm status armed_away on partition 2
2/25/2022, 6:51:49 PM [info] Subscribing to Home assistant commands topics
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/1/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/2/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/1-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/2-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/3-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/4-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/5-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/6-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/7-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/9-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/10-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/11-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/12-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/13-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/14-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/17-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/18-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/19-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/20-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/21-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/22-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/23-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/24-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/25-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/26-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to riscopanel/alarm/zone/27-bypass/set topic
2/25/2022, 6:51:49 PM [info] Subscribing to panel partitions events
2/25/2022, 6:51:49 PM [info] Subscribing to panel zones events
2/25/2022, 6:51:49 PM [info] Initialization completed
ob1w4nken0b1 commented 2 years ago

Sorry to hear that...for my kind of config the fix worked right...could it be panel model related?

vanackej commented 2 years ago

@markxroberts Thats strange. I'll need at least debug logs to understand what might happens

markxroberts commented 2 years ago

Thanks. Same debug log as issue #24

vanackej commented 2 years ago

@markxroberts I only see logs with info level in #24. Commands logs is not enough, I need to have full debug log for this one

markxroberts commented 2 years ago

OK. Have set log level to debug, but can't see the config option to output this to a file. Too many lines to copy from console directly as exceeds buffer!

vanackej commented 2 years ago

Can't you redirect your standard output to a file ? cmd > debug_logs.txt

vanackej commented 2 years ago

@markxroberts In your config.json : zone reference as Kitchen LH Window In your logs : Zone label from panel seems to be : Kitchen LH Wndow => no 'i'

I think thats your issue.

markxroberts commented 2 years ago

It's amazing how you can look at something for ages and miss something so simple, isn't it? That's why I was never any good at coding! Thank you.

vanackej commented 2 years ago

0.4.1 available with all fixes released