Doesn't seem to retrieve settings from account.mycroft.ai

Hello, everyone. I’m having trouble getting this skill to load login information from settingsmeta.

I have this settingsmeta.json file in the skill directory:

{
    "skillMetadata": {
	"sections": [
	    {
		"name": "Login Information",
		"fields": [
		    {
			"type": "label",
			"label": "Provide the login information provided by your calendar service provider."
		    },
		    {
			"name": "user",
			"type": "text",
			"label": "Username",
			"value": "",
			"placeholder": "CalDAV username"
		    },
		    {
			"name": "password",
			"type": "password",
			"label": "Password",
			"value": ""
		    },
		    {
			"name": "url",
			"type": "text",
			"label": "URL",
			"value": ""
		    }
		]
	    }
	]
    }
}

I can see the fields properly formatted on account.mycroft.ai, and I’ve entered the information into the fields and clicked save. This is what I have in the skill’s init.py file:

    def initialize(self):
        self.register_entity_file('when.entity')

        self.user = self.settings.get('user')
        if not self.user:
            self.speak('failed to retrieve username')
        self.password = self.settings.get('password')
        if not self.password:
            self.speak('failed to retrieve password')
        self.url = self.settings.get('url')
        if not self.url:
            self.speak('failed to retrieve url')

Every time, I’m getting the “failed to retrieve” notifications. The variables are set to None in the init method.

The data is not populating in my ~/.config/mycroft/skills/my-calendar-skill/settings.json file. But the fields are there.

{"__mycroft_skill_firstrun": false, "password": "", "username": "", "internal_python_variable_name": "", "url": "", "user": ""}

I’ve checked the docs multiple times, and don’t see where I’m going wrong here.

clear the logs (better overview) and restart mycroft in debug log mode. Then check the skills.log what is happening when fetching the meta from the web api.

Have a look here: Skill Settings - Mycroft AI

I changed the initialize method to write to the log files instead of speaking the error.

def initialize(self):
        self.register_entity_file('when.entity')

        self.log.info('Collecting login information')
        self.user = self.settings.get('user')
        if not self.user:
            self.log.info('Failed to retrieve username')
        self.password = self.settings.get('password')
        if not self.password:
            self.log.info('failed to retrieve password')
        self.url = self.settings.get('url')
        if not self.url:
            self.log.info('failed to retrieve u r l')
        self.log.info('Completed login information retrieval attempt')

This is the output of :find "MyCalendar" in debug mode.

 16:31:12.231 | INFO     | 23388 | MyCalendar | Collecting login information
 16:31:12.232 | INFO     | 23388 | MyCalendar | Failed to retrieve username
 16:31:12.232 | INFO     | 23388 | MyCalendar | failed to retrieve password
 16:31:12.232 | INFO     | 23388 | MyCalendar | failed to retrieve u r l
 16:31:12.232 | INFO     | 23388 | MyCalendar | Completed login information retrieval attempt

No error messages. :thinking:

I wrote a very simple skill which requires some settings from account.mycroft.ai, maybe by following what I did it could help you.

Good luck.

was this skill installed using msm? As i was looking for the code on github.

Thank you. I saw that section of the docs, but I didn’t see that it applied since I didn’t need the skill to do anything extra while when mycroft did its periodic user settings updates. I checked out your skill (cool stuff btw) and made similar changes in mine.

def initialize(self):
    self.register_entity_file('when.entity')
                
    self.setting_change_callback = self.on_websettings_changed
    self.on_websettings_changed()

        
def on_websettings_changed(self):

    self.log.info('Collecting login information')

    self.user = self.settings.get('user')
    if not self.user:
        self.log.info('Failed to retrieve username')

    self.password = self.settings.get('password')
    if not self.password:
        self.log.info('failed to retrieve password')

    self.url = self.settings.get('url')
    if not self.url:
        self.log.info('failed to retrieve url')

    self.log.info('Completed login information retrieval attempt')

Unfortunately, I’m still getting the same result as using self.settings.get() within initialize().

1 Like

I created the skill locally using mycroft-msk create. I haven’t pushed it to github.

Do you mind to share your code, it will be easier for us to help.

Here goes nothing, I guess.

I use it with fruux.com, and it works well enough. Haven’t tried it with anything else, though.

I tried your skill, I got the information retrieved successfully at least in settings.json

2021-11-26 18:42:59,517 DEBUG mycroft.skills.settings:download:390 Skill settings changed since last download
2021-11-26 18:42:59,521 INFO mycroft.skills.settings:_emit_settings_change_events:435 Emitting skill.settings.change event for skill @4a0651d4-9072-4662-83bd-7032a9698df8|my-calendar 
2021-11-26 18:42:59,524 DEBUG mycroft.skills.settings:save_remote_settings_cache:348 Updated local cache of remote skill settings.
2021-11-26 18:42:59,548 INFO mycroft.skills.mycroft_skill.mycroft_skill:handle_settings_change:360 Updating settings for skill MyCalendar
2021-11-26 18:42:59,552 INFO mycroft.skills.settings:save_settings:116 Skill settings successfully saved to /home/mycroft/.config/mycroft/skills/my-calendar.dan8745/settings.json
{"__mycroft_skill_firstrun": false, "url": "http://localhost", "user": "goldyfruit", "password": "12345"}

When I iask “what’s in my calendar” it returns a Python trace.

2021-11-26 18:49:02,806 ERROR mycroft.skills.mycroft_skill.mycroft_skill:on_error:923 An error occurred while processing a request in My Calendar
Traceback (most recent call last):
  File "/home/mycroft/core/mycroft/skills/mycroft_skill/event_container.py", line 73, in wrapper
    handler(message)
  File "/opt/mycroft/skills/my-calendar.dan8745/__init__.py", line 120, in handle_calendar_my
    calendars = self.get_calendars()
  File "/opt/mycroft/skills/my-calendar.dan8745/__init__.py", line 58, in get_calendars
    password=self.password)
  File "/opt/mycroft-venv/lib/python3.7/site-packages/caldav/davclient.py", line 321, in __init__
    if self.url.username is not None:
AttributeError: 'NoneType' object has no attribute 'username'
1 Like

I tried wiping and reinstalling from the github repo and it works now.

Are you using fruux? Or if you don’t mind, what kind of server are you using?

Thanks for spending time on this.

1 Like

Great!

I’m not using any calendar services, I was just testing your skill :slight_smile:

Sometime you just need to remove and re-install the skill.

I was hinting at that, yet don’t know if this is intended or slipped through the cracks. @gez-mycroft (to summarize: skill is recognized by the web api, but not able to synchronize, if created with mycroft-msk)

whenever you make changes to a local skill selene thinks its a new skill, you should have something in the web page about “version 1” and “version 2” above the skill name, or maybe it was related to having same skill in multiple devices i don’t recall

there are 2 major bugs with selene skill settings flagged for more than a year now

  • selene will not sync settings if it gets confused about the skill due to code changes / multiple devices
  • it will also overwrite any settings changed on device with the web version of those settings

this is also the reason i stopped using settingsmeta completely in my skills

Thanks for the ping @SGee

I just created a new Skill, with no remote git repo and the settings synced straight away to the backend, then entering values got synced back. So (un)fortunately that rules out a blanket issue with any Skill created with MSK.

Are there any other steps you can think of that would help me replicate the issue?


In terms of the Selene bugs mentioned.

  • Has this been logged in an issue? If there are multiple devices or different versions of settings they will be listed under separate tabs in the backend.
  • The local settings shouldn’t get overwritten by remote unless the user makes a change to them as of #2707

There’s definitely improvements we need to make to settings, but as far as I’m aware - they’re working as designed right now.

Obligatory plug
If you know anyone that wants to work on exactly these problems - we’re currently looking for a backend engineer: