diff --git a/bundles/org.openhab.binding.unifi/README.md b/bundles/org.openhab.binding.unifi/README.md index fb812a2e2..6eeebae1c 100644 --- a/bundles/org.openhab.binding.unifi/README.md +++ b/bundles/org.openhab.binding.unifi/README.md @@ -168,6 +168,8 @@ The `wirelessClient` information that is retrieved is available as these channel | Channel ID | Item Type | Description | Permissions | |------------|----------------------|----------------------------------------------------------------------|-------------| | online | Switch | Online status of the client | Read | +| name | String | Name of device (from the controller web UI) | Read | +| hostname | String | Hostname of device (from the controller web UI) | Read | | site | String | Site name (from the controller web UI) the client is associated with | Read | | macAddress | String | MAC address of the client | Read | | ipAddress | String | IP address of the client | Read | @@ -192,6 +194,8 @@ The `wiredClient` information that is retrieved is available as these channels: | Channel ID | Item Type | Description | Permissions | |------------|----------------------|----------------------------------------------------------------------|-------------| | online | Switch | Online status of the client | Read | +| name | String | Name of device (from the controller web UI) | Read | +| hostname | String | Hostname of device (from the controller web UI) | Read | | site | String | Site name (from the controller web UI) the client is associated with | Read | | macAddress | String | MAC address of the client | Read | | ipAddress | String | IP address of the client | Read | diff --git a/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/UniFiBindingConstants.java b/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/UniFiBindingConstants.java index 7d36ef133..6d92947d5 100644 --- a/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/UniFiBindingConstants.java +++ b/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/UniFiBindingConstants.java @@ -61,6 +61,8 @@ public final class UniFiBindingConstants { // List of common wired + wireless client channels public static final String CHANNEL_ONLINE = "online"; + public static final String CHANNEL_NAME = "name"; + public static final String CHANNEL_HOSTNAME = "hostname"; public static final String CHANNEL_SITE = "site"; public static final String CHANNEL_MAC_ADDRESS = "macAddress"; public static final String CHANNEL_IP_ADDRESS = "ipAddress"; diff --git a/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/cache/UniFiCache.java b/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/cache/UniFiCache.java index 04dc87963..04ba7a3c6 100644 --- a/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/cache/UniFiCache.java +++ b/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/cache/UniFiCache.java @@ -41,7 +41,6 @@ import org.slf4j.LoggerFactory; abstract class UniFiCache { public enum Prefix { - ALIAS, DESC, HOSTNAME, ID, diff --git a/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/cache/UniFiClientCache.java b/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/cache/UniFiClientCache.java index 6db44d40c..3dfc3bc07 100644 --- a/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/cache/UniFiClientCache.java +++ b/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/cache/UniFiClientCache.java @@ -12,11 +12,11 @@ */ package org.openhab.binding.unifi.internal.api.cache; -import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.ALIAS; import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.HOSTNAME; import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.ID; import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.IP; import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.MAC; +import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.NAME; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -27,7 +27,7 @@ import org.openhab.binding.unifi.internal.api.dto.UniFiClient; * {@link UniFiClient} instances. * * The cache uses the following prefixes: mac, ip, hostname, and - * alias + * name * * @author Matthew Bowman - Initial contribution */ @@ -35,7 +35,7 @@ import org.openhab.binding.unifi.internal.api.dto.UniFiClient; class UniFiClientCache extends UniFiCache { public UniFiClientCache() { - super(ID, MAC, IP, HOSTNAME, ALIAS); + super(ID, MAC, IP, HOSTNAME, NAME); } @Override @@ -48,11 +48,15 @@ class UniFiClientCache extends UniFiCache { case IP: return client.getIp(); case HOSTNAME: - return client.getHostname(); - case ALIAS: - return client.getAlias(); + return safeTidy(client.getHostname()); + case NAME: + return safeTidy(client.getName()); default: return null; } } + + private static @Nullable String safeTidy(final @Nullable String value) { + return value == null ? null : value.trim().toLowerCase(); + } } diff --git a/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/dto/UniFiClient.java b/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/dto/UniFiClient.java index 109ad1efc..1c77a5572 100644 --- a/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/dto/UniFiClient.java +++ b/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/dto/UniFiClient.java @@ -41,12 +41,9 @@ public abstract class UniFiClient implements HasId { private String ip; - @JsonAdapter(UniFiTidyLowerCaseStringDeserializer.class) private String hostname; - @SerializedName("name") - @JsonAdapter(UniFiTidyLowerCaseStringDeserializer.class) - private String alias; + private String name; private Integer uptime; @@ -85,8 +82,8 @@ public abstract class UniFiClient implements HasId { return hostname; } - public String getAlias() { - return alias; + public String getName() { + return name; } public Integer getUptime() { @@ -128,7 +125,7 @@ public abstract class UniFiClient implements HasId { @Override public String toString() { return String.format( - "UniFiClient{id: '%s', mac: '%s', ip: '%s', hostname: '%s', alias: '%s', wired: %b, guest: %b, blocked: %b, experience: %d, device: %s}", - id, mac, getIp(), hostname, alias, isWired(), guest, blocked, experience, getDevice()); + "UniFiClient{id: '%s', mac: '%s', ip: '%s', hostname: '%s', name: '%s', wired: %b, guest: %b, blocked: %b, experience: %d, device: %s}", + id, mac, getIp(), hostname, name, isWired(), guest, blocked, experience, getDevice()); } } diff --git a/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiClientThingHandler.java b/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiClientThingHandler.java index 6d01b4829..cf1be9bc9 100644 --- a/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiClientThingHandler.java +++ b/bundles/org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal/handler/UniFiClientThingHandler.java @@ -19,9 +19,11 @@ import static org.openhab.binding.unifi.internal.UniFiBindingConstants.CHANNEL_C import static org.openhab.binding.unifi.internal.UniFiBindingConstants.CHANNEL_ESSID; import static org.openhab.binding.unifi.internal.UniFiBindingConstants.CHANNEL_EXPERIENCE; import static org.openhab.binding.unifi.internal.UniFiBindingConstants.CHANNEL_GUEST; +import static org.openhab.binding.unifi.internal.UniFiBindingConstants.CHANNEL_HOSTNAME; import static org.openhab.binding.unifi.internal.UniFiBindingConstants.CHANNEL_IP_ADDRESS; import static org.openhab.binding.unifi.internal.UniFiBindingConstants.CHANNEL_LAST_SEEN; import static org.openhab.binding.unifi.internal.UniFiBindingConstants.CHANNEL_MAC_ADDRESS; +import static org.openhab.binding.unifi.internal.UniFiBindingConstants.CHANNEL_NAME; import static org.openhab.binding.unifi.internal.UniFiBindingConstants.CHANNEL_ONLINE; import static org.openhab.binding.unifi.internal.UniFiBindingConstants.CHANNEL_RECONNECT; import static org.openhab.binding.unifi.internal.UniFiBindingConstants.CHANNEL_RSSI; @@ -176,6 +178,19 @@ public class UniFiClientThingHandler extends UniFiBaseThingHandler c.isGuest()); break; case CHANNEL_GUEST_VOUCHER: - String voucher = site.getVoucher(); + final String voucher = site.getVoucher(); state = (voucher != null) ? StringType.valueOf(voucher) : UnDefType.UNDEF; break; case CHANNEL_GUEST_VOUCHERS_GENERATE: @@ -111,11 +116,11 @@ public class UniFiSiteThingHandler extends UniFiBaseThingHandler - The MAC address, IP address, hostname or alias of the client + The MAC address, IP address, hostname or name of the client diff --git a/bundles/org.openhab.binding.unifi/src/main/resources/OH-INF/i18n/unifi.properties b/bundles/org.openhab.binding.unifi/src/main/resources/OH-INF/i18n/unifi.properties index b4ed105ef..ee1b74eda 100644 --- a/bundles/org.openhab.binding.unifi/src/main/resources/OH-INF/i18n/unifi.properties +++ b/bundles/org.openhab.binding.unifi/src/main/resources/OH-INF/i18n/unifi.properties @@ -21,7 +21,7 @@ thing-type.unifi.wlan.description = A UniFi Wireless LAN # thing types config thing-type.config.unifi.client.cid.label = Client ID -thing-type.config.unifi.client.cid.description = The MAC address, IP address, hostname or alias of the client +thing-type.config.unifi.client.cid.description = The MAC address, IP address, hostname or name of the client thing-type.config.unifi.client.considerHome.label = Consider Home Interval thing-type.config.unifi.client.considerHome.description = The interval in seconds to consider the client as home thing-type.config.unifi.client.site.label = Site @@ -61,12 +61,21 @@ channel-type.unifi.guest.label = Guest channel-type.unifi.guest.description = Is the client connected a guest channel-type.unifi.guestClients.label = Guest Clients channel-type.unifi.guestClients.description = Number of guest clients connected +channel-type.unifi.guestVoucher.label = Guest Voucher +channel-type.unifi.guestVoucher.description = Guest voucher for access through the guest portal +channel-type.unifi.guestVouchersGenerate.label = Generate Guest Vouchers +channel-type.unifi.guestVouchersGenerate.description = Generate additional guest vouchers for access through the guest portal +channel-type.unifi.guestVouchersGenerate.command.option.GENERATE = Generate +channel-type.unifi.hostname.label = Hostname +channel-type.unifi.hostname.description = Hostname of the client channel-type.unifi.ipAddress.label = IP Address channel-type.unifi.ipAddress.description = IP address of the client channel-type.unifi.lastSeen.label = Last Seen channel-type.unifi.lastSeen.description = Timestamp of when the client was last seen channel-type.unifi.macAddress.label = MAC Address channel-type.unifi.macAddress.description = MAC address of the client +channel-type.unifi.name.label = Name +channel-type.unifi.name.description = Name of the client channel-type.unifi.online.label = Online channel-type.unifi.online.description = Online status of the client channel-type.unifi.passphrase.label = Passphrase @@ -124,6 +133,18 @@ channel-type.unifi.wpaMode.description = WPA Mode of the Wi-Fi network # channel types config +channel-type.config.unifi.guestVouchersGenerate.voucherCount.label = Number +channel-type.config.unifi.guestVouchersGenerate.voucherCount.description = Number of vouchers to create +channel-type.config.unifi.guestVouchersGenerate.voucherDataQuota.label = Data Transfer Quota +channel-type.config.unifi.guestVouchersGenerate.voucherDataQuota.description = Data transfer quota in MB per user, no limit if not set +channel-type.config.unifi.guestVouchersGenerate.voucherDownLimit.label = Download Speed Limit +channel-type.config.unifi.guestVouchersGenerate.voucherDownLimit.description = Download speed limit in kbps, no limit if not set +channel-type.config.unifi.guestVouchersGenerate.voucherExpiration.label = Expiration Time +channel-type.config.unifi.guestVouchersGenerate.voucherExpiration.description = Minutes a voucher is valid after activation +channel-type.config.unifi.guestVouchersGenerate.voucherUpLimit.label = Upload Speed Limit +channel-type.config.unifi.guestVouchersGenerate.voucherUpLimit.description = Upload speed limit in kbps, no limit if not set +channel-type.config.unifi.guestVouchersGenerate.voucherUsers.label = Users +channel-type.config.unifi.guestVouchersGenerate.voucherUsers.description = Number of users for voucher, 0 if no limit channel-type.config.unifi.poeEnable.mode.label = On Mode channel-type.config.unifi.poeEnable.mode.description = The value to set when setting PoE on. channel-type.config.unifi.poeEnable.mode.option.auto = Auto @@ -137,7 +158,7 @@ error.bridge.offline.invalid_credentials = Invalid username and/or password - pl error.bridge.offline.invalid_hostname = Invalid hostname - please double-check your configuration: {0} error.bridge.offline.ssl_error = Error establishing an SSL connection with the UniFi controller: {0} error.controller.parse_error = Could not parse JSON from the UniFi Controller. Is the bridge configured with the correct host and/or port? -error.thing.client.offline.configuration_error = You must define a MAC address, IP address, hostname or alias for this thing. +error.thing.client.offline.configuration_error = You must define a MAC address, IP address, hostname or name for this thing. error.thing.offline.bridge_offline = The UniFi Controller is currently offline. error.thing.offline.configuration_error = You must choose a UniFi Controller for this thing. error.thing.poe.offline.configuration_error = The configuration parameter macAddress must be set and not be empty. diff --git a/bundles/org.openhab.binding.unifi/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.unifi/src/main/resources/OH-INF/thing/thing-types.xml index 640a10e51..bce8ac886 100644 --- a/bundles/org.openhab.binding.unifi/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.unifi/src/main/resources/OH-INF/thing/thing-types.xml @@ -71,6 +71,8 @@ + + @@ -95,6 +97,8 @@ + + @@ -248,6 +252,20 @@ + + String + + Name of the client + + + + + String + + Hostname of the client + + + String