Search in sources :

Example 1 with StateWifiFirmwareResponse

use of org.eclipse.smarthome.binding.lifx.internal.protocol.StateWifiFirmwareResponse in project smarthome by eclipse.

the class LifxLightPropertiesUpdater method handleResponsePacket.

public void handleResponsePacket(Packet packet) {
    if (!updating) {
        return;
    }
    if (packet instanceof StateVersionResponse) {
        Products products = Products.getProductFromProductID(((StateVersionResponse) packet).getProduct());
        long productVersion = ((StateVersionResponse) packet).getVersion();
        properties.put(LifxBindingConstants.PROPERTY_PRODUCT_ID, Long.toString(products.getProduct()));
        properties.put(LifxBindingConstants.PROPERTY_PRODUCT_NAME, products.getName());
        properties.put(LifxBindingConstants.PROPERTY_PRODUCT_VERSION, Long.toString(productVersion));
        properties.put(LifxBindingConstants.PROPERTY_VENDOR_ID, Long.toString(products.getVendor()));
        properties.put(LifxBindingConstants.PROPERTY_VENDOR_NAME, products.getVendorName());
        receivedPacketTypes.add(packet.getPacketType());
    } else if (packet instanceof StateHostFirmwareResponse) {
        String hostVersion = ((StateHostFirmwareResponse) packet).getVersion().toString();
        properties.put(LifxBindingConstants.PROPERTY_HOST_VERSION, hostVersion);
        receivedPacketTypes.add(packet.getPacketType());
    } else if (packet instanceof StateWifiFirmwareResponse) {
        String wifiVersion = ((StateWifiFirmwareResponse) packet).getVersion().toString();
        properties.put(LifxBindingConstants.PROPERTY_WIFI_VERSION, wifiVersion);
        receivedPacketTypes.add(packet.getPacketType());
    }
    if (receivedAllResponsePackets()) {
        updating = false;
        propertiesUpdateListeners.forEach(listener -> listener.handlePropertiesUpdate(properties));
        logger.debug("{} : Finished updating light properties", logId);
    }
}
Also used : Products(org.eclipse.smarthome.binding.lifx.internal.protocol.Products) StateHostFirmwareResponse(org.eclipse.smarthome.binding.lifx.internal.protocol.StateHostFirmwareResponse) StateWifiFirmwareResponse(org.eclipse.smarthome.binding.lifx.internal.protocol.StateWifiFirmwareResponse) StateVersionResponse(org.eclipse.smarthome.binding.lifx.internal.protocol.StateVersionResponse)

Aggregations

Products (org.eclipse.smarthome.binding.lifx.internal.protocol.Products)1 StateHostFirmwareResponse (org.eclipse.smarthome.binding.lifx.internal.protocol.StateHostFirmwareResponse)1 StateVersionResponse (org.eclipse.smarthome.binding.lifx.internal.protocol.StateVersionResponse)1 StateWifiFirmwareResponse (org.eclipse.smarthome.binding.lifx.internal.protocol.StateWifiFirmwareResponse)1