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.surepetcare.internal.handler;
15 import static org.openhab.binding.surepetcare.internal.SurePetcareConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.surepetcare.internal.SurePetcareAPIHelper;
19 import org.openhab.binding.surepetcare.internal.dto.SurePetcareHousehold;
20 import org.openhab.core.library.types.DecimalType;
21 import org.openhab.core.library.types.StringType;
22 import org.openhab.core.thing.Thing;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * The {@link SurePetcareHouseholdHandler} is responsible for handling things created to represent Sure Petcare
30 * @author Rene Scherer - Initial Contribution
33 public class SurePetcareHouseholdHandler extends SurePetcareBaseObjectHandler {
35 private final Logger logger = LoggerFactory.getLogger(SurePetcareHouseholdHandler.class);
37 public SurePetcareHouseholdHandler(Thing thing, SurePetcareAPIHelper petcareAPI) {
38 super(thing, petcareAPI);
42 protected void updateThing() {
43 SurePetcareHousehold household = petcareAPI.getHousehold(thing.getUID().getId());
44 if (household != null) {
45 logger.debug("Updating all thing channels for household : {}", household);
46 updateState(HOUSEHOLD_CHANNEL_ID, new DecimalType(household.id));
47 updateState(HOUSEHOLD_CHANNEL_NAME, new StringType(household.name));
48 updateState(HOUSEHOLD_CHANNEL_TIMEZONE_ID, new DecimalType(household.timezoneId));
50 logger.debug("Trying to update unknown household: {}", thing.getUID().getId());