Variables {
   seconde     1000
   five_secs   5000
   minute     60000
}

Display LCD2USB {
    Driver    'LCD2USB'
    Size      '16x2'
    Backlight 0
    Icons     1
}

Widget Hello {
    class 'Text'
    expression 'Hello LCD'
    width 9
}

Layout MyLayout {
    Row1 {
        Col1 'Hello'
    }
    Row2 {
        Col2 'Hello'
    }
}

Widget Date {
    class 'Text'
    expression strftime('%d/%m',time())
    width 5
    align 'L'
    update minute
}

Widget Time {
    class 'Text'
    expression strftime('%H:%M',time())
    width 5
    align 'L'
    update second
}

Layout MyLayout {
    Row1 {
        Col12 'Date'
    }
    Row2 {
        Col12 'Time'
    }
}

Widget Busy {
    class 'Text'
    expression proc_stat::cpu('busy', second)
    postfix '%'
    width 5
    precision 0
    align 'R'
    update second
}
Layout MyLayout {
    Row1 {
        Col1 'Busy'
        Col12 'Date'
    }
    Row2 {
        Col12 'Time'
    }
}

Plugin MySQL {
    server 'meteo.local'
    port 3306
    user 'user'
    password 'password'
    database 'meteo'
}

Widget MySQLTemp {
    class 'Text'
    expression MySQL::query('SELECT temperature FROM meteo.sensor_data WHERE sensor_id=1 order by date DESC limit 1;')
    width 4
    update minute
}

Widget Degree {
    class 'Icon'
    Bitmap {
        Row1 '.**..'
        Row2 '*..*.'
        Row3 '*..*.'
        Row4 '.**..'
        Row5 '.....'
        Row6 '.....'
        Row7 '.....'
        Row8 '.....'
    }
}

Layout MyLayout {
    Row1 {
        Col1 'Busy'
        Col12 'Date'
    }
    Row2 {
        Col1 'MySQLTemp'
        Col5 'Degree'
        Col12 'Time'
    }
}

#!/bin/bash
MY_APP_ID="NetworkMonitoring.app"
MY_APP_TOKEN="4uZTLMMwSyiPB42tSCWLpSSZbXIYi+d+F32tVMx2j1p8oSUUk4Awr/OMZne4RRlY"
. /home/seb/freeboxos-bash-api/freeboxos_bash_api.sh
login_freebox "$MY_APP_ID" "$MY_APP_TOKEN"
answer=$(call_freebox_api '/connection/')
rate_down=$(get_json_value_for_key "$answer" 'result.rate_down')
echo "$rate_down 1048576" | awk '{printf "%.1f", $1 / $2}' | tr , .

#!/bin/bash
MY_APP_ID="NetworkMonitoring.app"
MY_APP_TOKEN="4uZTLMMwSyiPB42tSCWLpSSZbXIYi+d+F32tVMx2j1p8oSUUk4Awr/OMZne4RRlY"
. /home/seb/freeboxos-bash-api/freeboxos_bash_api.sh
login_freebox "$MY_APP_ID" "$MY_APP_TOKEN"
answer=$(call_freebox_api '/connection/')
rate_up=$(get_json_value_for_key "$answer" 'result.rate_up')
echo "$rate_up 1024" | awk '{printf "%d", $1 / $2}' | tr , .

Widget DownRate {
    class 'Text'
    expression exec('/home/seb/freeboxos-bash-api/rate_down.sh', five_secs)
    prefix 'D'
    width 4
    align 'R'
    update five_secs
}

Widget UpRate {
    class 'Text'
    expression exec('/home/seb/freeboxos-bash-api/rate_up.sh', five_secs)
    prefix 'U'
    width 4
    align 'R'
    update five_secs
}

Layout MyLayout {
    Row1 {
        Col1 'Busy'
        Col7 'UpRate'
        Col12 'Date'
    }
    Row2 {
        Col1 'MySQLTemp'
        Col5 'Degree'
        Col7 'DownRate'
        Col12 'Time'
    }
}