forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[miio] Improve Yeelight Color channel (openhab#7431)
* [miio] Improve Yeelight Color channel * fix yeelight delay channel * allow better control for Color item * Allow for google home support without rules * make yeelight dimmer more intuitive https://community.openhab.org/t/xiaomi-robot-vacuum-binding/31317/1418 Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com> Signed-off-by: Daan Meijer <daan@studioseptember.nl>
- Loading branch information
1 parent
54f1350
commit 3441b75
Showing
5 changed files
with
138 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...hab.binding.miio/src/test/java/org/openhab/binding/miio/internal/ActionConditionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Copyright (c) 2010-2020 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.miio.internal; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.junit.Test; | ||
import org.openhab.binding.miio.internal.basic.ActionConditions; | ||
import org.openhab.binding.miio.internal.basic.MiIoDeviceActionCondition; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonPrimitive; | ||
|
||
/** | ||
* Test case for {@link ActionConditions} | ||
* | ||
* @author Marcel Verpaalen - Initial contribution | ||
* | ||
*/ | ||
@NonNullByDefault | ||
public class ActionConditionTest { | ||
|
||
@Test | ||
public void assertBrightnessExisting() { | ||
MiIoDeviceActionCondition condition = new MiIoDeviceActionCondition(); | ||
condition.setName("BrightnessExisting"); | ||
Map<String, Object> deviceVariables = Collections.emptyMap(); | ||
JsonElement value = new JsonPrimitive(1); | ||
JsonElement resp = ActionConditions.executeAction(condition, deviceVariables, value, null); | ||
// dimmed to 1 | ||
assertNotNull(resp); | ||
assertEquals(new JsonPrimitive(1), resp); | ||
|
||
// fully on | ||
value = new JsonPrimitive(100); | ||
resp = ActionConditions.executeAction(condition, deviceVariables, value, null); | ||
assertNotNull(resp); | ||
assertEquals(new JsonPrimitive(100), resp); | ||
|
||
// >100 | ||
value = new JsonPrimitive(200); | ||
resp = ActionConditions.executeAction(condition, deviceVariables, value, null); | ||
assertNotNull(resp); | ||
assertEquals(new JsonPrimitive(100), resp); | ||
|
||
// switched off = invalid brightness | ||
value = new JsonPrimitive(0); | ||
resp = ActionConditions.executeAction(condition, deviceVariables, value, null); | ||
assertNull(resp); | ||
assertNotEquals(new JsonPrimitive(0), resp); | ||
|
||
value = new JsonPrimitive(-1); | ||
resp = ActionConditions.executeAction(condition, deviceVariables, value, null); | ||
assertNull(resp); | ||
assertNotEquals(new JsonPrimitive(-1), resp); | ||
} | ||
} |