Set TEXT of a virtual text device with spaces

Moderator: leecollings

Post Reply
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Set TEXT of a virtual text device with spaces

Post by Number8 »

I'm trying to set the value of the TEXT virtual device using bash and curl, the value having spaces.
I have no problems with the following command in a brower

Code: Select all

http://192.168.21.240:8080/json.htm?type=command&param=udevice&idx=217&nvalue=0&svalue=Please power ON this gear 
However when using this code

Code: Select all

message="Please power on this gear"
messageIDX=217
curl --silent $DOMOTICZSERVER:$DOMOTICZPORT'/json.htm?type=command&param=udevice&idx='$messageIDX'&nvalue=0&svalue='$message
Only the first word is displayed. I tried many things including escaping the single quote. At best only the first word of the message is displayed, or using many other solutions I tried an error is trigerred on the server side.
Any clue?
Thank you
Debian buster on NUC and three RPi with buster.
User avatar
gizmocuz
Posts: 2552
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Set TEXT of a virtual text device with spaces

Post by gizmocuz »

try do some url encoding

message="Please%20power%20on%20this%20gear"
Quality outlives Quantity!
RobertH
Posts: 12
Joined: Sunday 15 November 2015 19:10
Target OS: Windows
Domoticz version:
Location: Norway, Kongsberg
Contact:

Re: Set TEXT of a virtual text device with spaces

Post by RobertH »

Use %20 for space.

Sent from my SM-G925K using Tapatalk
Domoticz running on Windows Server 2008 in VMware (ESXi), UZB1 stick, 3x FIBARO FGD212 Dimmer, 1x FIBARO RGBW Controller FGRGBWM-441, 2x FIBARO FGMS001 Motion Sensor and 2x Popp 009006 Plug-in Switch
paulvha
Posts: 40
Joined: Friday 29 January 2016 16:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Set TEXT of a virtual text device with spaces

Post by paulvha »

I expect the issue with argument passing to curl. try double quotes : "$message"
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: Set TEXT of a virtual text device with spaces

Post by Number8 »

Thanks guys, it did the trick. I'm using the same idea to display accented characters
fyi double quote was one of my first tries. It does not work.
Debian buster on NUC and three RPi with buster.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest