/// <summary> /// Gets the button state for the device. /// </summary> /// <param name="buttonNumber">Button number to get the state for</param> /// <param name="state">The button state</param> /// <returns>the status of the send message</returns> public Messages.PowerLineModemMessage.MessageResponse GetButtonState(byte buttonNumber, out ButtonState state) { byte[] data = new byte[14]; data[0] = buttonNumber; data[1] = (byte)ExtendedGetSetCommands.DataRequest; InsteonPacket response; Messages.PowerLineModemMessage.MessageResponse ret = this.SendExtendedCommandWithResponse(InsteonPacket.ExtendedCommand.ExtendedGetSet, 0, data, out response); if (ret == Messages.PowerLineModemMessage.MessageResponse.Ack) { data = response.UserData; state = new ButtonState(); state.FollowMask = data[2]; state.OffMask = data[3]; state.X10HouseCode = data[4]; state.X10UnitCode = data[5]; state.RampRate = data[6]; state.OnLevel = data[7]; state.GlobalLEDBrightness = data[8]; state.Toggle = data[9] != 0; state.LedState = data[10] != 0; state.X10AllOnOff = data[11] != 0; state.ButtonNonToggleSendsOn = data[12] != 0; state.TriggerAllLinkCommand = data[13] != 0; } else { state = null; } return(ret); }
/// <summary> /// Gets the text string from the device. /// </summary> /// <param name="outTextString"></param> /// <returns></returns> public Messages.PowerLineModemMessage.MessageResponse GetTextString(out string outTextString) { outTextString = textString; if (textString == null) { InsteonPacket packet = new InsteonPacket(this.deviceId, InsteonPacket.Command.ProductDataRequest, 0x2); packet.Flags.ExtendedMessage = true; packet.UserData = new byte[14]; InsteonPacket response; Messages.PowerLineModemMessage.MessageResponse ret = coms.SendDirectInsteonPacket(packet, out response); if (ret == Messages.PowerLineModemMessage.MessageResponse.Ack) { // Response should be an extended message. if (response.Flags.ExtendedMessage) { int i; for (i = 0; i < response.UserData.Length; i++) { if (response.UserData[i] == 0) { break; } } textString = System.Text.Encoding.ASCII.GetString(response.UserData, 0, i); outTextString = textString; return(ret); } } return(ret); } return(Messages.PowerLineModemMessage.MessageResponse.Ack); }
/// <summary> /// Gets the mode of the pool (spa or pool). /// </summary> /// <param name="mode">The mode of the pool</param> /// <returns></returns> public Messages.PowerLineModemMessage.MessageResponse GetPoolMode(out PoolMode mode) { byte response; Messages.PowerLineModemMessage.MessageResponse ret = this.SendStandardCommandWithResponse(InsteonPacket.Command.PoolControl, (byte)PoolControlCommand.GetPoolMode, out response); mode = (PoolMode)response; return(ret); }
/// <summary> /// Turns the specific pool device off. /// </summary> /// <param name="device">The pool device to turn off</param> /// <returns></returns> public Messages.PowerLineModemMessage.MessageResponse TurnPoolDeviceOff(PoolDevice device) { // Need to get the status. Messages.PowerLineModemMessage.MessageResponse ret = this.SendStandardCommand(InsteonPacket.Command.PoolOff, (byte)device); if (ret == Messages.PowerLineModemMessage.MessageResponse.Ack) { poolDeviceOn.Remove(device); } return(ret); }
public Messages.PowerLineModemMessage.MessageResponse SetOnLevelForButton(byte button, byte onLevel) { byte[] data = new byte[14]; data[0] = button; data[1] = (byte)ExtendedGetSetCommands.SetTriggerAllLinkStateForButton; data[2] = onLevel; InsteonPacket response; Messages.PowerLineModemMessage.MessageResponse ret = this.SendExtendedCommandWithResponse(InsteonPacket.ExtendedCommand.ExtendedGetSet, 0, data, out response); return(ret); }
public Messages.PowerLineModemMessage.MessageResponse SetNonToggleOnOffStateForButton(byte button, bool nonToggleOnOffState) { byte[] data = new byte[14]; data[0] = button; data[1] = (byte)ExtendedGetSetCommands.SetNonToggleOnOffStateForButton; data[2] = (byte)(nonToggleOnOffState ? 0x00 : 0xff); InsteonPacket response; Messages.PowerLineModemMessage.MessageResponse ret = this.SendExtendedCommandWithResponse(InsteonPacket.ExtendedCommand.ExtendedGetSet, 0, data, out response); return(ret); }
/// <summary> /// Sets if the button follows the led state. /// </summary> /// <param name="button"></param> /// <param name="buttonLedFollows"></param> /// <returns></returns> public Messages.PowerLineModemMessage.MessageResponse SetLedFollowMaskForButton(byte button, bool buttonLedFollows) { byte[] data = new byte[14]; data[0] = button; data[1] = (byte)ExtendedGetSetCommands.SetLedFOllowMask; data[2] = (byte)(buttonLedFollows ? 0x00 : 0xff); InsteonPacket response; Messages.PowerLineModemMessage.MessageResponse ret = this.SendExtendedCommandWithResponse(InsteonPacket.ExtendedCommand.ExtendedGetSet, 0, data, out response); return(ret); }
/// <summary> /// Turns the light off quickly. /// </summary> /// <returns></returns> public Messages.PowerLineModemMessage.MessageResponse setLightOffFast() { // Need to get the status. Messages.PowerLineModemMessage.MessageResponse ret = this.SendStandardCommand(InsteonPacket.Command.LightOffFast, (byte)0); if (ret == Messages.PowerLineModemMessage.MessageResponse.Ack) { this.hasStatus = true; this.onLevel = 0; } return(ret); }
public Messages.PowerLineModemMessage.MessageResponse SetX10AddressForButton(byte button, byte x10HouseCOde, byte x10UnitCode) { byte[] data = new byte[14]; data[0] = button; data[1] = (byte)ExtendedGetSetCommands.SetTriggerAllLinkStateForButton; data[2] = x10HouseCOde; data[3] = x10UnitCode; InsteonPacket response; Messages.PowerLineModemMessage.MessageResponse ret = this.SendExtendedCommandWithResponse(InsteonPacket.ExtendedCommand.ExtendedGetSet, 0, data, out response); return(ret); }
/// <summary> /// Sends a standard command off to do stuff. /// </summary> /// <param name="cmd">The command to send</param> /// <param name="command2">The second part of the command to update</param> /// <returns></returns> protected Messages.PowerLineModemMessage.MessageResponse SendStandardCommandWithResponse(InsteonPacket.Command cmd, byte command2, out byte outCommand2) { InsteonPacket packet = new InsteonPacket(this.deviceId, cmd); packet.Command2 |= command2; InsteonPacket response; Messages.PowerLineModemMessage.MessageResponse ret = coms.SendDirectInsteonPacket(packet, out response); if (ret == Messages.PowerLineModemMessage.MessageResponse.Ack) { outCommand2 = response.Command2; } else { outCommand2 = 0; } return(ret); }
/// <summary> /// Brightens one step. /// </summary> /// <returns></returns> public Messages.PowerLineModemMessage.MessageResponse Brighten() { // Need to get the status. Messages.PowerLineModemMessage.MessageResponse ret = this.SendStandardCommand(InsteonPacket.Command.Bright, (byte)0); if (ret == Messages.PowerLineModemMessage.MessageResponse.Ack) { if (this.hasStatus) { int newLevel = this.onLevel + (256 / 32); if (newLevel > 0xff) { newLevel = 0xff; } this.onLevel = (byte)newLevel; } } return(ret); }
/// <summary> /// Change the temperature of the pool down by a few degrees. /// </summary> /// <param name="changeBy">Number of degrees to change by</param> /// <returns></returns> public Messages.PowerLineModemMessage.MessageResponse PoolTemperatureDown(byte changeBy) { Messages.PowerLineModemMessage.MessageResponse ret = this.SendStandardCommand(InsteonPacket.Command.PoolTemperatureDown, changeBy); return(ret); }
/// <summary> /// Gets the ph of the water. /// </summary> /// <param name="ph">The ph of the water in pool or spa</param> /// <returns></returns> public Messages.PowerLineModemMessage.MessageResponse GetPh(out byte ph) { Messages.PowerLineModemMessage.MessageResponse ret = this.SendStandardCommandWithResponse(InsteonPacket.Command.PoolControl, (byte)PoolControlCommand.GetWaterTemperature, out ph); return(ret); }
/// <summary> /// Gets the ambient temperature of the air around the pool. /// </summary> /// <param name="temperature">The temperature of the air around the spa</param> /// <returns></returns> public Messages.PowerLineModemMessage.MessageResponse GetAmbientTemperature(out byte temperature) { Messages.PowerLineModemMessage.MessageResponse ret = this.SendStandardCommandWithResponse(InsteonPacket.Command.PoolControl, (byte)PoolControlCommand.GetAmbientTemperature, out temperature); return(ret); }