cgarwood / homeassistant-zwave_mqtt

Limited Pre-Release of the new OZW1.6 Z-Wave component. Currently has limited platform support. Check the README for more details.
72 stars 8 forks source link

Issue setting zwave_mqtt.set_config_parameter #81

Closed i-am-snappy closed 4 years ago

i-am-snappy commented 4 years ago

Blew away Z-Wave network and configuring from scratch in homeassistant_zwave_mqtt. Devices added fine via add_node.

I have been trying to use set_config_parameter from the HomeAssistant Services page, however it is not working. Warnings in log are along the lines of:

WARNING (MainThread) [custom_components.zwave_mqtt.services] Unknown config parameter 22799473241227284 on Node 7 with selection 1

I can change parameters via MQTT and publish as described by Isa: https://github.com/cgarwood/homeassistant-zwave_mqtt/issues/45#issuecomment-592093905 but was trying to accomplish via Services tab.

image

I am doing something wrong, but cant figure it out. Solution not explicitly indicated in https://github.com/cgarwood/homeassistant-zwave_mqtt/issues/67#issue-570540248 .

Also adding dump file: mqtt_dump.txt

silfa718 commented 4 years ago

I had a similar issue, I don't think that service call is working. see this for how to do this #67

i-am-snappy commented 4 years ago

Cheers Silfa - I spun my wheels for a bit with the service calls - Ended up pushing MQTT Publish packets out to change about 150 values. Was thinking I was doing something wrong with service calls. Once confirmed what the problem is, I'll close this..

image

kpine commented 4 years ago

You're using the value id. Did you try the parameter index value (1, 2, 3, etc.)? Same as core HA zwave. It should find the appropriate ValueID for you.

marcelveldt commented 4 years ago

You indeed need to use the index of the config param. That said, we can easily improve this in the future by allowing some other methods to change config, like by name and valueid

i-am-snappy commented 4 years ago

I can see the Index value eg. 81 (and yes it is the same as HA Z-Wave). This is what i initially tried. Also tried versions of {}, yaml etc. Still doesn't work. Service call may be broken as Silfa mentions??

image

image

EDIT: In MQTT Explorer, I can see the service call is calling the correct ValueIDKey but failing on Incorrect Field Type: Not Integer. I think I am doing something wrong... image

kpine commented 4 years ago

The value is a list, so you need to specify the label of the list item, not an integer. It is probably a string, like the ones listed above it, e.g. "Night Light Mode".

i-am-snappy commented 4 years ago

Also tried strings and doesn't work.

It looks like it has got to do with the double quotes put around the value in the setvalue command initiated from service calls. When I publish MQTT data it works, ie: image

However through service call examples above it puts quotes around integer.

kpine commented 4 years ago

Yeah, it doesn't look like lists are properly supported just yet.

Here is the formatted mqtt dump for that config parameter:

{
  "Label": "Configure the state of the LED",
  "Value": {
    "List": [
      {
        "Value": 0,
        "Label": "The LED will follow the status (on/off) of its load. (Default)"
      },
      {
        "Value": 1,
        "Label": "When the state of the Switch changes, the LED will follow the status (on/off) of its load, but the LED will turn off after 5 seconds."
      },
      {
        "Value": 2,
        "Label": "Night Light Mode"
      }
    ],
    "Selected": "The LED will follow the status (on/off) of its load. (Default)",
    "Selected_id": 0
  },
  "Units": "",
  "Min": 0,
  "Max": 1,
  "Type": "List",
  "Instance": 1,
  "CommandClass": "COMMAND_CLASS_CONFIGURATION",
  "Index": 81,
  "Node": 7,
  "Genre": "Config",
  "Help": "",
  "ValueIDKey": 22799473241227284,
  "ReadOnly": false,
  "WriteOnly": false,
  "ValueSet": false,
  "ValuePolled": false,
  "ChangeVerified": false,
  "Event": "valueAdded",
  "TimeStamp": 1586583641
}

qt-openzwave wants you to send setValue with the position (index) of the list item. So if you want to set "Night Light Mode", you call setValue with integer 2, as you've done manually, not '2' or "Night Light Mode". zwave_mqtt is detecting that the config parameter is a list type and converting whatever value you have given to a string.

So as you've observed, if you try a value of 2, it probably gets converted to '2' and sends it as the payload. I am assuming qt-openzwave wants an integer.

There's an existing issue https://github.com/cgarwood/python-openzwave-mqtt/issues/53 to support lists. The comment sounds like it's from the POV of reading list values, but setting them will obviously need to be considered somewhere.

i-am-snappy commented 4 years ago

Roger that - I know this is a work in progress, couldn't figure out if it were me or not. Setting list values via MQTT Publish is not that hard a work-around, now documented in this, and this #67. Will close issue as not to duplicate.