IOLinc.pm |
In user code:
use Insteon::IOLinc; $io_device = new Insteon::IOLinc('12.34.56',$myPLM);
In items.mht:
INSTEON_IOLINC, 12.34.56, io_device, io_group
Turning on a relay:
$io_device->set('on');
Turning off a relay:
$io_device->set('off');
Requesting sensor status:
$io_device->request_sensor_status();
Print the Current Device Settings to the log:
$io_device->get_operating_flag();
Support for the Insteon IOLinc.
The IOLinc is a strange device in that commands sent to it control one aspect of the device, but commands received from it are from another aspect of the device.
As a result of the IOLinc's oddities, when the IOLinc is set as a controller of another device, that other device will be controlled by the sensor state. However, when the IOLinc is set as a responder in a link, the relay of the IOLinc will change with the commands sent by the controller.
MisterHouse objects are only designed to hold the state of a single aspect. As a
result of the IOLinc's oddities, the $io_device defined using the examples above
will track the state of the relay only. The state of the sensor can be obtained
using the request_sensor_status()
command.
One more oddity is that using the "set" button on the side of the device to change the state of the relay, will cause MH to perceive this as a change in the state of the sensor, thus placing the sensor and relay objects out of sync.
To create a device that directly tracks the state of the sensor, you can use
Insteon::IOLinc_sensor
. The state of the child object will reflect the state
of the sensor and it will be automatically updated as long as the IOLinc is
linked to the
However, if you want to directly link an obect to the sensor be sure to use the normal SCENE_MEMBER code in your mht file with the IOLinc defined as the controller.
Instructions for this object are contained in Insteon::IOLinc_sensor
.
This module works with the Insteon IOLinc device from Smarthome. The EZIO device uses a different set of commands and this code will offer only limited, if any support at all, for EZIO devices.
The state that the relay is in when the device is linked to the PLM matters if you are using relay mode Momentary_A (I think).
The implementation of Momentary_A needs work. It can be properly set on the device, however it isn't clear how the preference for ON of OFF is selected. This is likely done in D1-D3 in the responder link. Setting the link to OFF in the definition may be enough to make it work, I don't yet know.
Insteon::BaseDevice, Insteon::DeviceController
new()
Instantiates a new object.
set(state[,setby,response])
Handles setting and receiving states from the device.
If the set command originates from the device, it represents the sensor state and is processed accordingly. All other set commands are sent to the device and control the relay state.
request_sensor_status()
Works just like request_status()
but it requests the status of the sensor.
Will cause the sensor status to be printed to the log.
As an alternative to calling the function repeatedly, you can define an Insteon::IOLinc_sensor object.
_is_info_request()
Checks to see if an incomming message contains the sensor state or the operating flags for the device. If not the message is passed on to Insteon::BaseObject::_is_info_requested().
_process_message()
Checks for and handles unique IOLinc messages such as the momentary time settings.
All other messages are transferred to Insteon::BaseObject::_process_message()|Insteon::BaseInsteon/Insteon::BaseObject
.
is_acknowledged([ack])
Hijacks the routine in BaseObject. This is used to set a timer to revert the relay state if a momentary state is used.
set_momentary_time(time)
$time in tenths of seconds (deciseconds) is the length of time the relay will close when
a Momentary mode is is selected in set_relay_mode
.
Acceptable Values for time: [2-255]
Default: 20 (2 Seconds)
get_momentary_time()
Prints the device's current momentary time setting to the log. And stores it in memory so that MH can reset the state of the relay after the appropriate amount of time
set_relay_linked([0|1])
If set to 1 whenever the Sensor is On the Relay will be on and whenever the Sensor is Off the Relay will be Off.
Default 0
set_trigger_reverse([0|1])
If set to 1, it reverses the sensor value so that a closed sensor switch reports its state as OFF and an open sensor switch reports its state as ON.
Default 0
set_relay_mode([Latching|Momentary_A|Momentary_B|Momentary_C])
Latching: The relay will remain open or closed until another command is received. Momentary time is ignored.
Momentary_A: The relay will close momentarily. If it is Linked while On it will respond to On. If it is Linked while Off it will respond to Off. (This setting is likely not implemented properly by MH, if you need this setting you will have to be a guinea pig and test it out for us. Questions: Can this be achieved by defining links as off? When this is used, how does the IOLinc respond to direct ON and OFF commands rather than All-Link Commands?)
Momentary_B: Both - On and Off both cause the relay to close momentarily.
Momentary_C: Look at Sensor - If the sensor is On the relay will close momentarily when an On command is received. If the sensor is Off the relay will close momentarily when an Off command is received.
Default Latching
get_voice_cmds
Returns a hash of voice commands where the key is the voice command name and the value is the perl code to run when the voice command name is called.
Higher classes which inherit this object may add to this list of voice commands by redefining this routine while inheriting this routine using the SUPER function.
This routine is called by the Insteon::generate_voice_commands manpage to generate the necessary voice commands.
Kevin Robert Keegan
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
User Code:
$io_device_sensor = new Insteon::IOLinc_sensor($io_device);
Where $io_device is the parent device defined above.
Creates a device that directly tracks the state of the IOLinc sensor. The state of this object will reflect the state of the sensor and it will be automatically updated as long as the IOLinc is linked to the PLM.
Tie_events can be used on this child object. However, if you want to directly link an obect to the sensor be sure to use the normal SCENE_MEMBER code in your mht file with the main IOLinc device defined as the controller.
new()
Instantiates a new object.
set_receive()
Receives sensor state messages from the parent object and sets the state of this device accordingly.
Kevin Robert Keegan
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
IOLinc.pm |