This commit is contained in:
Thomas Vogl 2024-03-02 21:53:38 +01:00
parent f88d80d6db
commit ac8486d150
2 changed files with 14 additions and 14 deletions

View File

@ -39,7 +39,7 @@ public abstract class AbstractEcowittServlet extends HttpServlet {
@Nullable @Nullable
protected StateUpdater stateUpdater = null; protected StateUpdater stateUpdater = null;
private final Logger logger = LoggerFactory.getLogger(AbstractEcowittServlet.class); protected final Logger logger = LoggerFactory.getLogger(AbstractEcowittServlet.class);
protected void doPost(HttpServletRequest request, HttpServletResponse response) { protected void doPost(HttpServletRequest request, HttpServletResponse response) {
for (Map.Entry<String, String[]> stringEntry : request.getParameterMap().entrySet()) { for (Map.Entry<String, String[]> stringEntry : request.getParameterMap().entrySet()) {

View File

@ -57,53 +57,53 @@ public class EcowittGW1000Servlet extends AbstractEcowittServlet {
} }
String type = channelUID.getId(); String type = channelUID.getId();
float value; Float value;
switch (type) { switch (type) {
case "humidity": case "humidity":
case "atmospheric-humidity": case "atmospheric-humidity":
case "moisture": case "moisture":
value = Float.parseFloat(strValue); value = new Float(Float.parseFloat(strValue));
stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, Units.PERCENT)); stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, Units.PERCENT));
break; break;
case "temperature": case "temperature":
case "outdoor-temperature": case "outdoor-temperature":
value = Float.parseFloat(strValue); value = new Float(Float.parseFloat(strValue));
stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, ImperialUnits.FAHRENHEIT)); stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, ImperialUnits.FAHRENHEIT));
break; break;
case "uv-index": case "uv-index":
case "lightning-num": case "lightning-num":
value = Float.parseFloat(strValue); value = new Float(Float.parseFloat(strValue));
stateUpdater.updateState(ch.getUID(), new DecimalType(value)); stateUpdater.updateState(ch.getUID(), new DecimalType(value));
break; break;
case "rain-amount": case "rain-amount":
value = Float.parseFloat(strValue); value = new Float(Float.parseFloat(strValue));
stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, ImperialUnits.INCH)); stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, ImperialUnits.INCH));
break; break;
case "rain-rate": case "rain-rate":
value = Float.parseFloat(strValue); value = new Float(Float.parseFloat(strValue));
stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, Units.INCHES_PER_HOUR)); stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, Units.INCHES_PER_HOUR));
break; break;
case "wind-speed": case "wind-speed":
value = Float.parseFloat(strValue); value = new Float(Float.parseFloat(strValue));
stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, ImperialUnits.MILES_PER_HOUR)); stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, ImperialUnits.MILES_PER_HOUR));
break; break;
case "wind-direction": case "wind-direction":
value = Float.parseFloat(strValue); value = new Float(Float.parseFloat(strValue));
stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, Units.DEGREE_ANGLE)); stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, Units.DEGREE_ANGLE));
break; break;
case "barometric-pressure": case "barometric-pressure":
value = Float.parseFloat(strValue); value = new Float(Float.parseFloat(strValue));
stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, ImperialUnits.INCH_OF_MERCURY)); stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, ImperialUnits.INCH_OF_MERCURY));
break; break;
case "solar-radiation": case "solar-radiation":
value = Float.parseFloat(strValue); value = new Float(Float.parseFloat(strValue));
stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, Units.IRRADIANCE)); stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, Units.IRRADIANCE));
break; break;
case "lightning-distance": case "lightning-distance":
value = Float.parseFloat(strValue); value = new Float(Float.parseFloat(strValue));
stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, MetricPrefix.KILO(SIUnits.METRE))); stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, MetricPrefix.KILO(SIUnits.METRE)));
break; break;
@ -113,12 +113,12 @@ public class EcowittGW1000Servlet extends AbstractEcowittServlet {
break; break;
case "pm25-particles": case "pm25-particles":
value = Float.parseFloat(strValue); value = new Float(Float.parseFloat(strValue));
stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, Units.MICROGRAM_PER_CUBICMETRE)); stateUpdater.updateState(ch.getUID(), new QuantityType<>(value, Units.MICROGRAM_PER_CUBICMETRE));
break; break;
case "battery-level": case "battery-level":
value = Float.parseFloat(strValue); value = new Float(Float.parseFloat(strValue));
int batLevel = 0; int batLevel = 0;
switch (id) { switch (id) {
case "pm25batt1": case "pm25batt1":