sendCommand with special character

I recently bought the aqara Aqara roller shade companion E1.
The payload for changing the position of the blinds should be in this format according to

{“position” :X}

My thing is configured like this:

Type string : position [stateTopic="zigbee2mqtt/rolgordijn_keuken", commandTopic="zigbee2mqtt/rolgordijn_keuken/set", transformationPattern="JSONPATH:$.position"]

Item like this:

String                RolgordijnKeukenPosition                                       "Positie"                                                                                                                     {channel="mqtt:topic:mosquitto:rolgordijn_keuken:position"}

With my knowlegde i was able to come up with this:

   RolgordijnKeukenPosition.sendCommand( " {"position" :3} " )

But i get the following error:
2022-08-07 22:15:38.121 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘rolgordijn.rules’ has errors, therefore ignoring it: [35,46]: missing ‘)’ at ‘position’

[35,62]: mismatched input ‘)’ expecting ‘end’

I tried lots of variations but i can’t get it to work. Can anyone help me with this one? Feel like i could be missing something simple. The problem is in the " character.

Yep. You can’t have double quotations within double quotations, because you end up with two separate pairs.

I think you can either use single quotes or escape the inner quotation marks with \:

" {'position' :3} "
' {"position" :3} '
" {\"position\" :3} "

I might be wrong about these, as I haven’t had this particular scenario.

Seems to do the trick. Thank you :slight_smile:

You should be able use


as commandTopic.
By this you just should be able to send


In addition in this case I would change your channel and item from string to numeric

That also works like a charm.
How did you come up with that?

That’s the default zigbee2mqtt behavior and should work for all attributes you can set.

With this you can link directly a dimmer item to your channel and do not need any kind of rule or additional transformation. Hope it will make your life a bit easier :slight_smile:

1 Like

Sure does :). Thanks