Code Monkey home page Code Monkey logo

Comments (19)

mariusmotea avatar mariusmotea commented on June 4, 2024

Check issue #20 . Is just a python script that need to be executed. config.json file is also mandatory.

from diyhue.

perler avatar perler commented on June 4, 2024

ok, thanks. any chance to change port 80? looks hard coded and in my case deConz is already running there..

from diyhue.

mariusmotea avatar mariusmotea commented on June 4, 2024

if you change port 80, then no hue application will be able to connect. Port must be changed on deconz side to 8080.

BTW, the version that support deconz is not published yet, please monitor the repo.

from diyhue.

mariusmotea avatar mariusmotea commented on June 4, 2024

Check branch develop for deconz support

from diyhue.

Krocko avatar Krocko commented on June 4, 2024

How can we change the deConz Port? Get the error

pi@raspberrypi:~ $ cd diyHue/BridgeEmulator/
pi@raspberrypi:~/diyHue/BridgeEmulator $ sudo ./HueEmulator.py
Config loaded
start ssdp broadcast
server stopped
config saved
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "./HueEmulator.py", line 106, in ssdpSearch
    sock.bind(server_address)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 98] Address already in use

from diyhue.

mariusmotea avatar mariusmotea commented on June 4, 2024

There is a workaround but i don't use it so far, see dresden-elektronik/deconz-rest-plugin#179 . My method is this:

  1. start hue emulator
  2. start deconz (will see the port 80 is used and will use 8080)
  3. stop hue emulator
  4. start hue emulator (now it will connect to deconz and deconz websocket)

Until developers of deconz will not provide some support here, there will be no easy option.

from diyhue.

Krocko avatar Krocko commented on June 4, 2024

Ok. That solved it. But i canโ€™t get a Connection to deCONZ.

from diyhue.

mariusmotea avatar mariusmotea commented on June 4, 2024

i forget two steps:
4. click "Unlock Gateway" in deconz settings (this error is displayed, but can he hard to see because of port listening issue for port 1900/udp)
5. edit in config.json deconz => enable => true
6. start Hue Emulator.

from diyhue.

mariusmotea avatar mariusmotea commented on June 4, 2024

look my output if i don't click "Unlock Gateway":

pi@raspberrypi:~ $ sudo ./HueEmulator.py 
Config loaded
registration fail, is the link button pressed?
start ssdp broadcast
Starting httpd...
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "./HueEmulator.py", line 105, in ssdpSearch
    sock.bind(server_address)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 98] Address already in use

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "./HueEmulator.py", line 539, in websocketClient
    ws = EchoClient('ws://127.0.0.1:' + str(bridge_config["deconz"]["websocketport"]))
KeyError: 'websocketport'

as you can see there is a record in first lines:
registration fail, is the link button pressed?

If i press the "Unlock Gateway" button:

pi@raspberrypi:~ $ sudo ./HueEmulator.py 
Config loaded
register new light 1
register new light 2
register new light 3
register new light 4
register new light 5
register new light 6
register TRADFRI remote control
register TRADFRI remote control as Philips Motion Sensor
register TRADFRI remote control
register TRADFRI remote control
update status for light 1
update status for light 3
update status for light 2
LightRequest: http://127.0.0.1:8080/api/283145a4e198cc6535/lights/1/state
 LightRequest: http://127.0.0.1:8080/api/283145a4e198cc6535/lights/2/state
LightRequest: http://127.0.0.1:8080/api/283145a4e198cc6535/lights/4/state
LightRequest: http://127.0.0.1:8080/api/283145a4e198cc6535/lights/3/state
{"e":"changed","id":"3","r":"lights","state":{"bri":0},"t":"event"}
update status for light 5
LightRequest: http://127.0.0.1:8080/api/283145a4e198cc6535/lights/5/state
update status for light 4
LightRequest: http://127.0.0.1:8080/api/283145a4e198cc6535/lights/6/state
update status for light 6
start ssdp broadcast
Starting httpd...
Exception in thread Thread-9:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "./HueEmulator.py", line 105, in ssdpSearch
    sock.bind(server_address)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 98] Address already in use

There is again the error "Address already in use" but this is for ssdp discover process, some applications use this to discover the Philips Hue Bridge (official one for example). If you already discovered the hue emulator, then you can ignore this error.

from diyhue.

mariusmotea avatar mariusmotea commented on June 4, 2024

Can i close this issue, was solved?

from diyhue.

perler avatar perler commented on June 4, 2024

ok, it's cumbersome but works, and I think you should keep this open until it's a bit more automated.

from diyhue.

perler avatar perler commented on June 4, 2024

ok, still in regard to getting things started, this here does not work:

Open http://{bridgeIP}/hue, type the bridge ip and before to click "Save" press the link button on the Hue Bridge. The total number of lights copied to Bridge Emulator will be displayed.

I assume, this is the IP the diyHue script is listening to? nothing there.. output from the script:

~/work/diyHue/BridgeEmulator# ./HueEmulator.py
Config loaded
server stopped
config saved

are there any logs to be found?

from diyhue.

mariusmotea avatar mariusmotea commented on June 4, 2024

agree, check for new updates, i add improvements at last with one PR per day. Tomorrow deconz setup will be made entirely from webgui

from diyhue.

mariusmotea avatar mariusmotea commented on June 4, 2024

Regarding the issue, to have the error that kill the application do the following:

on the end of the script you have this

if __name__ == "__main__":
    if bridge_config["deconz"]["enabled"]:
        scanDeconz()
        Thread(target=websocketClient).start()
    try:
        updateAllLights()
        Thread(target=ssdpSearch).start()
        Thread(target=ssdpBroadcast).start()
        Thread(target=schedulerProcessor).start()
        run()
    except:

move one by one the functions under try like in this example, until you receive the error (most likely config.json corrupted, or port 80 already in use):

    Thread(target=ssdpSearch).start()
    try:
        updateAllLights()
        Thread(target=ssdpSearch).start()
        #Thread(target=ssdpBroadcast).start()
        Thread(target=schedulerProcessor).start()
        run()
    except:

from diyhue.

perler avatar perler commented on June 4, 2024

I am not quite sure, what you want me to do. i can certainly comment out one line after another, but the output is the same.

port 80 is not in use:

lsof -i -P|grep :80
deCONZ 2269 pi 12u IPv4 16772 0t0 TCP *:8080 (LISTEN)

from diyhue.

mariusmotea avatar mariusmotea commented on June 4, 2024

in a few hours i will create a new PR and this one will made the integration with deconz more simple. Because i add few more keys in default config.json it will be better to start with new config from scratch. I will write here this is done.

from diyhue.

perler avatar perler commented on June 4, 2024

from diyhue.

mariusmotea avatar mariusmotea commented on June 4, 2024

I push the new release. After you start deconz on port 8080 start also Hue Emulator with new default config. Next is to click "Unlock Gateway" in deconz config then open in browser http://{raspberry ip}/deconz. Now the registration process must be done with deconz, but most likely there are no rooms configured on bridge to have what to configure on this page. Open smarthone application, configure the rooms and lights, then refresh this page to have the rooms as options.

from diyhue.

mariusmotea avatar mariusmotea commented on June 4, 2024

Is this solved, can i close?

from diyhue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.