|
14 | 14 |
|
15 | 15 | import org.eclipse.jdt.annotation.NonNullByDefault;
|
16 | 16 | import org.eclipse.jdt.annotation.Nullable;
|
| 17 | +import org.openhab.binding.automower.internal.rest.api.automowerconnect.dto.HeadlightMode; |
17 | 18 | import org.openhab.binding.automower.internal.things.AutomowerCommand;
|
18 | 19 | import org.openhab.binding.automower.internal.things.AutomowerHandler;
|
19 | 20 | import org.openhab.core.automation.annotation.ActionInput;
|
@@ -131,4 +132,131 @@ public void resumeSchedule() {
|
131 | 132 | public static void resumeSchedule(ThingActions actions) {
|
132 | 133 | ((AutomowerActions) actions).resumeSchedule();
|
133 | 134 | }
|
| 135 | + |
| 136 | + @RuleAction(label = "@text/action-confirm-error-label", description = "@text/action-confirm-error-desc") |
| 137 | + public void confirmError() { |
| 138 | + AutomowerHandler automowerHandler = handler; |
| 139 | + if (automowerHandler == null) { |
| 140 | + logger.warn("Automower Action service ThingHandler is null!"); |
| 141 | + } else { |
| 142 | + automowerHandler.sendAutomowerConfirmError(); |
| 143 | + } |
| 144 | + } |
| 145 | + |
| 146 | + public static void confirmError(ThingActions actions) { |
| 147 | + ((AutomowerActions) actions).confirmError(); |
| 148 | + } |
| 149 | + |
| 150 | + @RuleAction(label = "@text/action-reset-cutting-blade-usage-time-label", description = "@text/action-reset-cutting-blade-usage-time-desc") |
| 151 | + public void resetCuttingBladeUsageTime() { |
| 152 | + AutomowerHandler automowerHandler = handler; |
| 153 | + if (automowerHandler == null) { |
| 154 | + logger.warn("Automower Action service ThingHandler is null!"); |
| 155 | + } else { |
| 156 | + automowerHandler.sendAutomowerResetCuttingBladeUsageTime(); |
| 157 | + } |
| 158 | + } |
| 159 | + |
| 160 | + public static void resetCuttingBladeUsageTime(ThingActions actions) { |
| 161 | + ((AutomowerActions) actions).resetCuttingBladeUsageTime(); |
| 162 | + } |
| 163 | + |
| 164 | + @RuleAction(label = "@text/action-set-settings-label", description = "@text/action-set-settings-desc") |
| 165 | + public void setSettings( |
| 166 | + @ActionInput(name = "cutting-height", label = "@text/action-input-cutting-height-label", description = "@text/action-input-cutting-height-desc") @Nullable Byte cuttingHeight, |
| 167 | + @ActionInput(name = "headlight-mode", label = "@text/action-input-headlight-mode-label", description = "@text/action-input-headlight-mode-desc") @Nullable String headlightMode) { |
| 168 | + AutomowerHandler automowerHandler = handler; |
| 169 | + if (automowerHandler == null) { |
| 170 | + logger.warn("Automower Action service ThingHandler is null!"); |
| 171 | + } else { |
| 172 | + try { |
| 173 | + if (headlightMode != null) { |
| 174 | + automowerHandler.sendAutomowerSettings(cuttingHeight, HeadlightMode.valueOf(headlightMode)); |
| 175 | + } else { |
| 176 | + automowerHandler.sendAutomowerSettings(cuttingHeight, null); |
| 177 | + } |
| 178 | + } catch (IllegalArgumentException e) { |
| 179 | + logger.warn("Invalid HeadlightMode: {}, Error: {}", headlightMode, e.getMessage()); |
| 180 | + } |
| 181 | + } |
| 182 | + } |
| 183 | + |
| 184 | + public static void setSettings(ThingActions actions, @Nullable Byte cuttingHeight, @Nullable String headlightMode) { |
| 185 | + ((AutomowerActions) actions).setSettings(cuttingHeight, headlightMode); |
| 186 | + } |
| 187 | + |
| 188 | + @RuleAction(label = "@text/action-set-work-area-label", description = "@text/action-set-work-area-desc") |
| 189 | + public void setWorkArea( |
| 190 | + @ActionInput(name = "workarea-id", label = "@text/action-input-workarea-id-label", description = "@text/action-input-workarea-id-desc") long workAreaId, |
| 191 | + @ActionInput(name = "enable", label = "@text/action-input-enable-label", description = "@text/action-input-enable-desc") boolean enable, |
| 192 | + @ActionInput(name = "cutting-height", label = "@text/action-input-cutting-height-label", description = "@text/action-input-cutting-height-desc") byte cuttingHeight) { |
| 193 | + AutomowerHandler automowerHandler = handler; |
| 194 | + if (automowerHandler == null) { |
| 195 | + logger.warn("Automower Action service ThingHandler is null!"); |
| 196 | + } else { |
| 197 | + automowerHandler.sendAutomowerWorkArea(workAreaId, enable, cuttingHeight); |
| 198 | + } |
| 199 | + } |
| 200 | + |
| 201 | + public static void setWorkArea(ThingActions actions, long workAreaId, boolean enable, byte cuttingHeight) { |
| 202 | + ((AutomowerActions) actions).setWorkArea(workAreaId, enable, cuttingHeight); |
| 203 | + } |
| 204 | + |
| 205 | + @RuleAction(label = "@text/action-set-stayoutzone-label", description = "@text/action-set-stayoutzone-desc") |
| 206 | + public void setStayOutZone( |
| 207 | + @ActionInput(name = "zone-id", label = "@text/action-input-zone-id-label", description = "@text/action-input-zone-id-desc") String zoneId, |
| 208 | + @ActionInput(name = "enable", label = "@text/action-input-enable-label", description = "@text/action-input-enable-desc") boolean enable) { |
| 209 | + AutomowerHandler automowerHandler = handler; |
| 210 | + if (automowerHandler == null) { |
| 211 | + logger.warn("Automower Action service ThingHandler is null!"); |
| 212 | + } else { |
| 213 | + automowerHandler.sendAutomowerStayOutZone(zoneId, enable); |
| 214 | + } |
| 215 | + } |
| 216 | + |
| 217 | + public static void setStayOutZone(ThingActions actions, String zoneId, boolean enable) { |
| 218 | + ((AutomowerActions) actions).setStayOutZone(zoneId, enable); |
| 219 | + } |
| 220 | + |
| 221 | + @RuleAction(label = "@text/action-set-calendartask-label", description = "@text/action-set-calendartask-desc") |
| 222 | + public void setCalendarTask( |
| 223 | + @ActionInput(name = "workarea-id", label = "@text/action-input-workarea-id-label", description = "@text/action-input-workarea-id-desc") @Nullable Long workAreaId, |
| 224 | + @ActionInput(name = "start", label = "@text/action-input-start-label", description = "@text/action-input-start-desc") short[] start, |
| 225 | + @ActionInput(name = "duration", label = "@text/action-input-duration-label", description = "@text/action-input-duration-desc") short[] duration, |
| 226 | + @ActionInput(name = "monday", label = "@text/action-input-monday-label", description = "@text/action-input-monday-desc") boolean[] monday, |
| 227 | + @ActionInput(name = "tuesday", label = "@text/action-input-tuesday-label", description = "@text/action-input-tuesday-desc") boolean[] tuesday, |
| 228 | + @ActionInput(name = "wednesday", label = "@text/action-input-wednesday-label", description = "@text/action-input-wednesday-desc") boolean[] wednesday, |
| 229 | + @ActionInput(name = "thursday", label = "@text/action-input-thursday-label", description = "@text/action-input-thursday-desc") boolean[] thursday, |
| 230 | + @ActionInput(name = "friday", label = "@text/action-input-friday-label", description = "@text/action-input-friday-desc") boolean[] friday, |
| 231 | + @ActionInput(name = "saturday", label = "@text/action-input-saturday-label", description = "@text/action-input-saturday-desc") boolean[] saturday, |
| 232 | + @ActionInput(name = "sunday", label = "@text/action-input-sunday-label", description = "@text/action-input-sunday-desc") boolean[] sunday) { |
| 233 | + AutomowerHandler automowerHandler = handler; |
| 234 | + if (automowerHandler == null) { |
| 235 | + logger.warn("Automower Action service ThingHandler is null!"); |
| 236 | + } else { |
| 237 | + automowerHandler.sendAutomowerCalendarTask(workAreaId, start, duration, monday, tuesday, wednesday, |
| 238 | + thursday, friday, saturday, sunday); |
| 239 | + } |
| 240 | + } |
| 241 | + |
| 242 | + public static void setCalendarTask(ThingActions actions, @Nullable Long workAreaId, short[] start, short[] duration, |
| 243 | + boolean[] monday, boolean[] tuesday, boolean[] wednesday, boolean[] thursday, boolean[] friday, |
| 244 | + boolean[] saturday, boolean[] sunday) { |
| 245 | + ((AutomowerActions) actions).setCalendarTask(workAreaId, start, duration, monday, tuesday, wednesday, thursday, |
| 246 | + friday, saturday, sunday); |
| 247 | + } |
| 248 | + |
| 249 | + @RuleAction(label = "@text/action-poll-label", description = "@text/action-poll-desc") |
| 250 | + public void poll() { |
| 251 | + AutomowerHandler automowerHandler = handler; |
| 252 | + if (automowerHandler == null) { |
| 253 | + logger.warn("Automower Action service ThingHandler is null!"); |
| 254 | + } else { |
| 255 | + automowerHandler.poll(); |
| 256 | + } |
| 257 | + } |
| 258 | + |
| 259 | + public static void poll(ThingActions actions) { |
| 260 | + ((AutomowerActions) actions).poll(); |
| 261 | + } |
134 | 262 | }
|
0 commit comments