i8beef / HomeAutio.Mqtt.GoogleHome

MIT License
215 stars 29 forks source link

use valueMap for commands (Unexpected character encountered while parsing value: {.) #130

Closed fightforlife closed 3 years ago

fightforlife commented 3 years ago

Hi i8beef,

I am currently trying to use the valueMap for a simple onOff command. But it is not working for me. Most likely it is just a typing error somewhere but I cannot find it.

Do you have to change the way you use the valueMap for commands rahter than states?

Error: Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: {. Path '['action.devices.commands.OnOff'].on', line 3, position 11.

Attributes
{
  "commandOnlyOnOff": true,
  "queryOnlyOnOff": false
}

Commands
{
  "action.devices.commands.OnOff": {
    "on": {
      "topic": "tasmota/gateway/cmnd/Backlog",
      "valueMap": [
        {
            "google": "true",
            "type": "value",
            "mqtt": "smartRCsend 1131857,24,1,15,300; Delay 1;"
        },
        {
            "google": "false",
            "type": "value",
            "mqtt": "smartRCsend 1131860,24,1,15,300; Delay 1;"
        }
    ]
    }
  }
}

State //currently not used
{
  "on": {
    "topic": "MQTT_STATE_TOPIC",
    "valueMap": null
  }
}

Thanks in advance!

i8beef commented 3 years ago

You put the valueMap on the state, not the command. Its still a bidirectional solution, its just the configuration for it is always on the state because its essentially a "state transformation".

fightforlife commented 3 years ago

Thank you very much! Wokring perfectly now. For anyone finding this as a reference:

Attributes
{
  "commandOnlyOnOff": false,
  "queryOnlyOnOff": false
}

Commands
{
  "action.devices.commands.OnOff": {
    "on": "tasmota/gateway/cmnd/Backlog"
  }
}

State
{
  "on": {
    "topic": "tasmota/gateway/cmnd/Backlog",
    "valueMap": [
      {
        "google": "true",
        "mqtt": "smartRCsend 1131857,24,1,15,300; Delay 1;",
        "type": "value"
      },
      {
        "google": "false",
        "mqtt": "smartRCsend 1131860,24,1,15,300; Delay 1;",
        "type": "value"
      }
    ]
  }
}