mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[netatmo] Switching siren channel of the Presence to Read-Only (#17397)
* Switching siren channel of the Presence to Read-Only Signed-off-by: Gaël L'hopital <gael@lhopital.org> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
5bed85b447
commit
02dec79d82
@ -568,7 +568,7 @@ Warnings:
|
||||
| signal | strength | Number | Read-only | Signal strength (0 for no signal, 1 for weak...) |
|
||||
| signal | value | Number:Power | Read-only | Signal strength in dBm |
|
||||
| presence | floodlight | String | Read-write | Sets the floodlight to ON/OFF/AUTO |
|
||||
| presence | siren | Switch | Read-write | Status of the siren, if silent or emitting an alarm |
|
||||
| presence | siren | Switch | Read-only | Status of the siren, if silent or emitting an alarm |
|
||||
| last-event | type | String | Read-only | Type of event |
|
||||
| last-event | subtype | String | Read-only | Sub-type of event |
|
||||
| last-event | time | DateTime | Read-only | Time of occurrence of event |
|
||||
|
@ -25,7 +25,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.FeatureArea;
|
||||
import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.FloodLightMode;
|
||||
import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.SirenStatus;
|
||||
import org.openhab.binding.netatmo.internal.api.dto.Home;
|
||||
import org.openhab.binding.netatmo.internal.api.dto.HomeEvent;
|
||||
import org.openhab.binding.netatmo.internal.api.dto.HomeEvent.NAEventsDataResponse;
|
||||
@ -127,12 +126,6 @@ public class SecurityApi extends RestManager {
|
||||
post(uriBuilder, ApiResponse.Ok.class, payload);
|
||||
}
|
||||
|
||||
public void changeSirenStatus(String homeId, String moduleId, SirenStatus status) throws NetatmoException {
|
||||
UriBuilder uriBuilder = getApiUriBuilder(PATH_STATE);
|
||||
String payload = PAYLOAD_SIREN_PRESENCE.formatted(homeId, moduleId, status.name().toLowerCase());
|
||||
post(uriBuilder, ApiResponse.Ok.class, payload);
|
||||
}
|
||||
|
||||
public void setPersonAwayStatus(String homeId, String personId, boolean away) throws NetatmoException {
|
||||
UriBuilder uriBuilder = getApiUriBuilder(away ? SUB_PATH_PERSON_AWAY : SUB_PATH_PERSON_HOME);
|
||||
String payload = String.format(away ? PAYLOAD_PERSON_AWAY : PAYLOAD_PERSON_HOME, homeId, personId);
|
||||
|
@ -96,7 +96,7 @@ public enum ModuleType {
|
||||
Set.of(ChannelHelperCapability.class, ParentUpdateCapability.class), ChannelGroup.SIGNAL,
|
||||
ChannelGroup.BATTERY, ChannelGroup.TIMESTAMP, new ChannelGroup(SirenChannelHelper.class, GROUP_SIREN)),
|
||||
|
||||
PRESENCE(FeatureArea.SECURITY, "NOC", 1, "camera", HOME,
|
||||
PRESENCE(FeatureArea.SECURITY, "NOC", 2, "camera", HOME,
|
||||
Set.of(PresenceCapability.class, ChannelHelperCapability.class, ParentUpdateCapability.class),
|
||||
ChannelGroup.SIGNAL, ChannelGroup.EVENT,
|
||||
new ChannelGroup(PresenceChannelHelper.class, GROUP_SECURITY_EVENT, GROUP_CAM_STATUS, GROUP_CAM_LIVE,
|
||||
|
@ -18,7 +18,6 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.FloodLightMode;
|
||||
import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.SirenStatus;
|
||||
import org.openhab.binding.netatmo.internal.handler.CommonInterface;
|
||||
import org.openhab.binding.netatmo.internal.handler.channelhelper.ChannelHelper;
|
||||
import org.openhab.binding.netatmo.internal.providers.NetatmoDescriptionProvider;
|
||||
@ -53,13 +52,12 @@ public class PresenceCapability extends CameraCapability {
|
||||
try {
|
||||
changeFloodlightMode(FloodLightMode.valueOf(command.toString()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.info("Incorrect command '{}' received for channel '{}'", command, channelName);
|
||||
logger.warn("Incorrect command '{}' received for channel '{}'", command, channelName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (CHANNEL_SIREN.equals(channelName) && command instanceof OnOffType) {
|
||||
getSecurityCapability().ifPresent(cap -> cap.changeSirenStatus(handler.getId(),
|
||||
command == OnOffType.ON ? SirenStatus.SOUND : SirenStatus.NO_SOUND));
|
||||
} else if (CHANNEL_SIREN.equals(channelName)) {
|
||||
logger.info("Channel '{}' is read-only", channelName);
|
||||
return;
|
||||
}
|
||||
super.handleCommand(channelName, command);
|
||||
|
@ -26,7 +26,6 @@ import org.openhab.binding.netatmo.internal.api.NetatmoException;
|
||||
import org.openhab.binding.netatmo.internal.api.SecurityApi;
|
||||
import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.FeatureArea;
|
||||
import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.FloodLightMode;
|
||||
import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.SirenStatus;
|
||||
import org.openhab.binding.netatmo.internal.api.dto.HomeData;
|
||||
import org.openhab.binding.netatmo.internal.api.dto.HomeDataModule;
|
||||
import org.openhab.binding.netatmo.internal.api.dto.HomeDataPerson;
|
||||
@ -237,15 +236,4 @@ class SecurityCapability extends RestCapability<SecurityApi> {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void changeSirenStatus(String moduleId, SirenStatus status) {
|
||||
getApi().ifPresent(api -> {
|
||||
try {
|
||||
api.changeSirenStatus(handler.getId(), moduleId, status);
|
||||
handler.expireData();
|
||||
} catch (NetatmoException e) {
|
||||
logger.warn("Error changing siren status '{}' : {}", status, e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -225,7 +225,7 @@
|
||||
<channel-group-type id="presence">
|
||||
<label>Presence Camera</label>
|
||||
<channels>
|
||||
<channel id="siren" typeId="siren-status-rw"/>
|
||||
<channel id="siren" typeId="siren-status"/>
|
||||
<channel id="floodlight" typeId="floodlight-mode"/>
|
||||
</channels>
|
||||
</channel-group-type>
|
||||
|
@ -14,6 +14,12 @@
|
||||
</update-channel>
|
||||
</instruction-set>
|
||||
|
||||
<instruction-set targetVersion="2">
|
||||
<update-channel id="siren" groupIds="presence">
|
||||
<type>netatmo:siren-status</type>
|
||||
</update-channel>
|
||||
</instruction-set>
|
||||
|
||||
</thing-type>
|
||||
|
||||
</update:update-descriptions>
|
||||
|
Loading…
Reference in New Issue
Block a user