eouia / MMM-CalendarExt

Calendar views for MagicMirror
MIT License
55 stars 18 forks source link

Problems when using MMM-CalenderExt with MMM-pages and MMM-MMM-ProfileSwitcher #81

Closed Tom-Hirschberger closed 4 years ago

Tom-Hirschberger commented 4 years ago

Hi, i ran into problems when using a combination of these three modules. I am not sure which of the modules is responsible for my problem.

My mirror uses two pages and i am using two different calenders. I use MMM-ProfileSwitcher to define which calenders should be displayed: Profile "everyone" and "default" only show the events of calender one. Profile "Tom" displays the events of both calenders.

MMM-CalenderExt should only be visible on page 0. If i switch to page 1 it should be hidden.

So far so good. Everything works if i only switch my profile on page 0. If i switch to "Tom" both calenders apear. But if i switch the profile while i am on page 1 where MMM-CalenderExt is hidden the module appears.

eouia commented 4 years ago

https://github.com/eouia/MMM-CalendarExt/wiki/How-to-use-with-profiles

Tom-Hirschberger commented 4 years ago

I used that guide to configure my modules. Profiles work well and my events will be displayed or hidden. But if i change the profile while the module is hidden by the paging module it appears although it should not.

eouia commented 4 years ago

Show me your config.

eouia commented 4 years ago

By the way, ProfileSwitcher itself works with Page? I think there could be a racing collision to obtain lockstring.

Tom-Hirschberger commented 4 years ago
        {
        module: 'MMM-CalendarExt',
            position: "top_center",
            config: {
                system: {
                    show: ["daily", "upcoming"],
                    locale: 'de',
                    redrawInterval:60000,
                },
                views: {
                daily: {
                    position:'bottom_bar',
                    positionOrder: "0",
                    counts:7,
                },
                upcoming: {
                    position:'top_left',
                    limit:5
                },
                },
                defaultCalendar: {
                    maxEntries:50,
                    maxDays:180,
                    interval: 1000*60*5,
                    profiles: []
                },
                calendars :[
                {
                    name: "Hirschberger",
                    symbol: "calendar-o",
                    styleName: "style1",
                    url: "MY_URL_ONE.ics",
                },
                {
                    name: "Tom",
                    symbol: "calendar-o",
                    styleName: "style2",
                    url: "MY_URL_TWO.ics",
                    profiles: ["Tom"]
                },
                ],
            },
            classes: 'default everyone'
        },
        {
            module: 'MMM-pages',
            config: {
                modules:
                    [
                        [ "MMM-CalendarExt","MMM-NOAA3","MMM-DWD-Pollen"],
                        [ "MMM-Spotify" ]
                    ],
                fixed: ["MMM-Remote-Control","clock","MMM-GPIO-Notifications","MMM-Screen-Powersave-Notification","MMM-Notification-To-Command","MMM-Serial-Notifications","MMM-Volume","MMM-page-indicator", "MMM-ViewNotifications"],
            },
        },
        {
            module: 'MMM-ProfileSwitcher',
            config: {
                ignoreModules: ["MMM-Remote-Control","clock","MMM-GPIO-Notifications","MMM-Screen-Powersave-Notification","MMM-Notification-To-Command","MMM-Serial-Notifications","MMM-Volume","MMM-pages","MMM-page-indicator","MMM-ViewNotifications"],
            }
        },
Tom-Hirschberger commented 4 years ago

Today i tried an different approach and removed the MMM-pages and MMM-page-indicator modules. I introduced different classes for pageOneEveryone, pageTwoEveryone, pageOneTom and pageTwoTom. My config now looks like this:

{
        module: 'MMM-CalendarExt',
            position: "top_center",
            config: {
                system: {
                    show: ["daily", "upcoming"],
                    locale: 'de',
                    redrawInterval:60000,
                },
                views: {
                daily: {
                    position:'bottom_bar',
                    positionOrder: "0",
                    counts:7,
                },
                upcoming: {
                    position:'top_left',
                    limit:5
                },
                },
                defaultCalendar: {
                    maxEntries:50,
                    maxDays:180,
                    interval: 1000*60*5,
                    profiles: []
                },
                calendars :[
                {
                    name: "Hirschberger",
                    symbol: "calendar-o",
                    styleName: "style1",
                    url: "CALENDER_ONE.ics",
                },
                {
                    name: "Tom",
                    symbol: "calendar-o",
                    styleName: "style2",
                    url: "CALENDER_TWO.ics",
                    profiles: ["pageOneTom"]
                },
                ],
            },
            classes: 'default pageOneEveryone pageOneTom'
        },

Now the CalenderExt module gets hidden as expected. But if i change the profiles in order pageOneEveryone->pageOneTom->pageTwoEveryone->pageOneEveryone it takes the refresh interval till my Tom events are removed from the calender

Tom-Hirschberger commented 4 years ago

The new problem seems to be solved if useProfileConfig is enabled. Maybe writing a new module which supports rolling through "horizontal" and "vertical" profiles and displaying an indicator like the pages module is the easy way

Tom-Hirschberger commented 4 years ago

Still do not know why the module does not work as expected in combination with MMM-pages and MMM-page-indicator but i wrote a new module https://github.com/Tom-Hirschberger/MMM-ProfileControl which only uses profiles and arranges them into horizontal groups. It provides an indicator by itself (based on MMM-page-indicator code) and supports vertical groups, too.

Now i can switch through pages and can use different profiles on each page.

I think the ticket can be closed if nobody else uses this combination of modules.

eouia commented 4 years ago

Wow, you made such a progress. Have you used MMM-CalendarExt2? It has more advanced feature than this module. It can change scene by custom notification trigger like your case. I think it could be one of option to consider. https://github.com/eouia/MMM-CalendarExt2/wiki/3.-Usage

Tom-Hirschberger commented 4 years ago

Oh. Did not see that. You'r right, looks like scenes are exactly what i am looking for. But i need to make a configuration which uses the "CHANGED_PROFILE" notification to select the proper scene. I will check this out the text days if there is time

Tom-Hirschberger commented 4 years ago
        {
            module: 'MMM-CalendarExt2',
            config: {
                calendars :[
                    {
                        name: "C_Hirschberger",
                        symbol: "calendar-o",
                        styleName: "style1",
                        url: "CALENDER_ONE.ics",
                    },
                    {
                        name: "C_Tom",
                        symbol: "calendar-o",
                        styleName: "style2",
                        url: "CALENDER_TWO.ics",
                    },
                ],
                views: [
                    {
                      name: "V_upcoming_both",
                      mode: "upcoming",
                      slotCount: 1,
                      position: "top_left",
                      calendars: ["C_Hirschberger", "C_Tom"],
                    },
                    {
                      name: "V_week_both",
                      mode: "week",
                      type: "column",
                      slotCount: 1,
                      position: "bottom_bar",
                      positionOrder: "0",
                      calendars: ["C_Hirschberger", "C_Tom"],
                    },
                    {
                        name: "V_monthly_both",
                        mode: "monthly",
                        position: "center",
                        calendars: ["C_Hirschberger", "C_Tom"],
                    },
                    {
                        name: "V_upcoming_Hirschberger",
                        mode: "upcoming",
                        slotCount: 1,
                        position: "top_left",
                        calendars: ["C_Hirschberger"],
                    },
                    {
                        name: "V_week_Hirschberger",
                        mode: "week",
                        type: "column",
                        slotCount: 1,
                        position: "bottom_bar",
                        positionOrder: "0",
                        calendars: ["C_Hirschberger"],
                    },
                ],
                scenes: [
                    {
                        name: "pageOneEveryone",
                        views: ["V_upcoming_Hirschberger", "V_week_Hirschberger"],
                    },
                    {
                        name: "pageOneTom",
                        views: ["V_upcoming_both", "V_week_both"],
                    },
                    {
                        name: "pageTwoMarion",
                        views: ["V_monthly_both"],
                    },
                ],
                notifications: {
                    "CHANGED_PROFILE" : {
                      exec: "changeSceneByName",
                      payload: (payload) => {return payload.to}
                    }
                },
        },

Tried it with the configuration above but each time the the CHANGED_PROFILE notification is received it duplicates the views.

But it only happens if i use the custom notifications rewrite function. If i send an CALEXT2_SCENE_NEXT notification everything works fine

I tried sending a CALEXT2_SCENE_CHANGE with type "name" each time the profile changes in my MMM-ProfileControl module but the views get duplicated this way, too.

Tom-Hirschberger commented 4 years ago

I do not get it. It differs which module sends the CALEXT2_SCENE_CHANGE.

If i send it as a result of CHANGED_PROFILE in MMM-ProfileControl the views get duplicated (the old one stays and one more with the new content gets added). If i send it in MMM-SerialNotifications everything works fine.

But both send an notification with the same content.

Tom-Hirschberger commented 4 years ago

I think it is an race condition in the work function of MMM-CalendarExt2.js (this.currentScene might be overwritten by one of the timers?) but i think the best idea is to close this issue and discuss this in the MMM-CalenderExt2 project.