Howto add support of new device in Plutohome
IN PROGRESS …
Overview
Plutohome supports many devices (thanks to developers) but somethimes you need to have some specific devices in your smart home. Add a new device into Plutohome system can be done by two ways:
- using GSD (Generic Serial Device). It is right for most external devices that are controlled by RS232, USB or Ethernet;
- using a generator to build a cross-platform C++ project for your device.
This howto will describe the first way of adding of support of new device in the Plutohome.
Let’s start.
Generic Serial Device
To use GSD it’s needed to be installed package for Generic_Serial_Device. To check it run in concole following command:
dpkg -l 'pluto-generic-serial-device'
If this package is not exisitng in your system just install it:
apt-get install pluto-generic-serial-device pluto-libserial
After installation you have to quick reload DCERouter. If the package was installed successful you’ll able to see Generic_Serial_Device in the list of running processes and watch its log.
You can reload DCERouter using utility MessageSend – /usr/pluto/bin/MessageSend.
– created a device template
– defined a couple of commands (On_A and Off_A) just to test
– added Ruby Internal Commands
– defined proper serial parameters (dev/ttyS0, 9600 8N1)
– saved the new template
– added a child device to core (where is the new device plugged in)
Ruby Code
Private Method Listing – define here any functions you may need like send_and_receive_confirmation, and call it every time you need instead of Send() and Recv() and verify if the response is the one you expect
Process IDLE – function which will be called once in few seconds (do whatever you want)
Process Incoming Data – called when device has something to say(you probably need to read it)
Process Initialize – called when pluto device is starting (initialize connection parameters here, say hello to device, whatever)
Process Receive Command For Child – called when you you receive a command addressed to one of your children
Process Release – called when pluto device is finishing (for example on router quick reload), maybe you need to say goodbye to the device (if needed by protocol)
The GSD device is usually controlled via CORE, or whatever computer which has the physical device, and it’s children are controlled via GSD device.
if cmd.id_ == 192 #192 is ON
id=device_.childdevices[cmd_.devidto_].devdata_[12]
if id==0
conn_.Send("ALA")
end
end
n Ruby context you may call following methods:
conn_.Send(
conn_.Recv(
Some useful variables:
device_.devdata[] => gives you acces to data you entered in “Device Data” section when you added the device (the number is shown on web interface).