[freeboxos] Fix triggering of event firmware_updated (#17161)

Also update the firmware property when the player is reachable for the first time.
Do not trigger the event firmware_updated when just first setting the firmware property.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2024-07-29 19:51:36 +02:00 committed by GitHub
parent 20251feb09
commit f42fd6260a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,11 +36,16 @@ public interface FreeDeviceIntf extends ApiConsumerIntf {
default long checkUptimeAndFirmware(long newUptime, long oldUptime, String firmwareVersion) {
if (newUptime < oldUptime) {
triggerChannel(getEventChannelUID(), "restarted");
}
if (oldUptime < 0 || newUptime < oldUptime) {
Map<String, String> properties = editProperties();
if (!firmwareVersion.equals(properties.get(Thing.PROPERTY_FIRMWARE_VERSION))) {
String property = properties.get(Thing.PROPERTY_FIRMWARE_VERSION);
if (!firmwareVersion.equals(property)) {
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, firmwareVersion);
updateProperties(properties);
triggerChannel(getEventChannelUID(), "firmware_updated");
if (property != null) {
triggerChannel(getEventChannelUID(), "firmware_updated");
}
}
}
return newUptime;