alko icon indicating copy to clipboard operation
alko copied to clipboard

Implement mowing window

Open jonkristian opened this issue 1 year ago • 1 comments

@udosw has already started some work around this. Adding it as a separate issue for clarity, as I'm sure this is something we would want to see added to the integration.

          I started with requesting the mowingWindows to see the structure of the json:

curl -s -X GET -H "Authorization: Bearer $TOKEN" -H "Accept: application/json" https://api.al-ko.com/v1/iot/things/${thingname}/state/reported | jq -r .mowingWindows This results in:

{
  "monday": {
[...]
  "sunday": {
    "window_1": {
      "activityMode": false,
      "marginMode": false,
      "startHour": 8,
      "startMinute": 0,
      "duration": 330,
      "entryPoint": 0,
      "narrowPassageMode": false
    },
    "window_2": {
      "activityMode": false,
      "marginMode": false,
      "startHour": 13,
      "startMinute": 30,
      "duration": 330,
      "entryPoint": 0,
      "narrowPassageMode": false
    }
  }
}

So the code to set a mowingWindow to active is:

curl -s -X PATCH -H "Authorization: Bearer $TOKEN" -H "Accept: application/json" https://api.al-ko.com/v1/iot/things/${thingname}/state/desired -d '{"mowingWindows": {"sunday": {"window_2": {"activityMode": true}}}}' You can even see the marker change from grey to red in the inTouch app realtime.

Originally posted by @udosw in https://github.com/jonkristian/alko/issues/6#issuecomment-2209501253

jonkristian avatar Jul 05 '24 23:07 jonkristian

Some hints from my side for setting the "entryPoint". Hopefully it helps. 32: start from basis 33: random 0 - 5: entry points 1 to 6 -> thingState.state.reported.entryPoints

Defined entry points in the mower: "thingState": { "state": { "reported": { "entryPoints": [ 10269, 814, -> entry point 1 1618, -> entry point 2 2266, -> entry point 3 3615, -> entry point 4 5627, -> entry point 5 9106 -> entry point 6 ], } } }

My restful command: rest_command: alko_mowingwindow_set: url: !secret alko_url_state_desired method: PATCH headers: Authorization: !secret alko_bearer Accept: application/json verify_ssl: true payload: | { "mowingWindows": { "{{ day }}": { "window_{{window}}": { "activityMode": {{ act }},"marginMode": {{ mar }},"narrowPassageMode": {{ pas }},"startHour": {{ hour }},"startMinute": {{ minute }},"duration": {{ duration }}, "entryPoint": {{ ep }} }}}}

Bubble card popup: Image

afuerhoff avatar Apr 14 '25 18:04 afuerhoff

Made some progress on this, do you think time and duration value ranges are sane? I also noticed in the mobile app that there's an option to set entryPoint to 'Automatic selected', not sure about that one but maybe it's enough with these options?:

            - label: "Base Station"
              value: 32
            - label: "Random"
              value: 33
            - label: "Start Point 1"
              value: 0
            - label: "Start Point 2"
              value: 1
            - label: "Start Point 3"
              value: 2
            - label: "Start Point 4"
              value: 3
            - label: "Start Point 5"
              value: 4
            - label: "Start Point 6"
              value: 5

Image

jonkristian avatar Jun 14 '25 09:06 jonkristian

The Automatic entry point corresponds to random. Start time and duration is ok for me. I think the entry point 1 to 6 is dependent to the mower model.

afuerhoff avatar Jun 14 '25 09:06 afuerhoff

I was looking into getting the entrypoints populated in the list, but I think that's gonna be hard to do. So maybe start with these fixed entry points and see how that goes. I still have some work left before i can get this shipped, but it's a start.

jonkristian avatar Jun 14 '25 09:06 jonkristian

For me it is ok. I know what you mean.

afuerhoff avatar Jun 14 '25 09:06 afuerhoff

Just seen. It gives an attribute configNumEntryPoints in the api.

afuerhoff avatar Jun 14 '25 18:06 afuerhoff

Yes, i saw that too, however only codes, no description of what they are, seems to be generated per user almost. I think for now, we can just let Entry Point be an empty input and possibly add in a new sensor with these values, for those that want to pass it, fine, but it also works without :)

jonkristian avatar Jun 14 '25 19:06 jonkristian

Implemented in v0.3.4

jonkristian avatar Jun 15 '25 13:06 jonkristian

Many thanks.

One Hint. Now I have several states double in the frontend. The old states are unavailable.

afuerhoff avatar Jun 15 '25 13:06 afuerhoff

Doubled? Or are some greyed out? I've added model prefix to all entities, so if you didn't re-add your device, you would get this, those that are greyed out can just be removed.

jonkristian avatar Jun 15 '25 13:06 jonkristian

Ok. Understand. See above. Just edited the post.

afuerhoff avatar Jun 15 '25 13:06 afuerhoff