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] Add channels device#deviceName, relay#outputName + refactoring #8396

Merged
merged 9 commits into from
Sep 12, 2020
24 changes: 8 additions & 16 deletions bundles/org.openhab.binding.shelly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ Depending on the device type and firmware release channels might be not availabl
|----------|-------------|---------|---------|---------------------------------------------------------------------------------|
|relay |output |Switch |r/w |Controls the relay's output channel (on/off) |
| |input |Switch |yes |ON: Input/Button is powered, see General Notes on Channels |
| |channelName |String |yes |Logical name of this channel as configured in the Shelly App ||
| |outputName |String |yes |Logical name of this relay output as configured in the Shelly App |
|sensors |temperature1 |Number |yes |Temperature value of external sensor #1 (if connected to temp/hum addon) |
| |temperature2 |Number |yes |Temperature value of external sensor #2 (if connected to temp/hum addon) |
| |temperature3 |Number |yes |Temperature value of external sensor #3 (if connected to temp/hum addon) |
Expand All @@ -344,7 +344,7 @@ Depending on the device type and firmware release channels might be not availabl
|relay |output |Switch |r/w |Controls the relay's output channel (on/off) |
| |input |Switch |yes |ON: Input/Button is powered, see General Notes on Channels |
| |button |Trigger |yes |Event trigger with payload SHORT_PRESSED or LONG_PRESSED (FW 1.5.6+) |
| |channelName |String |yes |Logical name of this channel as configured in the Shelly App ||
| |outputName |String |yes |Logical name of this relay output as configured in the Shelly App |
|meter |currentWatts |Number |yes |Current power consumption in Watts |
| |lastPower1 |Number |yes |Energy consumption in Watts for a round minute, 1 minute ago |
| |lastPower2 |Number |yes |Energy consumption in Watts for a round minute, 2 minutes ago |
Expand All @@ -363,7 +363,7 @@ Depending on the device type and firmware release channels might be not availabl
|relay |output |Switch |r/w |Controls the relay's output channel (on/off) |
| |input |Switch |yes |ON: Input/Button is powered, see General Notes on Channels |
| |button |Trigger |yes |Event trigger with payload SHORT_PRESSED or LONG_PRESSED (FW 1.5.6+) |
| |channelName |String |yes |Logical name of this channel as configured in the Shelly App ||
| |outputName |String |yes |Logical name of this relay output as configured in the Shelly App |
|meter1 |currentWatts |Number |yes |Current power consumption in Watts |
| |totalKWH |Number |yes |Total energy consumption in Watts since the device powered up (resets on restart)|
| |returnedKWH |Number |yes |Total returned energy, kw/h |
Expand All @@ -387,7 +387,7 @@ The thing id is derived from the service name, so that's the reason why the thin
|relay |output |Switch |r/w |Controls the relay's output channel (on/off) |
| |input |Switch |yes |ON: Input/Button is powered, see General Notes on Channels |
| |button |Trigger |yes |Event trigger with payload SHORT_PRESSED or LONG_PRESSED (FW 1.5.6+) |
| |channelName |String |yes |Logical name of this channel as configured in the Shelly App ||
| |outputName |String |yes |Logical name of this relay output as configured in the Shelly App |
|meter1 |currentWatts |Number |yes |Current power consumption in Watts |
| |totalKWH |Number |yes |Total energy consumption in Watts since the device powered up (resets on restart)|
| |returnedKWH |Number |yes |Total returned energy, kw/h |
Expand Down Expand Up @@ -424,14 +424,14 @@ The thing id is derived from the service name, so that's the reason why the thin
| |autoOff |Number |r/w |Relay #1: Sets a timer to turn the device OFF after every ON command; in seconds|
| |timerActive |Switch |yes |Relay #1: ON: An auto-on/off timer is active |
| |button |Trigger |yes |Event trigger with payload SHORT_PRESSED or LONG_PRESSED (FW 1.5.6+) |
| |channelName |String |yes |Logical name of this channel as configured in the Shelly App ||
| |outputName |String |yes |Logical name of this relay output as configured in the Shelly App |
|relay2 |output |Switch |r/w |Relay #2: Controls the relay's output channel (on/off) |
| |input |Switch |yes |ON: Input/Button is powered, see General Notes on Channels |
| |autoOn |Number |r/w |Relay #2: Sets a timer to turn the device ON after every OFF command; in seconds|
| |autoOff |Number |r/w |Relay #2: Sets a timer to turn the device OFF after every ON command; in seconds|
| |timerActive |Switch |yes |Relay #2: ON: An auto-on/off timer is active |
| |button |Trigger |yes |Event trigger with payload SHORT_PRESSED or LONG_PRESSED (FW 1.5.6+) |
| |channelName |String |yes |Logical name of this channel as configured in the Shelly App ||
| |outputName |String |yes |Logical name of this relay output as configured in the Shelly App |
|meter |currentWatts |Number |yes |Current power consumption in Watts |
| |lastPower1 |Number |yes |Energy consumption in Watts for a round minute, 1 minute ago |
| |totalKWH |Number |yes |Total energy consumption in Watts since the device powered up (resets on restart)|
Expand All @@ -447,7 +447,6 @@ The thing id is derived from the service name, so that's the reason why the thin
| |state |String |yes |Roller state: open/close/stop |
| |stopReason |String |yes |Last stop reasons: normal, safety_switch or obstacle |
| |event |Trigger |yes |Roller event/trigger with payload ROLLER_OPEN / ROLLER_CLOSE / ROLLER_STOP |
| |channelName |String |yes |Logical name of this channel as configured in the Shelly App ||
|meter |currentWatts |Number |yes |Current power consumption in Watts |
| |lastPower1 |Number |yes |Accumulated energy consumption in Watts for the full last minute |
| |totalKWH |Number |yes |Total energy consumption in Watts since the device powered up (reset on restart) |
Expand Down Expand Up @@ -480,7 +479,6 @@ For this the binding aggregates the power consumption of both relays and include
| |state |String |yes |Roller state: open/close/stop |
| |stopReason |String |yes |Last stop reasons: normal, safety_switch or obstacle |
| |event |Trigger |yes |Roller event/trigger with payload ROLLER_OPEN / ROLLER_CLOSE / ROLLER_STOP |
| |channelName |String |yes |Logical name of this channel as configured in the Shelly App ||
|meter | | | |See group meter1 for Shelly 2 |

The roller positioning calibration has to be performed using the Shelly App before the position can be set in percent.
Expand Down Expand Up @@ -517,10 +515,7 @@ The Shelly 4Pro provides 4 relays and 4 power meters.
| |autoOn |Number |r/w |Sets a timer to turn the device ON after every OFF command; in seconds |
| |autoOff |Number |r/w |Sets a timer to turn the device OFF after every ON command; in seconds |
| |button |Trigger |yes |Event trigger with payload SHORT_PRESSED or LONG_PRESSED (FW 1.5.6+) |
| |channelName |String |yes |Logical name of this channel as configured in the Shelly App ||
|status |loaderror |Switch |yes |Last error, "no" if none |
| |overload |Switch |yes |Overload condition detected, switch dimmer off or reduce load! |
| |overtemperature |Switch|yes |Internal device temperature over maximum. Switch off, check physical installation|
| |outputName |String |yes |Logical name of this relay output as configured in the Shelly App |
|meter |currentWatts |Number |yes |Current power consumption in Watts |
| |lastPower1 |Number |yes |Energy consumption in Watts for a round minute, 1 minute ago |
| |lastPower2 |Number |yes |Energy consumption in Watts for a round minute, 2 minutes ago |
Expand All @@ -538,10 +533,7 @@ The Shelly 4Pro provides 4 relays and 4 power meters.
| |autoOn |Number |r/w |Sets a timer to turn the device ON after every OFF command; in seconds |
| |autoOff |Number |r/w |Sets a timer to turn the device OFF after every ON command; in seconds |
| |button |Trigger |yes |Event trigger with payload SHORT_PRESSED or LONG_PRESSED (FW 1.5.6+) |
| |channelName |String |yes |Logical name of this channel as configured in the Shelly App ||
|status |loaderror |Switch |yes |Last error, "no" if none |
| |overload |Switch |yes |Overload condition detected, switch dimmer off or reduce load! |
| |overtemperature |Switch|yes |Internal device temperature over maximum. Switch off, check physical installation|
| |outputName |String |yes |Logical name of this relay output as configured in the Shelly App |
|meter |currentWatts |Number |yes |Current power consumption in Watts |
| |lastPower1 |Number |yes |Energy consumption in Watts for a round minute, 1 minute ago |
| |lastPower2 |Number |yes |Energy consumption in Watts for a round minute, 2 minutes ago |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public class ShellyBindingConstants {

// Relay
public static final String CHANNEL_GROUP_RELAY_CONTROL = "relay";
public static final String CHANNEL_NAME = "channelName";
public static final String CHANNEL_OUTPUT_NAME = "outputName";
public static final String CHANNEL_OUTPUT = "output";
public static final String CHANNEL_INPUT = "input";
public static final String CHANNEL_INPUT1 = "input1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ public ShellyChannelDefinitionsDTO(ShellyTranslationProvider m) {
.add(new ShellyChannel(m, CHGR_DEVST, CHANNEL_DEVST_UPDATE, "updateAvailable", ITEM_TYPE_SWITCH))

// Relay
.add(new ShellyChannel(m, CHGR_RELAY, CHANNEL_NAME, "channelName", ITEM_TYPE_STRING))
.add(new ShellyChannel(m, CHGR_RELAY, CHANNEL_OUTPUT_NAME, "outputName", ITEM_TYPE_STRING))

// Roller
.add(new ShellyChannel(m, CHGR_ROLLER, CHANNEL_NAME, "name", ITEM_TYPE_STRING))
.add(new ShellyChannel(m, CHGR_ROLLER, CHANNEL_ROL_CONTROL_STATE, "rollerState", ITEM_TYPE_STRING))

// RGBW2
Expand Down Expand Up @@ -220,7 +219,7 @@ public static Map<String, Channel> createRelayChannels(final Thing thing, final
String group = profile.getControlGroup(idx);

ShellySettingsRelay rs = profile.settings.relays.get(idx);
addChannel(thing, add, rs.name != null, group, CHANNEL_NAME);
addChannel(thing, add, rs.name != null, group, CHANNEL_OUTPUT_NAME);

// Shelly 1/1PM Addon
if (relay.extTemperature != null) {
Expand All @@ -237,7 +236,6 @@ public static Map<String, Channel> createRelayChannels(final Thing thing, final

public static Map<String, Channel> createRollerChannels(Thing thing, final ShellyControlRoller roller) {
Map<String, Channel> add = new LinkedHashMap<>();
addChannel(thing, add, roller.name != null, CHGR_ROLLER, CHANNEL_NAME);
addChannel(thing, add, roller.state != null, CHGR_ROLLER, CHANNEL_ROL_CONTROL_STATE);
return add;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public boolean updateRelays(ShellySettingsStatus status) throws ShellyApiExcepti
if ((relay.isValid == null) || relay.isValid) {
String groupName = profile.getControlGroup(i);
ShellySettingsRelay rs = profile.settings.relays.get(i);
updated |= updateChannel(groupName, CHANNEL_NAME, getStringType(rs.name));
updated |= updateChannel(groupName, CHANNEL_OUTPUT_NAME, getStringType(rs.name));

if (getBool(relay.overpower)) {
postEvent(ALARM_TYPE_OVERPOWER, false);
Expand Down Expand Up @@ -367,7 +367,7 @@ public boolean updateRelays(ShellySettingsStatus status) throws ShellyApiExcepti
createRollerChannels(control);

if (control.name != null) {
updated |= updateChannel(groupName, CHANNEL_NAME, getStringType(control.name));
updated |= updateChannel(groupName, CHANNEL_OUTPUT_NAME, getStringType(control.name));
}

String state = getString(control.state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ channel-type.shelly.deviceName.label = Device Name
channel-type.shelly.deviceName.description = Symbolic Device Name as configured in the Shelly App.

# Relay, external sensors
channel-type.shelly.channelName.label = Channel Name
channel-type.shelly.channelName.description = Channel Name as configured in the Shelly App.
channel-type.shelly.outputName.label = Output Name
channel-type.shelly.outputName.description = Output/Channel Name as configured in the Shelly App.
channel-type.shelly.temperature1.label = Temperature 1
channel-type.shelly.temperature1.description = Temperature of external Sensor #1
channel-type.shelly.temperature2.label = Temperature 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ thing-type.shelly.shellygas.group.device.description = Informationen zum Ger


# channels
channel-type.shelly.channelName.label = Kanalname
channel-type.shelly.channelName.description = Name des Relais-Kanals (Konfiguriation in der Shelly App)
channel-type.shelly.outputName.label = Ausgangsname
channel-type.shelly.outputName.description = Name des Relais-Ausgangs/Kanals (Konfiguriation innerhalb der Shelly App)
markus7017 marked this conversation as resolved.
Show resolved Hide resolved
channel-type.shelly.timerAutoOn.label = Auto-EIN Timer
channel-type.shelly.timerAutoOn.description = Wenn das Relais ausgeschaltet wird, wird dieses automatisch wieder nach n Sekunden eingeschaltet
channel-type.shelly.timerAutoOff.label = Auto-AUS Timer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@
<description>Temperatures from external sensors connected to the optional Addon</description>
</channel-group-type>

<channel-type id="channelName">
<channel-type id="outputName">
<item-type>String</item-type>
<label>@text/channel-type.shelly.channelName.label</label>
<description>@text/channel-type.shelly.channelName.description</description>
<label>@text/channel-type.shelly.outputName.label</label>
<description>@text/channel-type.shelly.outputName.description</description>
<state readOnly="true">
</state>
</channel-type>
Expand Down