Skip to content

Commit

Permalink
[mercedesme] UOM cleanup (#18332)
Browse files Browse the repository at this point in the history
* metadata adjuster remove

Signed-off-by: Bernd Weymann <[email protected]>
  • Loading branch information
weymann authored Mar 7, 2025
1 parent 02d33f1 commit 6eeffe4
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 349 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@
import org.openhab.core.i18n.TimeZoneProvider;
import org.openhab.core.i18n.UnitProvider;
import org.openhab.core.io.net.http.HttpClientFactory;
import org.openhab.core.items.MetadataRegistry;
import org.openhab.core.storage.StorageService;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerFactory;
import org.openhab.core.thing.link.ItemChannelLinkRegistry;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
Expand All @@ -47,7 +45,8 @@
import org.osgi.service.component.annotations.Reference;

/**
* The {@link MercedesMeHandlerFactory} is responsible for creating thing handlers.
* The {@link MercedesMeHandlerFactory} is responsible for creating thing
* handlers.
*
* @author Bernd Weymann - Initial contribution
*/
Expand All @@ -65,16 +64,14 @@ public class MercedesMeHandlerFactory extends BaseThingHandlerFactory {
private final MercedesMeCommandOptionProvider mmcop;
private final MercedesMeStateOptionProvider mmsop;
private @Nullable ServiceRegistration<?> discoveryServiceReg;
private @Nullable MercedesMeMetadataAdjuster mdAdjuster;

public static String ohVersion = "unknown";

@Activate
public MercedesMeHandlerFactory(@Reference HttpClientFactory hcf, @Reference StorageService storageService,
final @Reference LocaleProvider lp, final @Reference LocationProvider locationP,
final @Reference TimeZoneProvider tzp, final @Reference MercedesMeCommandOptionProvider cop,
final @Reference MercedesMeStateOptionProvider sop, final @Reference UnitProvider up,
final @Reference MetadataRegistry mdr, final @Reference ItemChannelLinkRegistry iclr) {
final @Reference MercedesMeStateOptionProvider sop, final @Reference UnitProvider up) {
this.storageService = storageService;
localeProvider = lp;
locationProvider = locationP;
Expand All @@ -83,7 +80,6 @@ public MercedesMeHandlerFactory(@Reference HttpClientFactory hcf, @Reference Sto

Utils.initialize(tzp, lp);
Mapper.initialize(up);
mdAdjuster = new MercedesMeMetadataAdjuster(mdr, iclr, up);
httpClient = hcf.getCommonHttpClient();
discoveryService = new MercedesMeDiscoveryService();
}
Expand Down Expand Up @@ -123,9 +119,6 @@ protected void deactivate(ComponentContext componentContext) {
discoveryServiceReg.unregister();
discoveryServiceReg = null;
}
if (mdAdjuster != null) {
mdAdjuster = null;
}
}

public static String getVersion() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@
<state pattern="%1$td.%1$tm. %1$tH:%1$tM" readOnly="true"/>
</channel-type>
<channel-type id="max-soc">
<item-type>Number:Dimensionless</item-type>
<item-type unitHint="%">Number:Dimensionless</item-type>
<label>Charge SoC Maximum</label>
<state pattern="%d %%"/>
<state pattern="%d %unit%"/>
<command>
<options>
<option value="50 %">50 %</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="accel">
<item-type>Number:Dimensionless</item-type>
<item-type unitHint="%">Number:Dimensionless</item-type>
<label>Acceleration Score</label>
<description>Score for smooth acceleration</description>
<state readOnly="true"/>
</channel-type>
<channel-type id="coasting">
<item-type>Number:Dimensionless</item-type>
<item-type unitHint="%">Number:Dimensionless</item-type>
<label>Coasting Score</label>
<description>Score for driving without braking</description>
<state readOnly="true"/>
</channel-type>
<channel-type id="constant">
<item-type>Number:Dimensionless</item-type>
<item-type unitHint="%">Number:Dimensionless</item-type>
<label>Constant Score</label>
<description>Score for driving with constant speed</description>
<state readOnly="true"/>
</channel-type>
<channel-type id="bonus">
<item-type>Number:Length</item-type>
<item-type unitHint="km,mi">Number:Length</item-type>
<label>Bonus Range</label>
<description>Additional range vs. very sportive driver</description>
<state pattern="%d %unit%" readOnly="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,79 @@
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="mileage">
<item-type>Number:Length</item-type>
<item-type unitHint="km,mi">Number:Length</item-type>
<label>Mileage</label>
<state pattern="%d km" readOnly="true"/>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="range-electric">
<item-type>Number:Length</item-type>
<item-type unitHint="km,mi">Number:Length</item-type>
<label>Electric Range</label>
<state pattern="%d km" readOnly="true"/>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="radius-electric">
<item-type>Number:Length</item-type>
<item-type unitHint="km,mi">Number:Length</item-type>
<label>Electric Radius</label>
<state pattern="%d km" readOnly="true"/>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="home-distance">
<item-type>Number:Length</item-type>
<item-type unitHint="km,mi">Number:Length</item-type>
<label>Distance to Home</label>
<state pattern="%.3f km" readOnly="true"/>
<state pattern="%.3f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="soc">
<item-type>Number:Dimensionless</item-type>
<item-type unitHint="%">Number:Dimensionless</item-type>
<label>Battery Charge Level</label>
<state pattern="%d %%" readOnly="true"/>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="charged">
<item-type>Number:Energy</item-type>
<item-type unitHint="kWh">Number:Energy</item-type>
<label>Charged Battery Energy</label>
<state pattern="%.2f kWh" readOnly="true"/>
<state pattern="%.2f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="uncharged">
<item-type>Number:Energy</item-type>
<item-type unitHint="kWh">Number:Energy</item-type>
<label>Uncharged Battery Energy</label>
<state pattern="%.2f kWh" readOnly="true"/>
<state pattern="%.2f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="range-fuel">
<item-type>Number:Length</item-type>
<item-type unitHint="km,mi">Number:Length</item-type>
<label>Fuel Range</label>
<state pattern="%d km" readOnly="true"/>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="radius-fuel">
<item-type>Number:Length</item-type>
<item-type unitHint="km,mi">Number:Length</item-type>
<label>Fuel Radius</label>
<state pattern="%d km" readOnly="true"/>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="fuel-level">
<item-type>Number:Dimensionless</item-type>
<item-type unitHint="%">Number:Dimensionless</item-type>
<label>Fuel Level</label>
<state pattern="%d %%" readOnly="true"/>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="adblue-level">
<item-type>Number:Dimensionless</item-type>
<item-type unitHint="%">Number:Dimensionless</item-type>
<label>AdBlue Level</label>
<description>AdBlue tank level in percent </description>
<state pattern="%d %%" readOnly="true"/>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="fuel-remain">
<item-type>Number:Volume</item-type>
<item-type unitHint="l,gal">Number:Volume</item-type>
<label>Remaining Fuel</label>
<state pattern="%.2f l" readOnly="true"/>
<state pattern="%.2f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="fuel-open">
<item-type>Number:Volume</item-type>
<item-type unitHint="l,gal">Number:Volume</item-type>
<label>Open Fuel Capacity</label>
<state pattern="%.2f l" readOnly="true"/>
<state pattern="%.2f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="range-hybrid">
<item-type>Number:Length</item-type>
<item-type unitHint="km,mi">Number:Length</item-type>
<label>Hybrid Range</label>
<state pattern="%d km" readOnly="true"/>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
<channel-type id="radius-hybrid">
<item-type>Number:Length</item-type>
<item-type unitHint="km,mi">Number:Length</item-type>
<label>Hybrid Radius</label>
<state pattern="%d km" readOnly="true"/>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
</thing:thing-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="pressure-front-right">
<item-type>Number:Pressure</item-type>
<item-type unitHint="bar,psi">Number:Pressure</item-type>
<label>Tire Pressure Front Right</label>
<state pattern="%.1f bar" readOnly="true"/>
<state pattern="%.1f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="pressure-rear-right">
<item-type>Number:Pressure</item-type>
<item-type unitHint="bar,psi">Number:Pressure</item-type>
<label>Tire Pressure Rear Right</label>
<state pattern="%.1f bar" readOnly="true"/>
<state pattern="%.1f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="pressure-front-left">
<item-type>Number:Pressure</item-type>
<item-type unitHint="bar,psi">Number:Pressure</item-type>
<label>Tire Pressure Front Left</label>
<state pattern="%.1f bar" readOnly="true"/>
<state pattern="%.1f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="pressure-rear-left">
<item-type>Number:Pressure</item-type>
<item-type unitHint="bar,psi">Number:Pressure</item-type>
<label>Tire Pressure Rear Left</label>
<state pattern="%.1f bar" readOnly="true"/>
<state pattern="%.1f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="sensor-available">
<item-type>Number</item-type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="distance">
<item-type>Number:Length</item-type>
<item-type unitHint="km,mi">Number:Length</item-type>
<label>Trip Distance</label>
<state readOnly="true"/>
<state pattern="%.1f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="driven-time">
<item-type>String</item-type>
Expand All @@ -31,10 +31,10 @@
<state pattern="%.1f" readOnly="true"/>
</channel-type>
<channel-type id="distance-reset">
<item-type>Number:Length</item-type>
<item-type unitHint="km,mi">Number:Length</item-type>
<label>Rst Distance</label>
<description>Distance since last Reset</description>
<state readOnly="true"/>
<state pattern="%.1f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="driven-time-reset">
<item-type>String</item-type>
Expand Down
Loading

0 comments on commit 6eeffe4

Please sign in to comment.