OpenZWave / Zwave2Mqtt

Fully configurable Zwave to MQTT gateway and Control Panel using NodeJS and Vue
MIT License
356 stars 97 forks source link

[bug] with custom device thermostat, "Cannot read property 'value_id' of undefined" #841

Open pdbogen opened 3 years ago

pdbogen commented 3 years ago

Version

Build/Run method

Zwave2Mqtt version: 4.0.6 Openzwave Version: 1.6.0

Describe the bug

This worked alright in 4.0.5, but in 4.0.6 my custom device config for my thermostat is not correctly producing HA thermostat devices.

I see this in the logs:

2020-11-29T01:10:26.402Z z2m:Gateway Error while discovering device climate_thermostat of node 34: Cannot read property 'value_id' of undefined

Here's my customDevices.json:

{
  "21076-33136-512": [
    {
      "type": "climate",
      "object_id": "thermostat",
      "values": [
        "49-1-1",
        "64-1-0",
        "67-1-1",
        "67-1-2"
      ],
      "mode_map": {
        "auto": "Auto",
        "cool": "Cool",
        "off": "Off",
        "heat": "Heat"
      },
      "setpoint_topic": {
        "Cool": "67-1-2",
        "Heat": "67-1-1"
      },
      "discovery_payload": {
        "min_temp": 50,
        "max_temp": 99,
        "modes": [
          "auto",
          "cool",
          "off",
          "heat"
        ],
        "mode_state_topic": "64-1-0",
        "mode_command_topic": true,
        "current_temperature_topic": "49-1-1",
        "current_temperature_template": "{{ value_json.value }}",
        "temperature_state_template": "{{ value_json.value }}",
        "temperature_command_topic": true
      }
    }
  ]
}
robertsLando commented 3 years ago

@pdbogen Are you sure all your valueIds exists? Also here you are missing the Auto setpoint, when you set the auto mode I check for its valueId in setpoint_topic and that error could come from this:

"setpoint_topic": {
        "Cool": "67-1-2",
        "Heat": "67-1-1",
        "Auto": "67-1-X"
      },
pdbogen commented 3 years ago

oh, good call. I gather I also need one for Off?

robertsLando commented 3 years ago

oh, good call. I gather I also need one for Off?

Nope that't the only one that doesn't need a setpoint

doguitar commented 3 years ago

Having the same issue with the same versions as the OP and didn't want to report a duplicate issue. Although this is the first I'm trying so I can't speak to if this would have worked in the past.

{
  "57-8-17": [
    {
      "type": "climate",
      "object_id": "thermostat",
      "values": ["27-67-1-1", "27-67-1-2", "27-64-1-0", "27-49-1-1"],
      "mode_map": {"off": "Off", "heat": "Heat", "cool": "Cool"},
      "setpoint_topic": {"Heat": "27-67-1-1", "Cool": "27-67-1-2"},
      "discovery_payload": {
        "min_temp": 50,
        "max_temp": 90,
        "modes": ["off", "heat", "cool"],
        "mode_state_topic": "27-64-1-0",
        "mode_command_topic": true,
        "current_temperature_topic": "27-49-1-1",
        "current_temperature_template": "{{ value_json.value }}",
        "temperature_state_template": "{{ value_json.value }}",
        "temperature_command_topic": true
      }
    }
  ]
}

On a side note, the error logging for this method is pretty unhelpful. There's a single try/catch wrapping the entire method.

robertsLando commented 3 years ago

@doguitar In zwavejs2mqtt now climates are auto discovered: https://github.com/zwave-js/zwavejs2mqtt

doguitar commented 3 years ago

What's the purpose/objective of the fork? Besides devices support (which is pretty major), why should I switch?

robertsLando commented 3 years ago

It's explained here: https://github.com/zwave-js/zwavejs2mqtt#why-zwavejs