Read the statement by Michael Teeuw here.
Sending notification from MMM-Remote-Control to MMM-ProfileSwitcher
-
Hello
I’m stuck trying to use the notification request feature of MMM-Remote-Control to send a notification to MMM-ProfileSwitcher in order to switch profiles. I’m doing this via a web GET request, which I know works already as I’ve got Monitor On and Monitor Off functioning correctly using http://IP.ADDRESS:PORT/remote?action=MONITOROFF
I know I’ve mashed together from two read me’s, but there’s no reason it shouldn’t work. I’m using: http://IP.ADDRESS:PORT/remote?action=NOTIFICATION¬ification=‘CURRENT_PROFILE’&payload=‘profilename’ i.e. ‘CURRENT_PROFILE’ is written exactly like that with the 2x ’ and profilename is the name of the profile I want to change to, again with 2x '.
I’ve also tried ", %27, %22, and all varieties with {} around it. I usually get the message {“status”:“Unexpected token ’ in JSON at position 0”} although I have had {“status”:“success”} with " around profilename, but nothing happened.
Can anyone help me please?
-
Anybody out there able to help? It’s so frustrating as every other part of MM has been fantastic and relatively easy. Can anyone at least confirm that it should work in theory?
-
It looks like it should work. Are you trying this from a javascript, or are you just trying to figure out the static URL you need to call?
Please have a look at this example: https://jsfiddle.net/5yzw2zrb/6/
On the left you can see javascript code you could use to build the needed URL, and on the left you can see an example. Adapt the variables in the code to build some other kind of notification. Dont forget to run the script, e.g., with CTRL+Return, to see the the new result.
Edit: Another example which should be working out of the box is building an alert notification.
-
@Jopyth thank you for that tool. I will try a few things out later. I am trying to find the correct static URL to use, and fingers crossed this will get me there!
-
@Jopyth thank you again for your help. I got it working with the following: http://IP.ADDRESS:PORT/remote?action=NOTIFICATION¬ification=CURRENT_PROFILE&payload=%22profilename%22
So it was the unnecessary ’ ’ around CURRENT_PROFILE that was breaking it before. I’ll see about sugggesting an edit to the relevant module read me. Cheers
-
@tismepaulo https://github.com/Jopyth/MMM-Remote-Control/blob/master/README.md#notification-request the readme is correct it doesn’t say to put quotes around the notification
-
@strawberry-3.141 you’re right, but https://github.com/tosti007/MMM-ProfileSwitcher/blob/master/README.md#switching-profiles kinda does. I was going to add to the Using with other modules section of MMM-ProfileSwitcher
-
@tismepaulo thats a diffenrent use case the example shown in your link is for using inside a module and not as a http request, so therefore you need the quotes
-
@strawberry-3.141 ah OK, thanks :)