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

[Sonos] add few properties #3964

Merged
merged 2 commits into from Aug 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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