Search in sources :

Example 1 with SetLightInfraredRequest

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

the class LifxLightStateChanger method handleInfraredChange.

@Override
public void handleInfraredChange(PercentType oldInfrared, PercentType newInfrared) {
    int infrared = percentTypeToInfrared(pendingLightState.getInfrared());
    SetLightInfraredRequest packet = new SetLightInfraredRequest(infrared);
    replacePacketsInMap(packet);
}
Also used : SetLightInfraredRequest(org.eclipse.smarthome.binding.lifx.internal.protocol.SetLightInfraredRequest)

Example 2 with SetLightInfraredRequest

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

the class LifxLightStateChanger method handleResponsePacket.

public void handleResponsePacket(Packet packet) {
    if (packet instanceof AcknowledgementResponse) {
        long ackTimestamp = System.currentTimeMillis();
        PendingPacket pendingPacket;
        try {
            lock.lock();
            pendingPacket = removeAcknowledgedPacket(packet.getSequence());
        } finally {
            lock.unlock();
        }
        if (pendingPacket != null) {
            Packet sentPacket = pendingPacket.packet;
            logger.debug("{} : {} packet was acknowledged in {}ms", logId, sentPacket.getClass().getSimpleName(), ackTimestamp - pendingPacket.lastSend);
            // LifxLightCurrentStateUpdater
            if (sentPacket instanceof SetPowerRequest) {
                GetLightPowerRequest powerPacket = new GetLightPowerRequest();
                communicationHandler.sendPacket(powerPacket);
            } else if (sentPacket instanceof SetColorRequest) {
                GetRequest colorPacket = new GetRequest();
                communicationHandler.sendPacket(colorPacket);
                getZonesIfZonesAreSet();
            } else if (sentPacket instanceof SetColorZonesRequest) {
                getZonesIfZonesAreSet();
            } else if (sentPacket instanceof SetLightInfraredRequest) {
                GetLightInfraredRequest infraredPacket = new GetLightInfraredRequest();
                communicationHandler.sendPacket(infraredPacket);
            }
        } else {
            logger.debug("{} : No pending packet found for ack with sequence number: {}", logId, packet.getSequence());
        }
    }
}
Also used : Packet(org.eclipse.smarthome.binding.lifx.internal.protocol.Packet) SetLightInfraredRequest(org.eclipse.smarthome.binding.lifx.internal.protocol.SetLightInfraredRequest) GetRequest(org.eclipse.smarthome.binding.lifx.internal.protocol.GetRequest) SetColorZonesRequest(org.eclipse.smarthome.binding.lifx.internal.protocol.SetColorZonesRequest) AcknowledgementResponse(org.eclipse.smarthome.binding.lifx.internal.protocol.AcknowledgementResponse) GetLightInfraredRequest(org.eclipse.smarthome.binding.lifx.internal.protocol.GetLightInfraredRequest) GetLightPowerRequest(org.eclipse.smarthome.binding.lifx.internal.protocol.GetLightPowerRequest) SetPowerRequest(org.eclipse.smarthome.binding.lifx.internal.protocol.SetPowerRequest) SetColorRequest(org.eclipse.smarthome.binding.lifx.internal.protocol.SetColorRequest)

Aggregations

SetLightInfraredRequest (org.eclipse.smarthome.binding.lifx.internal.protocol.SetLightInfraredRequest)2 AcknowledgementResponse (org.eclipse.smarthome.binding.lifx.internal.protocol.AcknowledgementResponse)1 GetLightInfraredRequest (org.eclipse.smarthome.binding.lifx.internal.protocol.GetLightInfraredRequest)1 GetLightPowerRequest (org.eclipse.smarthome.binding.lifx.internal.protocol.GetLightPowerRequest)1 GetRequest (org.eclipse.smarthome.binding.lifx.internal.protocol.GetRequest)1 Packet (org.eclipse.smarthome.binding.lifx.internal.protocol.Packet)1 SetColorRequest (org.eclipse.smarthome.binding.lifx.internal.protocol.SetColorRequest)1 SetColorZonesRequest (org.eclipse.smarthome.binding.lifx.internal.protocol.SetColorZonesRequest)1 SetPowerRequest (org.eclipse.smarthome.binding.lifx.internal.protocol.SetPowerRequest)1