MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. bimbim2401
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    B
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 4
    • Posts 12
    • Groups 0

    bimbim2401

    @bimbim2401

    1
    Reputation
    632
    Profile views
    12
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    bimbim2401 Unfollow Follow

    Best posts made by bimbim2401

    • RE: Module Sending notification to a python project

      Hey,

      i have succeed to make it works with the following in the main.py, my problem was due to the port which was already in use, and then i have to take another one.

      add the import

      from threading import Thread
      from urllib.parse import unquote
      

      then just before the main function add

      class WebSocketsListener(Thread):
      """Thread chargé d'ecouter les messages sur la websocket."""
      
      def __init__(self, assistant):
          Thread.__init__(self)
          self.websocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          self.websocket.bind(('127.0.0.1', 8081))
          self.assistant = assistant
      
      
      def run(self):
          print ("Open socket")
      
          while True:
              self.websocket.listen(5)
              client, address = self.websocket.accept()
              print (format( address ))
      
              response = client.recv(255)
              if response != "":
                  print (response)
                  str_response = response.decode("utf-8")
                  if 'assistant' in str_response:
                      
                      if 'mode' in str_response:
                          if 'start' in str_response:
                              print("start the assistant") 
                              self.assistant.start_conversation()
                          if 'stop' in str_response: 
                              print("stop  the assistant") 
                              self.assistant.stop_conversation()
      
                      elif 'say' in str_response:
                          token = str_response[str_response.find("say=")+4:str_response.find("HTTP")-1]
                          token = unquote(token)
                          say(token)
      
          print ("Close socket")
          client.close()
          stock.close()
      

      in the main function just before the for event in events

          webSocketsListener = WebSocketsListener(assistant)
          webSocketsListener.start()
      

      With this, open a web browser and write
      http://127.0.0.1:8081/assistant?mode=start
      it will start manually the assistant like with the hotword"ok google"
      http://127.0.0.1:8081/assistant?mode=stop
      to stop the assistant if the conversation is too long
      http://127.0.0.1:8081/assistant?say=Hello karim how are you
      and then gassistPI will say what you write

      in the magic mirror module, you have to send this request in the node helper.js

       socketNotificationReceived: function(notification, payload) {
      
          var res = "";
          var ipadress = "127.0.0.1";
          var port = "8081";
      
      
      console.log("google assistant Node Helper Received a socket notification: " + notification + " payload:" + payload);
      if (notification === "ASSISTANT_START"){
      	request("http://"+ipadress+":"+port+"/assistant?mode=start", { json: true }, (err, res, body) => {
      		if (err) { return console.log(err); }
      		console.log(body.url);
      		console.log(body.explanation);
      	});
      }
      else if (notification === "ASSISTANT_STOP"){
      	request("http://"+ipadress+":"+port+"/assistant?mode=stop", { json: true }, (err, res, body) => {
      		if (err) { return console.log(err); }
      		console.log(body.url);
      		console.log(body.explanation);
      	});
      	
      }
      else if (notification === "ASSISTANT_SAY"){
      	console.log("assistant payload:"+payload);
      	request("http://"+ipadress+":"+port+"/assistant?say="+payload, { json: true }, (err, res, body) => {
      		if (err) { return console.log(err); }
      		console.log(body.url);
      		console.log(body.explanation);
      	});
      }		
      }	
      

      Thanks for your help

      posted in Requests
      B
      bimbim2401

    Latest posts made by bimbim2401

    • newsfeed error at every launch time pubdate undefined

      Hello

      I have this issues since some month in my magic mirror with the newfeeds module, can someone can help me please ?

      Create new news fetcher for url: http://www.leparisien.fr/actualites-a-la-une.rss.xml#xtor=RSS-1481423633 - Interval: 300000
      Can’t parse feed item:
      { title: ‘Transports : Ticket de métro et carte Navigo sur smartphone, c’est déjà possible !’,
      link: ‘http://www.leparisien.fr/info-paris-ile-de-france-oise/transports/transports-ticket-de-metro-et-carte-navigo-sur-smartphone-c-est-deja-possible-07-01-2019-7982625.php#xtor=RSS-1481423633’ }
      Title: Transports : Ticket de métro et carte Navigo sur smartphone, c’est déjà possible !
      Description:
      Pubdate: undefined
      Can’t parse feed item:
      { title: ‘Cavani, Verratti, Di Maria et Marquinhos sont tous rentrés de vacances à l’heure !’,
      link: ‘http://www.leparisien.fr/sports/football/psg/cavani-verratti-di-maria-et-marquinhos-sont-tous-rentres-de-vacances-a-l-heure-07-01-2019-7982655.php#xtor=RSS-1481423633’ }
      Title: Cavani, Verratti, Di Maria et Marquinhos sont tous rentrés de vacances à l’heure !
      Description:
      Pubdate: undefined
      Can’t parse feed item:
      { title: ‘Méru : la déchetterie ne verra pas le jour avant 2020’,
      link: ‘http://www.leparisien.fr/oise-60/meru-la-dechetterie-ne-verra-pas-le-jour-avant-2020-07-01-2019-7982652.php#xtor=RSS-1481423633’ }
      Title: Méru : la déchetterie ne verra pas le jour avant 2020
      Description:
      Pubdate: undefined
      Can’t parse feed item:
      { title: ‘Cires-lès-Mello : qui est responsable de la pollution d’un chemin communal ?’,
      link: ‘http://www.leparisien.fr/oise-60/cires-les-mello-qui-est-responsable-de-la-pollution-d-un-chemin-communal-07-01-2019-7982574.php#xtor=RSS-1481423633’ }
      Title: Cires-lès-Mello : qui est responsable de la pollution d’un chemin communal ?
      Description:
      Pubdate: undefined
      Can’t parse feed item:
      { title: ‘Coup d’Etat raté au Gabon : le chef du commando arrêté, deux autres membres abattus’,
      link: ‘http://www.leparisien.fr/international/gabon-des-militaires-investissent-la-radio-d-etat-07-01-2019-7982211.php#xtor=RSS-1481423633’ }
      Title: Coup d’Etat raté au Gabon : le chef du commando arrêté, deux autres membres abattus
      Description:
      Pubdate: undefined
      Can’t parse feed item:
      { title: ‘Les Golden Globes sont-ils vraiment l’«antichambre» des Oscars ?’,
      link: ‘http://www.leparisien.fr/culture-loisirs/les-golden-globes-sont-ils-vraiment-l-antichambre-des-oscars-07-01-2019-7982646.php#xtor=RSS-1481423633’ }
      Title: Les Golden Globes sont-ils vraiment l’«antichambre» des Oscars ?
      Description:
      Pubdate: undefined
      Can’t parse feed item:
      { title: ‘Val-de-Marne : trois hommes écroués après l’arrestation du gang de Rungis’,
      link: ‘http://www.leparisien.fr/val-de-marne-94/val-de-marne-trois-hommes-ecroues-apres-l-arrestation-du-gang-de-rungis-07-01-2019-7982649.php#xtor=RSS-1481423633’ }
      Title: Val-de-Marne : trois hommes écroués après l’arrestation du gang de Rungis
      Description:
      Pubdate: undefined
      Can’t parse feed item:
      { title: ‘Nantes : le forcené retranché chez lui interpellé et placé en garde à vue’,
      link: ‘http://www.leparisien.fr/faits-divers/nantes-un-forcene-retranche-chez-lui-le-raid-sur-place-07-01-2019-7982586.php#xtor=RSS-1481423633’ }
      Title: Nantes : le forcené retranché chez lui interpellé et placé en garde à vue
      Description:
      Pubdate: undefined

      posted in Bug Hunt
      B
      bimbim2401
    • RE: Home made 60" touch Magic Mirror

      Thanks so If the ir frame is equal to the mirror size for example 60” and the tv is 40” i imagine that you need to calibrate the ir frame or something like this ?

      posted in Show your Mirror
      B
      bimbim2401
    • RE: Home made 60" touch Magic Mirror

      What about the ir frame size ? The same as the monitor ? If yes how do you put the camera through the glass ?

      Or have you take a bigger size ?

      posted in Show your Mirror
      B
      bimbim2401
    • RE: Led without Bread-boards !

      Hello

      I made a small module for the mmm to pilot led strip but you need breadboard transistor and resistance

      Tell me if you want me to explain more

      posted in Requests
      B
      bimbim2401
    • RE: Module Sending notification to a python project

      Hey,

      i have succeed to make it works with the following in the main.py, my problem was due to the port which was already in use, and then i have to take another one.

      add the import

      from threading import Thread
      from urllib.parse import unquote
      

      then just before the main function add

      class WebSocketsListener(Thread):
      """Thread chargé d'ecouter les messages sur la websocket."""
      
      def __init__(self, assistant):
          Thread.__init__(self)
          self.websocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          self.websocket.bind(('127.0.0.1', 8081))
          self.assistant = assistant
      
      
      def run(self):
          print ("Open socket")
      
          while True:
              self.websocket.listen(5)
              client, address = self.websocket.accept()
              print (format( address ))
      
              response = client.recv(255)
              if response != "":
                  print (response)
                  str_response = response.decode("utf-8")
                  if 'assistant' in str_response:
                      
                      if 'mode' in str_response:
                          if 'start' in str_response:
                              print("start the assistant") 
                              self.assistant.start_conversation()
                          if 'stop' in str_response: 
                              print("stop  the assistant") 
                              self.assistant.stop_conversation()
      
                      elif 'say' in str_response:
                          token = str_response[str_response.find("say=")+4:str_response.find("HTTP")-1]
                          token = unquote(token)
                          say(token)
      
          print ("Close socket")
          client.close()
          stock.close()
      

      in the main function just before the for event in events

          webSocketsListener = WebSocketsListener(assistant)
          webSocketsListener.start()
      

      With this, open a web browser and write
      http://127.0.0.1:8081/assistant?mode=start
      it will start manually the assistant like with the hotword"ok google"
      http://127.0.0.1:8081/assistant?mode=stop
      to stop the assistant if the conversation is too long
      http://127.0.0.1:8081/assistant?say=Hello karim how are you
      and then gassistPI will say what you write

      in the magic mirror module, you have to send this request in the node helper.js

       socketNotificationReceived: function(notification, payload) {
      
          var res = "";
          var ipadress = "127.0.0.1";
          var port = "8081";
      
      
      console.log("google assistant Node Helper Received a socket notification: " + notification + " payload:" + payload);
      if (notification === "ASSISTANT_START"){
      	request("http://"+ipadress+":"+port+"/assistant?mode=start", { json: true }, (err, res, body) => {
      		if (err) { return console.log(err); }
      		console.log(body.url);
      		console.log(body.explanation);
      	});
      }
      else if (notification === "ASSISTANT_STOP"){
      	request("http://"+ipadress+":"+port+"/assistant?mode=stop", { json: true }, (err, res, body) => {
      		if (err) { return console.log(err); }
      		console.log(body.url);
      		console.log(body.explanation);
      	});
      	
      }
      else if (notification === "ASSISTANT_SAY"){
      	console.log("assistant payload:"+payload);
      	request("http://"+ipadress+":"+port+"/assistant?say="+payload, { json: true }, (err, res, body) => {
      		if (err) { return console.log(err); }
      		console.log(body.url);
      		console.log(body.explanation);
      	});
      }		
      }	
      

      Thanks for your help

      posted in Requests
      B
      bimbim2401
    • RE: Module Sending notification to a python project

      Sorry but i cannot succeed to launch multiple script i found to intercept the get request from the module in python.

      i need some help … sorry this is my first program in python language

      Here is the script i want to modify : https://github.com/shivasiddharth/GassistPi/blob/master/src/main.py

      posted in Requests
      B
      bimbim2401
    • RE: Module Sending notification to a python project

      F12 and then network ? Right ?

      posted in Requests
      B
      bimbim2401
    • RE: Module Sending notification to a python project

      Thanks both for your response

      Do you think that the python code I have wrote is ok or can you give me the direction for the python code for listening to the notification

      posted in Requests
      B
      bimbim2401
    • RE: Module Sending notification to a python project

      so i just need to create a websocket in a python script like this below ? and it will listen to all notification from the magic mirror sending by the method sendnotification ?

      import SocketServer

      class MyTCPHandler(SocketServer.BaseRequestHandler):
      “”"
      The RequestHandler class for our server.

      It is instantiated once per connection to the server, and must
      override the handle() method to implement communication to the
      client.
      """
      
      def handle(self):
          # self.request is the TCP socket connected to the client
          self.data = self.request.recv(1024).strip()
          print "{} wrote:".format(self.client_address[0])
          print self.data
          # just send back the same data, but upper-cased
          self.request.sendall(self.data.upper())
      

      if name == “main”:
      HOST, PORT = “localhost”, 8080

      # Create the server, binding to localhost on port 8080
      server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler)
      
      # Activate the server; this will keep running until you
      # interrupt the program with Ctrl-C
      server.serve_forever()
      

      or do i have to add the MMM-WEBSOCKET module found here :
      https://github.com/JanLoebel/MMM-websocket

      posted in Requests
      B
      bimbim2401
    • Module Sending notification to a python project

      Hello,

      can someone help me to create a simple module that send all notification from the magic mirror module to a python script. I need also some help to create the code in python to intercept the notification.

      Which goal ? I have a google assistant develop in python, i am using the facial recognition and i want to send notification from MMM-facial or other module to the google assistant which is develop in python to say something when a notification is received.

      here is the link of the google assistant project : https://github.com/shivasiddharth/GassistPi

      One other way is to create a module based on the python project but i do not know how to do it, and then it will received all the notification.

      I know there is a lot of assistant module for the magic mirror, but this one works very well, it has a lot of functionnality and i can configure it easyly in french.

      thanks so much.

      posted in Requests
      B
      bimbim2401