alko
alko copied to clipboard
Implement mowing window
@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
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:
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
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.
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.
For me it is ok. I know what you mean.
Just seen. It gives an attribute configNumEntryPoints in the api.
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 :)
Implemented in v0.3.4
Many thanks.
One Hint. Now I have several states double in the frontend. The old states are unavailable.
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.
Ok. Understand. See above. Just edited the post.