[Konnected] Taking configured onValue into account when sending status to actuator (#13360)
* Taking configured onvalue into account when sending status to actuator * Added documentation for onValue configuration Signed-off-by: Haavar Valeur <haavar@haavar.com>
This commit is contained in:
parent
ce6b0a876d
commit
9c534e37a8
|
@ -48,6 +48,11 @@ You will need to add channels for the zones that you have connected and configur
|
||||||
You will need to configure each channel with the appropriate zone number corresponding to the zone on The Konnected Alarm Panel.
|
You will need to configure each channel with the appropriate zone number corresponding to the zone on The Konnected Alarm Panel.
|
||||||
Then you need to link the corresponding item to the channel.
|
Then you need to link the corresponding item to the channel.
|
||||||
|
|
||||||
|
Switches and actuators can be configured as high or low level triggered.
|
||||||
|
This is done though setting the parameter onValue to 1 for high level trigger or 0 for low level trigger.
|
||||||
|
The default setting is high level triggered (1).
|
||||||
|
It may for example be useful to set channel to low level trigger when using a low level trigger relay board, to avoid inverting the switch logic.
|
||||||
|
|
||||||
For the actuator type channels you can also add configuration parameters times, pause and momentary which will be added to the payload that is sent to the Konnected Alarm Panel.
|
For the actuator type channels you can also add configuration parameters times, pause and momentary which will be added to the payload that is sent to the Konnected Alarm Panel.
|
||||||
These parameters will tell the module to pulse the actuator for certain time period.
|
These parameters will tell the module to pulse the actuator for certain time period.
|
||||||
A momentary switch actuates a switch for a specified time (in milliseconds) and then reverts it back to the off state.
|
A momentary switch actuates a switch for a specified time (in milliseconds) and then reverts it back to the off state.
|
||||||
|
|
|
@ -92,10 +92,7 @@ public class KonnectedHandler extends BaseThingHandler {
|
||||||
if (channelType.contains(CHANNEL_SWITCH)) {
|
if (channelType.contains(CHANNEL_SWITCH)) {
|
||||||
logger.debug("A command was sent to a sensor type so we are ignoring the command");
|
logger.debug("A command was sent to a sensor type so we are ignoring the command");
|
||||||
} else {
|
} else {
|
||||||
int sendCommand = (OnOffType.OFF.compareTo((OnOffType) command));
|
sendActuatorCommand((OnOffType) command, zone, channelUID);
|
||||||
logger.debug("The command being sent to zone {} for channel:{} is {}", zone, channelUID.getAsString(),
|
|
||||||
sendCommand);
|
|
||||||
sendActuatorCommand(sendCommand, zone, channelUID);
|
|
||||||
}
|
}
|
||||||
} else if (command instanceof RefreshType) {
|
} else if (command instanceof RefreshType) {
|
||||||
// check to see if handler has been initialized before attempting to get state of pin, else wait one minute
|
// check to see if handler has been initialized before attempting to get state of pin, else wait one minute
|
||||||
|
@ -404,10 +401,10 @@ public class KonnectedHandler extends BaseThingHandler {
|
||||||
/**
|
/**
|
||||||
* Sends a command to the module via {@link KonnectedHTTPUtils}
|
* Sends a command to the module via {@link KonnectedHTTPUtils}
|
||||||
*
|
*
|
||||||
* @param scommand the string command, either 0 or 1 to send to the actutor pin on the Konnected module
|
* @param command the state to send to the actuator
|
||||||
* @param zone the zone to send the command to on the Konnected Module
|
* @param zone the zone to send the command to on the Konnected Module
|
||||||
*/
|
*/
|
||||||
private void sendActuatorCommand(Integer scommand, String zone, ChannelUID channelId) {
|
private void sendActuatorCommand(OnOffType command, String zone, ChannelUID channelId) {
|
||||||
try {
|
try {
|
||||||
Channel channel = getThing().getChannel(channelId.getId());
|
Channel channel = getThing().getChannel(channelId.getId());
|
||||||
if (channel != null) {
|
if (channel != null) {
|
||||||
|
@ -415,23 +412,17 @@ public class KonnectedHandler extends BaseThingHandler {
|
||||||
channelId.getId(), channelId.getGroupId(), channelId);
|
channelId.getId(), channelId.getGroupId(), channelId);
|
||||||
ZoneConfiguration zoneConfig = channel.getConfiguration().as(ZoneConfiguration.class);
|
ZoneConfiguration zoneConfig = channel.getConfiguration().as(ZoneConfiguration.class);
|
||||||
KonnectedModuleGson payload = new KonnectedModuleGson();
|
KonnectedModuleGson payload = new KonnectedModuleGson();
|
||||||
payload.setState(scommand);
|
|
||||||
|
|
||||||
payload.setZone(thingID, zone);
|
payload.setZone(thingID, zone);
|
||||||
|
|
||||||
// check to see if this is an On Command type, if so add the momentary, pause, times to the payload if
|
if (command == OnOffType.ON) {
|
||||||
// they exist on the configuration.
|
payload.setState(zoneConfig.onValue);
|
||||||
if (scommand == zoneConfig.onValue) {
|
|
||||||
payload.setTimes(zoneConfig.times);
|
payload.setTimes(zoneConfig.times);
|
||||||
logger.debug("The times configuration was set to: {} for channelID: {}.", zoneConfig.times,
|
|
||||||
channelId);
|
|
||||||
payload.setMomentary(zoneConfig.momentary);
|
payload.setMomentary(zoneConfig.momentary);
|
||||||
logger.debug("The momentary configuration set to: {} channelID: {}.", zoneConfig.momentary,
|
|
||||||
channelId);
|
|
||||||
payload.setPause(zoneConfig.pause);
|
payload.setPause(zoneConfig.pause);
|
||||||
logger.debug("The pause configuration was set to: {} for channelID: {}.", zoneConfig.pause,
|
} else {
|
||||||
channelId);
|
payload.setState(zoneConfig.onValue == 1 ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String payloadString = gson.toJson(payload);
|
String payloadString = gson.toJson(payload);
|
||||||
logger.debug("The command payload is: {}", payloadString);
|
logger.debug("The command payload is: {}", payloadString);
|
||||||
String path = "";
|
String path = "";
|
||||||
|
|
Loading…
Reference in New Issue