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.miio.internal.robot;
15 import java.util.concurrent.TimeUnit;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
22 * @author Marcel Verpaalen - Initial contribution
25 public enum ConsumablesType {
26 MAIN_BRUSH(300, "Main Brush"),
27 SIDE_BRUSH(200, "Side Brush"),
28 FILTER(150, "Filter"),
30 UNKNOWN(0, "Unknown");
32 private final int lifeTime;
33 private final String description;
35 ConsumablesType(int lifeTime, String description) {
36 this.lifeTime = lifeTime;
37 this.description = description;
40 public static double remainingHours(int usedSeconds, ConsumablesType consumableType) {
41 return Math.max((double) consumableType.lifeTime - TimeUnit.SECONDS.toHours(usedSeconds), 0);
44 public static int remainingPercent(int usedSeconds, ConsumablesType consumableType) {
45 return (int) (100D * remainingHours(usedSeconds, consumableType) / consumableType.lifeTime);
48 public int getLifeTime() {
52 public String getDescription() {
57 public String toString() {