| JA-100 | thermostat_%nr% | Number:Temperature | the thermostat %nr% value |
| JA-100F | sec-%nr% | String | the section %nr% status/control |
| JA-100F | pg-%nr% | Switch | the PG switch %nr% status/control |
+| JA-100F | thm-%nr% | Number:Temperature | the thermometer %nr% value |
The state, pgm, thermometer, thermostat, sec and pg channels for the JA-100/JA-100F alarms are dynamically created according to your configuration.
-* The sections are represented by String channels (with possible values "set", "unset", "partialSet" for JA-100 and
-possible values "ARM", "PARTIAL_ARM" and "DISARM" for JA100-F)
+* The sections are represented by String channels (with possible values "set", "unset", "partialSet" for JA-100 and possible values "ARM", "PARTIAL_ARM" and "DISARM" for JA100-F)
## Full Example
import org.openhab.binding.jablotron.internal.model.JablotronLoginResponse;
import org.openhab.binding.jablotron.internal.model.ja100f.JablotronGetPGResponse;
import org.openhab.binding.jablotron.internal.model.ja100f.JablotronGetSectionsResponse;
+import org.openhab.binding.jablotron.internal.model.ja100f.JablotronGetThermoDevicesResponse;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
return null;
}
- String urlParameters = "{\"connect-device\":false,\"list-type\":\"FULL\",\"service-id\":"
- + handler.thingConfig.getServiceId() + ",\"service-states\":true}";
+ String urlParameters = getCommonUrlParameters(handler.thingConfig.getServiceId());
return sendJsonMessage(url, urlParameters, JablotronGetPGResponse.class);
}
+ private String getCommonUrlParameters(String serviceId) {
+ return "{\"connect-device\":false,\"list-type\":\"FULL\",\"service-id\":" + serviceId
+ + ",\"service-states\":true}";
+ }
+
+ protected @Nullable JablotronGetThermoDevicesResponse sendGetThermometers(Thing th, String alarm) {
+ String url = JABLOTRON_API_URL + alarm + "/thermoDevicesGet.json";
+ JablotronAlarmHandler handler = (JablotronAlarmHandler) th.getHandler();
+
+ if (handler == null) {
+ logger.debug("Thing handler is null");
+ return null;
+ }
+
+ String urlParameters = getCommonUrlParameters(handler.thingConfig.getServiceId());
+
+ return sendJsonMessage(url, urlParameters, JablotronGetThermoDevicesResponse.class);
+ }
+
protected @Nullable JablotronGetSectionsResponse sendGetSections(Thing th, String alarm) {
String url = JABLOTRON_API_URL + alarm + "/sectionsGet.json";
JablotronAlarmHandler handler = (JablotronAlarmHandler) th.getHandler();
return null;
}
- String urlParameters = "{\"connect-device\":false,\"list-type\":\"FULL\",\"service-id\":"
- + handler.thingConfig.getServiceId() + ",\"service-states\":true}";
+ String urlParameters = getCommonUrlParameters(handler.thingConfig.getServiceId());
return sendJsonMessage(url, urlParameters, JablotronGetSectionsResponse.class);
}
import org.openhab.binding.jablotron.internal.model.JablotronServiceDetailSegment;
import org.openhab.binding.jablotron.internal.model.ja100f.JablotronGetPGResponse;
import org.openhab.binding.jablotron.internal.model.ja100f.JablotronGetSectionsResponse;
+import org.openhab.binding.jablotron.internal.model.ja100f.JablotronGetThermoDevicesResponse;
import org.openhab.binding.jablotron.internal.model.ja100f.JablotronSection;
import org.openhab.binding.jablotron.internal.model.ja100f.JablotronState;
+import org.openhab.binding.jablotron.internal.model.ja100f.JablotronThermoDevice;
import org.openhab.core.cache.ExpiringCache;
import org.openhab.core.library.types.OnOffType;
+import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
+import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
updateThing(thingBuilder.build());
}
+ private void createThermoChannel(String name, String label) {
+ ChannelTypeUID alarmStatus = new ChannelTypeUID(BINDING_ID, "temperature");
+ ThingBuilder thingBuilder = editThing();
+ Channel channel = ChannelBuilder.create(new ChannelUID(thing.getUID(), name), "Number").withLabel(label)
+ .withType(alarmStatus).build();
+ thingBuilder.withChannel(channel);
+ updateThing(thingBuilder.build());
+ }
+
private @Nullable JablotronGetSectionsResponse sendGetSections() {
JablotronBridgeHandler handler = getBridgeHandler();
if (handler != null) {
updateSectionState(resp.getData().getStates());
}
+ // thermo devices
+ JablotronGetThermoDevicesResponse respThermo = handler.sendGetThermometers(getThing(), alarmName);
+ if (respThermo != null) {
+ createThermoDeviceChannels(respThermo.getData().getThermoDevices());
+ updateThermoState(respThermo.getData().getStates());
+ }
+
// update events
List<JablotronHistoryDataEvent> events = sendGetEventHistory();
if (events != null && !events.isEmpty()) {
}
}
+ private void createThermoDeviceChannels(List<JablotronThermoDevice> thermoDevices) {
+ for (JablotronThermoDevice device : thermoDevices) {
+ String id = device.getObjectDeviceId().toLowerCase();
+ logger.trace("object device id: {} with name: {}", id, device.getName());
+ Channel channel = getThing().getChannel(id);
+ if (channel == null) {
+ logger.debug("Creating a new channel: {}", id);
+ createThermoChannel(id, device.getName());
+ }
+ }
+ }
+
private void updateSectionState(String section, List<JablotronState> states) {
for (JablotronState state : states) {
String id = state.getCloudComponentId();
}
}
+ private void updateThermoState(List<JablotronState> states) {
+ for (JablotronState state : states) {
+ logger.debug("updating thermo state: {}", state.getObjectDeviceId());
+ String id = state.getObjectDeviceId();
+ updateSection(id, state);
+ }
+ }
+
private void updateSection(String id, JablotronState state) {
logger.debug("component id: {} with state: {}", id, state.getState());
State newState;
newState = new StringType(state.getState());
} else if (id.startsWith("PG-")) {
newState = "ON".equals(state.getState()) ? OnOffType.ON : OnOffType.OFF;
+ } else if (id.startsWith("THM-")) {
+ newState = new QuantityType<>(state.getTemperature(), SIUnits.CELSIUS);
} else {
logger.debug("unknown component id: {}", id);
return;
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.jablotron.internal.model.ja100f;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * The {@link JablotronGetThermoDevicesData} class defines the data object for the
+ * getThermoDevices response
+ *
+ * @author Ondrej Pecta - Initial contribution
+ */
+@NonNullByDefault
+public class JablotronGetThermoDevicesData {
+
+ List<JablotronState> states = new ArrayList<>();
+
+ @SerializedName(value = "thermo-devices")
+ List<JablotronThermoDevice> thermoDevices = new ArrayList<>();
+
+ public List<JablotronState> getStates() {
+ return states;
+ }
+
+ public List<JablotronThermoDevice> getThermoDevices() {
+ return thermoDevices;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.jablotron.internal.model.ja100f;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
+/**
+ * The {@link JablotronGetThermoDevicesResponse} class defines the response object for the
+ * getThermometers call
+ *
+ * @author Ondrej Pecta - Initial contribution
+ */
+@NonNullByDefault
+public class JablotronGetThermoDevicesResponse {
+
+ JablotronGetThermoDevicesData data = new JablotronGetThermoDevicesData();
+
+ public JablotronGetThermoDevicesData getData() {
+ return data;
+ }
+}
@SerializedName(value = "cloud-component-id", alternate = "component-id")
String cloudComponentId = "";
+ @SerializedName(value = "object-device-id")
+ String objectDeviceId = "";
+
String state = "";
+ float temperature = 0;
public String getCloudComponentId() {
return cloudComponentId;
public String getState() {
return state;
}
+
+ public float getTemperature() {
+ return temperature;
+ }
+
+ public String getObjectDeviceId() {
+ return objectDeviceId;
+ }
}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.jablotron.internal.model.ja100f;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * The {@link JablotronThermoDevice} class defines the thermal device object
+ * for the getThermoDevices response
+ *
+ * @author Ondrej Pecta - Initial contribution
+ */
+@NonNullByDefault
+public class JablotronThermoDevice {
+
+ @SerializedName(value = "object-device-id")
+ String objectDeviceId = "";
+
+ String name = "";
+
+ public String getObjectDeviceId() {
+ return objectDeviceId;
+ }
+
+ public String getName() {
+ return name;
+ }
+}