diff --git a/doc/Samsung-HVAC-buscontrol.md b/doc/Samsung-HVAC-buscontrol.md index 7722055..bdbee1c 100644 --- a/doc/Samsung-HVAC-buscontrol.md +++ b/doc/Samsung-HVAC-buscontrol.md @@ -71,12 +71,9 @@ This command is an information request. The bytes in the command are all zeroes, | Data byte | Settings | | :---: | :--- | -| 1 | bit 5-0 : set temperature - 9 | -| | bit 6 : always set to '1' ? | -| 2 | bit 5-0 : room temperature - 9 | -| | bit 6 : always set to '1' ? | -| 3 | bit 5-0 : output air temperature - 9 | -| | bit 6 : always set to '1' ? | +| 1 | bit 6-0 : set temperature + 55 | +| 2 | bit 6-0 : room temperature + 55 | +| 3 | bit 5-0 : output air temperature + 55 | | 4 |

bit 2-0 : fan speed
0 = auto
2 = low
4 = medium
5 = high

| | |

bit 7-3 : blade swing
1A = swing up/down
1F = blade swing off

| | 5 |

bit 3-0 : 1 = wired control
2 = remote control

| @@ -84,8 +81,7 @@ This command is an information request. The bytes in the command are all zeroes, | |

bit 7 : 0 = power is off
1 = power in on

| | 6 | bit 4 : 1 = filter needs cleaning | | 7 | 0 | -| 8 | bit 5-0 : another temperature - 9 | -| | bit 6 : always set to '1' ? | +| 8 | bit 6-0 : another temperature + 55 | ### Command 53 diff --git a/hvac-controller/src/main/java/org/chuma/hvaccontroller/packet/Get52ResponsePacket.java b/hvac-controller/src/main/java/org/chuma/hvaccontroller/packet/Get52ResponsePacket.java index d8ad085..9f1eb25 100644 --- a/hvac-controller/src/main/java/org/chuma/hvaccontroller/packet/Get52ResponsePacket.java +++ b/hvac-controller/src/main/java/org/chuma/hvaccontroller/packet/Get52ResponsePacket.java @@ -4,7 +4,7 @@ import org.chuma.hvaccontroller.device.OperatingMode; public class Get52ResponsePacket extends AbstractPacket { - public static final int MASK_TEMPERATURE = 0x3F; + public static final int MASK_TEMPERATURE = 0x7F; public static final int MASK_FAN_SPEED = 0x07; public static final int MASK_ON = 0x80; public static final int MASK_MODE_AUTO = 0x20; @@ -73,7 +73,7 @@ public int getAir2Temperature() { } private int decodeTemperature(int byteIndex) { - return (packetData.data[byteIndex] & MASK_TEMPERATURE) + 9; + return (packetData.data[byteIndex] & MASK_TEMPERATURE) - 55; } public boolean isOn() { diff --git a/hvac-controller/src/test/java/org/chuma/hvaccontroller/device/PacketReaderTest.java b/hvac-controller/src/test/java/org/chuma/hvaccontroller/device/PacketReaderTest.java index f8c5954..bc2810e 100644 --- a/hvac-controller/src/test/java/org/chuma/hvaccontroller/device/PacketReaderTest.java +++ b/hvac-controller/src/test/java/org/chuma/hvaccontroller/device/PacketReaderTest.java @@ -13,6 +13,7 @@ import org.chuma.hvaccontroller.packet.Get54ResponsePacket; import org.chuma.hvaccontroller.packet.Get64ResponsePacket; import org.chuma.hvaccontroller.packet.Packet; +import org.chuma.hvaccontroller.packet.PacketData; import org.chuma.hvaccontroller.packet.PacketFactory; import org.chuma.hvaccontroller.packet.SetPacketResponse; @@ -69,7 +70,7 @@ public void parsePackets() throws Exception { } { // 3 = {Get52ResponsePacket@2108} "0x20->0x84 tgtTemp:23;roomTemp:25;airTemp:25;fan:SPEED_1;on:0 auto:0 defrost:1 mode:HEAT;air2Temp:25" - Get52ResponsePacket p = (Get52ResponsePacket)packets[3]; + Get52ResponsePacket p = (Get52ResponsePacket) packets[3]; Assert.assertEquals(23, p.getTargetTemperature()); Assert.assertEquals(25, p.getRoomTemperature()); Assert.assertEquals(25, p.getAirTemperature()); @@ -82,7 +83,7 @@ public void parsePackets() throws Exception { } { // 180 = {Get52ResponsePacket@2400} "0x20->0x84 tgtTemp:24;roomTemp:25;airTemp:25;fan:AUTO;on:1 auto:1 defrost:0 mode:COOL;air2Temp:25" - Get52ResponsePacket p = (Get52ResponsePacket)packets[180]; + Get52ResponsePacket p = (Get52ResponsePacket) packets[180]; Assert.assertEquals(24, p.getTargetTemperature()); Assert.assertEquals(25, p.getRoomTemperature()); Assert.assertEquals(25, p.getAirTemperature()); @@ -95,7 +96,7 @@ public void parsePackets() throws Exception { } { // 270 = {Get52ResponsePacket@2092} "0x20->0x84 tgtTemp:24;roomTemp:24;airTemp:24;fan:SPEED_3;on:1 auto:0 defrost:0 mode:FAN;air2Temp:24" - Get52ResponsePacket p = (Get52ResponsePacket)packets[270]; + Get52ResponsePacket p = (Get52ResponsePacket) packets[270]; Assert.assertEquals(24, p.getAirTemperature()); Assert.assertEquals(24, p.getTargetTemperature()); Assert.assertEquals(FanSpeed.SPEED_3, p.getFanSpeed()); @@ -106,7 +107,7 @@ public void parsePackets() throws Exception { } { // 333 = {Get52ResponsePacket@2093} "0x20->0x84 tgtTemp:25;roomTemp:23;airTemp:24;fan:SPEED_1;on:1 auto:0 defrost:0 mode:HEAT;air2Temp:24" - Get52ResponsePacket p = (Get52ResponsePacket)packets[333]; + Get52ResponsePacket p = (Get52ResponsePacket) packets[333]; Assert.assertEquals(25, p.getTargetTemperature()); Assert.assertEquals(24, p.getAirTemperature()); Assert.assertEquals(24, p.getAir2Temperature()); @@ -118,7 +119,7 @@ public void parsePackets() throws Exception { } { // 513 = {Get52ResponsePacket@2094} "0x20->0x84 tgtTemp:25;roomTemp:22;airTemp:22;fan:SPEED_1;on:0 auto:0 defrost:0 mode:HEAT;air2Temp:22" - Get52ResponsePacket p = (Get52ResponsePacket)packets[513]; + Get52ResponsePacket p = (Get52ResponsePacket) packets[513]; Assert.assertEquals(22, p.getAirTemperature()); Assert.assertEquals(25, p.getTargetTemperature()); Assert.assertEquals(FanSpeed.SPEED_1, p.getFanSpeed()); @@ -128,37 +129,37 @@ public void parsePackets() throws Exception { } { // 321 = {Get53ResponsePacket@2095} "0x20->0x84 ;;;;sleep:0;;;mode:HEAT;" - Get53ResponsePacket p = (Get53ResponsePacket)packets[321]; + Get53ResponsePacket p = (Get53ResponsePacket) packets[321]; Assert.assertEquals(OperatingMode.HEAT, p.getMode()); Assert.assertFalse(p.isSleepMode()); } { // 390 = {Get53ResponsePacket@2096} "0x20->0x84 ;;;;sleep:1;;;mode:HEAT;" - Get53ResponsePacket p = (Get53ResponsePacket)packets[390]; + Get53ResponsePacket p = (Get53ResponsePacket) packets[390]; Assert.assertEquals(OperatingMode.HEAT, p.getMode()); Assert.assertTrue(p.isSleepMode()); } { // 393 = {Get54ResponsePacket@2097} "0x20->0x84 ;quite:0 bladePos:1" - Get54ResponsePacket p = (Get54ResponsePacket)packets[393]; + Get54ResponsePacket p = (Get54ResponsePacket) packets[393]; Assert.assertFalse(p.isQuite()); Assert.assertEquals(1, p.getBladePosition()); } { // 357 = {Get54ResponsePacket@2098} "0x20->0x84 ;quite:1 bladePos:1" - Get54ResponsePacket p = (Get54ResponsePacket)packets[357]; + Get54ResponsePacket p = (Get54ResponsePacket) packets[357]; Assert.assertTrue(p.isQuite()); Assert.assertEquals(1, p.getBladePosition()); } { // 324 = {Get54ResponsePacket@2742} "0x20->0x84 ;quite:0 bladePos:2" - Get54ResponsePacket p = (Get54ResponsePacket)packets[324]; + Get54ResponsePacket p = (Get54ResponsePacket) packets[324]; Assert.assertFalse(p.isQuite()); Assert.assertEquals(2, p.getBladePosition()); } { // 348 = {SetPacketResponse@2099} "0x20->0x84 sleep:0;;temp:25 fan:SPEED_1;mode:HEAT;on:1;;quite:1;" - SetPacketResponse p = (SetPacketResponse)packets[348]; + SetPacketResponse p = (SetPacketResponse) packets[348]; Assert.assertFalse(p.isSleep()); Assert.assertEquals(25, p.getTargetTemperature()); Assert.assertEquals(FanSpeed.SPEED_1, p.getFanSpeed()); @@ -168,21 +169,33 @@ public void parsePackets() throws Exception { } { // 387 = {SetPacketResponse@2100} "0x20->0x84 sleep:1;;temp:25 fan:SPEED_1;mode:HEAT;on:1;;quite:0;" - SetPacketResponse p = (SetPacketResponse)packets[387]; + SetPacketResponse p = (SetPacketResponse) packets[387]; Assert.assertTrue(p.isSleep()); Assert.assertFalse(p.isQuite()); } { // 378 = {Get64ResponsePacket@2793} "0x20->0x84 ;;unitTemp:22.80" - Get64ResponsePacket p = (Get64ResponsePacket)packets[378]; + Get64ResponsePacket p = (Get64ResponsePacket) packets[378]; Assert.assertEquals(22.80, p.getUnitTemperature(), 0.001); } { // 27 = {Get64ResponsePacket@2132} "0x20->0x84 ;;unitTemp:25.60" - Get64ResponsePacket p = (Get64ResponsePacket)packets[27]; + Get64ResponsePacket p = (Get64ResponsePacket) packets[27]; Assert.assertEquals(25.60, p.getUnitTemperature(), 0.001); } pr.stop(); } } -} + + @Test + public void parseLowTemperaturePacket() throws Exception { + { + Get52ResponsePacket p = (Get52ResponsePacket) PacketFactory.Deserialize(new PacketData(new int[]{50, 32, 132, 82, 78, 80, 64, 253, 130, 12, 0, 64, 155, 52}, 100)); + Assert.assertEquals("0x20->0x84 tgtTemp:23;roomTemp:25;airTemp:9;fan:SPEED_3;on:1 auto:0 defrost:0 mode:COOL;air2Temp:9", p.toString()); + } + { + Get52ResponsePacket p = (Get52ResponsePacket) PacketFactory.Deserialize(new PacketData(new int[]{50, 32, 132, 82, 78, 79, 63, 253, 130, 12, 0, 63, 132, 52}, 100)); + Assert.assertEquals("0x20->0x84 tgtTemp:23;roomTemp:24;airTemp:8;fan:SPEED_3;on:1 auto:0 defrost:0 mode:COOL;air2Temp:8", p.toString()); + } + } +} \ No newline at end of file