2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.lifx.internal.dto;
15 import org.openhab.core.library.types.OnOffType;
18 * Represents light power states (on or off).
20 * @author Tim Buckley - Initial contribution
21 * @author Karel Goderis - Enhancement for the V2 LIFX Firmware and LAN Protocol Specification
22 * @author Wouter Born - Added OnOffType conversion methods
24 public enum PowerState {
29 private final int value;
31 private PowerState(int value) {
36 * Gets the integer value of this power state.
38 * @return the integer value
40 public int getValue() {
44 public static PowerState fromValue(int value) {
45 // a response can have a power level between 0 and 65535 when the light
46 // has just been switched ON or OFF
47 return value == OFF.value ? OFF : ON;
50 public static PowerState fromOnOffType(OnOffType onOff) {
51 return onOff == OnOffType.ON ? ON : OFF;
54 public OnOffType toOnOffType() {
55 return this == ON ? OnOffType.ON : OnOffType.OFF;