修改风扇设置
This commit is contained in:
parent
3ad5a7da6c
commit
8aad063e68
@ -14,6 +14,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -167,7 +168,7 @@ public class TuyaDeviceService {
|
||||
if (type.equalsIgnoreCase("boolean")) {
|
||||
jsonObject.put("value", Boolean.parseBoolean(data.getValue()));
|
||||
} else if (type.equalsIgnoreCase("Integer")) {
|
||||
jsonObject.put("value", Integer.parseInt(query.getValue()));
|
||||
jsonObject.put("value", Integer.parseInt(data.getValue()));
|
||||
} else if (type.equalsIgnoreCase("Enum")) {
|
||||
jsonObject.put("value", data.getValue());
|
||||
} else if (type.equalsIgnoreCase("auto_add_integer")) {
|
||||
@ -198,14 +199,18 @@ public class TuyaDeviceService {
|
||||
return Mono.just(tuyaResponse);
|
||||
}
|
||||
javaList.add(jsonObject);
|
||||
List<JSONObject> collect = javaList.stream().filter(jl -> !ObjectUtils.isEmpty(jl.get("value")))
|
||||
Set<JSONObject> collect = javaList.stream().filter(jl -> !ObjectUtils.isEmpty(jl.get("value")))
|
||||
.filter(jl -> !jl.getString("value").startsWith("{"))
|
||||
.filter(jl -> !jl.getString("value").startsWith("[")).collect(Collectors.toList());
|
||||
.filter(jl -> !jl.getString("value").startsWith("[")).collect(Collectors.toSet());
|
||||
if (Objects.equals(deviceInfo.getString("category"), "fs")) {
|
||||
JSONObject fsJson = new JSONObject();
|
||||
fsJson.put("code", "switch");
|
||||
fsJson.put("value", true);
|
||||
collect.add(fsJson);
|
||||
collect.clear();
|
||||
collect.add(jsonObject);
|
||||
if (!Objects.equals(data.getMatchingFields(), "关")) {
|
||||
JSONObject fsJson = new JSONObject();
|
||||
fsJson.put("code", "switch");
|
||||
fsJson.put("value", true);
|
||||
collect.add(fsJson);
|
||||
}
|
||||
}
|
||||
commands.put("commands", categoryBoolean ? Arrays.asList(jsonObject) : collect);
|
||||
Boolean result = tuyaDeviceConnector.controlDevice(query.getDeviceId(), commands);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user