mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 23:22:02 +01:00
[jablotron] Added thermometers support for JA100F alarms (#13361)
Signed-off-by: Ondrej Pecta <opecta@gmail.com>
This commit is contained in:
parent
8ee4ac86db
commit
7d9e277a15
@ -56,11 +56,11 @@ Binding itself doesn't require specific configuration.
|
|||||||
| JA-100 | thermostat_%nr% | Number:Temperature | the thermostat %nr% value |
|
| JA-100 | thermostat_%nr% | Number:Temperature | the thermostat %nr% value |
|
||||||
| JA-100F | sec-%nr% | String | the section %nr% status/control |
|
| JA-100F | sec-%nr% | String | the section %nr% status/control |
|
||||||
| JA-100F | pg-%nr% | Switch | the PG switch %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 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
|
* 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)
|
||||||
possible values "ARM", "PARTIAL_ARM" and "DISARM" for JA100-F)
|
|
||||||
|
|
||||||
## Full Example
|
## Full Example
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ import org.openhab.binding.jablotron.internal.model.JablotronHistoryDataEvent;
|
|||||||
import org.openhab.binding.jablotron.internal.model.JablotronLoginResponse;
|
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.JablotronGetPGResponse;
|
||||||
import org.openhab.binding.jablotron.internal.model.ja100f.JablotronGetSectionsResponse;
|
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.Bridge;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
@ -334,12 +335,30 @@ public class JablotronBridgeHandler extends BaseBridgeHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String urlParameters = "{\"connect-device\":false,\"list-type\":\"FULL\",\"service-id\":"
|
String urlParameters = getCommonUrlParameters(handler.thingConfig.getServiceId());
|
||||||
+ handler.thingConfig.getServiceId() + ",\"service-states\":true}";
|
|
||||||
|
|
||||||
return sendJsonMessage(url, urlParameters, JablotronGetPGResponse.class);
|
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) {
|
protected @Nullable JablotronGetSectionsResponse sendGetSections(Thing th, String alarm) {
|
||||||
String url = JABLOTRON_API_URL + alarm + "/sectionsGet.json";
|
String url = JABLOTRON_API_URL + alarm + "/sectionsGet.json";
|
||||||
JablotronAlarmHandler handler = (JablotronAlarmHandler) th.getHandler();
|
JablotronAlarmHandler handler = (JablotronAlarmHandler) th.getHandler();
|
||||||
@ -349,8 +368,7 @@ public class JablotronBridgeHandler extends BaseBridgeHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String urlParameters = "{\"connect-device\":false,\"list-type\":\"FULL\",\"service-id\":"
|
String urlParameters = getCommonUrlParameters(handler.thingConfig.getServiceId());
|
||||||
+ handler.thingConfig.getServiceId() + ",\"service-states\":true}";
|
|
||||||
|
|
||||||
return sendJsonMessage(url, urlParameters, JablotronGetSectionsResponse.class);
|
return sendJsonMessage(url, urlParameters, JablotronGetSectionsResponse.class);
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,15 @@ import org.openhab.binding.jablotron.internal.model.JablotronHistoryDataEvent;
|
|||||||
import org.openhab.binding.jablotron.internal.model.JablotronServiceDetailSegment;
|
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.JablotronGetPGResponse;
|
||||||
import org.openhab.binding.jablotron.internal.model.ja100f.JablotronGetSectionsResponse;
|
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.JablotronSection;
|
||||||
import org.openhab.binding.jablotron.internal.model.ja100f.JablotronState;
|
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.cache.ExpiringCache;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
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.types.StringType;
|
||||||
|
import org.openhab.core.library.unit.SIUnits;
|
||||||
import org.openhab.core.thing.Channel;
|
import org.openhab.core.thing.Channel;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
@ -141,6 +145,15 @@ public class JablotronJa100FHandler extends JablotronAlarmHandler {
|
|||||||
updateThing(thingBuilder.build());
|
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() {
|
private @Nullable JablotronGetSectionsResponse sendGetSections() {
|
||||||
JablotronBridgeHandler handler = getBridgeHandler();
|
JablotronBridgeHandler handler = getBridgeHandler();
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
@ -177,6 +190,13 @@ public class JablotronJa100FHandler extends JablotronAlarmHandler {
|
|||||||
updateSectionState(resp.getData().getStates());
|
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
|
// update events
|
||||||
List<JablotronHistoryDataEvent> events = sendGetEventHistory();
|
List<JablotronHistoryDataEvent> events = sendGetEventHistory();
|
||||||
if (events != null && !events.isEmpty()) {
|
if (events != null && !events.isEmpty()) {
|
||||||
@ -213,6 +233,18 @@ public class JablotronJa100FHandler extends JablotronAlarmHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
private void updateSectionState(String section, List<JablotronState> states) {
|
||||||
for (JablotronState state : states) {
|
for (JablotronState state : states) {
|
||||||
String id = state.getCloudComponentId();
|
String id = state.getCloudComponentId();
|
||||||
@ -230,6 +262,14 @@ public class JablotronJa100FHandler extends JablotronAlarmHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
private void updateSection(String id, JablotronState state) {
|
||||||
logger.debug("component id: {} with state: {}", id, state.getState());
|
logger.debug("component id: {} with state: {}", id, state.getState());
|
||||||
State newState;
|
State newState;
|
||||||
@ -238,6 +278,8 @@ public class JablotronJa100FHandler extends JablotronAlarmHandler {
|
|||||||
newState = new StringType(state.getState());
|
newState = new StringType(state.getState());
|
||||||
} else if (id.startsWith("PG-")) {
|
} else if (id.startsWith("PG-")) {
|
||||||
newState = "ON".equals(state.getState()) ? OnOffType.ON : OnOffType.OFF;
|
newState = "ON".equals(state.getState()) ? OnOffType.ON : OnOffType.OFF;
|
||||||
|
} else if (id.startsWith("THM-")) {
|
||||||
|
newState = new QuantityType<>(state.getTemperature(), SIUnits.CELSIUS);
|
||||||
} else {
|
} else {
|
||||||
logger.debug("unknown component id: {}", id);
|
logger.debug("unknown component id: {}", id);
|
||||||
return;
|
return;
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
@ -28,7 +28,11 @@ public class JablotronState {
|
|||||||
@SerializedName(value = "cloud-component-id", alternate = "component-id")
|
@SerializedName(value = "cloud-component-id", alternate = "component-id")
|
||||||
String cloudComponentId = "";
|
String cloudComponentId = "";
|
||||||
|
|
||||||
|
@SerializedName(value = "object-device-id")
|
||||||
|
String objectDeviceId = "";
|
||||||
|
|
||||||
String state = "";
|
String state = "";
|
||||||
|
float temperature = 0;
|
||||||
|
|
||||||
public String getCloudComponentId() {
|
public String getCloudComponentId() {
|
||||||
return cloudComponentId;
|
return cloudComponentId;
|
||||||
@ -37,4 +41,12 @@ public class JablotronState {
|
|||||||
public String getState() {
|
public String getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getTemperature() {
|
||||||
|
return temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getObjectDeviceId() {
|
||||||
|
return objectDeviceId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user