Added speedtest skill

This commit is contained in:
Mathieu B 2021-08-01 18:25:40 +02:00
parent 8492038b38
commit 7957fd4ab5
3 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,32 @@
import speedtest
from jarvis.skills import Skill, SkillRegistering
from jarvis.skills.decorators import intent_file_handler
class SpeedTestSkill(Skill, metaclass=SkillRegistering):
def __init__(self, data=dict):
super().__init__("SpeedTestSkill", data)
@intent_file_handler("start_speedtest.intent", "StartSpeedTestIntent")
def handle_speedtest(self, data):
try:
self.speak_dialog('starting_speedtest')
speed = speedtest.Speedtest()
# speed.get_servers([])
speed.get_best_server()
speed.download()
speed.upload(pre_allocate=False)
# speed.results.share()
result = speed.results.dict()
down_speed = ('%.2f' % float((result["download"]) / 1000000))
up_speed = ('%.2f' % float((result["upload"]) / 1000000))
self.speak_dialog('result', {'DOWN': down_speed, 'UP': up_speed})
except:
self.speak_dialog("error")
def create_skill(data):
return SpeedTestSkill(data)

View File

@ -0,0 +1,3 @@
Votre débit est de {{DOWN}} mégabits descendant et {{UP}} montant
Vous atteignez des vitesses de {{DOWN}} mégabits en téléchargement et environ {{UP}} en envoi
Votre connexion atteint les {{DOWN}} mégabits en téléchargement et près de {{UP}} mégabits en envoi

View File

@ -0,0 +1 @@
(Lance|Fait|Test) (un|le) (test (de|du)|) (réseau|débit|speedtest)