Giter VIP home page Giter VIP logo

wappsto-python's People

Contributors

andreasbomholtz avatar bubriks avatar dimitar-chicken avatar evelinamihailova avatar jkida98 avatar karstentonnesenseluxit avatar mads-slx avatar tacozmacleo avatar tsvetomir-ivanov avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wappsto-python's Issues

Offline log data

When the connection to wappsto is lost, all events should be stored to disk. When the is a connection again, it should upload all the stored events.

  • Option to enable this feature + location of the data
  • Option of maximum data stored
  • Compact old data after a day
  • Send the old events back in a slow manner

Depfu Error: No dependency files found

Hello,

We've tried to activate or update your repository on Depfu and couldn't find any supported dependency files. If we were to guess, we would say that this is not actually a project Depfu supports and has probably been activated by error.

Monorepos

Please note that Depfu currently only searches for your dependency files in the root folder. We do support monorepos and non-root files, but don't auto-detect them. If that's the case with this repo, please send us a quick email with the folder you want Depfu to work on and we'll set it up right away!

How to deactivate the project

  • Go to the Settings page of either your own account or the organization you've used
  • Go to "Installed Integrations"
  • Click the "Configure" button on the Depfu integration
  • Remove this repo (Wappsto/wappsto-python) from the list of accessible repos.

Please note that using the "All Repositories" setting doesn't make a lot of sense with Depfu.

If you think that this is a mistake

Please let us know by sending an email to [email protected].


This is an automated issue by Depfu. You're getting it because someone configured Depfu to automatically update dependencies on this project.

Spaces in strings is being removed when json is saved

All the spaces in a string is being removed when saving the json. So the device description is

"'description': 'The Grove - Red LED Button is stable and reliable with 100 000 times long life. With the build-in LED, you can apply it to many interesting projects, it is really useful to use the LED to show the status of the button. We use a high-quality N-Channel MOSFET to control the LED to ensure the high switching speed and low power consumption.'"

but it is being saved like:

'"description":"TheGrove-RedLEDButtonisstableandreliablewith100000timeslonglife.Withthebuild-inLED,youcanapplyittomanyinterestingprojects,itisreallyusefultousetheLEDtoshowthestatusofthebutton.Weuseahigh-qualityN-ChannelMOSFETtocontroltheLEDtoensurethehighswitchingspeedandlowpowerconsumption.".

Empty string is converted into null

When the json looks like this:
{"min":0,"max":1,"step":1,"unit":""}
It is converted into this:
{"min": 0, "max": 1, "step": 1, "unit": null}
It should be:
{"min": 0, "max": 1, "step": 1}

Cannot stop wappsto while connecting

You cannot use ctrl-c or any signal to stop the program while it is connecting to wappsto.
If there is a typo in the name or port it is not possible to stop the program in a nice way.

This should be possible during initialization as well, and handles so everything is close nicely.

Test for missing callbacks

If main.py does not set all callbacks wappsto-python must not crash when it tries to call these.
It should write an error instead.

Test cases to cover network, device, value, status callback - and when not set - could be a good diea.

Support bulk requests

When there are multiple items in the queue, it would be helpful to group all the events together in a single request.

So instead of sending a single json-rpc request, you should send a bulk json-rpc request.

It is basically just adding all the events into an array before sending them.

Stuck after reconnect

After there was this error in the logs, the device stop sending any messages to the server. But after a control message from the server to the device, it started sending event again.

ERROR: Error reporting state: TLS/SSL connection has been closed (EOF) (_ssl.c:2337)
INFO: Server Disconnect
INFO: Current status: Reconnecting
INFO: Trying to reconnect in 5 seconds
ERROR: Error reporting state: TLS/SSL connection has been closed (EOF) (_ssl.c:2337)
DEBUG: Update pir value to: 0
INFO: Closing connection...
INFO: Reconnected
INFO: Current status: Connected
INFO: Sending reconnect data
INFO: Current status: Running
INFO: Wappsto Initialization Complete.

Enable flake8 on tests

In tox.ini remove "test" under ignore and start fixing errors :)

Also change line with to 120 from 80.

AttributeError: 'NoneType' object has no attribute 'handlers'

Feb 27 08:31:37 SELUXIT rapid-prototype-runner[325]: 2020-02-27 08:31:37,349 - DEBUG: Callback <function network_callback at 0x762322b8> has been set.
Feb 27 08:31:37 SELUXIT rapid-prototype-runner[325]: Traceback (most recent call last):
Feb 27 08:31:37 SELUXIT rapid-prototype-runner[325]: File "main.py", line 196, in
Feb 27 08:31:37 SELUXIT rapid-prototype-runner[325]: service.get_by_id("8cd4c33f-05d0-45da-951d-0d7361e5b220").set_callback(wappsto_8cd4c33f_05d0_45da_951d_0d7361e5b220_callback)
Feb 27 08:31:37 SELUXIT rapid-prototype-runner[325]: File "/usr/lib/python3.7/site-packages/wappsto/init.py", line 129, in get_by_id
Feb 27 08:31:37 SELUXIT rapid-prototype-runner[325]: return self.socket.handlers.get_by_id(id)
Feb 27 08:31:37 SELUXIT rapid-prototype-runner[325]: AttributeError: 'NoneType' object has no attribute 'handlers'
Feb 27 08:31:37 SELUXIT rapid-prototype-runner[325]: Program ERROR with return code: 1

Implement new system test

  1. Remove existing test
  2. Design new "system test only"
    2.b. Design basic testcase
  3. Implement
    3.a. Mock ssl methods - do not make a local server
    3.b Implement basic testcase

Basic testcase:
load json, connect, initialize data model, send event, receive event, close

Failed to handle large bulk reply

Feb 19 15:58:03 PQPI-076802be rapid-prototype-runner[295]: 2020-02-19 15:58:03,765 - ERROR: Value error: b'[{"jsonrpc":"2.0","id":179,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:52.510Z"}
}},{"jsonrpc":"2.0","id":180,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:52.596Z"}}},{"jsonrpc":"2.0","id":181,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:52.646Z"
}}},{"jsonrpc":"2.0","id":182,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:52.763Z"}}},{"jsonrpc":"2.0","id":183,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:52.848Z
"}}},{"jsonrpc":"2.0","id":184,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:52.935Z"}}},{"jsonrpc":"2.0","id":185,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:52.975
Z"}}},{"jsonrpc":"2.0","id":186,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:53.082Z"}}},{"jsonrpc":"2.0","id":187,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:53.16
7Z"}}},{"jsonrpc":"2.0","id":188,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:53.253Z"}}},{"jsonrpc":"2.0","id":189,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:53.2
94Z"}}},{"jsonrpc":"2.0","id":190,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:53.400Z"}}},{"jsonrpc":"2.0","id":191,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:53.
483Z"}}},{"jsonrpc":"2.0","id":192,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:53.569Z"}}},{"jsonrpc":"2.0","id":193,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:53
.611Z"}}},{"jsonrpc":"2.0","id":194,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:53.717Z"}}},{"jsonrpc":"2.0","id":196,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:5
3.731Z"}}},{"jsonrpc":"2.0","id":195,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:53.814Z"}}},{"jsonrpc":"2.0","id":197,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:'
Feb 19 15:58:03 PQPI-076802be rapid-prototype-runner[295]: 2020-02-19 15:58:03,781 - ERROR: Value error: b'57:53.900Z"}}},{"js'
Feb 19 15:58:03 PQPI-076802be rapid-prototype-runner[295]: 2020-02-19 15:58:03,793 - ERROR: Value error: b'onrpc":"2.0","id":198,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:53.941Z"}}},{"
jsonrpc":"2.0","id":199,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:54.047Z"}}},{"jsonrpc":"2.0","id":200,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:54.131Z"}}},{
"jsonrpc":"2.0","id":201,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:54.217Z"}}},{"jsonrpc":"2.0","id":202,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:54.258Z"}}},
{"jsonrpc":"2.0","id":203,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:54.369Z"}}},{"jsonrpc":"2.0","id":204,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:54.452Z"}}}
,{"jsonrpc":"2.0","id":205,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:54.538Z"}}},{"jsonrpc":"2.0","id":206,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:54.578Z"}}
},{"jsonrpc":"2.0","id":207,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:54.686Z"}}},{"jsonrpc":"2.0","id":208,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:54.769Z"}
}},{"jsonrpc":"2.0","id":209,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:54.855Z"}}},{"jsonrpc":"2.0","id":210,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:54.899Z"
}}},{"jsonrpc":"2.0","id":211,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:55.006Z"}}},{"jsonrpc":"2.0","id":212,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:55.089Z
"}}},{"jsonrpc":"2.0","id":213,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:55.175Z"}}},{"jsonrpc":"2.0","id":214,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:55.216
Z"}}},{"jsonrpc":"2.0","id":215,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:55.325Z"}}},{"jsonrpc":"2.0","id":216,"result":{"value":true,"meta":{"server_send_time":"2020-02-19T14:57:55'
Feb 19 15:58:03 PQPI-076802be rapid-prototype-runner[295]: 2020-02-19 15:58:03,806 - ERROR: Value error: b'.409Z"}}},{"jsonrpc'

Wrong URL in init POST

When connection, the url in the RPC POST message is "/network//device" and it should just be "/network"

{"jsonrpc": "2.0", "method": "POST", "params": {"url": "/network/1b2f5a4c-3b94-46ee-8826-d9096906e6d4/device", "data": {"name": "Truck Portable Air Tuner", "meta": {"id": "00455c1d-6e76-4581-9299-85886a9cca40", "type": "device", "version": "2.0"}, "included": "1", "manufacturer": "Brunsforge", "product": "P-3239", "version": "2.0", "serial": "0391431465-1", "description": "Is like chalk and cheese What do you call cheese that isn't yours? Nacho Cheese; say cheese it is blue sky thinking processed cheese has several technical advantages over traditional cheese but don't you agree? It is no use crying over spilled milk they can also age quite well in ripening cellars where wash, rinse, repeat they can also age quite well in ripening cellars where cut the cheese.", "protocol": "Finsync Tag Controller_protocol", "communication": "always"}}, "id": 2}

Update initial report state

It should be possible to set the initial value of the report states before the first POST message is send to wappsto.

Handling incoming messages while initializing

Currently the initialization process do not use the ID of the RPC message sent with the POST request to verify that success/fail is received for the correct message.
If a control/get message is sent form the server during the initialization process, it can disrupt everything.

AttributeError: 'NoneType' object has no attribute 'uuid'

Feb 27 12:09:57 SELUXIT rapid-prototype-runner[323]: File "main.py", line 208, in
Feb 27 12:09:57 SELUXIT rapid-prototype-runner[323]: service.get_by_id("0d1ad152-f102-4d40-ae29-62e66a12d406").set_callback(wappsto_0d1ad152_f102_4d40_ae29_62e66a12d406_callback)
Feb 27 12:09:57 SELUXIT rapid-prototype-runner[323]: File "/usr/lib/python3.7/site-packages/wappsto/init.py", line 131, in get_by_id
Feb 27 12:09:57 SELUXIT rapid-prototype-runner[323]: return self.handler.get_by_id(id)
Feb 27 12:09:57 SELUXIT rapid-prototype-runner[323]: File "/usr/lib/python3.7/site-packages/wappsto/connection/handlers.py", line 219, in get_by_id
Feb 27 12:09:57 SELUXIT rapid-prototype-runner[323]: if value.control_state.uuid == id:
Feb 27 12:09:57 SELUXIT rapid-prototype-runner[323]: AttributeError: 'NoneType' object has no attribute 'uuid'
Feb 27 12:09:57 SELUXIT rapid-prototype-runner[323]: Program ERROR with return code: 1
Feb 27 12:09:57 SELUXIT rapid-prototype-runner[323]: Updated to Default.
Feb 27 12:09:57 SELUXIT rapid-prototype-runner[323]: Starting Default Script

Limit bulk size

There should be a limit on the amount of event that will be bulked together to avoid to large messages.

Maybe max 10 messages together in a single bulk.

Sending Empty Message

In the logs I have seen this log message:

DEBUG: Raw Send Json: b'[]'

But it should not be possible to send an empty message.

Conversion problem for small values

We use this function:

    def __convert_to_real(self, raw_value):
        if self.minimum < 0:
            total = abs(self.minimum) + self.maximum
        elif self.minimum and self.maximum < 0:
            total = abs(self.minimum) - abs(self.maximum)
        else:
            total = self.maximum - self.minimum
        return ((float(raw_value) * total) / 4095) + self.minimum

Where self.minimum is 0, and self.maximum is 100
Input raw value is 1 or 2 as you saw.

Status msg and callbacks are disconneted

The status object/callback are disconnected from the main running thread, and all information may not be updated to the user.
In the main.py file it is difficult to import status and get the correct status object.

Evaluate log level

A lot of places in the code info is used as log level where it maybe should be debug.
Other places warnings and errors are printed as info, etc.

Refactor send_data.py

send_data.py is a queue item/msg, so it has a very confusing name - as the connection.py have a function called send_data as well.

Remove '_cl' from variable names

Rename all the '_cl' variables, because it makes more sense that it is the name of the variable, and then just change the name of the import.

Increase coverage

We need better coverage of the code, to make sure that most of the code is tested. It is okay to add some exception handling to coverage ignore.

Implementation of delta and period

For each value there is an option to define delta and period.
Here is how we would like these two entries to work:

A refresh (get request) from the server must be sent no matter what period and delta is set to.

period, is a time defined in second that defines how often a value should be updated.
If the code sends multiple updates, these should be blocked (for example a period of 20 minutes will block values being updated every minute.)
When the time for period is triggered Wappsto-python should call a 'refresh' to ensure the value is updated.

delta, is a size that the value must be bigger/smaller than before it should be updated, for example a delta in temperature of 0.5 degree ensure that the temperature must be 0.5 degree varmer or colder before a new measurement is sent - even if the sensor measures every second.

When both delta and period are defined, delta should work as before, but period must ensure that as minimum we still update in the period interval, but only if delta values have not been triggered.

Number rounding

The values that are send is now looking like this:

DEBUG: Raw Send Json: b'{"jsonrpc": "2.0", "method": "PUT", "params": {"url": "/network/076802be-e65b-42b6-bcda-76d51e08fed8/device/4b7590d4-f6a8-4f73-9683-0a15b6d97185/value/7436695d-d57f-4fc6-a08a-4eaaeebbedea/state/8a9a5eca-a558-4cc7-935c-554478584ebb", "data": {"meta": {"id": "8a9a5eca-a558-4cc7-935c-554478584ebb", "type": "state", "version": "2.0"}, "type": "Report", "status": "Send", "data": "967.0000000000000", "timestamp": "2020-02-04T13:43:33.327822Z"}}, "id": 764}'

The value should be limited to the step size, so 967 instead of 967.0000000000000

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.