GithubHelp home page GithubHelp logo

Comments (18)

Ra72xx avatar Ra72xx commented on July 29, 2024 2

Anything I can do to help with this?
Currently the Nuki integration of HomeAssistant is pretty useless for me as the bridge constantly goes offline without any warning. Sometimes it gets online by itself after some time, sometimes one (or several) restarts of Homeassistant help.
I tried the above php piece of code with "php -f filename.php", but that only prints out the file content (?!?).

from pynuki.

pschmitt avatar pschmitt commented on July 29, 2024

Thanks for raising this.
What does running the following bit of code yield back?

from pynuki import NukiBridge
nb = NukiBridge.discover()[0]
nb.token = "YOUR_TOKEN"
print(f"locks: {nb.locks}")
print(f"openers: {nb.openers}")

from pynuki.

dvbit avatar dvbit commented on July 29, 2024

Fyi 111.0 works

from pynuki.

pschmitt avatar pschmitt commented on July 29, 2024

That's python.

from pynuki.

Ra72xx avatar Ra72xx commented on July 29, 2024

Stupid me... ;-)

from pynuki.

Ciqsky avatar Ciqsky commented on July 29, 2024

Thanks for raising this.
What does running the following bit of code yield back?

from pynuki import NukiBridge
nb = NukiBridge.discover()
nb.token = "YOUR_TOKEN"
print(f"locks: {nb.locks}")
print(f"openers: {nb.openers}")

How I can run this code from HASSIO?? How I can help you to resolve this problem?

from pynuki.

Ra72xx avatar Ra72xx commented on July 29, 2024

Doesn't work.

pi@raspi:~ $ python code.py 
  File "code.py", line 4
    print(f"locks: {nb.locks}")
                             ^
SyntaxError: invalid syntax

EDIT: Sorry, too fast. But also no success from my homeassistant virutalenv:

(homeassistant) $ python code.py 
Traceback (most recent call last):
  File "code.py", line 3, in <module>
    nb.token = "secret"
AttributeError: 'list' object has no attribute 'token'

from pynuki.

pschmitt avatar pschmitt commented on July 29, 2024

My bad it should have been:

nb​ ​=​ ​NukiBridge​.​discover​()[​0​]

I updated the original post above.

from pynuki.

Ra72xx avatar Ra72xx commented on July 29, 2024
  File "code.py", line 2
    nb​ ​=​ ​NukiBridge​.​discover​()[​0​]
      ^
SyntaxError: invalid character in identifier

from pynuki.

chiefdeputy avatar chiefdeputy commented on July 29, 2024

Try

from pynuki import NukiBridge
nb = NukiBridge.discover()
for bridge in nb:
  bridge.token = "xxxx"
  print(f"locks: {bridge.locks}")
  print(f"openers: {bridge.openers}")

from pynuki.

Ra72xx avatar Ra72xx commented on July 29, 2024

Do I have to enter this when the lock is working or offline? Currently it is online (strange - without any change in the configuration it has been online for at least 24h). Result is

locks: [<NukiLock: {'deviceType': 0, 'nukiId': xxxx, 'name': 'door', 'firmwareVersion': '2.7.20', 'mode': 2, 'state': 1, 'stateName': 'locked', 'batteryCritical': False}>]
openers: []

from pynuki.

Ra72xx avatar Ra72xx commented on July 29, 2024

So now the lock is offline again. However, the piece of code gives the same result as before.

locks: [<NukiLock: {'deviceType': 0, 'nukiId': xxxx, 'name': 'door', 'firmwareVersion': '2.7.20', 'mode': 2, 'state': 3, 'stateName': 'unlocked', 'batteryCritical': False}>]
openers: []

The reported state is wrong. And trying to operate the lock from HA gives

404 Client Error: Not Found for url: http:/nukiip:8080/lockAction?ts=2020-06-26T16:24:22Z&r .....

from pynuki.

pschmitt avatar pschmitt commented on July 29, 2024

The snippet's purpose is just to provide some basic info about your devices. Nothing more. No need to run it again.

from pynuki.

derandiunddasbo avatar derandiunddasbo commented on July 29, 2024

Don't know if this provides any clue to solve the issue, but operating the lock via python script from the HA instance (in my case a bash session inside the HA container) is working just fine, even while the lock is shown as unavailable in HA the whole time.

from pynuki.

Ciqsky avatar Ciqsky commented on July 29, 2024

@pschmitt do you think to resolve this problem in pynuki? Or is an HA problem?

from pynuki.

jacekkjw avatar jacekkjw commented on July 29, 2024

Definitly it's a pynuki problem. In the newest version of HA: 0.113, I downgraded nuki component to vs 0.110.7 (last worked) and together a pynuki to vs 1.3.3. Nuki lock works good again. I think (based on logs of HA), the problem appears during polling the state of nuki lock when nuki bridge is in unstable state (for example overload 503 error). I'm not sure but the problem cause one of these to lines or even both:

82: self._json = {k: v for k, v in data.items() if k != "success"}
or
93 self._json = data[0]._json.

At vs 1.3.3 of pynuki coresponding lines look that:

97: self._json.update({k: v for k, v in data.items() if k != 'success'})
and
103: self._json.update(data[0]._json)

You keep nuki_id in the _json list. If you've get messed return form the bridge (during unstable state) setting just new value to the list can result in lossing nuki_id information. If you update the list (as was in previous version - 1.3.3) the messed answer from bridge doesn't overwirite nuki_id.

from pynuki.

pearlythepirate avatar pearlythepirate commented on July 29, 2024

The fix here resolves the issue in the original post which leads me to believe it is an HA integration problem.

The only substantive difference in the lock.py (from the zip) is in line 54 removing an erroneous comma.

Using the new lock.py in my HA v0.113 got rid of the "volatized" error in my logs and now the included _LOGGER.warning entries which were the only other change in that file.

from pynuki.

pschmitt avatar pschmitt commented on July 29, 2024

So with 1.3.7 to reproduce this issue:

from pynuki import NukiBridge

nb = NukiBridge.discover()[0]
nb.token = "MY_TOKEN"

l = nb.locks[0]

print(l._json)
l.update()
print(l._json)
l.update()
print(l._json)
l.update(aggressive=True)
print(l._json)
# Shit hits the fan here:
l.update(aggressive=True)

It turns out the bridge does not return the nukiId in the response when polling with aggressive=True.

I must say that I was quite surprised that:

  1. The responses are different
  2. HASS uses aggressive polling by default. This is bad.

from pynuki.

Related Issues (10)

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.