Skip to content

Commit

Permalink
[hdpowerview] add type 38 shade to database (openhab#12761)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
  • Loading branch information
andrewfg authored and octa22 committed May 18, 2022
1 parent a97c536 commit 744095a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class ShadeCapabilitiesDatabase {
new Type( 9).capabilities(7).text("Duette DuoLite Top Down Bottom Up"),
new Type(18).capabilities(1).text("Silhouette"),
new Type(23).capabilities(1).text("Silhouette"),
new Type(38).capabilities(9).text("Silhouette Duolite"),
new Type(42).capabilities(0).text("M25T Roller Blind"),
new Type(43).capabilities(1).text("Facette"),
new Type(44).capabilities(0).text("Twist"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ private void updateAllStatuses() {
private void updateDeviceStatus(@Nullable OrbitBhyveDevice device, @Nullable OrbitBhyveSprinklerHandler handler) {
if (device != null && handler != null) {
handler.setDeviceOnline(device.isConnected());
handler.updateDeviceStatus(device.getStatus());
handler.updateDeviceStatus(device);
handler.updateSmartWatering(device.getWaterSenseMode());
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.openhab.binding.orbitbhyve.internal.model.OrbitBhyveDevice;
import org.openhab.binding.orbitbhyve.internal.model.OrbitBhyveDeviceStatus;
import org.openhab.binding.orbitbhyve.internal.model.OrbitBhyveProgram;
import org.openhab.binding.orbitbhyve.internal.model.OrbitBhyveWateringStatus;
import org.openhab.binding.orbitbhyve.internal.model.OrbitBhyveZone;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.DecimalType;
Expand Down Expand Up @@ -157,7 +158,7 @@ private synchronized void doInit() {
if (device != null) {
setDeviceOnline(device.isConnected());
createChannels(device.getZones());
updateDeviceStatus(device.getStatus());
updateDeviceStatus(device);
}
List<OrbitBhyveProgram> programs = handler.getPrograms();
for (OrbitBhyveProgram program : programs) {
Expand Down Expand Up @@ -187,7 +188,8 @@ private synchronized void cacheProgram(OrbitBhyveProgram program) {
}
}

public void updateDeviceStatus(OrbitBhyveDeviceStatus status) {
public void updateDeviceStatus(OrbitBhyveDevice device) {
OrbitBhyveDeviceStatus status = device.getStatus();
if (!status.getMode().isEmpty()) {
updateState(CHANNEL_MODE, new StringType(status.getMode()));
updateState(CHANNEL_CONTROL, "off".equals(status.getMode()) ? OnOffType.OFF : OnOffType.ON);
Expand All @@ -197,9 +199,42 @@ public void updateDeviceStatus(OrbitBhyveDeviceStatus status) {
updateState(CHANNEL_NEXT_START, dt);
logger.debug("Next start time: {}", status.getNextStartTime());
}

OrbitBhyveWateringStatus wateringStatus = status.getWateringStatus();
if (wateringStatus != null) {
if (wateringStatus.getProgram() != null) {
updateProgramWatering(wateringStatus.getProgram(), OnOffType.ON);
}
if (!wateringStatus.getCurrentStation().isEmpty()) {
updateZoneWatering(status.getWateringStatus().getCurrentStation(), OnOffType.ON);
}
} else {
for (int zone = 1; zone <= device.getZones().size(); zone++) {
updateZoneWatering(String.valueOf(zone), OnOffType.OFF);
}
for (String program : programs.keySet()) {
updateProgramWatering(program, OnOffType.OFF);
}
}
updateState(CHANNEL_RAIN_DELAY, new DecimalType(status.getDelay()));
}

private void updateProgramWatering(@Nullable String program, OnOffType state) {
if (program != null) {
Channel ch = thing.getChannel("enable_program_" + program);
if (ch != null) {
updateState(ch.getUID(), state);
}
}
}

private void updateZoneWatering(String zone, OnOffType state) {
Channel ch = thing.getChannel("zone_" + zone);
if (ch != null) {
updateState(ch.getUID(), state);
}
}

private void createProgram(OrbitBhyveProgram program) {
String channelName = "program_" + program.getProgram();
if (thing.getChannel(channelName) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.openhab.binding.orbitbhyve.internal.model;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

import com.google.gson.annotations.SerializedName;

Expand All @@ -36,6 +37,10 @@ public class OrbitBhyveDeviceStatus {
@SerializedName("rain_delay_started_at")
String rainDelayStartedAt = "";

@SerializedName("watering_status")
@Nullable
OrbitBhyveWateringStatus wateringStatus = new OrbitBhyveWateringStatus();

public String getMode() {
return mode;
}
Expand All @@ -47,4 +52,8 @@ public String getNextStartTime() {
public int getDelay() {
return delay;
}

public @Nullable OrbitBhyveWateringStatus getWateringStatus() {
return wateringStatus;
}
}

0 comments on commit 744095a

Please sign in to comment.