Plugwise-2-py - an evolution of earlier python/linux work

Plugwise Forum about Plugwise devices and the Source software.

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby edwinth » Mon Aug 17, 2015 2:16 pm

Hello SevenW,

I'm trying to migrate to your version of plugwise support for linux but I'm getting errors during install
Maybe you can point me in the right direction on how to fix this ? (running on raspberry Pi2)

Thanks in advance!

Edwin


Code: Select all
pi@domoticzpi ~/Plugwise-2-py $ sudo pip install .
Processing /home/pi/Plugwise-2-py
  Requirement already satisfied (use --upgrade to upgrade): plugwise2py==2.0 from file:///home/pi/Plugwise-2-py in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): crcmod in /usr/local/lib/python2.7/dist-packages (from plugwise2py==2.0)
Requirement already satisfied (use --upgrade to upgrade): paho-mqtt in /usr/local/lib/python2.7/dist-packages (from plugwise2py==2.0)
Requirement already satisfied (use --upgrade to upgrade): pyserial in /usr/local/lib/python2.7/dist-packages/pyserial-2.7-py2.7.egg (from plugwise2py==2.0)
Building wheels for collected packages: plugwise2py
  Running setup.py bdist_wheel for plugwise2py
  Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-eZJLBe-build/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpgqEqilpip-wheel-:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-eZJLBe-build/setup.py", line 25, in <module>
      scripts=['Plugwise-2.py', 'Plugwise-2-web.py', 'plugwise_util'],
    File "/usr/lib/python2.7/distutils/core.py", line 138, in setup
      ok = dist.parse_command_line()
    File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.49-py2.7.egg/setuptools/dist.py", line 232, in parse_command_line
      result = _Distribution.parse_command_line(self)
    File "/usr/lib/python2.7/distutils/dist.py", line 467, in parse_command_line
      args = self._parse_command_opts(parser, args)
    File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.49-py2.7.egg/setuptools/dist.py", line 558, in _parse_command_opts
      nargs = _Distribution._parse_command_opts(self, parser, args)
    File "/usr/lib/python2.7/distutils/dist.py", line 523, in _parse_command_opts
      cmd_class = self.get_command_class(command)
    File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.49-py2.7.egg/setuptools/dist.py", line 362, in get_command_class
      ep.require(installer=self.fetch_build_egg)
    File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2099, in require
      working_set.resolve(self.dist.requires(self.extras),env,installer))
    File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2309, in requires
      dm = self._dep_map
    File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2538, in _dep_map
      self.__dep_map = self._compute_dependencies()
    File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2571, in _compute_dependencies
      common = frozenset(reqs_for_extra(None))
    File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2568, in reqs_for_extra
      if req.marker_fn(override={'extra':extra}):
    File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.49-py2.7.egg/_markerlib/markers.py", line 109, in marker_fn
      return eval(compiled_marker, environment)
    File "<environment marker>", line 1, in <module>
  NameError: name 'sys_platform' is not defined

----------------------------------------
Failed building wheel for plugwise2py
Failed to build plugwise2py
edwinth
Starting Member
Starting Member
 
Posts: 2
Joined: June 2013

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby edwinth » Tue Aug 18, 2015 10:56 am

Tried the installation on a clean domoticz sdcard image(v2563) on spare pi. Install succeeds but errors pop up in logs after starting

Cirkle+ and plugwise stick were working ok using the old style script and tested with original source software on windows.
Serial port mapping to usb is fixed ( http://www.domoticz.com/wiki/PersistentUSBDevices )

manual start of plugwise_util gives me
Code: Select all
/home/pi/Plugwise-2-py$ ./plugwise_util
Traceback (most recent call last):
  File "./plugwise_util", line 14, in <module>
    import plugwise.util
ImportError: No module named util


pw-logger.log
Code: Select all
2015-08-17 14:23:29,947 - pw-logger - INFO - logging started
2015-08-17 14:23:29,949 - pw-logger - INFO - MQTT client initializing for 127.0.0.1:1883
2015-08-17 14:23:29,956 - pw-logger - INFO - MQTT connected return code 0
2015-08-17 14:23:29,957 - pw-logger - DEBUG - MQTT init done
2015-08-17 14:23:29,958 - pw-logger - INFO - MQTT subscribed to plugwise2py/cmd/# with qos 0
2015-08-17 14:23:29,960 - pw-logger - INFO - MQTT thread started
2015-08-17 14:23:29,962 - pw-logger - INFO - MQTT connected return code 0
2015-08-17 14:23:29,965 - pw-logger - DEBUG - SEND   14 '\x05\x05\x03\x03000AB43C\r\n'
2015-08-17 14:23:29,972 - pw-logger - DEBUG - STRU      '--->' '0000' '0001' <data> 'FEED' '<---'
2015-08-17 14:23:29,973 - pw-logger - DEBUG - DATA    4 '00C1'
2015-08-17 14:23:29,975 - pw-logger - DEBUG - PARS      '00C1' EVAL '193'
2015-08-17 14:23:29,982 - pw-logger - DEBUG - STRU      '--->' '0011' '0001' <data> 'E48B' '<---'
2015-08-17 14:23:29,983 - pw-logger - DEBUG - DATA   26 '0101030D6F0000729E10D603FF'
2015-08-17 14:23:29,985 - pw-logger - DEBUG - PARS      '01' EVAL '1'
2015-08-17 14:23:29,985 - pw-logger - DEBUG - PARS      '01' EVAL '1'
2015-08-17 14:23:29,986 - pw-logger - DEBUG - PARS      '030D6F0000729E10' EVAL '219954002609217040'
2015-08-17 14:23:29,987 - pw-logger - DEBUG - PARS      'D603' EVAL '54787'
2015-08-17 14:23:29,988 - pw-logger - DEBUG - PARS      'FF' EVAL '255'
2015-08-17 14:23:29,989 - pw-logger - DEBUG - <plugwise.protocol.PlugwiseStatusResponse object at 0x10e2dd0>
2015-08-17 14:23:29,995 - pw-logger - DEBUG - SEND   30 '\x05\x05\x03\x030023000D6F0001729E102443\r\n'
2015-08-17 14:23:30,003 - pw-logger - DEBUG - STRU      '-->>' '0000' '0002' <data> '103F' '<---'
2015-08-17 14:23:30,004 - pw-logger - DEBUG - DATA    4 '00C1'
2015-08-17 14:23:30,006 - pw-logger - DEBUG - PARS      '00C1' EVAL '193'
2015-08-17 14:23:30,064 - pw-logger - INFO - MQTT Subscribed: 1 (0,)
2015-08-17 14:23:31,583 - pw-logger - DEBUG - STRU      '-->>' '0000' '0002' <data> 'BA99' '<---'
2015-08-17 14:23:31,584 - pw-logger - DEBUG - DATA    4 '00E1'
2015-08-17 14:23:31,585 - pw-logger - ERROR - unexpected response [1]:'expected response code 0024, received code 0000'
2015-08-17 14:23:31,586 - pw-logger - DEBUG - STRU      '-->>' '0000' '0002' <data> 'BA99' '<---'
2015-08-17 14:23:31,587 - pw-logger - DEBUG - DATA    4 '00E1'
2015-08-17 14:23:31,589 - pw-logger - DEBUG - PARS      '00E1' EVAL '225'
2015-08-17 14:23:31,590 - pw-logger - DEBUG - Received an error status '00E1' from circle 'circle+' - Network slow or circle offline - Retry receive ...
2015-08-17 14:23:33,598 - pw-logger - ERROR - OFFLINE Circle 'circle+' during initialization Error: Timeout while waiting for response from circle 'circle+'
2015-08-17 14:23:33,599 - pw-logger - INFO - adding circle: circle+
2015-08-17 14:23:33,602 - pw-logger - DEBUG - read_schedules
2015-08-17 14:23:33,604 - pw-logger - INFO - generate schedule: __PW2PY__test-alternate
2015-08-17 14:23:33,606 - pw-logger - INFO - generate schedule: __PW2PY__test-10
2015-08-17 14:23:33,607 - pw-logger - DEBUG - poll_configuration()
2015-08-17 14:23:33,609 - pw-logger - DEBUG - read_apply_controls
2015-08-17 14:23:33,610 - pw-logger - INFO - mac from controls not found in circles


pw-communications.log
Code: Select all
2015-08-17 14:23:29,900 - pwcomm - logging started
2015-08-17 14:23:29,964 - pwcomm - SEND   14 ---> 000A                             B43C <---
2015-08-17 14:23:29,974 - pwcomm - RECV   22 ---> 0000 0001 00C1 ................  FEED <---
2015-08-17 14:23:29,984 - pwcomm - RECV   60 ---> 0011 0001 .... 000D6F00045243B0 0101030D6F0000729E10D603FF E48B <---
2015-08-17 14:23:29,994 - pwcomm - SEND   30 ---> 0023           000D6F0001729E10  2443 <---
2015-08-17 14:23:30,005 - pwcomm - RECV   22 -->> 0000 0002 00C1 ................  103F <---
2015-08-17 14:23:30,015 - pwcomm - DTRC   91 '# APSRequestNodeInfo: Source MAC: 000D6F00045243B0# APSRequestNodeInfo: Destination MAC: \r\n'
2015-08-17 14:23:30,017 - pwcomm - DSHR   18 '000D6F0001729E10\r\n'
2015-08-17 14:23:31,588 - pwcomm - RECV   22 -->> 0000 0002 00E1 ................  BA99 <---
2015-08-17 14:23:33,596 - pwcomm - TOUT      '' - <!> Timeout on serial port
2015-08-17 14:24:21,892 - pwcomm - logging started
2015-08-17 14:24:21,980 - pwcomm - SEND   14 ---> 000A                             B43C <---
2015-08-17 14:24:22,805 - pwcomm - RECV   22 ---> 0000 0003 00C1 ................  BA6E <---
2015-08-17 14:24:22,814 - pwcomm - RECV   60 ---> 0011 0003 .... 000D6F00045243B0 0101030D6F0000729E10D603FF 319F <---
2015-08-17 14:24:22,824 - pwcomm - SEND   30 ---> 0023           000D6F0001729E10  2443 <---
2015-08-17 14:24:22,835 - pwcomm - RECV   22 -->> 0000 0004 00C1 ................  DDBA <---
2015-08-17 14:24:22,845 - pwcomm - DTRC   91 '# APSRequestNodeInfo: Source MAC: 000D6F00045243B0# APSRequestNodeInfo: Destination MAC: \r\n'
2015-08-17 14:24:22,848 - pwcomm - DSHR   18 '000D6F0001729E10\r\n'
2015-08-17 14:24:24,416 - pwcomm - RECV   22 -->> 0000 0004 00E1 ................  771C <---
2015-08-17 14:24:26,424 - pwcomm - TOUT      '' - <!> Timeout on serial port
edwinth
Starting Member
Starting Member
 
Posts: 2
Joined: June 2013

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby pixiandreas » Sat Aug 29, 2015 7:50 pm

Hello

I have start to use your script with openhab and it works perfect, but i have 2 questions:

1: Is it possible to change the interval to send info to mqtt, i think 10 sec is i little bit to much (i have 20 circles)
2: Some of my circles i disconnected but will bill we connected , is there any problem to have some circles disconnected for a week or 2 ??


I have also create an upstart script (init)

with this script you can easy stop and start it
And it will respwan automatically it it dies

Code: Select all
# description "Start and Stop Plugwise2py"
# author "Andreas Henriksson"
#
# Will NOT work on system without upstart (raspberry pi ...)
#
# Changes to be done:
#
# 1. setuid = Users who's running the script
# 2. chdir = Path to Plugwise-2-py directory
# 3. Change path to Plugwiae-2.py in script area

start on runlevel [2345]
stop on runlevel [^2345]

setuid andreas
chdir /home/andreas/Plugwise-2-py

respawn
respawn limit 20 5

script   
    /home/andreas/Plugwise-2-py/Plugwise-2.py
end script




Andreas H
pixiandreas
Starting Member
Starting Member
 
Posts: 3
Joined: June 2012

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby SevenW » Mon Nov 02, 2015 9:52 pm

The actual error in the pip output could be due to an older version of the python installation tools. It may be solved by this:
Code: Select all
pip install --upgrade setuptools


Otherwise, some more hints are in this forum:
https://github.com/mushorg/glastopf/issues/200

edwinth wrote:Hello SevenW,

I'm trying to migrate to your version of plugwise support for linux but I'm getting errors during install
Maybe you can point me in the right direction on how to fix this ? (running on raspberry Pi2)

Thanks in advance!

Edwin
SevenW
Starting Member
Starting Member
 
Posts: 26
Joined: May 2012

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby SevenW » Mon Nov 02, 2015 10:09 pm

edwinth wrote:
manual start of plugwise_util gives me
Code: Select all
/home/pi/Plugwise-2-py$ ./plugwise_util
Traceback (most recent call last):
  File "./plugwise_util", line 14, in <module>
    import plugwise.util
ImportError: No module named util



Solved this problem. Updated version of plugwise_util in github now.

SevenW
SevenW
Starting Member
Starting Member
 
Posts: 26
Joined: May 2012

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby SevenW » Mon Nov 02, 2015 10:17 pm

Hi Edwin,

I hope this is solved by now. What I see from the attached logging looks like the circle+ is not seen by the stick. It communicates properly with the stick, but the stick generates an error reply 0xE1. It could be cause by
1. Circle+ out of range of Stick or unconnected (unlikely)
2. Typo in MAC of the circle+ in the configuration file (easy to make error).

edwinth wrote:Tried the installation on a clean domoticz sdcard image(v2563) on spare pi. Install succeeds but errors pop up in logs after starting

Cirkle+ and plugwise stick were working ok using the old style script and tested with original source software on windows.
Serial port mapping to usb is fixed ( http://www.domoticz.com/wiki/PersistentUSBDevices )


SevenW
SevenW
Starting Member
Starting Member
 
Posts: 26
Joined: May 2012

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby SevenW » Mon Nov 02, 2015 10:31 pm

pixiandreas wrote:Hello

I have start to use your script with openhab and it works perfect, but i have 2 questions:

1: Is it possible to change the interval to send info to mqtt, i think 10 sec is i little bit to much (i have 20 circles)
2: Some of my circles i disconnected but will bill we connected , is there any problem to have some circles disconnected for a week or 2 ??


Hi Andreas,

Thanks for the upstart script. I will take a look at it end see if I can at it to the installation instructions.

Question 1:
Yes, by modifiying line 1224 in Plugwise-2.py from:
Code: Select all
            #align to next 10 second boundary, while checking for input commands.
            ref = datetime.now()
            proceed_at = ref + timedelta(seconds=(10 - ref.second%10), microseconds= -ref.microsecond)
            while datetime.now() < proceed_at:
                if mqtt: self.process_mqtt_commands()
                time.sleep(0.5)

to, for example 30 seconds heartbeat:
Code: Select all
           proceed_at = ref + timedelta(seconds=(30 - ref.second%30), microseconds= -ref.microsecond)

I think the program will still behave well for values of 60 seconds or more.

Question 2:
Disconnected circles is not a real problem, unless there are many. The program is robust, but not smart in this. Every unconnected/out of range/offline circle generates a timeout after about two seconds. So every missing circle adds 2 seconds delay and with many missing circles it can exceed the 10 seconds (default heart beat), so the cycle time becomes longer than intended. It also generates more logging, but as said, it just works.

SevenW
SevenW
Starting Member
Starting Member
 
Posts: 26
Joined: May 2012

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby 3ssen » Mon Dec 12, 2016 3:23 pm

I'm trying to use plugwise-2-py. Installed everything and configured two circles to test the plugwise-2-web. When I try to switch a circle it doesn't respond.

My workaround for now is using the config page in the website and switch there.

Does anyone know what can be the problem?
3ssen
Starting Member
Starting Member
 
Posts: 1
Joined: December 2016

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby Edwin » Mon Feb 27, 2017 10:40 pm

HI,i cant get it to start at all,
i folowed the wiki ,configured the config.json files and the node red flow ,node red is running and mosquito also,i have made a dummy hardware device idx 9 and adjust that in the node red flow
but when i try to run plugwise-2.py i get this error:

pi@raspberrypi:~/Plugwise-2-py $ python Plugwise-2.py
True
Traceback (most recent call last):
File "Plugwise-2.py", line 88, in <module>
open_logcomm(logpath+"pw-communication.log")
File "/home/pi/Plugwise-2-py/swutil/util.py", line 106, in open_logcomm
handler = logging.handlers.RotatingFileHandler(filename, maxBytes=1000000, backupCount=5)
File "/usr/lib/python2.7/logging/handlers.py", line 117, in __init__
BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
File "/usr/lib/python2.7/logging/handlers.py", line 64, in __init__
logging.FileHandler.__init__(self, filename, mode, encoding, delay)
File "/usr/lib/python2.7/logging/__init__.py", line 911, in __init__
StreamHandler.__init__(self, self._open())
File "/usr/lib/python2.7/logging/__init__.py", line 936, in _open
stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: u'/home/pi/pwlog/pw-communication.log'
pi@raspberrypi:~/Plugwise-2-py $

what is wrong?

thanks
Edwin
Member
Member
 
Posts: 446
Joined: October 2007
Location: Netherlands

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby Bwired » Tue Feb 28, 2017 4:39 pm

try to start it with "sudo"
User avatar
Bwired
Administrator
Administrator
 
Posts: 5301
Joined: March 2006
Location: Netherlands

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby Edwin » Tue Feb 28, 2017 6:26 pm

thanks,
now it works
how can i run it just as pi?
Edwin
Member
Member
 
Posts: 446
Joined: October 2007
Location: Netherlands

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby Bwired » Wed Mar 01, 2017 12:00 am

i had the same problems, look at where the software is installed and you see that owner is mostly root, you need to change all to PI and try again.
User avatar
Bwired
Administrator
Administrator
 
Posts: 5301
Joined: March 2006
Location: Netherlands

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby Edwin » Wed Mar 01, 2017 7:44 am

Thank u very much,
I will do that.

Greetings
Edwin
Edwin
Member
Member
 
Posts: 446
Joined: October 2007
Location: Netherlands

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby Edwin » Wed Mar 01, 2017 9:15 am

Its working now,
But when i start plugwise-2-web.py it starts for a few minuts and then it stops and i cant switch the circles
It gives this error:

python Plugwise-2-web.py
handle(): Exception: in SimpleHTTPRequestHandler.handle(): (32, 'Broken pipe')
finish(): Exception: in SimpleHTTPRequestHandler.finish(): (32, 'Broken pipe')

What could be the problem?
Edwin
Member
Member
 
Posts: 446
Joined: October 2007
Location: Netherlands

Re: Plugwise-2-py - an evolution of earlier python/linux work

Postby Bwired » Wed Mar 01, 2017 5:52 pm

mhhh dont know, try to mail Sevenw with this problem
he has a Github for this also...
User avatar
Bwired
Administrator
Administrator
 
Posts: 5301
Joined: March 2006
Location: Netherlands

PreviousNext

Return to Plugwise Forum

Who is online

Users browsing this forum: No registered users and 1 guest