Coder Social home page Coder Social logo

fabieu / sureflap-api Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 2.0 3.63 MB

SureFlap API is a simple, yet powerful RESTful API for products from Sure Petcare

Home Page: https://gitlab.com/sustineo/sureflap-api

License: Apache License 2.0

Python 95.30% Dockerfile 1.93% HTML 2.77%
sureflap rest restful-api python api sure-petcare

sureflap-api's Introduction

Hey there, Iโ€™m Fabian ๐Ÿ‘‹

I'm a passionate Software Developer from Germany. In the following sections you can learn more about me, my skills and my passion.

๐Ÿ”ญ My projects:

Visit my GitLab profile for all my current and latest projects.

โค๏ธ Iโ€™m passionate about:

  • Coding ๐Ÿ’ป
  • Home and task automation ๐Ÿ“ฐ
  • Learning new things
  • Sports (fistball, fitness)

๐Ÿš€ My stack:

  • Frontend: Plain HTML, CSS and JS
  • Backend: Java (Spring Boot), Python
  • Database: MongoDB, PostgreSQL
  • Infrastructure: Linux, Windows, Docker

๐Ÿ“ˆ My other accounts:

  • Docker Hub: fabieu - Docker container image library
  • GitLab: fabieu - Hosting private repositories and CI/CD pipeline

๐Ÿ“ซ How to reach me:

sureflap-api's People

Contributors

a-tell avatar fabieu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

sureflap-api's Issues

Error while installing dependencies

Hi,
when trying to install the dependencies I get the following errors:
pip install -r requirements.txt
Exception: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 330, in run wheel_cache File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 295, in populate_requirement_set wheel_cache=wheel_cache): File "/usr/lib/python2.7/dist-packages/pip/req/req_file.py", line 84, in parse_requirements filename, comes_from=comes_from, session=session File "/usr/lib/python2.7/dist-packages/pip/download.py", line 422, in get_file_content content = auto_decode(f.read()) File "/usr/lib/python2.7/dist-packages/pip/utils/encoding.py", line 25, in auto_decode return data[len(bom):].decode(encoding) File "/usr/lib/python2.7/encodings/utf_16.py", line 16, in decode return codecs.utf_16_decode(input, errors, True) UnicodeDecodeError: 'utf16' codec can't decode byte 0x0d in position 702: truncated data
Additionally I got the following message beforehand:
Could not find a version that satisfies the requirement cachetools==4.1.1 (from -r requirements.txt (line 1)) (from versions: 0.0.0, 0.1.0, 0.2.0, 0.3.0, 0.3.1, 0.4.0, 0.5.0, 0.5.1, 0.6.0, 0.7.0, 0.7.1, 0.8.0, 0.8.1, 0.8.2, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.1.6, 2.0.0, 2.0.1, 2.1.0, 3.0.0, 3.1.0, 3.1.1) No matching distribution found for cachetools==4.1.1 (from -r requirements.txt (line 1))
I've changed it to 3.1.1 in requirements.txt.
I'm using Python 3.5.3-1 on a RPi3 with Raspbian Stretch. My goal is creating a module for my MagicMirror that simply displays the current location of my cat (indoor/outdoor).

SwaggerUI TypeError: Failed to fetch

Hi again,
I've set up the server and can access the SwaggerUI with http://xxx.xxx.xxx.xxx:2311
However, I didn't manage to run it via pm2. That may be because I have to use python3.6 -m pipenv run python server.py to run it.
So, pm2 start python3.6 -m pipenv run python server.py --watch --name SureFlap_API doesn't seem to work. It gets added but I can't access the UI.

Apart from that problem, when I start the server manually I can access the UI but if I'm using the "Try it out"-feature it returns

CURL
curl -X GET "http://localhost:3001/households" -H "accept: application/json"
Request URL
http://localhost:3001/households
Code
TypeError: Failed to fetch

Thank you very much for your help so far!

Support for flap locking?

Just for confirmation, as I couldn't find anything in the documentation related to this - but there isn't support for controlling the locking status of a flap, is there?

ERROR: Exception in ASGI application

Unfortunately, I am getting this error since yesterday, when trying to fetch the "Position" / Location of the pets:

KeyError: 'position'
INFO:     192.168.0.6:56838 - "GET /households/123456/pets/location HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 366, in run_asgi
    result = await app(self.scope, self.receive, self.send)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/fastapi/applications.py", line 269, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.12/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.12/site-packages/starlette/exceptions.py", line 93, in __call__
    raise exc
  File "/usr/local/lib/python3.12/site-packages/starlette/exceptions.py", line 82, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.12/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/usr/local/lib/python3.12/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 670, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 266, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 65, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 227, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 162, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/anyio/to_thread.py", line 49, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2103, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 823, in run
    result = context.run(func, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/app/sureflap_api/main.py", line 76, in get_pets_locations
    return pets.get_pets_location(household_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/app/sureflap_api/modules/pets.py", line 75, in get_pets_location
    since = datetime.strptime(pet['position']['since'], "%Y-%m-%dT%H:%M:%S+00:00").replace(tzinfo=timezone.utc)
                              ~~~^^^^^^^^^^^^
KeyError: 'position'

I also have the impression, that some things in the app are different - maybe SurePet did some changes again?

Thanks for looking into it! :)

Cannot control the lock status

Hi

Thank you very much for developing this piece of software :-)
I have installed the docker variant and I can run all the GET commands just fine.

However if I try to change the lock state on one of my flaps, I receive an http/422 error:

Request: {{baseUrl}}/devices/:device_id/control?lock_mode=out

Response
{
"detail": "{'success':false,'error':{}}"
}

Performing a GET on the device_id returns a result as expected.

Thank you for any help.

Holger

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.