Correct way to send commands from shell

Functionality and usage of the OpenNethome Server
Post Reply
lassiko
Posts: 25
Joined: Tue Dec 30, 2014 11:57 am

Correct way to send commands from shell

Post by lassiko »

I would like to know that what is the best way to send commands to Nethome from Shell?
Currently i am doing it (from another Raspberry) with wget, e.g TV_ON: wget -O - "http://192.168.0.105:8020/home?page=roo ... ion=toggle"

Is there a better or right way to do this?

thank you!
stefangsbb
Site Admin
Posts: 313
Joined: Sun Nov 30, 2014 2:16 pm

Re: Correct way to send commands from shell

Post by stefangsbb »

That was a quite creative way of doing it! There are many ways, but the one you use is a bit dangerous, since you are using a non published GUI interface which can change at any time when the GUI changes...

From Linux I would recommend to use NetCat (nc) to connect to an UDPCommandPort. In this example I have created a UDPCommandPort on port 8005, and the Id of my window lamp is 108. To toggle that lamp I use the command:

Code: Select all

echo 'call,108,toggle' | nc -u -w 0 192.168.1.100 8005
You can use a TCPCommandPort too, but then you get a line in the log for each connection and UDP is faster. For more information about the commands in the UDPCommandPort, see http://wiki.nethome.nu/doku.php/commandportsyntax
lassiko
Posts: 25
Joined: Tue Dec 30, 2014 11:57 am

Re: Correct way to send commands from shell

Post by lassiko »

Hi Stefan,

Thank you for this hint, works much better! :)

How about if i want to toggle a set of lights, e.g;
<HomeItem Class="Scene" >
<Attribute Name="ID">300</Attribute>
<Attribute Name="Name">Ulkovalot off scene</Attribute>
<Attribute Name="Delay">1.0</Attribute>
<Attribute Name="Command1">call,170,off</Attribute>
<Attribute Name="Command2">call,150,off</Attribute>
</HomeItem>

using a ID 300 did not work.

Thanks.
stefangsbb
Site Admin
Posts: 313
Joined: Sun Nov 30, 2014 2:16 pm

Re: Correct way to send commands from shell

Post by stefangsbb »

I am not sure I understand what you mean... The Id of an Item is automatically assigned by the server when the Item is created. The Scene-Item only have one action (called "Action"), so the only thing you can do with it would be:

Code: Select all

call,300,Action
Then it would perform the two commands with one seconds pause between.
Post Reply