Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[automower] Implementation of complete automower API [WIP] #17545

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.automower/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ All Husqvarna Automower models with "Automower Connect" should be supported. It

## Discovery

Once the bridge is created and configured, openHAB will automatically discover all Automowers registered on your account.
Once the bridge is created and configured, OpenHab will automatically discover all Automowers registered on your account.
lsiepel marked this conversation as resolved.
Show resolved Hide resolved

## Thing Configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ public class AutomowerBindingConstants {
public static final String CHANNEL_STATISTIC_NUMBER_OF_COLLISIONS = GROUP_STATUS + "stat-number-of-collisions";
public static final String CHANNEL_STATISTIC_TOTAL_CHARGING_TIME = GROUP_STATUS + "stat-total-charging-time";
public static final String CHANNEL_STATISTIC_TOTAL_CUTTING_TIME = GROUP_STATUS + "stat-total-cutting-time";
public static final String CHANNEL_STATISTIC_TOTAL_CUTTING_PERCENT = GROUP_STATUS + "stat-total-cutting-percent";
public static final String CHANNEL_STATISTIC_TOTAL_DRIVE_DISTANCE = GROUP_STATUS + "stat-total-drive-distance";
public static final String CHANNEL_STATISTIC_TOTAL_RUNNING_TIME = GROUP_STATUS + "stat-total-running-time";
public static final String CHANNEL_STATISTIC_TOTAL_SEARCHING_TIME = GROUP_STATUS + "stat-total-searching-time";
public static final String CHANNEL_STATISTIC_TOTAL_SEARCHING_PERCENT = GROUP_STATUS
+ "stat-total-searching-percent";

// Position Channels ids
public static final String GROUP_POSITIONS = ""; // no channel group in use at the moment, we'll possibly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,22 @@ private void updateChannelState(@Nullable Mower mower) {
updateState(CHANNEL_STATISTIC_TOTAL_SEARCHING_TIME,
new QuantityType<>(mower.getAttributes().getStatistics().getTotalSearchingTime(), Units.SECOND));

if (mower.getAttributes().getStatistics().getTotalRunningTime() != 0) {
updateState(CHANNEL_STATISTIC_TOTAL_CUTTING_PERCENT,
new QuantityType<>(
(float) mower.getAttributes().getStatistics().getTotalCuttingTime()
/ (float) mower.getAttributes().getStatistics().getTotalRunningTime() * 100.0,
Units.PERCENT));
updateState(CHANNEL_STATISTIC_TOTAL_SEARCHING_PERCENT,
new QuantityType<>(
(float) mower.getAttributes().getStatistics().getTotalSearchingTime()
/ (float) mower.getAttributes().getStatistics().getTotalRunningTime() * 100.0,
Units.PERCENT));
} else {
updateState(CHANNEL_STATISTIC_TOTAL_CUTTING_PERCENT, new QuantityType<>(0, Units.PERCENT));
updateState(CHANNEL_STATISTIC_TOTAL_SEARCHING_PERCENT, new QuantityType<>(0, Units.PERCENT));
}

updateState(LAST_POSITION,
new PointType(new DecimalType(mower.getAttributes().getLastPosition().getLatitude()),
new DecimalType(mower.getAttributes().getLastPosition().getLongitude())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@
<channel id="stat-number-of-collisions" typeId="statNumberOfCollisionsType"/>
<channel id="stat-total-charging-time" typeId="statTotalChargingTimeType"/>
<channel id="stat-total-cutting-time" typeId="statTotalCuttingTimeType"/>
<channel id="stat-total-cutting-percent" typeId="statTotalCuttingPercentType"/>
<channel id="stat-total-drive-distance" typeId="statTotalDriveDistanceType"/>
<channel id="stat-total-running-time" typeId="statTotalRunningTimeType"/>
<channel id="stat-total-searching-time" typeId="statTotalSearchingTimeType"/>
<channel id="stat-total-searching-percent" typeId="statTotalSearchingPercentType"/>

<!-- Commands -->
<channel id="start" typeId="start"/>
Expand Down Expand Up @@ -438,7 +440,7 @@
<item-type>Number:Time</item-type>
<label>Cutting Blade Usage Time</label>
<description>The time since the last reset of the cutting blade usage counter</description>
<state readOnly="true"/>
<state readOnly="true" pattern="%.1f h"/>
</channel-type>

<channel-type id="statNumberOfChargingCyclesType">
Expand All @@ -459,35 +461,49 @@
<item-type>Number:Time</item-type>
<label>Total Charging Time</label>
<description>Total charging time</description>
<state readOnly="true"/>
<state readOnly="true" pattern="%.1f h"/>
</channel-type>

<channel-type id="statTotalCuttingTimeType">
<item-type>Number:Time</item-type>
<label>Total Cutting Time</label>
<description>Total cutting time</description>
<state readOnly="true"/>
<state readOnly="true" pattern="%.1f h"/>
</channel-type>

<channel-type id="statTotalCuttingPercentType">
<item-type>Number:Dimensionless</item-type>
<label>Relative Total Cutting Time</label>
<description>Total cutting time in percent</description>
<state readOnly="true" pattern="%.1f %%"/>
</channel-type>

<channel-type id="statTotalDriveDistanceType">
<item-type>Number:Length</item-type>
<label>Total Drive Distance</label>
<description>Total driven distance</description>
<state readOnly="true"/>
<state readOnly="true" pattern="%.1f km"/>
</channel-type>

<channel-type id="statTotalRunningTimeType">
<item-type>Number:Time</item-type>
<label>Total Running Time</label>
<description>The total running time (the wheel motors have been running)</description>
<state readOnly="true"/>
<state readOnly="true" pattern="%.1f h"/>
</channel-type>

<channel-type id="statTotalSearchingTimeType">
<item-type>Number:Time</item-type>
<label>Total Searching Time</label>
<description>The total searching time</description>
<state readOnly="true"/>
<state readOnly="true" pattern="%.1f h"/>
</channel-type>

<channel-type id="statTotalSearchingPercentType">
<item-type>Number:Dimensionless</item-type>
<label>Relative Total Searching Time</label>
<description>The total searching time in percent</description>
<state readOnly="true" pattern="%.1f %%"/>
</channel-type>

<channel-type id="positionType">
Expand Down Expand Up @@ -546,7 +562,7 @@
<item-type>Number:Dimensionless</item-type>
<label>Cutting height in percent</label>
<description>Cutting height in percent. 0-100</description>
<state readOnly="true"/>
<state readOnly="true" pattern="%d %%"/>
</channel-type>

<channel-type id="workareasEnabledType">
Expand All @@ -560,7 +576,7 @@
<item-type>Number:Dimensionless</item-type>
<label>Work Area Progress</label>
<description>The progress on a work area. EPOS mowers and systematic mowing work areas only.</description>
<state readOnly="true"/>
<state readOnly="true" pattern="%d %%"/>
</channel-type>

<channel-type id="workareasLastTimeCompletedType">
Expand Down