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

cannot find accessory.state #434

Open
cactm08062 opened this issue Feb 4, 2023 · 3 comments
Open

cannot find accessory.state #434

cactm08062 opened this issue Feb 4, 2023 · 3 comments

Comments

@cactm08062
Copy link

Exception has occurred: FileNotFoundError
[WinError 2] The system cannot find the file specified: 'accessory.state'
File "C:\Users\OWNER\homekit_test\HAP-python\pyhap\accessory_driver.py", line 648, in persist
os.chmod(self.persist_file, 0o644)
File "C:\Users\OWNER\homekit_test\HAP-python\pyhap\accessory_driver.py", line 483, in add_accessory
self.persist()
File "C:\Users\OWNER\homekit_test\HAP-python\main.py", line 57, in
driver.add_accessory(accessory=get_accessory(driver))
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'accessory.state'

@Pythonaire
Copy link

The state-file will be created after the first homekit connection. It sounds like this process was never fulfilled.

@jiiiiiiiiiin
Copy link

jiiiiiiiiiin commented Aug 12, 2023

May I ask if you are experiencing this issue under the Windows operating system?
I have also encountered this issue. I tried to add the following code in line 646 of "pyhap/accessory_driver. py" to solve this problem。

with open(self.persist_file, "w", encoding="utf8") as file_handle:
    self.encoder.persist(file_handle, self.state)

@pjkundert
Copy link

On Windows os.chmod fails if the file doesn't exist; it's failing trying to make the current persistence file writable by the user, in preparation for swapping in the temporary file just written.

Fixed by #471

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

4 participants