Mycroft skill doesn't work

Hello everyone, I tried building a new skill on Mycroft, but it doesn’t work. Can anyone help me?
This is the skill:

from mycroft import MycroftSkill, intent_file_handler
import os

class Lightmgmt(MycroftSkill):
def init(self):
MycroftSkill.init(self)

@intent_file_handler('turn.on.intent')
def turn_on(self, message):

		self.speak_dialog("light_on")

def create_skill():
return Lightmgmt()

In the local folder I have:
light_on.dialog that contains:
“accendo la luce
la luca è accesa”

and turn.on.intent that contains:
“accendi la lampada
accendi”

That should read

__init__(self)

rather than init(self)

__init__ is a method belonging to all objects which runs when the object is created. There are other methods kind of like that, with names that start and end in underscores, which are also called automagically under specific circumstances, but you don’t need to worry about those for now (or, possibly, ever.)

I don’t know why but in my code there is the underscore!
I think I didn’t transcribe well, sorry…
Apart from that, do you know what problem can it be?

Well, might also be a transcription error, but that indentation isn’t right, either. Try encasing it in triple backticks

    ```python
    <paste code here>
    ```

It might jump out at me after that =P otherwise, when you say it doesn’t work, how not? Where does it fail, and what does it say?

In your pasted text there are spaces and tabs - we generally stay away from that debate and either will work but it needs to be consistent. Python doesn’t handle a mixture of tabs and spaces.

It may also be an indentation issue, Python is picky about consistency there too.

This version of the Skill works fine given those two other files exist in locale/en-us/

from mycroft import MycroftSkill, intent_file_handler
import os

class Lightmgmt(MycroftSkill):
    def __init__(self):
        MycroftSkill.__init__(self)

    @intent_file_handler('turn.on.intent')
    def turn_on(self, message):
        self.speak_dialog("light_on")

def create_skill():
    return Lightmgmt()

Some other random notes:

  • If you don’t need that __init__() method it can be excluded.
  • You can now use the shorter intent_handler decorator.

So this would make the Skill:

from mycroft import MycroftSkill, intent_handler

class Lightmgmt(MycroftSkill):

    @intent_handler('turn.on.intent')
    def turn_on(self, message):
        self.speak_dialog("light_on")

def create_skill():
    return Lightmgmt()