Questions about components of uPyEasy

Moderators: Voyager, BertB, Stuntteam, LisaM

Post Reply
Message
Author
AndrewJ
Normal user
Posts: 227
Joined: 14 Feb 2017, 12:38

Questions about components of uPyEasy

#1 Post by AndrewJ » 02 Feb 2018, 21:12

Hi Lisa,
A couple of "naive" questions coming up! Please excuse if they seem silly questions. ;)

As you know, I'm planning to try to develop an OpenHAB MQTT protocol, at least in basic form. Working towards that, I'm in the process of setting up my toolchain (I've moved over to Linux now, I gave up fighting Windows). I'm also getting my head round the contents of the uPyEasy software (Beta) in the github repository.

My questions are:
- could I hope to load source files onto my ESP32, without compilation/freezing (particularly thinking of the Lolin Pro with 4MB PSRAM). Even if it ran really slow it could be useful for development and initial testing, or is this out of the question?
- I noticed that the existing Domoticz MQTT imports "ujson", but I can't see this anywhere in the beta software. There is a "json" module, is that the one to use? Or, is there something more which I need to include alongside, such as Micropython-lib, but I can't even see ujson there either.

Hope you can point me in the right direction. :)
Andrew

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

Re: Questions about components of uPyEasy

#2 Post by LisaM » 03 Feb 2018, 20:00

AndrewJ wrote:
02 Feb 2018, 21:12
Hi Lisa,
A couple of "naive" questions coming up! Please excuse if they seem silly questions. ;)

As you know, I'm planning to try to develop an OpenHAB MQTT protocol, at least in basic form. Working towards that, I'm in the process of setting up my toolchain (I've moved over to Linux now, I gave up fighting Windows). I'm also getting my head round the contents of the uPyEasy software (Beta) in the github repository.

My questions are:
- could I hope to load source files onto my ESP32, without compilation/freezing (particularly thinking of the Lolin Pro with 4MB PSRAM). Even if it ran really slow it could be useful for development and initial testing, or is this out of the question?
- I noticed that the existing Domoticz MQTT imports "ujson", but I can't see this anywhere in the beta software. There is a "json" module, is that the one to use? Or, is there something more which I need to include alongside, such as Micropython-lib, but I can't even see ujson there either.

Hope you can point me in the right direction. :)
Andrew
Hi Andrew,

I have the entire uPyEasy source code tree in Unix, in the directory ~/.micropython/lib/upyeasy, and run it there also using: micropython -m upyeasy
In unix it's blazing fast, since it's using the PC memory and speed. Don't develop in any of the SOC's, like the ESP32, they are mindboggling slow when it comes to developing. SOC's are great in testing though.

Ujson? That sounds crazy to me, don't go down that path!
For Domoticz MQTT i'm using the MQTT standard library which i import in the top of the domoticz_mqtt.py file :

Code: Select all

from umqtt.robust import MQTTClient
This library can be found here: https://github.com/micropython/micropyt ... qtt.robust
Since i don't know anything about mqtt, i let the library do all the work!

Connecting:

Code: Select all

self._mq  = MQTTClient(self._client_id, self._server, self._port, self._user, self._password)
Sending data:

Code: Select all

self._mq.publish(self._queue_out, message)
I have no idea how mqtt works and have no desire to learn it either. I just looked up how domoticz want it's message structured and applied that the message and that's all. If i where you i would do the same thing... ;)

Keep life simple if you can. :lol:

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

Re: Questions about components of uPyEasy

#3 Post by AndrewJ » 04 Feb 2018, 11:54

Hi Lisa,
Many thanks for the tips, that's going to help me a lot. :) As you can see, I'm going through a steep learning curve. ;)
(the ujson thing came in from domoticz mqtt file, it uses ujson.dumps to produce the message to be sent, but maybe there are easier ways.)
Cheers,
Andrew

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

Re: Questions about components of uPyEasy

#4 Post by AndrewJ » 04 Feb 2018, 13:38

Hi again Lisa,
LisaM wrote:
03 Feb 2018, 20:00
I have the entire uPyEasy source code tree in Unix, in the directory ~/.micropython/lib/upyeasy, and run it there also using: micropython -m upyeasy
Sorry to trouble you, but I must be missing something basic here. I'm on Linux Mint. I've put micropython from the repository in my home directory, and to correspond with yours I made the filename wtih a dot so its 'hidden'.
Then I added a folder "upyeasy" in ~/.micropython/lib, and copied everything from the uPyEasy repository, so I have sub-folders docs, modules, and src which are all populated. But when I try to run "micropython -m upyeasy" (in terminal, in directory _/.micropython/lib/upyeasy) I just get "micropython: command not found".

My directory tree in _/.micropython looks like:
snapshot1.png
snapshot1.png (66.4 KiB) Viewed 2110 times
and in ~/.micropython/lib ...
snapshot2.png
snapshot2.png (78.38 KiB) Viewed 2110 times
Can you see where I'm going wrong, please?
TIA
Andrew

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

Re: Questions about components of uPyEasy

#5 Post by AndrewJ » 04 Feb 2018, 20:05

Answering my own question, after some more Googling... :oops:

Unix port of Micropython - setup on Linux Mint.
The penny finally dropped, the syntax I needed was " ./micropython " (i.e. run micropython). But first, I needed to "make" the micropython system. I found some instructions here...
https://github.com/micropython/micropyt ... d-variants. This may help anyone else who wants to add modules to uPyEasy.

Next little challenge is to get it to import modules from the upyeasy subdirectories. I'm currently playing with PYTHONPATH environment variable and putting entries into my ~/.bashrc file - does anyone know a better way?

Andrew

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

Re: Questions about components of uPyEasy

#6 Post by Edu.Uy » 04 Feb 2018, 20:50

I have been stuck when installing additional modules manually on
"ImportError: no module named '_onewire' "

Now I'm trying to add it from /extmod, but no success by now....

Please post here if you finally figure it out.

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

Re: Questions about components of uPyEasy

#7 Post by LisaM » 05 Feb 2018, 17:13

Edu.Uy wrote:
04 Feb 2018, 20:50
I have been stuck when installing additional modules manually on
"ImportError: no module named '_onewire' "

Now I'm trying to add it from /extmod, but no success by now....

Please post here if you finally figure it out.
The _onewire library is a hardware library which doesn't exists on unix, i've build a fake one just to make it run. It's attached to this post, just copy it into the .micropython/lib directory.

Cheers,

Lisa
Attachments
_onewire.zip
(947 Bytes) Downloaded 46 times

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

Re: Questions about components of uPyEasy

#8 Post by LisaM » 05 Feb 2018, 17:22

AndrewJ wrote:
04 Feb 2018, 20:05
Answering my own question, after some more Googling... :oops:

Unix port of Micropython - setup on Linux Mint.
The penny finally dropped, the syntax I needed was " ./micropython " (i.e. run micropython). But first, I needed to "make" the micropython system. I found some instructions here...
https://github.com/micropython/micropyt ... d-variants. This may help anyone else who wants to add modules to uPyEasy.

Next little challenge is to get it to import modules from the upyeasy subdirectories. I'm currently playing with PYTHONPATH environment variable and putting entries into my ~/.bashrc file - does anyone know a better way?

Andrew

Code: Select all

micropython
>>> import upip
>>> upip.install('micropython-os')
>>> upip.install('micropython-machine')
All installed library through upip are default located in ~/.micropython/lib
Copy the entire uPyEasy source tree in the same lib directory like: ~/.micropython/lib/upyeasy

If uPyEasy complains about a missing library during startup: micropython -m upyeasy
then install this library using >>> upip.install('micropython-XXX')
where XXX is the name of the library.

Cheers,

Lisa

Ps. currently my house is redecorated, so i'm a little bit slower then usual to respond.

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

Re: Questions about components of uPyEasy

#9 Post by Edu.Uy » 05 Feb 2018, 19:31

Tks Lisa,, that was very helpful.

I have it running now on unix.... good news

The last 2 things I solved was (in case of ANdrew of somebody else needs it):
1 - i had a problem with hal.py as in line 434 always look for ETH0, but I'M using WLAN0... so You can change it, or like me, add this code after ifname = 'eth0':

ifname = 'eth0'
if(os.popen('ip addr show '+ifname).read().split("<")[1].split(",")[0] == "NO-CARRIER"):
ifname = 'wlan0'

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

Hope this could help somebody else.

Lisa. I haven't finished my setup yet, but I'm here to help you in development or reporting issues if you need some help.
Also will try to make some documentation on "how to get uPyEasy working on micropython Unix port"....

Also noticed that some tabs (like hardware) works fast on Unix but takes several seconds (lots of seconds) running on ESP32.
I will try to set up my environment to be able to compile new uPyEasy firmware to try it further (also to have build to test the latest code !!! ). Any help on set up this ESP32 environment will be great....

Regards.
Edu.
LisaM wrote:
05 Feb 2018, 17:13
Edu.Uy wrote:
04 Feb 2018, 20:50
I have been stuck when installing additional modules manually on
"ImportError: no module named '_onewire' "

Now I'm trying to add it from /extmod, but no success by now....

Please post here if you finally figure it out.
The _onewire library is a hardware library which doesn't exists on unix, i've build a fake one just to make it run. It's attached to this post, just copy it into the .micropython/lib directory.

Cheers,

Lisa

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

Re: Questions about components of uPyEasy

#10 Post by AndrewJ » 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

Edu.Uy
Normal 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: 227
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: 227
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
Normal 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
Normal 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: 227
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: 227
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
Normal 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: 227
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: 33
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
Normal 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: 227
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: 33
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: 227
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: 509
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: 509
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: 227
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 1 guest