Questions about components of uPyEasy

Moderators: Voyager, BertB, grovkillen, Stuntteam, LisaM

Post Reply
Message
Author
Edu.Uy
New user
Posts: 8
Joined: 04 Feb 2018, 20:42

Re: Questions about components of uPyEasy

#11 Post by Edu.Uy » 06 Feb 2018, 13:33

Hi Andrew.

Try installing micropython-re-pcre (intead of only "re")

rgds
Edu

AndrewJ wrote: 06 Feb 2018, 13:26 Thanks Lisa and Eduardo for the tips.
I imported the micropython-os and -machine, and copied the _onewire module over.

I have encountered some missing libraries, which I've installed using upip.install. All seem fine, with one exception. I needed a module named "re" (regular expression) and it seemed to install with upip, but it still wouldn't import. Have either of you had this problem and found a solution please?

Best wishes
Andrew

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Questions about components of uPyEasy

#12 Post by AndrewJ » 06 Feb 2018, 14:21

Thanks, that worked! :)
A.

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Questions about components of uPyEasy

#13 Post by AndrewJ » 06 Feb 2018, 14:38

OK, I'm further forward again, think I'm almost there...

I'm getting further in the startup, but with the following error now:

Code: Select all

Set syslog hostname 0.0.0.0
reloaded sink syslog
2018-02-06 13:22:47 [debug] uPyEasy-uPyEasy: Hal: Entering SetTime
2018-02-06 13:22:47 [debug] uPyEasy-uPyEasy: Main: Pre-loading home page
2018-02-06 13:22:47 [debug] uPyEasy-uPyEasy: Hal: get_ip_address linux, ip: 192.168.1.4
2018-02-06 13:22:47 [debug] uPyEasy-uPyEasy: Main: uPyEasy Main Async Loop
Traceback (most recent call last):
  File "upyeasy/__main__.py", line 64, in <module>
  File "upyeasy/__main__.py", line 56, in main
  File "/home/andrew/.micropython/lib/picoweb/__init__.py", line 275, in run
  File "/home/andrew/.micropython/lib/uasyncio/core.py", line 146, in run_forever
  File "/home/andrew/.micropython/lib/uasyncio/core.py", line 101, in run_forever
  File "/home/andrew/.micropython/lib/uasyncio/__init__.py", line 241, in start_server
OSError: [Errno 13] EACCES
Any ideas how to resolve this? The line in question in __init__.py is s.bind(ai[-1])
EACCES sounds like access permissions (?) but how to correct?

EDIT: should have made clear that I'm connected from my Linux PC via ethernet. The ethernet connection has an unusual name (ens33) so I changed this in hal.py (line 433) to try to get it working, but still the same error.

Andrew

Edu.Uy
New user
Posts: 8
Joined: 04 Feb 2018, 20:42

Re: Questions about components of uPyEasy

#14 Post by Edu.Uy » 06 Feb 2018, 16:04

Hi, did you change the port in configs file as I post yesterday?

This is because upyeasy is taring to bind to port 80 the usually is used by de web server...


AndrewJ wrote: 06 Feb 2018, 14:38 OK, I'm further forward again, think I'm almost there...

I'm getting further in the startup, but with the following error now:

Code: Select all

Set syslog hostname 0.0.0.0
reloaded sink syslog
2018-02-06 13:22:47 [debug] uPyEasy-uPyEasy: Hal: Entering SetTime
2018-02-06 13:22:47 [debug] uPyEasy-uPyEasy: Main: Pre-loading home page
2018-02-06 13:22:47 [debug] uPyEasy-uPyEasy: Hal: get_ip_address linux, ip: 192.168.1.4
2018-02-06 13:22:47 [debug] uPyEasy-uPyEasy: Main: uPyEasy Main Async Loop
Traceback (most recent call last):
  File "upyeasy/__main__.py", line 64, in <module>
  File "upyeasy/__main__.py", line 56, in main
  File "/home/andrew/.micropython/lib/picoweb/__init__.py", line 275, in run
  File "/home/andrew/.micropython/lib/uasyncio/core.py", line 146, in run_forever
  File "/home/andrew/.micropython/lib/uasyncio/core.py", line 101, in run_forever
  File "/home/andrew/.micropython/lib/uasyncio/__init__.py", line 241, in start_server
OSError: [Errno 13] EACCES
Any ideas how to resolve this? The line in question in __init__.py is s.bind(ai[-1])
EACCES sounds like access permissions (?) but how to correct?

EDIT: should have made clear that I'm connected from my Linux PC via ethernet. The ethernet connection has an unusual name (ens33) so I changed this in hal.py (line 433) to try to get it working, but still the same error.

Andrew

Edu.Uy
New user
Posts: 8
Joined: 04 Feb 2018, 20:42

Re: Questions about components of uPyEasy

#15 Post by Edu.Uy » 06 Feb 2018, 16:05

Edu.Uy wrote: 05 Feb 2018, 19:31 ......

2- the default port(80) was already used in my Raspy, so I need to chang it in the config file in config/config/<name of your config file>
..look for the port key and change the value as you need

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Questions about components of uPyEasy

#16 Post by AndrewJ » 06 Feb 2018, 16:42

Edu.Uy wrote: 06 Feb 2018, 16:05 ......

2- the default port(80) was already used in my Raspy, so I need to chang it in the config file in config/config/<name of your config file>
..look for the port key and change the value as you need
Thanks Edu, I did see your comment about this, and it sounds like the same issue. My problem is that I'm on Linux (Mint), and (as far as I know) there isn't the equivalent config file that exists on the Raspberry. I've had a good look in Settings on my Linux system but not found anything yet to specify the port. I'm hoping that perhaps @LisaM will have some ideas, as she is on Ubuntu which is similar to Mint.
Thanks again for your support. :)
Andrew

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Questions about components of uPyEasy

#17 Post by AndrewJ » 06 Feb 2018, 19:50

Well, I've got it running! I did it by a bit of a hack, though. I worked on the theory that the Errno 13 EACCES problem was similar to the problem I had in the early times with uPyEasy on ESP32 (though the error number is different). This meant that the ESP32 would work on port 9000 etc, but not 80 or even 8000. (I've never yet understood why! Maybe something in my network/router.)

So I looked at how I might "pre-program" the port number to 9000, had a good look through the code, and found in __main__.py at line 56 ..

Code: Select all

app.run(host=ip_address, port=config["port"],debug=False, **params)
which I changed to ...

Code: Select all

 app.run(host=ip_address, port='9000',debug=False, **params)


Restarted with ./micropython -m upyeasy
and now it's running and I can get it in my browser on port 9000 :D

I'd still welcome any ideas why this seems to be necessary, but it's good enough to get me started.

Thanks Lisa and Edu for your help along the way! :D
Andrew

Edu.Uy
New user
Posts: 8
Joined: 04 Feb 2018, 20:42

Re: Questions about components of uPyEasy

#18 Post by Edu.Uy » 06 Feb 2018, 20:15

Good you have it working.

Just to clarify my comment, the config file is the upyeasy file... this config files are generated automatically by upyeasy the first tie you run it.
Is not Linux version dependent. Just internal uPyEasy config. The default one is in port 80.


Lisa, setting the wifi config on ESP32 (not only Unix) was a little confusing for me too. Maybe it need some re-work or document the steps for next release. I can help you with that if you need.
First I'm taring to make the setup for buid the firmware for ESP32 (any tip on this will be great).... then I will start deep dive into the code...

Regards.
Edu

AndrewJ wrote: 06 Feb 2018, 16:42
Edu.Uy wrote: 06 Feb 2018, 16:05 ......

2- the default port(80) was already used in my Raspy, so I need to chang it in the config file in config/config/<name of your config file>
..look for the port key and change the value as you need
Thanks Edu, I did see your comment about this, and it sounds like the same issue. My problem is that I'm on Linux (Mint), and (as far as I know) there isn't the equivalent config file that exists on the Raspberry. I've had a good look in Settings on my Linux system but not found anything yet to specify the port. I'm hoping that perhaps @LisaM will have some ideas, as she is on Ubuntu which is similar to Mint.
Thanks again for your support. :)
Andrew

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Questions about components of uPyEasy

#19 Post by AndrewJ » 06 Feb 2018, 20:44

Edu.Uy wrote: 06 Feb 2018, 20:15 Good you have it working.

Just to clarify my comment, the config file is the upyeasy file... this config files are generated automatically by upyeasy the first tie you run it.
Is not Linux version dependent. Just internal uPyEasy config. The default one is in port 80.
Hello, Edu,
Aah, I understand. Sorry, I thought it was something on the RasPi config.

Where is the config file located, please? I have had a look around where the other files are, but haven't seen it. It sounds like a neater solution than what I did!

+1 for clearer documentation. I'm willing to help.

------------------

Another question, if I may. Have you been able to configure a device in your unix port of uPyeasy? I'm not sure if it's possible as the hardware is all different, but when I try I get an error (here I was trying to add a DS18 device...

Code: Select all

2018-02-06 19:28:38 [debug] uPyEasy-uPyEasy: Plugin: ds18 contruction
2018-02-06 19:28:38 [debug] uPyEasy-uPyEasy: Plugin: ds18 contruction
2018-02-06 19:28:38 [debug] uPyEasy-uPyEasy: Plugins: Init device: dummy ,instantiate plugin: DS18B20
2018-02-06 19:28:38 [debug] uPyEasy-uPyEasy: Utils: uPyEasy Name
2018-02-06 19:28:38 [debug] uPyEasy-uPyEasy: Plugin: ds18 init
2018-02-06 19:28:38 [debug] uPyEasy-uPyEasy: Plugins: Read device store: dummy
2018-02-06 19:28:38 [debug] uPyEasy-uPyEasy: Plugin: ds18 init, pin used: d0
2018-02-06 19:28:38 [debug] uPyEasy-uPyEasy: Hal: pin = d0
2018-02-06 19:28:38 [debug] uPyEasy-uPyEasy: Hal: pin linux: 0
1517945318.103 <HTTPRequest object at 7fa4ea795500> <StreamWriter <_socket 27>> OSError(13,)
Traceback (most recent call last):
  File "/home/andrew/.micropython/lib/picoweb/__init__.py", line 186, in _handle
  File "upyeasy/pages.py", line 1247, in devicesettingpage
  File "upyeasy/plugin.py", line 118, in initdevice
  File "upyeasy/plugins/ds18.py", line 79, in init
  File "upyeasy/hal.py", line 741, in pin
  File "/home/andrew/.micropython/lib/machine/pin.py", line 14, in __init__
OSError: [Errno 13] EACCES

I'd be interested to know if it works for you.
Regards
Andrew.

User avatar
micropet
Normal user
Posts: 34
Joined: 23 Jan 2018, 11:39
Location: Essen, Germany
Contact:

Re: Questions about components of uPyEasy

#20 Post by micropet » 08 Feb 2018, 18:53

That's mine now:
I copied _onewire.py to micropython/lib and compiled everything again.
But it is not found.


root@d50:/opt/micropython/ports/unix# ./micropython -m upyeasy
loaded sink log
loaded sink console
loaded sink syslog
2018-02-08T18:34:46.003 [debug] uPyEasy: Init: Init constructor
2018-02-08T18:34:46.003 [debug] uPyEasy: Init: Entering init
2018-02-08 18:34:46 [debug] uPyEasy: Init: Create directory config
2018-02-08 18:34:46 [debug] uPyEasy: Init: Create directory config exception: OSError(17,)
2018-02-08 18:34:46 [debug] uPyEasy: Init: Create directory plugins
2018-02-08 18:34:46 [debug] uPyEasy: Init: Create directory plugins exception: OSError(17,)
2018-02-08 18:34:46 [debug] uPyEasy: Init: Create directory protocols
2018-02-08 18:34:46 [debug] uPyEasy: Init: Create directory protocols exception: OSError(17,)
2018-02-08 18:34:46 [debug] uPyEasy: Init: Create directory scripts
2018-02-08 18:34:46 [debug] uPyEasy: Init: Create directory scripts exception: OSError(17,)
2018-02-08 18:34:46 [debug] uPyEasy: Init: Create directory rules
2018-02-08 18:34:46 [debug] uPyEasy: Init: Create directory rules exception: OSError(17,)
2018-02-08 18:34:46 [debug] uPyEasy: Init: config Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: network Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: protocol Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: controller Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: hardware Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: dxpin Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: dxmap Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: plugin Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: pluginstore Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: device Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: service Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: notification Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: advanced Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: script Table
2018-02-08 18:34:46 [debug] uPyEasy: Init: rule Table
2018-02-08 18:34:46 [debug] uPyEasy: Hal: Init
2018-02-08 18:34:46 [debug] uPyEasy: Hal: init, network record present
2018-02-08 18:34:46 [debug] uPyEasy: Hal: linux
2018-02-08 18:34:46 [debug] uPyEasy: Protocols: Load
2018-02-08 18:34:46 [debug] uPyEasy: Protocols: Init protocol records
2018-02-08 18:34:46 [debug] uPyEasy: Protocols: Load protocol domoticz_mqtt
2018-02-08 18:34:46 [debug] uPyEasy: Protocols: Create protocol Record: domoticz_mqtt
2018-02-08 18:34:46 [debug] uPyEasy: Protocols: Load protocol domoticz_http
2018-02-08 18:34:46 [debug] uPyEasy: Protocols: Create protocol Record: domoticz_http
2018-02-08 18:34:46 [debug] uPyEasy: Protocols: Init protocol records, run async loop
2018-02-08 18:34:46 [debug] uPyEasy: Plugins: Load
2018-02-08 18:34:46 [debug] uPyEasy: Plugins: init plugin records
2018-02-08 18:34:46 [debug] uPyEasy: Plugins: Register frozen plugin switch
2018-02-08 18:34:46 [debug] uPyEasy: Plugin: switch contruction
2018-02-08 18:34:46 [debug] uPyEasy: Plugins: Create frozen plugin Record: switch
2018-02-08 18:34:46 [debug] uPyEasy: Plugins: Register frozen plugin bme280
2018-02-08 18:34:46 [debug] uPyEasy: Plugins: Create frozen plugin Record: bme280
2018-02-08 18:34:46 [debug] uPyEasy: Plugins: Register frozen plugin test
2018-02-08 18:34:46 [debug] uPyEasy: Plugins: Create frozen plugin Record: test
2018-02-08 18:34:46 [debug] uPyEasy: Plugins: Register frozen plugin ds18
Traceback (most recent call last):
File "upyeasy/__main__.py", line 64, in <module>
File "upyeasy/__main__.py", line 40, in main
File "upyeasy/init.py", line 216, in init
File "upyeasy/plugin.py", line 60, in init
File "upyeasy/plugins/ds18.py", line 21, in <module>
File "onewire.py", line 5, in <module>
ImportError: no module named '_onewire'

Edu.Uy
New user
Posts: 8
Joined: 04 Feb 2018, 20:42

Re: Questions about components of uPyEasy

#21 Post by Edu.Uy » 08 Feb 2018, 20:24

micropet wrote: 08 Feb 2018, 18:53 That's mine now:
I copied _onewire.py to micropython/lib and compiled everything again.
But it is not found.
Try to copy it in ".micropython/lib directory" instead. It should work.

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Questions about components of uPyEasy

#22 Post by AndrewJ » 08 Feb 2018, 20:29

Hmm,
For the error 17's I;ve found if I delete the folders mentioned in each line (or rename to folder.bkp if you prefer) the first set of errors is removed. You'll probably have to do this again if you have to restart more than once.

For the _onewire error, double check that _onewire (as distinct from onewire) is in the .micropython/lib folder. If it is, I'm out of ideas - hopefuly @LisaM will be able to advise. I have found anyway that the _onewire module doesn't seem to work fully - if I try to add a DS18 device plugin in the unix port, it doesn't work for me.

Having said all that, it is early days for the uPyEasy system and we will surely get through these problems. :)
Andrew.

User avatar
micropet
Normal user
Posts: 34
Joined: 23 Jan 2018, 11:39
Location: Essen, Germany
Contact:

Re: Questions about components of uPyEasy

#23 Post by micropet » 08 Feb 2018, 21:12

[/quote]

Try to copy it in ".micropython/lib directory" instead. It should work.
[/quote]

Sorry, mistake from me.
It is ib ".micropython/lib directory", but the error remains.

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Questions about components of uPyEasy

#24 Post by AndrewJ » 09 Feb 2018, 16:52

Edu.Uy wrote: 06 Feb 2018, 20:15 Good you have it working.

Just to clarify my comment, the config file is the upyeasy file... this config files are generated automatically by upyeasy the first tie you run it.
Is not Linux version dependent. Just internal uPyEasy config. The default one is in port 80.

Regards.
Edu
Hi Edu,
Just getting back to you on this. I found your suggestion most useful today, when I ended up reinstalling micropython and upyeasy on my Linux PC. :D

I found the config file (although it took me a while at first!). The full path, on my PC at least, is

Code: Select all

  ~/micropython/ports/unix/config/config/2018-02-09_15-30-181062930438 
The first part fits with cloning micropython to my home directory, during which it creates ~/micropython and subfolders.
The actual filename will vary based on date and time of first running upyeasy.

So I changed the port= 80 to 9000, saved the file, restarted upyeasy.... and it went right onto port 9000. Brilliant. Thank you! :D
Best wishes
Andrew

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Questions about components of uPyEasy

#25 Post by LisaM » 10 Feb 2018, 19:29

AndrewJ wrote: 06 Feb 2018, 20:44 1517945318.103 <HTTPRequest object at 7fa4ea795500> <StreamWriter <_socket 27>> OSError(13,)
Traceback (most recent call last):
File "/home/andrew/.micropython/lib/picoweb/__init__.py", line 186, in _handle
File "upyeasy/pages.py", line 1247, in devicesettingpage
File "upyeasy/plugin.py", line 118, in initdevice
File "upyeasy/plugins/ds18.py", line 79, in init
File "upyeasy/hal.py", line 741, in pin
File "/home/andrew/.micropython/lib/machine/pin.py", line 14, in __init__
OSError: [Errno 13] EACCES
Hi Andrew, the contractor for the house remodeling (repairing cracks in the walls) is finally done and i'm having more time now.

The EACCES error (Error ACCESS) is often due to the Unix security layer, unless you give yourself more rights you can't access the unix hardware directly.
For the http port 80 you get the same problem, on unix everything under port 1024 is restricted and normal users can't access it (that's why 8000 or 9000 does work for you).

So you either use sudo:
sudo micropython -m upyeasy
OR give your user more rights.

Cheers,

Lisa

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Questions about components of uPyEasy

#26 Post by LisaM » 10 Feb 2018, 19:35

The FileDB database where all uPyEasy data is stored is indeed located on
~/.micropython/lib/upyeasy/config
.
Each table (entity) is in FileDB a directory under the config dir, for example hardware or config.
Each table record is a separate file in this (hardware,config, etc) directory with an unique datetimestamp as filename. The datetimestamp is the primary key for the record and is referenced when updating the record. See also the code for pages, like line 260:

Code: Select all

# Update config
        cid = db.configTable.update({"timestamp":config['timestamp']},name=config['name'],unit=config['unit'],password=config['password'],sleepenable=config['sleepenable'],sleeptime=config['sleeptime'],sleepfailure=config['sleepfailure'],port=config['port'])
Since every record is text based, it's save to change the contents of the record using a file editor.

Cheers,

Lisa

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Questions about components of uPyEasy

#27 Post by AndrewJ » 10 Feb 2018, 21:00

Hi Lisa,
Thanks for both your replies, that's good information!
I'll do some more tomorrow. I have a feeling that I might have a few more questions. ;)
Glad to hear the work on your house is done, that can be very disruptive.
Cheers,
Andrew.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests