Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classes #259

Closed
dand3l10n opened this issue Apr 12, 2021 · 16 comments
Closed

Classes #259

dand3l10n opened this issue Apr 12, 2021 · 16 comments

Comments

@dand3l10n
Copy link

Hello,

I installed everything and it is working fine. Only one thing, I want to use the custom classes. I created them in the config like in the examples but I don`t know how to control them. There is no button on the remote. Do I have to create them by my own like the custum menu?

@ezeholz
Copy link
Collaborator

ezeholz commented Apr 12, 2021

That's right. Classes just groups different modules and actions right now. You can create a custom menu using those classes, or calling them using the API.
Let me know if you need anything else!
Cheers :D

@dand3l10n
Copy link
Author

All right,
what should be the notification, action, and payload to control a class named "custom-item-1"?
That means I can control the classes as well from other modules via the notifications, right?

{
"id": "costum",
"type": "menu",
"icon": "id-card-o",
"text": "%%TRANSLATE:CUSTOM_MENU%%",
"items": [{
"id": "custom-item-1",
"type": "item",
"icon": "dot-circle-o",
"text": "Menu Item 1",
"action": "NOTIFICATION",
"content": {
"notification": "NOTIFCATION_TEXT_1",
"payload": "This notification requires a string payload"
}
},

@ezeholz
Copy link
Collaborator

ezeholz commented Apr 12, 2021

You can control them from other modules, that's right.
If you want a button to use for the class you need, you should add something like this:

{
    "id": "custom-item-1",
    "type": "item",
    "icon": "dot-circle-o",
    "text": "Menu Item 1",
    "action": "MANAGE_CLASSES",
    "content": {
        "payload": {
            TOGGLE: "your-class, another-class",
        }
    }
}

If you want to reach it from another module, send a REMOTE_ACTION notification, with payload:

{
    "action": 'MANAGE_CLASSES',
    "payload": {
        "TOGGLE": "your-class, another-class",
    }
}

@dand3l10n
Copy link
Author

Hi mate,
thank's so far.
It doesn't work out as I hope to.

The buttons on the remote are there. If I trigger the f_calendar button, it will show module_6_calendar and hide module_7_calendar but nothing else. This problem is the same in the two other classes.

Is there a way to hide, show or trigger multiple modules in one class?
Is it possible to send notifications to modules via the command line and trace the communication between the modules?

My config:
{
module: "MMM-Remote-Control",
position: 'bottom_left',
config: {
apiKey: '******',
customMenu: "remote_custom_menu.json",
classes: {
"f_calendar": {
show: ["module_6_calendar"],
hide: ["module_7_calendar", "module_3_MMM-NowPlayingOnSpotify", "module_9_MMM-OnThisDay"],
},
"m_calendar": {
show: ["module_7_calendar"],
hide: ["module_6_calendar", "MMM-OnThisDay", "MMM-NowPlayingOnSpotify"],
},
"homescreen": {
hide: ["module_7_calendar", "module_6_calendar"],
show: ["MMM-OnThisDay", "MMM-NowPlayingOnSpotify"],
},
},
}
},

remote_custom_menu.json:
{
"id": "custom-item-1",
"type": "item",
"icon": "dot-circle-o",
"text": "Menu Item 1",
"action": "MANAGE_CLASSES",
"content": {
"payload": {
TOGGLE: "f_calendar, m_calendar, homescreen",
}
}
}

@ezeholz
Copy link
Collaborator

ezeholz commented Apr 14, 2021

Is there a way to hide, show or trigger multiple modules in one class?

Alright, I found a bug right now. Classes should work as you're describing, maybe you can create only one class with toggle.
According to the bug, seems to be a problem when you use multiple identifiers or one identifier and some names. I'm gonna fix it soon.

Edit: Seems that the API it's working fine as it should. You can try it with http://mirror-IP/api/docs using the classes url below Module Control.

Is it possible to send notifications to modules via the command line and trace the communication between the modules?

What command line are you referring? If you mean the linux/windows one, that's not possible because of how MM is made of.
If you mean the developer console of the electron, it's up to every modules decision to return some functions to use. And to trace the notifications too, it depends on the modules you're using.

@ezeholz
Copy link
Collaborator

ezeholz commented Apr 14, 2021

Also, my bad, there's no need to create a custom menu. Below the Edit config.js menu, there's a Classes Menu where you can activate those classes. Let me know if that works.

@dand3l10n
Copy link
Author

I deleted the custom menu and tried it via the http://mirror-IP/api/docs site and the remote. The same thing happened with both methods.

ezeholz added a commit that referenced this issue Apr 15, 2021
@ezeholz
Copy link
Collaborator

ezeholz commented Apr 15, 2021

Let me know if the branch bug-fixes works for you.
And if you have any other question, feel free to ask :D

@dand3l10n
Copy link
Author

At first, thank you, really appreciate your work and help.
The problem with the classes is solved they work as they should be.

I got a new one instead.
The view editor on the remote doesn't work anymore. I did not change my config and I don't get any errors in the log.
Could you please double-check this?

I'm trying to control my mirror with my Alexa. I'm using the Alexa Control module (https://github.com/JoChef2/MMM-AlexaControl) to do that. I can create customized commands in this module. My plan was to send a notification from the Alexa module to the remote control. But the module forces me to bring the command in a shape like this.:
notification: ["NOTIFICATION", "PAYLOAD"]
I don't get it working with your example above.
Could you please give me an example for a command like this?

@ezeholz
Copy link
Collaborator

ezeholz commented Apr 16, 2021

I'm gonna check the view editor in a minute. About using Alexa, the Manage_Classes that I told you to use doesn't work as expected, so there's another bug that I found when looking into how to fix the previous one.

Just for you to know, Classes is one of the newest addition, and of course will have flaws.
Thanks for letting me know. :D

ezeholz added a commit that referenced this issue Apr 16, 2021
#259 Fix about view editor
@ezeholz
Copy link
Collaborator

ezeholz commented Apr 16, 2021

That solves the view editor bug. Let me know if it works.
I'm gonna work now with the notification. I'll let you know when it's up.

@dand3l10n
Copy link
Author

Thanks I wil try it the day after tomorrow. I'm busy tomorrow.

ezeholz added a commit that referenced this issue Apr 16, 2021
#259 Manage_Classes it's now handled inside node_helper
@ezeholz
Copy link
Collaborator

ezeholz commented Apr 16, 2021

Both changes are online. Test them when it's possible and let me know.
In all my tests, it worked fine.

notification: ["REMOTE_ACTION", {action: "MANAGE_CLASSES",classes: "f_calendar"}]
OR
notification: ["REMOTE_ACTION", {action: "MANAGE_CLASSES",classes: ["f_calendar","m_calendar"]}]

Those should work with Alexa module.

@dand3l10n
Copy link
Author

I can use the classes menu and the view editor without any issues. Thanks for that.
The Alexa control for a single module via your "remote control module" works fine.
I still can't control the classes via the notifications (Alexa module). I don't get any errors in the log.
Do you have another idea for me?

@ezeholz
Copy link
Collaborator

ezeholz commented Apr 19, 2021

You could try using the developer console on your Mirror, and check if it throws any error up there.

I saw in the Alexa Wiki some examples and they're using ["REMOTE_ACTION", '{action: "MANAGE_CLASSES",classes: ["f_calendar","m_calendar"]}'] too.

Let me know when you try it! :D

Edit: Also try ["REMOTE_ACTION", {action: "MANAGE_CLASSES", payload: {classes: ["f_calendar","m_calendar"]}}] just to be sure.

@dand3l10n
Copy link
Author

I got lucky with the last one.
["REMOTE_ACTION", {action: "MANAGE_CLASSES", payload: {classes: ["f_calendar","m_calendar"]}}]
Everything is working fine for now.
Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants