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

No work on Freebox One #2

Open
martialman opened this issue Dec 31, 2018 · 23 comments
Open

No work on Freebox One #2

martialman opened this issue Dec 31, 2018 · 23 comments

Comments

@martialman
Copy link

martialman commented Dec 31, 2018

Hello,

Tank you for your work,
I have the new freebox One and I can not run the script, yet I have no error but there is no reaction on my freebox :

script :

#!/usr/bin/env python3.5
from remotefreebox.freeboxcontroller import FreeboxController
fbx = FreeboxController()
fbx.press("Vol+")

return :

Freebox-Player.local. found at 192.168.0.1:24322
setup_device
bind sur  ('', 0)
connect called
run.
connected <remotefreebox.rudp.client.client object at 0x76767bd0>
connected, calling device_new
device_new called
pressing Vol+

Tank you for your help

@MaximeCheramy
Copy link
Owner

Unfortunately I don't have access to a Freebox One, I won't be able to help :/

Please let me know if you manage to make it work, I would happily update the library.

@tomredhot
Copy link

Same on Freebox Delta. I try to know why.
Thanks for your work btw :)

@martialman
Copy link
Author

Hello, thank you for your return, I found the solution, I have without expressing forgotten an apostrophe in the fbx.press ("1), and it worked!
My script contained two fbx.press and the second created an error in the terminal but the first worked on my TV.
I now put at the end of each script a 1 second tempo and it works perfectly for me. (Except that from a latency of 3 seconds, because I think that the script reconnects each time to the freebox when I change my chains, would it be possible to send a command without redoing the authentication of the beginning of the script? )
So I created a lot of script that I call with my switch domoticz.

Sample script for M6:

#!/usr/bin/env python3.5
import time
from remotefreebox.freeboxcontroller import FreeboxController

fbx = FreeboxController()
fbx.press('6')
time.sleep(1)
exit

Terminal return:

pi@raspy:~ $ /home/pi/domoticz/scripts/Freebox/Freebox6.py
Freebox-Player.local. found at 192.168.0.1:24322
setup_device
bind sur  ('', 0)
connect called
run.
connected <remotefreebox.rudp.client.client object at 0x7674a810>
connected, calling device_new
device_new called
pressing 6
(grab) list is now {1}
(grab) list is now {1, 2}
(grab) list is now {1, 2, 3}
(grab) list is now {1, 2, 3, 4}

Script for National géographique :

#!/usr/bin/env python3.5
import time
from remotefreebox.freeboxcontroller import FreeboxController

fbx = FreeboxController()
fbx.press('6')
time.sleep(0.1)
fbx.press('0')
time.sleep(0.1)
exit

Do not hesitate if you need.

Little parenthesis, for the 4K Mini, I installed adb on my raspberry and I use for example :

This script for connect to Freebox ( The first lines is not neccessary but for me the reconnection bug from time to time without the first 3 lines...) :

#!/bin/sh
sudo /usr/bin/adb disconnect 192.168.0.1
sudo /usr/bin/adb shell "input keyevent 20"
sudo adb kill-server
sudo adb start-server
sudo /usr/bin/adb connect 192.168.0.1

And this script for exemple National géographique :

#!/bin/sh
sudo /usr/bin/adb shell "input keyevent $((6 + 7)) "
sleep 0.1
sudo /usr/bin/adb shell "input keyevent $((0 + 7)) "

Thanks for everything, now with Alexa, Ifttt, domoticz and your script, I order my freebox to voice.

Thank you

@tomredhot
Copy link

Wow! Thanks!
I try this in few minutes!

@tomredhot
Copy link

tomredhot commented Jan 10, 2019

For the delay :
It's because the detect() function in FreeboxController class.
You can delete this line : freebox = detect()
and hardcode IP adress & Port directly in
fb_addr = (freebox.address, freebox.port)
eg for me :
fb_addr = (192.168.0.48, 24322)
Delay for me under 0.5 seconds
:)

@tomredhot
Copy link

fb_addr = ('192.168.0.48', 24322) with quote, sorry

@tomredhot
Copy link

tomredhot commented Jan 10, 2019

For use with shell :

#!/usr/bin/envpython3.5
import time
import sys, getopt
from remotefreebox.freeboxcontroller import FreeboxController
fbx = FreeboxController()
cmdFree=''
myopts, args = getopt.getopt(sys.argv[1:],"i:o:")
for o, a in myopts:
    if o == '-i':
        cmdFree=a
        fbx.press(cmdFree)
        time.sleep(0.5)
        print ("Cmd Free : %s" % (cmdFree) )
    else:
        print("Usage: %s -i input -o output" % sys.argv[0])
exit

Usable with :
python3 sendCmd.py -i Mute for Mute the TV
or
python3 sendCmd.py -i 1 for channel 1
or
python3 sendCmd.py -i Power for Toggle
or
python3 sendCmd.py -i 1 -i 4 -i 6 for channel 146 (press 1,4 & 6)
etc..

@martialman
Copy link
Author

Thanks for the tip, but I have a problem, I modified the file /usr/local/lib/python3.5/dist-packages/remotefreebox/freeboxcontroller.py by removing the line freebox = detect () and in replacing it with fbx_addr = ('192.168.0.9', 24322) but the search for freebox is always done at startup as if I did not modify anything, if you can help me in my error? I even deleted pycache

@tomredhot
Copy link

tomredhot commented Jan 10, 2019

No no
Don't replace it.
Delete it, & modify the line
fb_addr = (freebox.address, freebox.port)
by
fb_addr = ('IP', PORT)

@tomredhot
Copy link

 freebox = detect()
 success("%s found at %s:%s" % (freebox.name, freebox.address, freebox.port))
 fb_addr = (freebox.address, freebox.port)

to (for me) :

 #freebox = detect()
 #success("%s found at %s:%s" % (freebox.name, freebox.address, freebox.port))
 fb_addr = ('192.168.0.48', 24322)

@martialman
Copy link
Author

martialman commented Jan 10, 2019

sorry but I did exactly what you did but I made a mistake ...

my script:

#/usr/bin/python3

import sys
from threading import Thread
from .detectserver import detect

from .rudp.client import client_handler
from .event_loop import event_loop
from .rudp.rudp import rudp
from .rudp_hid_client import rudp_hid_client
from .fbx_descriptor import fbx_foils_hid_device_descriptor, fbx_get_command


def info(s):
    print(s, file=sys.stderr)

def success(s):
    print(s, file=sys.stderr)


class FreeboxController(object):
    def __init__(self):

        fb_addr = ('192.168.0.1', 24322)

        # rudp event loop
        evtloop = event_loop()
        r = rudp(evtloop)
        loop_thread = Thread(target=r.evtloop.loop)
        loop_thread.daemon = True
        loop_thread.start()

        def handle_packet(cl, cmd, data):
            info("handle packet main.py (%s %s %s)" % (cl, cmd, data))

        def link_info(cl, info_):
            info("link_info %s %s" % (cl, info_))

        def connected(cl):
            info("connected %s" % cl)

        def server_lost(cl):
            info("server_lost %s" % cl)

        my_handler = client_handler(handle_packet, link_info, connected,
                                    server_lost)
        self.client = rudp_hid_client(r, my_handler, fb_addr)
        self.client.setup_device(fbx_foils_hid_device_descriptor)

    def press(self, key):
        info("pressing %s" % key)
        self.client.send_command(*fbx_get_command(key))

    def write(self, text):
        for l in text:
            self.client.send_command(1, ord(l))

I think, i modify the bad file ?
/usr/local/lib/python3.5/dist-packages/remotefreebox/freeboxcontroller.py

@tomredhot
Copy link

no it's the good one.
Are sure about the IP & Port?

@tomredhot
Copy link

freebox = detect()
success("%s found at %s:%s" % (freebox.name, freebox.address, freebox.port))
success("Name : %s" % (freebox.name))
success("address : %s" % (freebox.address))
success("port : %s" % (freebox.port))

Try this for have the exact infos

@martialman
Copy link
Author

martialman commented Jan 10, 2019

Yes and more my script works perfectly, it changes the channels of my TV ....

You modify this file /usr/local/lib/python3.5/dist-packages/remotefreebox/freeboxcontroller.py ?

pi@raspy:~ $ /home/pi/domoticz/scripts/Freebox/Freebox6.py
Freebox-Player.local. found at 192.168.0.1:24322
setup_device
bind sur  ('', 0)
connect called
run.
connected <remotefreebox.rudp.client.client object at 0x7671e890>
connected, calling device_new
device_new called
pressing 6
(grab) list is now {1}
(grab) list is now {1, 2}
(grab) list is now {1, 2, 3}
(grab) list is now {1, 2, 3, 4}
pi@raspy:~ $ 

@tomredhot
Copy link

mmmh
My tree is :

  • sendCmd.py
  • remotefreebox (directory)
    • freeboxcontroller.py
    • fbx_descriptor
    • ... etc

& I exec
python3 sendCmd.py

@tomredhot
Copy link

I think you don't edit the good file.
If you're french. I can help you at 21h by discord, or skype if needed.

@martialman
Copy link
Author

I am French yes,
but you modify which file ???

@tomredhot
Copy link

I modify freeboxcontroller.py
I need to eat. Are you available at 21h on skype or discord for talk?

@martialman
Copy link
Author

yes i'm available, i have delete /usr/local/lib/python3.5/dist-packages/remotefreebox/freeboxcontroller.py and my script still works .... the file is no longer present in my raspberry ...

@tomredhot
Copy link

:D
Let's talk. TomRadote#2168 on discord.

@martialman
Copy link
Author

excuse me, but what's discord?

@tomredhot
Copy link

oh, it's a software for talk. "Thomas MALLEN" on skype if you prefer.

@martialman
Copy link
Author

pb solved, i made a mistake, i have install with pip3 install remote freebox and i can't modify the install, the solution is install the folder remotefreebox of github and your script in this folder and you can see the modification when you modify the file remotefreebox.py.

Thank you for all and a big thank you to TomRadote and MaximeCheramy

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

No branches or pull requests

3 participants