Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[shelly] Various small fixes for BLU HT, Range Extender, Plus 10V, TRV set temp #16746

Merged
merged 4 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ ShellyDeviceProfile getDeviceProfile(String thingType, @Nullable ShellySettingsD

void setValveMode(int id, boolean auto) throws ShellyApiException;

void setValveTemperature(int valveId, int value) throws ShellyApiException;
void setValveTemperature(int valveId, double value) throws ShellyApiException;

void setValveProfile(int valveId, int value) throws ShellyApiException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public void setSleepTime(int value) throws ShellyApiException {
}

@Override
public void setValveTemperature(int valveId, int value) throws ShellyApiException {
public void setValveTemperature(int valveId, double value) throws ShellyApiException {
httpRequest("/thermostat/" + valveId + "?target_t_enabled=1&target_t=" + value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ public void setValvePosition(int valveId, double value) throws ShellyApiExceptio
}

@Override
public void setValveTemperature(int valveId, int value) throws ShellyApiException {
public void setValveTemperature(int valveId, double value) throws ShellyApiException {
throw new ShellyApiException("API call not implemented");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class ShellyThingCreator {
public static final String SHELLYDT_PLUSSMOKE = "SNSN-0031Z";
public static final String SHELLYDT_PLUSUNI = "SNSN-0043X";
public static final String SHELLYDT_PLUSDIMMERUS = "SNDM-0013US";
public static final String SHELLYDT_PLUSDIMMER10V = "SNGW-0A11WW010";
public static final String SHELLYDT_PLUSDIMMER10V = "SNDM-00100WW";
public static final String SHELLYDT_PLUSWALLDISPLAY = "SAWD-0A1XX10EU1";

// Shelly Pro Series
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.openhab.binding.shelly.internal.api1.Shelly1CoapJSonDTO;
import org.openhab.binding.shelly.internal.api1.Shelly1CoapServer;
import org.openhab.binding.shelly.internal.api1.Shelly1HttpApi;
import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO;
import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2APClientList.Shelly2APClient;
import org.openhab.binding.shelly.internal.api2.Shelly2ApiRpc;
import org.openhab.binding.shelly.internal.api2.ShellyBluApi;
Expand Down Expand Up @@ -463,7 +464,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
break;
case CHANNEL_CONTROL_SETTEMP:
logger.debug("{}: Set temperature to {}", thingName, command);
api.setValveTemperature(0, getNumber(command).intValue());
api.setValveTemperature(0, getNumber(command).doubleValue());
break;
case CHANNEL_CONTROL_POSITION:
logger.debug("{}: Set position to {}", thingName, command);
Expand Down Expand Up @@ -821,6 +822,10 @@ public void postEvent(String event, boolean force) {
case SHELLY_WAKEUPT_POWERON:
case SHELLY_WAKEUPT_EXT_POWER:
case SHELLY_WAKEUPT_UNKNOWN:
case Shelly2ApiJsonDTO.SHELLY2_EVENT_OTASTART:
case Shelly2ApiJsonDTO.SHELLY2_EVENT_OTAPROGRESS:
case Shelly2ApiJsonDTO.SHELLY2_EVENT_OTADONE:
case SHELLY_EVENT_ROLLER_CALIB:
logger.debug("{}: {}", thingName, messages.get("event.filtered", event));
case ALARM_TYPE_NONE:
break;
Expand Down Expand Up @@ -1003,7 +1008,7 @@ protected boolean initializeThingConfig() {
String saddr = addr.getHostAddress();
if (!ip.equals(saddr)) {
logger.debug("{}: hostname {} resolved to IP address {}", thingName, config.deviceIp, saddr);
config.deviceIp = saddr + (port.isEmpty() ? ip : ip + ":" + port);
config.deviceIp = saddr + (port.isEmpty() ? "" : ":" + port);
}
} catch (UnknownHostException e) {
logger.debug("{}: Unable to resolve hostname {}", thingName, config.deviceIp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private void createRelayChannels(ShellySettingsRelay relay, int idx) {

private void createRollerChannels(ShellyRollerStatus roller) {
if (!areChannelsCreated()) {
updateChannelDefinitions(ShellyChannelDefinitions.createRollerChannels(getThing(), roller));
updateChannelDefinitions(ShellyChannelDefinitions.createRollerChannels(getThing(), profile, roller));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ public static Map<String, Channel> createRelayChannels(final Thing thing, final
addChannel(thing, add, rs.autoOff != null, group, CHANNEL_TIMER_AUTOOFF);
}

addAddonChannels(thing, profile, idx, add);

return add;
}

private static void addAddonChannels(final Thing thing, final ShellyDeviceProfile profile, int idx,
Map<String, Channel> add) {
// Shelly 1/1PM and Plus 1/1PM Addon
boolean addon = profile.settings.extSwitch != null && profile.settings.extSwitch.input0 != null
&& idx == getInteger(profile.settings.extSwitch.input0.relayNum);
Expand All @@ -385,11 +392,10 @@ public static Map<String, Channel> createRelayChannels(final Thing thing, final
}
addChannel(thing, add, profile.status.extHumidity != null && profile.status.extHumidity.sensor1 != null,
CHGR_SENSOR, CHANNEL_ESENSOR_HUMIDITY);

addChannel(thing, add, profile.status.extVoltage != null, CHGR_SENSOR, CHANNEL_ESENSOR_VOLTAGE);
addChannel(thing, add, profile.status.extDigitalInput != null, CHGR_SENSOR, CHANNEL_ESENSOR_DIGITALINPUT);
addChannel(thing, add, profile.status.extAnalogInput != null, CHGR_SENSOR, CHANNEL_ESENSOR_ANALOGINPUT);

return add;
}

public static Map<String, Channel> createDimmerChannels(final Thing thing, final ShellyDeviceProfile profile,
Expand Down Expand Up @@ -458,7 +464,8 @@ public static Map<String, Channel> createInputChannels(final Thing thing, final
return add;
}

public static Map<String, Channel> createRollerChannels(Thing thing, final ShellyRollerStatus roller) {
public static Map<String, Channel> createRollerChannels(final Thing thing, final ShellyDeviceProfile profile,
final ShellyRollerStatus roller) {
Map<String, Channel> add = new LinkedHashMap<>();
addChannel(thing, add, true, CHGR_ROLLER, CHANNEL_ROL_CONTROL_CONTROL);
addChannel(thing, add, true, CHGR_ROLLER, CHANNEL_ROL_CONTROL_STATE);
Expand All @@ -474,6 +481,9 @@ public static Map<String, Channel> createRollerChannels(Thing thing, final Shell
addChannel(thing, add, roller.currentPos != null, CHGR_ROLLER, CHANNEL_ROL_CONTROL_FAV);
}
}

addAddonChannels(thing, profile, 0, add);

return add;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parameter name="enableRangeExtender" type="boolean" required="false">
<label>@text/thing-type.config.shelly.enableRangeExtender.label</label>
<description>@text/thing-type.config.shelly.enableRangeExtender.description</description>
<default>true</default>
<default>false</default>
</parameter>
</config-description>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This script uses the BLE scan functionality in scripting to pass scan results to openHAB
* Supported BLU Devices: BLU Button 1, BLU Door/Window, BLU Motion, BLU H&T
* Version 0.3
* Version 0.4
*/

let ALLTERCO_DEVICE_NAME_PREFIX = ["SBBT", "SBDW", "SBMO", "SBHT"];
Expand Down Expand Up @@ -33,15 +33,17 @@ BTH[0x05] = { n: "Illuminance", t: uint24, f: 0.01 };
BTH[0x08] = { n: "Dewpoint", t: int16, f: 0.01 };
BTH[0x12] = { n: "Co2", t: uint16 };
BTH[0x14] = { n: "Moisture16", t: uint16, f: 0.01 };
BTH[0x14] = { n: "Moisture8", t: uint8 };
BTH[0x1a] = { n: "Door", t: uint8 };
BTH[0x20] = { n: "Moisture", t: uint8 };
BTH[0x21] = { n: "Motion", t: uint8 };
BTH[0x2d] = { n: "Window", t: uint8 };
BTH[0x2e] = { n: "Humidity", t: uint8 };
BTH[0x2f] = { n: "Moisture8", t: uint8 };
BTH[0x3a] = { n: "Button", t: uint8 };
BTH[0x3f] = { n: "Rotation", t: int16, f: 0.1 };
BTH[0x43] = { n: "Current", t: uint16, f: 0.1 };
BTH[0x43] = { n: "UVIndex", t: uint8 };
BTH[0x45] = { n: "Temperature", t: int16, f: 0.1 };
BTH[0x46] = { n: "UVIndex", t: uint8 };
BTH[0x51] = { n: "Acceleration", t: uint16, f: 0.1 };

function getByteSize(type) {
Expand Down