Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
[Sonos] add few properties (#3964)
Browse files Browse the repository at this point in the history
* Properties added: hardwareVersion, firmwareVersion, serialNumber, macAddress, ipAddress
* Avoid requesting the MAC address when we already have it

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo authored and kaikreuzer committed Aug 6, 2017
1 parent 025aa7d commit 8aa2fec
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
Expand Up @@ -59,7 +59,7 @@

<properties>
<property name="vendor">SONOS</property>
<property name="modelId"></property>
<property name="modelId">CONNECT</property>
</properties>

<config-description-ref uri="config:sonos:zoneplayer" />
Expand Down
Expand Up @@ -97,5 +97,7 @@ public class SonosBindingConstants {

// List of properties
public static final String IDENTIFICATION = "identification";
public static final String MAC_ADDRESS = "macAddress";
public static final String IP_ADDRESS = "ipAddress";

}
Expand Up @@ -871,6 +871,37 @@ protected void updateZoneInfo() {
for (String variable : result.keySet()) {
this.onValueReceived(variable, result.get(variable), "DeviceProperties");
}

Map<String, String> properties = editProperties();
boolean update = false;
if (StringUtils.isNotEmpty(this.stateMap.get("HardwareVersion"))
&& !this.stateMap.get("HardwareVersion").equals(properties.get(Thing.PROPERTY_HARDWARE_VERSION))) {
update = true;
properties.put(Thing.PROPERTY_HARDWARE_VERSION, this.stateMap.get("HardwareVersion"));
}
if (StringUtils.isNotEmpty(this.stateMap.get("DisplaySoftwareVersion")) && !this.stateMap
.get("DisplaySoftwareVersion").equals(properties.get(Thing.PROPERTY_FIRMWARE_VERSION))) {
update = true;
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, this.stateMap.get("DisplaySoftwareVersion"));
}
if (StringUtils.isNotEmpty(this.stateMap.get("SerialNumber"))
&& !this.stateMap.get("SerialNumber").equals(properties.get(Thing.PROPERTY_SERIAL_NUMBER))) {
update = true;
properties.put(Thing.PROPERTY_SERIAL_NUMBER, this.stateMap.get("SerialNumber"));
}
if (StringUtils.isNotEmpty(this.stateMap.get("MACAddress"))
&& !this.stateMap.get("MACAddress").equals(properties.get(MAC_ADDRESS))) {
update = true;
properties.put(MAC_ADDRESS, this.stateMap.get("MACAddress"));
}
if (StringUtils.isNotEmpty(this.stateMap.get("IPAddress"))
&& !this.stateMap.get("IPAddress").equals(properties.get(IP_ADDRESS))) {
update = true;
properties.put(IP_ADDRESS, this.stateMap.get("IPAddress"));
}
if (update) {
updateProperties(properties);
}
}

public String getCoordinator() {
Expand Down Expand Up @@ -1064,7 +1095,9 @@ public SonosMetaData getEnqueuedTransportURIMetaData() {
}

public String getMACAddress() {
updateZoneInfo();
if (StringUtils.isEmpty(stateMap.get("MACAddress"))) {
updateZoneInfo();
}
return stateMap.get("MACAddress");
}

Expand Down Expand Up @@ -1704,8 +1737,7 @@ public void setRepeat(Command command) {

public Boolean isShuffleActive() {
return ((stateMap.get("CurrentPlayMode") != null) && stateMap.get("CurrentPlayMode").startsWith("SHUFFLE"))
? true
: false;
? true : false;
}

public String getRepeatMode() {
Expand Down

0 comments on commit 8aa2fec

Please sign in to comment.