MycroftAI / skill-homeassistant

Mycroft Skill/Integration for Homeassistant
GNU Lesser General Public License v3.0
114 stars 62 forks source link

Language issue #25

Closed iditude closed 4 years ago

iditude commented 4 years ago

Hello,

I'm trying to use the skill and it works perfectly in English. However in french (configured by "lang": "fr-fr", in mycroft.conf), no keywords work. For instance I use "allume XXX" which is the equivalent to "turn on XXX" (according to this https://translate.mycroft.ai/fr/mycroft-skills/translate/homeassistant-fr.po#search=allume&sfields=source,target&unit=134631&offset=0) but faced with a blank response "Sorry I don't understand".

Logs are below.

Anything I'm doing wrong to change language?

Thanks

 10:52:23.476 | DEBUG    |   675 | mycroft.skills.intent_service:handle_utterance:329 | Utterances: ['allume entree']
~~~~lls.intent_service:handle_utterance:349 | Padatious intent: {'name': 'mycroft-stop.mycroftai:reboot.intent', 'sent': 'allume entree', 'matches': {}, 'conf': 0.17207702686938922}
 10:52:23.584 | DEBUG    |   675 | mycroft.skills.intent_service:handle_utterance:350 |     Adapt intent: None
 10:52:23.592 | DEBUG    |   675 | mycroft.skills.padatious_service:handle_fallback:157 | Padatious fallback attempt: allume entree
 10:52:23.593 | INFO     |   675 | QuestionsAnswersSkill | Searching for allume entree
 10:52:23.597 | DEBUG    |   675 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: fallback-query.mycroftai:QuestionQueryTimeout
 10:52:23.648 | DEBUG    |   675 | WolframAlphaSkill | WolframAlpha query: allume entree
Removing event fallback-query.mycroftai:QuestionQueryTimeout
 10:52:23.658 | DEBUG    |   675 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: fallback-query.mycroftai:QuestionQueryTimeout
Removing event fallback-query.mycroftai:QuestionQueryTimeout
 10:52:23.663 | DEBUG    |   675 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: fallback-query.mycroftai:QuestionQueryTimeout
 10:52:23.703 | DEBUG    |   675 | WolframAlphaSkill | translation: light entry
 10:52:23.704 | DEBUG    |   675 | WolframAlphaSkill | Non-question, ignoring: light entry
Removing event fallback-query.mycroftai:QuestionQueryTimeout
 10:52:23.749 | DEBUG    |   675 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: fallback-query.mycroftai:QuestionQueryTimeout
Removing event fallback-query.mycroftai:QuestionQueryTimeout
10:52:24.191 | INFO     |   675 | QuestionsAnswersSkill | Timeout occured check responses
 10:52:24.600 | DEBUG    |   675 | mycroft.skills.padatious_service:handle_fallback:157 | Padatious fallback attempt: allume entree
 10:52:30.103 | DEBUG    |   675 | urllib3.connectionpool | Starting new HTTPS connection (1): api.mycroft.ai:443
 10:52:30.468 | DEBUG    |   675 | urllib3.connectionpool | https://api.mycroft.ai:443 "GET /v1/device/aa930e2b-a455-40d8-840e-b25d3be1e668/skill/settings HTTP/1.1" 304 0
 10:52:30.475 | DEBUG    |   675 | mycroft.skills.settings:download:365 | No skill settings changes since last download
 10:53:07.251 | DEBUG    |   675 | urllib3.connectionpool | Starting new HTTPS connection (1): api.mycroft.ai:443
 10:53:07.622 | DEBUG    |   675 | urllib3.connectionpool | https://api.mycroft.ai:443 "GET /v1/device/aa930e2b-a455-40d8-840e-b25d3be1e668/setting HTTP/1.1" 304 0
 10:53:07.630 | DEBUG    |   675 | urllib3.connectionpool | Starting new HTTPS connection (1): api.mycroft.ai:443
 10:53:07.984 | DEBUG    |   675 | urllib3.connectionpool | https://api.mycroft.ai:443 "GET /v1/device/aa930e2b-a455-40d8-840e-b25d3be1e668/location HTTP/1.1" 304 0
  ^--- NEWEST ---^ 
forslund commented 4 years ago

Hi,

as part of the v20.02 updates the french translations has been included in the released skill. It would be great if you could retry now.

Thanks

iditude commented 4 years ago

Hello,

Thanks for the help. I can't get Homeassistant to properly install anymore on 20.2.

Here are the debug logs. Any ideas?

Thanks

~~~~DEBUG    |   673 | git.repo.base | Cmd(['git', 'clone', '-v', 'https://github.com/MycroftAI/mycroft-homeassistant', '/tmp/tmppgqv__wq'])'s unused stdout:
~~~~| Popen(['git', 'reset', '--hard', '985c4013205d0ef3a55fc7aa3859f52cf1796e9b'], cwd=/tmp/tmppgqv__wq, universal_newlines=False, shell=None, istream=None)
 12:11:15.223 | INFO     |   673 | msm.skill_entry | Installing system requirements...
~~~~   |   673 | mycroft.skills.skill_manager:_get_skill_directories:279 | Found skills directory with no skill: /opt/mycroft/skills/homeassistant.mycroftai/
 12:11:15.294 | INFO     |   673 | msm.skill_entry | Installing requirements.txt for homeassistant
~~~~   |   673 | mycroft.skills.skill_manager:_get_skill_directories:279 | Found skills directory with no skill: /opt/mycroft/skills/homeassistant.mycroftai/
~~~~   |   673 | mycroft.skills.skill_manager:_get_skill_directories:279 | Found skills directory with no skill: /opt/mycroft/skills/homeassistant.mycroftai/
 12:11:15.721 | DEBUG    |   679 | urllib3.connectionpool | https://api.mycroft.ai:443 "POST /v1/stt?lang=fr-FR&limit=1 HTTP/1.1" 200 3
 12:11:15.763 | DEBUG    |   679 | urllib3.connectionpool | Starting new HTTPS connection (1): api.mycroft.ai:443
 12:11:15.764 | DEBUG    |   679 | mycroft.client.speech.mic:listen:619 | Waiting for wake word...
 12:11:16.630 | DEBUG    |   679 | urllib3.connectionpool | https://api.mycroft.ai:443 "POST /v1/stt?lang=fr-FR&limit=1 HTTP/1.1" 200 3
 12:11:16.643 | ERROR    |   679 | mycroft.client.speech.listener:transcribe:239 | list index out of range
 12:11:16.645 | ERROR    |   679 | mycroft.client.speech.listener:transcribe:240 | Speech Recognition could not understand audio
~~~~   |   673 | mycroft.skills.skill_manager:_get_skill_directories:279 | Found skills directory with no skill: /opt/mycroft/skills/homeassistant.mycroftai/
~~~~   |   673 | mycroft.skills.skill_manager:_get_skill_directories:279 | Found skills directory with no skill: /opt/mycroft/skills/homeassistant.mycroftai/
~~~~   |   673 | mycroft.skills.skill_manager:_get_skill_directories:279 | Found skills directory with no skill: /opt/mycroft/skills/homeassistant.mycroftai/
 12:11:18.903 | INFO     |   673 | msm.skill_entry | Successfully installed homeassistant
 12:11:18.904 | INFO     |   673 | msm.mycroft_skills_manager | invalidating skills cache
 12:11:18.925 | DEBUG    |   673 | urllib3.connectionpool | Starting new HTTPS connection (1): api.mycroft.ai:443
 12:11:19.928 | DEBUG    |   673 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: mycroft.stop
 12:11:19.931 | DEBUG    |   673 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: mycroft.skill.enable_intent
 12:11:19.934 | DEBUG    |   673 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: mycroft.skill.disable_intent
 12:11:19.936 | DEBUG    |   673 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: mycroft.skill.set_cross_context
 12:11:19.939 | DEBUG    |   673 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: mycroft.skill.remove_cross_context
 12:11:19.941 | DEBUG    |   673 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: mycroft.skills.settings.changed
 12:11:19.944 | DEBUG    |   673 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: homeassistant.mycroftai.set
 12:11:19.984 | DEBUG    |   673 | mycroft.skills.skill_data:load_regex_from_file:64 | regex pre-munge: (?P<Action>allume|éteins|commute) (?P<Entity>.*)
~~~~lls.skill_data:load_regex_from_file:66 | regex post-munge: (?P<homeassistant_mycroftaiAction>allume|éteins|commute) (?P<homeassistant_mycroftaiEntity>.*)
~~~~ile:64 | regex pre-munge: (?P<Action>allume|éteins|commute) (?P<Entity>tous les|toutes les) (?P<Domain>interrupteur(s)?|lumière(s)?|(boolean )?input(s)?)
~~~~eins|commute) (?P<homeassistant_mycroftaiEntity>tous les|toutes les) (?P<homeassistant_mycroftaiDomain>interrupteur(s)?|lumière(s)?|(boolean )?input(s)?)
~~~~ 673 | mycroft.skills.skill_data:load_regex_from_file:64 | regex pre-munge: ((tourne|mets|commute) )?(?P<Entity>.*) (?P<Action>en marche|on|en arrêt|off)
~~~~m_file:66 | regex post-munge: ((tourne|mets|commute) )?(?P<homeassistant_mycroftaiEntity>.*) (?P<homeassistant_mycroftaiAction>en marche|on|en arrêt|off)
 12:11:20.006 | DEBUG    |   673 | mycroft.skills.skill_data:load_regex_from_file:64 | regex pre-munge: (allume|active|lance|appelle) (?P<Entity>.*)
~~~~UG    |   673 | mycroft.skills.skill_data:load_regex_from_file:66 | regex post-munge: (allume|active|lance|appelle) (?P<homeassistant_mycroftaiEntity>.*)
 12:11:20.011 | DEBUG    |   673 | mycroft.skills.skill_data:load_regex_from_file:64 | regex pre-munge: (?P<Value>100?%|[1-9][0-9]?%?)(\D|$)
~~~~15 | DEBUG    |   673 | mycroft.skills.skill_data:load_regex_from_file:66 | regex post-munge: (?P<homeassistant_mycroftaiValue>100?%|[1-9][0-9]?%?)(\D|$)
~~~~l_data:load_regex_from_file:64 | regex pre-munge: (mets|règles) (?:(l'intensité de|la lumière))?(?P<Entity>.*) (à) (?P<BrightnessValue>\d*)(?: pourcent)?
~~~~ge: (mets|règles) (?:(l'intensité de|la lumière))?(?P<homeassistant_mycroftaiEntity>.*) (à) (?P<homeassistant_mycroftaiBrightnessValue>\d*)(?: pourcent)?
~~~~e-munge: (tamise|illumine|augmente|monte|diminue|descend) (?:(l'intensité de|la lumière))?(?P<Entity>.*?) (?:de)? (?P<BrightnessValue>\d*)?(?: pourcent)?
~~~~ue|descend) (?:(l'intensité de|la lumière))?(?P<homeassistant_mycroftaiEntity>.*?) (?:de)? (?P<homeassistant_mycroftaiBrightnessValue>\d*)?(?: pourcent)?
~~~~ DEBUG    |   673 | mycroft.skills.skill_data:load_regex_from_file:64 | regex pre-munge: (quel|quelle) est (l'état|le statut|la valeur) de (?P<Entity>.*)
~~~~oft.skills.skill_data:load_regex_from_file:66 | regex post-munge: (quel|quelle) est (l'état|le statut|la valeur) de (?P<homeassistant_mycroftaiEntity>.*)
~~~~UG    |   673 | mycroft.skills.skill_data:load_regex_from_file:64 | regex pre-munge: (quelle|quel) est (le|la|l')?(état|statut|valeur) de ?(?P<Entity>.*)
~~~~skills.skill_data:load_regex_from_file:66 | regex post-munge: (quelle|quel) est (le|la|l')?(état|statut|valeur) de ?(?P<homeassistant_mycroftaiEntity>.*)
~~~~EBUG    |   673 | mycroft.skills.skill_data:load_regex_from_file:64 | regex pre-munge: (dis|donne) moi (le|la|l')?(statut|état|valeur) de ?(?P<Entity>.*)
~~~~t.skills.skill_data:load_regex_from_file:66 | regex post-munge: (dis|donne) moi (le|la|l')?(statut|état|valeur) de ?(?P<homeassistant_mycroftaiEntity>.*)
~~~~ |   673 | mycroft.skills.skill_data:load_regex_from_file:64 | regex pre-munge: lis (à haute voix )?(le|la|l' )?(statut|état|valeur) (de )?(?P<Entity>.*)
~~~~s.skill_data:load_regex_from_file:66 | regex post-munge: lis (à haute voix )?(le|la|l' )?(statut|état|valeur) (de )?(?P<homeassistant_mycroftaiEntity>.*)
~~~~UG    |   673 | mycroft.skills.skill_data:load_regex_from_file:64 | regex pre-munge: lit (à haute voix )?(le|la[l' )?(état|valeur|capteur) (?P<Entity>.*)
~~~~skills.skill_data:load_regex_from_file:66 | regex post-munge: lit (à haute voix )?(le|la[l' )?(état|valeur|capteur) (?P<homeassistant_mycroftaiEntity>.*)
 12:11:20.109 | WARNING  |   673 | mycroft.skills.fallback_skill:remove_fallback:139 | Could not remove fallback!
 12:11:20.116 | DEBUG    |   673 | mycroft.messagebus.client.client:remove:169 | Removing found 'mycroft.stop'
 12:11:20.124 | DEBUG    |   673 | mycroft.messagebus.client.client:remove:169 | Removing found 'mycroft.skill.enable_intent'
 12:11:20.128 | DEBUG    |   673 | mycroft.messagebus.client.client:remove:169 | Removing found 'mycroft.skill.disable_intent'
 12:11:20.131 | DEBUG    |   673 | mycroft.messagebus.client.client:remove:169 | Removing found 'mycroft.skill.set_cross_context'
 12:11:20.133 | DEBUG    |   673 | mycroft.messagebus.client.client:remove:169 | Removing found 'mycroft.skill.remove_cross_context'
12:11:20.138 | DEBUG    |   673 | mycroft.messagebus.client.client:remove:169 | Removing found 'mycroft.skills.settings.changed'
 12:11:20.141 | DEBUG    |   673 | mycroft.messagebus.client.client:remove:169 | Removing found 'homeassistant.mycroftai.set'
~~~~   |   673 | mycroft.skills.skill_loader:_create_skill_instance:249 | Skill initialization failed with error('unterminated character set at position 26')
Traceback (most recent call last):
  File "/home/pi/mycroft-core/mycroft/skills/skill_loader.py", line 238, in _create_skill_instance
    self.instance.load_data_files()
  File "/home/pi/mycroft-core/mycroft/skills/mycroft_skill/mycroft_skill.py", line 1140, in load_data_files
    self.load_regex_files(root_directory)
  File "/home/pi/mycroft-core/mycroft/skills/mycroft_skill/mycroft_skill.py", line 1177, in load_regex_files
    regexes = load_regex(regex_dir, self.skill_id)
  File "/home/pi/mycroft-core/mycroft/skills/skill_data.py", line 107, in load_regex
    regexes += load_regex_from_file(join(path, f), skill_id)
  File "/home/pi/mycroft-core/mycroft/skills/skill_data.py", line 68, in load_regex_from_file
    re.compile(regex)
  File "/usr/lib/python3.7/re.py", line 234, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.7/re.py", line 286, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.7/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.7/sre_parse.py", line 930, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.7/sre_parse.py", line 426, in _parse_sub
    not nested and not items))
  File "/usr/lib/python3.7/sre_parse.py", line 816, in _parse
    p = _parse_sub(source, state, sub_verbose, nested + 1)
  File "/usr/lib/python3.7/sre_parse.py", line 426, in _parse_sub
    not nested and not items))
  File "/usr/lib/python3.7/sre_parse.py", line 532, in _parse
    source.tell() - here)
re.error: unterminated character set at position 26
 12:11:20.156 | ERROR    |   673 | mycroft.skills.skill_loader:_communicate_load_status:286 | Skill homeassistant.mycroftai failed to load
iditude commented 4 years ago

Answering to myself: I can install the skill in English and then switch mycroft language to fr-fr. So it's only an install issue for foreign language.

The main issue remains though. No understanding from Mycroft in FR (while works perfectly in EN).

Thanks

forslund commented 4 years ago

Thanks for reporting, Sounds a bit like an incorrectly translated regex. Will verify when I'm at acomputer

andlo commented 4 years ago

I have simalar issue in danish. Some of the regex files were badly and it errors out when loading. I did copy the sv-se files to danish one by one until it worked and then I translated that file by hand....

forslund commented 4 years ago

pythex seem to indicate%3F(%3FP%3CEntity%3E.%3F)%20(%3F%3Ade)%3F%20(%3FP%3CBrightnessValue%3E%5Cd)%3F(%3F%3A%20pourcent)%3F&test_string=&ignorecase=0&multiline=0&dotall=0&verbose=0) dimming.rx in the fr-fr isn't correct and a tleast one of the lines in sensore.rx (pythex)

... also seems to be a couple of more...

The first one I'm not quite sure what's the matter, the second is a missing ]

iditude commented 4 years ago

Hello,

Thanks for looking into this. I was able to find indeed a few mistakes. I don't know how to make those changes to the code though.

in dimming.rx change the line

(tamise|illumine|augmente|monte|diminue|descend) (?:(l'intensité de|la lumière))?(?P<Entity>.*?) (?:de)? (?P<BrightnessValue>\d*)?(?: pourcent)? to (tamise|illumine|augmente|monte|diminue|descend) (?:(l'intensité de|la lumière))?(?P<Entity>.*?) (?:de)? (?P<BrightnessValue>\d*)(?: pourcent)?

in sensor.rx change the lines lis (à haute voix )?(le|la|l' )?(statut|état|valeur) (de )?(?P<Entity>.*) to lis (à haute voix )?(le|la|l')?(statut|état|valeur) (de )?(?P<Entity>.*)

and lit (à haute voix )?(le|la[l' )?(état|valeur|capteur) (?P<Entity>.*) to lit (à haute voix )?(le|la|l')?(état|valeur|capteur) (?P<Entity>.*)

I don't know how to change the code myself in my install as I get a warning of code change in the log.

Thanks

iditude commented 4 years ago

Hello, any idea? Thanks

andlo commented 4 years ago

What warnig do you get ? You should be able to cange whatever you want, and then skillmanager pickups that there is changes and reloads the skill. So maybe the warning is just about you changed something?

iditude commented 4 years ago

Thanks for the help. The error message I'm getting during load is the following:

~~~~ | ERROR    |  1230 | msm.mycroft_skills_manager | Error running install_or_update on homeassistant: SkillModified(Uncommitted changes:
         M regex/fr-fr/dimming.rx
         M regex/fr-fr/sensor.rx
)

As far as request is confirmed. Asking for "allume entree" (entree being a home assistant entity to turn on), this is what I get in debug:

~~~~ntent: {'name': 'mycroft-installer.mycroftai:install.beta.intent', 'sent': 'allume entree', 'matches': {}, 'conf': 0.10994971366593027}
 14:50:12.979 | DEBUG    |  3806 | mycroft.skills.intent_service:handle_utterance:364 |     Adapt intent: None
 14:50:12.986 | DEBUG    |  3806 | mycroft.skills.padatious_service:handle_fallback:164 | Padatious fallback attempt: allume entree
 14:50:12.987 | INFO     |  3806 | QuestionsAnswersSkill | Searching for allume entree
~~~~ | DEBUG    |  3806 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: fallback-query.mycroftai:QuestionQueryTimeout
 14:50:13.046 | DEBUG    |  3806 | WolframAlphaSkill | WolframAlpha query: allume entree
Removing event fallback-query.mycroftai:QuestionQueryTimeout
~~~~ | DEBUG    |  3806 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: fallback-query.mycroftai:QuestionQueryTimeout
Removing event fallback-query.mycroftai:QuestionQueryTimeout
~~~~ | DEBUG    |  3806 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: fallback-query.mycroftai:QuestionQueryTimeout
 14:50:13.108 | DEBUG    |  3806 | WolframAlphaSkill | translation: light entry
 14:50:13.108 | DEBUG    |  3806 | WolframAlphaSkill | Non-question, ignoring: light entry
Removing event fallback-query.mycroftai:QuestionQueryTimeout
~~~~ | DEBUG    |  3806 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: fallback-query.mycroftai:QuestionQueryTimeout
~~~~urllib3.connectionpool | https://api.mycroft.ai:443 "GET /v1/device/aa930e2b-a455-40d8-840e-b25d3be1e668/skill/settings HTTP/1.1" 304 0
 14:50:13.245 | DEBUG    |  3806 | mycroft.skills.settings:download:361 | No skill settings changes since last download
Removing event fallback-query.mycroftai:QuestionQueryTimeout
 14:50:14.150 | INFO     |  3806 | QuestionsAnswersSkill | Timeout occured check responses
 14:50:14.998 | DEBUG    |  3806 | mycroft.skills.padatious_service:handle_fallback:164 | Padatious fallback attempt: allume entree

There's nothing about homeassistant so it's not even picking up. Any ideas?

Thanks

andlo commented 4 years ago

That looks like the to files dimming.rx and has some errors. Edit those and correct - what is correct I cant tell, as I am not good at regex, but you can look into the same files in en-us filder and maybe see what is different and correc acording to that.

It can be as simple as a space the wrong place or an entityname beeing translated.

I dont know why the new french translatios is pulled from translation server if there the files dont pass regex test.

when and if you figure out what is wrong please go to translate.mycroft.ai and correct the errors if you can locate them.

iditude commented 4 years ago

OK so I'm not sure how to correct this. The fact is, the english version shows the same error in dimming.rx

https://pythex.org/?regex=(dim%7Cbrighten%7Cincrease%7Cdecrease)%20(%3F%3Abrightness%20of%20)%3F(%3FP%3CEntity%3E.*%3F)%20(%3F%3Aby)%3F%20(%3FP%3CBrightnessValue%3E%5Cd*)%3F(%3F%3A%20percent)%3F&test_string=Today%20is%202020-03-15.&ignorecase=0&multiline=0&dotall=0&verbose=0

the same line as the FR one we need to remove a question mark to fix it.

(dim|brighten|increase|decrease) (?:brightness of )?(?P<Entity>.*?) (?:by)? (?P<BrightnessValue>\d*)?(?: percent)?

to

(dim|brighten|increase|decrease) (?:brightness of )?(?P<Entity>.*?) (?:by)? (?P<BrightnessValue>\d*)(?: percent)?

Any ideas?

kamir86 commented 4 years ago

Hello, i fixed the same problem on italian language. The problem is that an adapt intent is used for example in "turn on/off" command. The adapt intent extrapolate the "on" or "off" word from the utterance and then it uses that word as is to call home assistant service, but almost all the other languages don't use those keywords on utterance.
This lead the home assistant service call to fail. I found an hack on code for the german language (https://github.com/MycroftAI/mycroft-homeassistant/blob/20.02/__init__.py#L199) in order to avoid that fail.

I replaced the adapt intent with three padatious intents (one for turning on, one for turning off, one for toggle) and that fixed the root cause of the problem.

I can submit a pull request for english and italian, but i need translation support for the other languages.

Tony763 commented 4 years ago

@kamir86 could you upload your code? I am working on czech support so it would help me.

kamir86 commented 4 years ago

hello @Tony763 here's my patch described above: https://github.com/kamir86/mycroft-homeassistant/commit/d8dcd3e0e583e17f50e8e6618636baae97fd96bf

Tony763 commented 4 years ago

Good job @kamir86, For czech support I need a turn on/of action divided as we us only one word action. My friend @Manasovo will send you a PR with DE translation. I am not sure if other languages worked.

kamir86 commented 4 years ago

Great, with DE translation I think we can also safely remove the hackish "if" that I found in code

Manasovo commented 4 years ago

on the place ... https://github.com/kamir86/mycroft-homeassistant/pull/1/commits/d12849e55169310e4ab0bff4e56022450e452038

Tony763 commented 4 years ago

@kamir86 I have also problem with Adapt for other actions, only your Padatious actions works. I will rewrite all actions from Adapt to Padatious for English and Czech and send it to your repo. Now works: Turn on/off/toggle, sensor.

iditude commented 4 years ago

Hello,

I'm happy to support for french, but have no coding experience. What can I do?

Thanks

Tony763 commented 4 years ago

For now you can copy turn.on.intent (off and toggle) from vocab/en-us in kamir86 branch to fr-fr, translate them and test them. If they will work, you can send them as PR. I will try to send PR with rewrited sensor tonight.

kamir86 commented 4 years ago

Hello @iditude , if you're not familiare with github you can also translate these sentences: toggle {Entity} switch {Entity} Can you toggle {Entity} please? Can you switch {Entity} please? I'd like to switch {Entity} I'd like to toggle {Entity}

turn off {Entity} Can you turn off {Entity} please? I'd like to turn off {Entity} I would like {Entity} off

turn on {Entity} Can you turn on {Entity} please? I'd like to turn on {Entity} I would like {Entity} on

A little note, I think that french has "articles" (le, les) like Italian. You can write optional part of your sentence using left and right parentheses and pipe (or operator). For example: I'd like (the|) {Entity} (light|) on Matches: 1- I'd like bedroom on 2- I'd like the bedroom light on 3- I'd like bedroom light on 4- I'd like the bedroom on

Tony763 commented 4 years ago

@kamir86 I send you PR with rewrited sensor, CS support and some clean up, I will rewrite next intents in next few days.

Tony763 commented 4 years ago

@andlo All intens were rewrited, @kamir86 have them on his fork. We will need to re-translate them. CS, EN and IT will be done. I read that you are Danish so if you have time, could You also participace? Do you know a way how to push changes back to translate.mycroft platform?

iditude commented 4 years ago

Hello,

Please find FR translations. The one thing I'm not sure is formatting for the pronoumn. For instance when used "le" or "la" there is a space separating with the entity name "la chambre" but when using "l'", there is no space (e.g. the hallway is "l'entrée"). Not sure how to capture this using "(le|la|l') {Entity}" in the code below

Thanks!

bascules (le|la|l') {Entity} changes (le|la|l') {Entity} peux-tu basculer (le|la|l') {Entity} s'il te plait? peux-tu changer (le|la|l') {Entity} s'il te plait? je voudrais basculer (le|la|l') {Entity} je voudrais changer (le|la|l') {Entity}

éteins (le|la|l') {Entity} peux-tu éteindre (le|la|l') {Entity} s'il te plait? je voudrais éteindre (le|la|l') {Entity}

allumes (le|la|l') {Entity} peux-tu allumer (le|la|l') {Entity} s'il te plait? je voudrais allumer (le|la|l') {Entity}

Tony763 commented 4 years ago

Hello, try this fork and let me know

Gotanius commented 4 years ago

I seem to be having a related issue. When I'm running mycroft in dutch (nl-nl) and this skill it won't recognize my intent/requests. Giving either responses about not understanding me or about not knowing how to communicate with home assistant. When I change mycroft to en-us it works fine with home assistant.

2020-06-15 15:20:28.067 | INFO | 31240 | QuestionsAnswersSkill | Searching for schakel boog lamp in Removing event fallback-query.mycroftai:QuestionQueryTimeout Removing event fallback-query.mycroftai:QuestionQueryTimeout Removing event fallback-query.mycroftai:QuestionQueryTimeout Removing event fallback-query.mycroftai:QuestionQueryTimeout 2020-06-15 15:20:29.319 | INFO | 31240 | QuestionsAnswersSkill | Timeout occured check responses

Maybe the solution for german and italian will also wor for dutch. I've added the translations below: Schakel (de|het) {Entity} om Zet (de|het) {Entity} om Kan je (de|het) {Entity} alsjeblieft omzetten? Kan je (de|het) {Entity} alsjeblief omschakelen? Ik wil (de|het) {Entity} omschakelen Ik wil (de|het) {Entity} omzetten

Zet (de|het) {Entity} uit Kan je (de|het) {Entity} alsjeblieft uitzetten? Ik wil graag (de|het) {Entity} uitzetten Kan (de|het) {Entity} uit

Zet (de|het) {Entity}aan Kan je (de|het) {Entity} alsjeblieft? Ik wil graag (de|het) {Entity} aanzetten Kan (de|het) {Entity} aan

kamir86 commented 4 years ago

@Gotanius it'll work also for dutch I'll update my branch as soon as possible

Gotanius commented 4 years ago

I've created a fork and translated the nl-nl vocab files. Weird issue is now that I get a invalid token error. Even though the token is correct. I even created a new token to test it. Any idea what is causing this?

kamir86 commented 4 years ago

You can check your hassio token configuration following this guide https://developers.home-assistant.io/docs/auth_api/#making-authenticated-requests . If all is correct and you're able to make a request with your token maybe there's some bug on plugin code. My installation works fine.

Gotanius commented 4 years ago

hmm I tried your fork and it seems to work (in english of course). When adding my own translations, fixing numvalue and trying to run it on nl-nl I'm getting

20:14:25.753` | ERROR    |  3099 | mycroft.skills.skill_loader:_create_skill_instance:249 | Skill initialization failed with error('nothing to repeat at position 0')
Traceback (most recent call last):
File "/home/pi/mycroft-core/mycroft/skills/skill_loader.py", line 238, in _create_skill_instance
    self.instance.load_data_files()
  File "/home/pi/mycroft-core/mycroft/skills/mycroft_skill/mycroft_skill.py", line 1180, in load_data_files
    self.load_regex_files(root_directory)
  File "/home/pi/mycroft-core/mycroft/skills/mycroft_skill/mycroft_skill.py", line 1217, in load_regex_files
    regexes = load_regex(regex_dir, self.skill_id)
  File "/home/pi/mycroft-core/mycroft/skills/skill_data.py", line 107, in load_regex
    regexes += load_regex_from_file(join(path, f), skill_id)
  File "/home/pi/mycroft-core/mycroft/skills/skill_data.py", line 68, in load_regex_from_file
    re.compile(regex)
  File "/usr/lib/python3.7/re.py", line 234, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.7/re.py", line 286, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.7/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.7/sre_parse.py", line 930, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.7/sre_parse.py", line 426, in _parse_sub
    not nested and not items))
  File "/usr/lib/python3.7/sre_parse.py", line 651, in _parse
    source.tell() - here + len(this))
re.error: nothing to repeat at position 0

Using en-us vocab/regex seems to fix this. I'll try to debug/translate these tomorrow.

kamir86 commented 4 years ago

May I have a patch file of your work for review?

Tony763 commented 4 years ago

@Gotanius: Helo, try my fork, it is based on @kamir86 branch, with all rewrited intents to Padatious, no need to mesh with regex any more and fixes for few issues. If anything not work, I can help.

Gotanius commented 4 years ago

@kamir86 I'm a total github n00b so I'm not sure how to give you a patch file. I can however point you to the fork I made based on @Tony763 fork.

@Tony763 when I try your fork (in en-us) I get issues regarding the home assistant server not accepting my token. Even though the token is correct.

Tony763 commented 4 years ago

@Gotanius Yesterday, I found a stupid mistake from time when I worked on fix for #13. Token was hard coded to mistmach to test it. You can get a fresh copy of fork or just change line 38 in __init__.py from token = "sgfsd" #self.settings.get('token') to token = self.settings.get('token').

Gotanius commented 4 years ago

@Tony763 that seems to make it connect. Now when I try for example to turn on a light. Mycroft asks me to confirm. When I confirm with a 'yes' I get a 'I agree, but to what?' response

Tony763 commented 4 years ago

@Gotanius Run: mycroft-stop mycroft-start debug

In console write: :log level debug Try Turn on intent and post me a output.

Gotanius commented 4 years ago

 12:42:54.202 | DEBUG    | 21185 | mycroft.skills.intent_service:handle_utterance:334 | Utterances: ['turn on boog lamp']
 12:42:54.982 | DEBUG    | 21185 | mycroft.skills.intent_service:handle_utterance:354 | Padatious intent: {'name': 'mycroft-homeassistant.tony763:turn.on.intent', 'sent': 'turn on {entity}', 'matches': {'entity': 'boog lamp'}, 'conf': 0.9052075320503652}
 12:42:54.986 | DEBUG    | 21185 | mycroft.skills.intent_service:handle_utterance:355 |     Adapt intent: None
 12:42:55.017 | DEBUG    | 21185 | urllib3.connectionpool | Starting new HTTPS connection (1): ######
 12:42:59.988 | DEBUG    | 21185 | urllib3.connectionpool | ###### "POST /api/conversation/process HTTP/1.1" 200 116
 12:43:06.584 | DEBUG    | 21191 | mycroft.client.speech.mic:trigger_listen:469 | Listen triggered from external source.
 12:43:06.645 | DEBUG    | 21191 | mycroft.client.speech.mic:listen:639 | Recording...
Playing WAVE '/home/pi/mycroft-core/mycroft/res/snd/start_listening.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Playing WAVE '/home/pi/mycroft-core/mycroft/res/snd/start_listening.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
 12:43:07.107 | INFO     | 21191 | __main__:handle_record_begin:37 | Begin Recording...
 12:43:07.122 | DEBUG    | 21185 | VolumeSkill | MUTING!
 12:43:07.123 | DEBUG    | 21185 | VolumeSkill | Finding Alsa Mixer for control...
 12:43:07.161 | DEBUG    | 21185 | VolumeSkill | Volume before mute: 99
 12:43:07.162 | DEBUG    | 21185 | VolumeSkill | 99
 12:43:07.162 | DEBUG    | 21185 | VolumeSkill | 0
 12:43:09.001 | DEBUG    | 21185 | urllib3.connectionpool | Starting new HTTPS connection (1): api.mycroft.ai:443
 12:43:09.565 | DEBUG    | 21185 | urllib3.connectionpool | https://api.mycroft.ai:443 "POST /v1/device/f3c5e37f-cbd6-44ca-bace-5d543e25b660/metric/timing HTTP/1.1" 204 0
 12:43:09.728 | DEBUG    | 21185 | mycroft.skills.intent_service:handle_utterance:334 | Utterances: ['yes']
 12:43:09.953 | DEBUG    | 21185 | mycroft.skills.intent_service:handle_utterance:354 | Padatious intent: {'name': 'mycroft-homeassistant.tony763:set.light.brightness.intent', 'sent': 'yes', 'matches': {}, 'conf': 0.1662044983255238}
 12:43:09.956 | DEBUG    | 21185 | mycroft.skills.intent_service:handle_utterance:355 |     Adapt intent: None
 12:43:09.978 | DEBUG    | 21185 | urllib3.connectionpool | Starting new HTTPS connection (1): #######
 12:43:10.080 | DEBUG    | 21185 | urllib3.connectionpool | Starting new HTTPS connection (1): api.mycroft.ai:443
 12:43:10.138 | INFO     | 21191 | __main__:handle_record_end:45 | End Recording...
 12:43:10.160 | DEBUG    | 21185 | VolumeSkill | Finding Alsa Mixer for control...
 12:43:10.222 | DEBUG    | 21191 | urllib3.connectionpool | Starting new HTTPS connection (1): api.mycroft.ai:443
 12:43:10.228 | DEBUG    | 21185 | VolumeSkill | 99
 12:43:10.449 | DEBUG    | 21185 | urllib3.connectionpool | ########## "POST /api/conversation/process HTTP/1.1" 200 75
 12:43:10.692 | DEBUG    | 21185 | urllib3.connectionpool | https://api.mycroft.ai:443 "POST /v1/device/f3c5e37f-cbd6-44ca-bace-5d543e25b660/metric/timing HTTP/1.1" 204 0
 12:43:11.107 | DEBUG    | 21191 | mycroft.client.speech.mic:listen:632 | Waiting for wake word...
 12:43:11.281 | DEBUG    | 21191 | urllib3.connectionpool | https://api.mycroft.ai:443 "POST /v1/stt?lang=en-US&limit=1 HTTP/1.1" 200 3
 12:43:11.409 | DEBUG    | 21191 | urllib3.connectionpool | Starting new HTTPS connection (1): api.mycroft.ai:443
 12:43:12.489 | DEBUG    | 21191 | urllib3.connectionpool | https://api.mycroft.ai:443 "POST /v1/stt?lang=en-US&limit=1 HTTP/1.1" 200 3
 12:43:12.508 | ERROR    | 21191 | mycroft.client.speech.listener:transcribe:239 | list index out of range
 12:43:12.522 | ERROR    | 21191 | mycroft.client.speech.listener:transcribe:240 | Speech Recognition could not understand audio
 12:43:13.834 | DEBUG    | 21191 | mycroft.client.speech.mic:trigger_listen:469 | Listen triggered from external source.
 12:43:13.916 | DEBUG    | 21191 | mycroft.client.speech.mic:listen:639 | Recording...

Ah I think it has trouble with the dutch names of my entities. When I try english names, they work. Scratch that. Turn on seems to work. Turn off does not.

Tony763 commented 4 years ago

Try to uncheck Enable conversation component as fallback in home assistant skill setings at https://account.mycroft.ai/skills and try it again.

Gotanius commented 4 years ago

that worked... Thanks. I'll try it with the dutch translations in a bit

Woehoe dutch works!

Tony763 commented 4 years ago

Glad to hear. Send me a PR with your changes.

Gotanius commented 4 years ago

I think I did it correctly. If not, I n00bed it, sorry.

iditude commented 4 years ago

Hello, try this fork and let me know

Hello,

Not sure how to do that from Mycroft. Happy to help, but would need some guidance on replacing the standard by a fork?

Thanks

Tony763 commented 4 years ago

@iditude Try:

mycroft-stop

cd  /opt/mycroft/skills/
mv homeassistant.mycroftai ../

git clone https://github.com/Tony763/mycroft-homeassistant.git

mv mycroft-homeassistant homeassistant.tony763

cp ../homeassistant.mycroftai/settings.json  homeassistant.tony763/

mycroft-start debug

test intent and post me a log

iditude commented 4 years ago

Hello,

I tried but no success. Debug is not very verbose though

Thoughts?


2020-07-14 09:39:45.779 | INFO     | 20409 | QuestionsAnswersSkill | Searching for allume entrée
Removing event fallback-query.mycroftai:QuestionQueryTimeout
Removing event fallback-query.mycroftai:QuestionQueryTimeout
Removing event fallback-query.mycroftai:QuestionQueryTimeout
Removing event fallback-query.mycroftai:QuestionQueryTimeout
2020-07-14 09:39:46.310 | INFO     | 20409 | QuestionsAnswersSkill | Timeout occured check responses
2020-07-14 09:40:21.120 | INFO     | 20409 | ConfigurationSkill | Remote configuration updated
2020-07-14 09:40:28.187 | INFO     | 20409 | QuestionsAnswersSkill | Searching for allume l'entrée
Removing event fallback-query.mycroftai:QuestionQueryTimeout
Removing event fallback-query.mycroftai:QuestionQueryTimeout
Removing event fallback-query.mycroftai:QuestionQueryTimeout
Removing event fallback-query.mycroftai:QuestionQueryTimeout```
gador commented 4 years ago

I had the same issue. Unfortunately it took me a while to figure out. My setup: Current picroft with mycroft-core 20.2.4

38 applied to the homeassistant.mycroftai folder:

cd /opt/mycroft/skills/homeassistant-mycroftai
git fetch origin pull/38/head:pull_38
git checkout pull_38

Confirmed it working with homeassistant in English. When switching to german ("de-de") with mycroft-config set lang "de-de" it stopped working. Neither the German nor the English utterance seemed to work.

Finally I found the following in /var/log/mycroft/skills.log:


2020-07-19 16:09:41.666 | INFO     | 15556 | mycroft.skills.skill_loader:load:114 | ATTEMPTING TO LOAD SKILL: homeassistant.mycroftai
2020-07-19 16:09:41.798 | INFO     | 15556 | mycroft.skills.settings:get_local_settings:78 | /home/pi/.config/mycroft/skills/homeassistant.mycroftai/
settings.json
2020-07-19 16:09:41.818 | INFO     | 15556 | mycroft.skills.settings:get_local_settings:78 | /home/pi/.config/mycroft/skills/homeassistant.mycroftai/
settings.json
2020-07-19 16:09:41.838 | DEBUG    | 15556 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: mycroft.stop
2020-07-19 16:09:41.852 | DEBUG    | 15556 | mycroft.skills.mycroft_skill.event_container:add:146 | Added event: mycroft.skill.enable_intent
[..]
2020-07-19 16:09:42.423 | DEBUG    | 15556 | mycroft.messagebus.client.client:remove:169 | Removing found 'homeassistant.mycroftai:set.climate.intent'
2020-07-19 16:09:42.439 | ERROR    | 15556 | mycroft.skills.skill_loader:_create_skill_instance:249 | Skill initialization failed with FileNotFoundError(2, 'No such file or directory')
Traceback (most recent call last):
  File "/home/pi/mycroft-core/mycroft/skills/skill_loader.py", line 243, in _create_skill_instance
    self.instance.initialize()
  File "/opt/mycroft/skills/homeassistant.mycroftai/__init__.py", line 89, in initialize
    with open((dirname(realpath(__file__))+"/vocab/"+self.language+"/turn.all.json"),encoding='utf8') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/opt/mycroft/skills/homeassistant.mycroftai/vocab/de-de/turn.all.json'
2020-07-19 16:09:42.455 | ERROR    | 15556 | mycroft.skills.skill_loader:_communicate_load_status:287 | Skill homeassistant.mycroftai failed to load

So it seemed "turn.all.json" was missing and the skill didn't load at all. This caused the intent handler to not even find homeassistant. Adding the file from the "en-us" directory (/opt/mycroft/skills/homeassistant.mycroftai/vocab/en-us/turn.all.json) to the german vocab folder and translating it, fixed it.

A quick find in the vocab directory reveals:

find . -iname 'turn.all.json'
./cs-cz/turn.all.json
./nl-nl/turn.all.json
./de-de/turn.all.json
./en-us/turn.all.json

(Obvioulsy I already added it to the "de-de" folder). So for all other languages this skill will probably fail to load. So either, it needs to be added for every language for the whole skill to work, or a workaround in the code to gracefully handle missing files..

@Tony763: shall I open a PR for the german translation, or do you want to make the changes yourself?

For reference, the translated turn.all.json:

{
  "light": ["Alle Lichter", "Alle Leuchten", "Alle L. E. D. s."],
  "switch": ["Alle Schalter", "Alle Steckdosen"]
}
Tony763 commented 4 years ago

@gador: Nice catch. Branch updated with your translation.

@iditude: Sorry for late reply. Please translate this and I will update my repo asap.

{
  "light": ["all lights", "all bulbs", "all L. E. D. s."],
  "switch": ["all switches", "all buttons"]
}
iditude commented 4 years ago

@Tony763 : yes sure! Here you go

Cheers

{
  "light": ["Toutes les lumières", "Toutes les ampoules", "Toutes les L. E. D. s."],
  "switch": ["Tous les interrupteurs", "Tous les boutons"]
}
iditude commented 4 years ago

Hello,

Thanks for the update. I'm still facing the same issue, but problem seems different as the homeassistant skill loads (and I verified presence of turn fr-fr/turn.all.json as indicated in the above posts)

Here are the full skills log from startup to requesting to turn on a light. https://pastebin.com/nTSZ3BvW

Any ideas?

P.S: Btw, this is supposed to be in DEBUG as started with mycroft-start debug but I don't find it particularly verbose.

gador commented 4 years ago

Here are the full skills log from startup to requesting to turn on a light. https://pastebin.com/nTSZ3BvW

Any ideas?

P.S: Btw, this is supposed to be in DEBUG as started with mycroft-start debug but I don't find it particularly verbose.

Hi @iditude, mycroft-start debug doesn't (as the name implies) start a debug session but will only start mycroft and launch a CLI session. (so basically mycroft-start && mycroft-cli-client).

mycroft-start --help
[...]
debug                    runs core services, then starts the CLI
[...]

So for debug output please launch the CLI (e.g. by mycroft-start debug) and then enter:

:log level debug

This will in fact generate debug output. If you wait too long, the services will already be started and you won't see any useful debug output. Alternatively, you can start a second ssh session (I assume you use ssh), stop the CLI agent with Ctrl-c and issue

mycroft-stop skills && mycroft-start skills

Then, in the first ssh session with the open CLI and debugging enabled, you should see the whole output of the skill loading process.

Hope that helps