continue work on ICE tacho

This commit is contained in:
Schrottkatze 2024-10-03 19:31:13 +02:00
parent f0b640eeed
commit effe29cd74
No known key found for this signature in database
2 changed files with 51 additions and 17 deletions

View file

@ -47,8 +47,19 @@
) )
) )
(defpoll iceData (defwidget iceTacho []
:interval "2s" (box
:initial "" :class "iceTacho"
`(iw dev wlp4s0 link | grep "WIFIonICE" > /dev/null) && curl https://iceportal.de/api1/rs/status` :tooltip "Tz${iceTachoData.tzn} (BR ${iceTachoData.br})"
(circular-progress
:value { iceTachoData.frac * 60 + 20 }
:thickness 3
)
(label :text "${iceTachoData.speed} km/h")
)
)
(deflisten iceTachoData
:initial "null"
{ "~/.config/eww/scripts/iceTacho.nu" }
) )

View file

@ -1,15 +1,38 @@
#!/usr/bin/env nu #!/usr/bin/env nu
const TABLE = [ const TABLE = {
[ br vmax ]; 401: 280
[ 401 280 ] 402: 280
[ 402 280 ] 403: 330
[ 403 330 ] 406: 330
[ 406 330 ] 407: 320
[ 407 320 ] 408: 320
[ 408 320 ] 411: 230
[ 411 230 ] 415: 230
[ 415 230 ] 412: 265
[ 412 265 ] 605: 200
[ 605 200 ] };
];
def main [ ] {
loop {
if ((iw dev wlp4s0 link | lines | filter {|it| $it =~ "WIFIonICE" } | length) == 1) {
let iceData = http get https://iceportal.de/api1/rs/status;
let tzn = $iceData.tzn;
let br = $iceData.series;
let speed = $iceData.speed;
let speedfrac = $speed / ($TABLE | get $br);
print ({
tzn: $tzn,
br: $br,
speed: $speed,
frac: $speedfrac
} | to json -r);
sleep 2sec;
} else {
print "null";
sleep 5sec;
}
}
}