can you set your loglevel to debug in domogik.conf?
and do the same thing?
with loglevel debug you will see a lot more info about whats happening
can you set your loglevel to debug in domogik.conf?
and do the same thing?
with loglevel debug you will see a lot more info about whats happening
I deinstalled first and updated to the moest recent version.
I installed plugin, configured everything and then started velbus plugin
I then activated relay channel 1 and 2, velbus.log :
2013-03-19 11:54:36,085 domogik-velbus DEBUG send hbeat
2013-03-19 11:54:36,086 domogik-velbus DEBUG normal send
2013-03-19 11:54:36,092 domogik-velbus DEBUG xPL Message sent by thread Manager-new-message-cb--xpltype-xpl-cmnd-schema-hbeat.request : xpl-stat
{
hop=1
source=domogik-velbus.bartdesktop
target=domogik-manager.bartdesktop
}
hbeat.app
{
interval=5
port=34110
remote-ip=127.0.0.1
status=2
}
2013-03-19 11:54:49,643 domogik-velbus DEBUG set relay on / dim to max
2013-03-19 11:54:49,643 domogik-velbus INFO write packet
2013-03-19 11:54:49,644 domogik-velbus INFO START SENDING PACKET TO 0x22
2013-03-19 11:54:49,645 domogik-velbus DEBUG 0ff822020201d204
2013-03-19 11:54:49,645 domogik-velbus DEBUG 8
2013-03-19 11:54:49,663 domogik-velbus DEBUG starting parser
2013-03-19 11:54:49,663 domogik-velbus DEBUG Received message with type: 'relay switch status' address: 34
2013-03-19 11:54:49,664 domogik-velbus INFO schema:lighting.device, data:{'device': '34-1', 'level': 100}
2013-03-19 11:54:49,664 domogik-velbus DEBUG normal send
2013-03-19 11:54:49,668 domogik-velbus DEBUG xPL Message sent by thread velbus-process-reader : xpl-trig
{
hop=1
source=domogik-velbus.bartdesktop
target=*
}
lighting.device
{
device=34-1
level=100
}
2013-03-19 11:54:49,671 domogik-velbus DEBUG starting parser
2013-03-19 11:54:49,671 domogik-velbus DEBUG Received message with type: 'switch status' address: 34
2013-03-19 11:54:49,672 domogik-velbus INFO schema:sensor.basic, data:{'device': '34-1', 'current': 'HIGH', 'type': 'input'}
2013-03-19 11:54:49,672 domogik-velbus DEBUG normal send
2013-03-19 11:54:49,675 domogik-velbus DEBUG xPL Message sent by thread velbus-process-reader : xpl-trig
{
hop=1
source=domogik-velbus.bartdesktop
target=*
}
sensor.basic
{
device=34-1
current=HIGH
type=input
}
2013-03-19 11:54:52,088 domogik-velbus DEBUG send hbeat
2013-03-19 11:54:52,093 domogik-velbus DEBUG normal send
2013-03-19 11:54:52,095 domogik-velbus DEBUG xPL Message sent by thread Manager-new-message-cb--xpltype-xpl-cmnd-schema-hbeat.request : xpl-stat
{
hop=1
source=domogik-velbus.bartdesktop
target=domogik-manager.bartdesktop
}
hbeat.app
{
interval=5
port=34110
remote-ip=127.0.0.1
status=2
}
2013-03-19 11:55:07,677 domogik-velbus DEBUG set relay on / dim to max
2013-03-19 11:55:07,677 domogik-velbus INFO write packet
2013-03-19 11:55:07,677 domogik-velbus INFO START SENDING PACKET TO 0x22
2013-03-19 11:55:07,677 domogik-velbus DEBUG 0ff822020202d104
2013-03-19 11:55:07,678 domogik-velbus DEBUG 8
2013-03-19 11:55:07,695 domogik-velbus DEBUG starting parser
2013-03-19 11:55:07,695 domogik-velbus DEBUG Received message with type: 'relay switch status' address: 34
2013-03-19 11:55:07,703 domogik-velbus DEBUG starting parser
2013-03-19 11:55:07,703 domogik-velbus DEBUG Received message with type: 'switch status' address: 34
2013-03-19 11:55:07,703 domogik-velbus INFO s[code]chema:sensor.basic, data:{'device': '34-2', 'current': 'HIGH', 'type': 'input'}
2013-03-19 11:55:07,704 domogik-velbus DEBUG normal send
2013-03-19 11:55:07,707 domogik-velbus DEBUG xPL Message sent by thread velbus-process-reader : xpl-trig
{
hop=1
source=domogik-velbus.bartdesktop
target=*
}
sensor.basic
{
device=34-2
current=HIGH
type=input
}
2013-03-19 11:55:08,090 domogik-velbus DEBUG send hbeat
2013-03-19 11:55:08,090 domogik-velbus DEBUG normal send
2013-03-19 11:55:08,096 domogik-velbus DEBUG xPL Message sent by thread Manager-new-message-cb--xpltype-xpl-cmnd-schema-hbeat.request : xpl-stat
{
hop=1
source=domogik-velbus.bartdesktop
target=domogik-manager.bartdesktop
}
hbeat.app
{
interval=5
port=34110
remote-ip=127.0.0.1
status=2
}
2013-03-19 11:55:24,099 domogik-velbus DEBUG send hbeat
2013-03-19 11:55:24,100 domogik-velbus DEBUG normal send
2013-03-19 11:55:24,101 domogik-velbus DEBUG xPL Message sent by thread Manager-new-message-cb--xpltype-xpl-cmnd-schema-hbeat.request : xpl-stat
{
hop=1
source=domogik-velbus.bartdesktop
target=domogik-manager.bartdesktop
}
hbeat.app
{
interval=5
port=34110
remote-ip=127.0.0.1
status=2
}
hmm
[quote]2013-03-19 11:55:07,695 domogik-velbus DEBUG Received message with type: ‘relay switch status’ address: 34
2013-03-19 11:55:07,703 domogik-velbus DEBUG starting parser[/quote]
this is wierd, the info is received but its not sending out the message i’ll need to check my code
the only thing i can think of is that it can not decode the packet …
can you try the following:
1- stop the velbus plugin
2- cd to the domogik directory
3- cd to src/domogik_packages/xpl/bin
4- run ‘python velbus.py -f’ (will stay in foregrond)
run your test again, and see if something is returned on stdout
you can also find me on irc channel domogik @freenode.net
Each click I have an exception :
domogik@bart-desktop:/usr/local/src/domogik/src/domogik_packages/xpl/bin$ python velbus.py -f
HUB discovery > starting
HUB discovery > looking for the hub. I hope there is one hub, Domogik won't work without the hub!
HUB discovery > Received HBEAT echo, HUB detected
HUB discovery > hub found, configuration in progress
QC : ask > h=bartdesktop, t=velbus, k=connection-type
HUB discovery > hub found, configuration in progress
QC : res > h=bartdesktop, t=velbus, k=connection-type, v=socket
QC : ask > h=bartdesktop, t=velbus, k=device
QC : res > h=bartdesktop, t=velbus, k=device, v=127.0.0.1:3788
Exception in thread Manager-new-message-cb--xpltype-xpl-cmnd-schema-lighting.basic:
Traceback (most recent call last):
File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
self.run()
File "/usr/lib/python2.6/threading.py", line 484, in run
self.__target(*self.__args, **self.__kwargs)
File "velbus.py", line 135, in process_lighting_basic
self.manager.send_setdimmervalue( address, chan, 255 )
File "/usr/local/lib/python2.6/dist-packages/Domogik-0.3.0-py2.6.egg/domogik_packages/xpl/lib/velbus.py", line 234, in send_setdimmervalue
data = chr(0x07) + self._channels_to_byte(channel) + chr(int(level)) + chr(0x00) + chr(0x01)
ValueError: chr() arg not in range(256)
Exception in thread Manager-new-message-cb--xpltype-xpl-cmnd-schema-lighting.basic:
Traceback (most recent call last):
File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
self.run()
File "/usr/lib/python2.6/threading.py", line 484, in run
self.__target(*self.__args, **self.__kwargs)
File "velbus.py", line 135, in process_lighting_basic
self.manager.send_setdimmervalue( address, chan, 255 )
File "/usr/local/lib/python2.6/dist-packages/Domogik-0.3.0-py2.6.egg/domogik_packages/xpl/lib/velbus.py", line 234, in send_setdimmervalue
data = chr(0x07) + self._channels_to_byte(channel) + chr(int(level)) + chr(0x00) + chr(0x01)
ValueError: chr() arg not in range(256)
did you install from the repository in development mode?
or did you do the real install and downloaded the package from the repo?
I did get the sources from mercurial :
hg clone hg.domogik.org/domogik/
Then I did an install from sources. Just resolved the syntax error by setting a line in comment :
print level
"""level = (255 / 100) * level"""
print level
data = chr(0x07) + self._channels_to_byte(channel) + chr(int(level)) + chr(0x00) + chr(0x01)
self.write_packet(address, data)
in : /usr/local/lib/python2.6/dist-packages/Domogik-0.3.0-py2.6.egg/domogik_packages/xpl/lib
but that was not the real problem
I will try a developpment install now and not a real one
i think i solved it on repo.domogik, and in the default branch
repo.domogik is only updated during the night, so w’ll have to wait until tomorow
almost debugged it myself I think …
something with the level in lib/velbus.py
# procee the velbus received messages
def _process_251(self, data):
"""
Process a 251 Message
Switch status => send out when a relay is switched
"""
for channel in self._byte_to_channels(data[5]):
print channel
device = str(ord(data[2])) + "-" + str(channel)
level = -1
if (ord(data[7]) & 0x03) == 0:
level = 0
if (ord(data[7]) & 0x03) == 1:
level = 100
if level != -1:
self._callback("lighting.device",
{"device" : device,
"level" : level})
print "level"
print level
I know dirthy debugging
def _channels_to_byte(self, chan):
"""
Convert a channel to a byte
only works for one channel at a time
"""
return chr( (1 << (**int(chan)** -1)) )
the int() is not around the chan, that’s the problem, if you add that it will work
no error on stdout now, but still an erorr not receiving the message.
I think it is in this code
# procee the velbus received messages
def _process_251(self, data):
"""
Process a 251 Message
Switch status => send out when a relay is switched
"""
for channel in self._byte_to_channels(data[5]):
print "channel proces 251"
print channel
print "level"
print (ord(data[7]) & 0x03)
device = str(ord(data[2])) + "-" + str(channel)
level = -1
if (ord(data[7]) & 0x03) == 0:
level = 0
if (ord(data[7]) & 0x03) == 1:
level = 100
if level != -1:
self._callback("lighting.device",
{"device" : device,
"level" : level})
debug print activating channel 1
channel proces 251
1
level
1
debug print activating channel 1
channel proces 251
2
level
2
Level should be 1 and not 2 …
I’ll certainly will find the problem, first have to read the docs, need to know the exact structure of the data array
don’t know if it’s a proper fix, I did not read the protocol_vmb4ry verry carefull but this solves my problem :
# procee the velbus received messages
def _process_251(self, data):
"""
Process a 251 Message
Switch status => send out when a relay is switched
"""
for channel in self._byte_to_channels(data[5]):
device = str(ord(data[2])) + "-" + str(channel)
level = -1
if (ord(data[7]) & 0x03) / channel == 0:
level = 0
if (ord(data[7]) & 0x03) / channel == 1:
level = 100
if level != -1:
self._callback("lighting.device",
{"device" : device,
"level" : level})
don’t think this is the fix, as this is not correct following the relay docu
I was looking in this pdf :
velleman.be/downloads/0/velb … vmb4ry.pdf
this part, the send relay status part :
https://dl.dropbox.com/u/7624058/Selection_416.png
As far as I see, it send in decimal
1 for channel 1
2 for channel 2
4 for channel 3
8 for channel 4
on databyte 2
Followind data I get when switcinh on relay channel 1, channel 2 and channel 3
Velserv: new connection from 127.0.0.1 on socket 7
SwitchRelayOn 127.0.0.1 on socket 07: add : 22 | prio : high | rtr : off | data : 02 01
RelayStatus 127.0.0.1 on socket 06: add : 22 | prio : low | rtr : off | data : FB 01 00 01 80 00 00 00
Buttonstatus 127.0.0.1 on socket 06: add : 22 | prio : high | rtr : off | data : 00 01 00 00
SetDimvalue 127.0.0.1 on socket 07: add : 22 | prio : high | rtr : off | data : 07 01 FF 00 01
SwitchRelayOn 127.0.0.1 on socket 07: add : 22 | prio : high | rtr : off | data : 02 02
RelayStatus 127.0.0.1 on socket 06: add : 22 | prio : low | rtr : off | data : FB 02 00 02 80 00 00 00
buttonstatus 127.0.0.1 on socket 06: add : 22 | prio : high | rtr : off | data : 00 02 00 00
SetDimvalue 127.0.0.1 on socket 07: add : 22 | prio : high | rtr : off | data : 07 02 FF 00 01
SwitchRelayOn 127.0.0.1 on socket 07: add : 22 | prio : high | rtr : off | data : 02 04
Relaystatus 127.0.0.1 on socket 06: add : 22 | prio : low | rtr : off | data : FB 04 00 04 80 00 00 00
SetDimvalue 127.0.0.1 on socket 07: add : 22 | prio : high | rtr : off | data : 07 04 FF 00 01
So this code can’t be correct :
if (ord(data[7]) & 0x03) == 0:
level = 0
if (ord(data[7]) & 0x03) == 1:
level = 100
because (ord(data[7]) & 0x03) is not 1 for channel 2 , 3 and 4
neither is my code correct for channel 3 and 4, but works for channel 1 and 2
my python isn’t that good, I’m a java developper … and I hate this binary shifts
but
if (ord(data[7]) & 0x03) == 0:
is to define the level of the relay, it has nothing todo with the channel number
I know it is to define the level of the relay
Am i looking wrong; akkording to the specs I thought
that for
relay channel 1 on you get xxxxxxxx1
relay channel 2 on you get xxxxxxx1x
relay channel 3 on you get xxxxxx1xx
relay channel 4 on you get xxxxx1xxx
I dind’t find in the docs one particular bit that says that channel is ON or OF
So I thaught you need to get the status like with the blinds
def _process_236(self, data):
"""
Process a 236 Message
blind channel status => send out when the blind status changes
chan <X> <status>
chan: 00000011=1, 00001100=2
status: 0=off, 1=chan 1 up, 2=chan 1 down, 4=chan 2 up, 8=chan 2 down
foreach _byte_to_blindchannel(data[5])
status _byte_to_channels data[7]
"""
chan = self._blinchannel_to_byte(data[5])
device = str(ord(data[2]))
status = self._byte_to_channels(data[7])
command = ]
if chan == 1:
if 1 in status:
command = "up"
if 2 in status:
command = "down"
elif chan == 2:
if 4 in status:
command = "up"
if 8 in status:
command = "down"
else:
command = "off"
if command == "":
self._callback("shutter.device",
{"device" : device + "-" + chan,
"command" : command})
i just checked, and your looking at the wrong command in the pdf, this is command dec(0) and not decimal(251)
you need to look at the command 251, as this is the relay status message, but it seems your correct, something is wrong in that code
and maybe i could use the dec(0) message to
ok i found the problem
i tested and based everything on the vm4yrld and vmb4yrno relays, and they have a different 251 message.
This means that at plugin start i will need to scan for all modules, and then depending on the module type parse the message different …
This will be a major rewrite of the plugin, so i guess for now the vmb4ry is not supported …
no problem, my ugly hack is working for now.
I only have one vmb4ry module at the moment.
As soon the raspberry arives i will install that see if it works and then order some more velbus modules and start replacing more teleruptors.
make sure, that if you install mysql on the raspberry that you enable per table innodb data files, this will speed up mysql on the rasp a lot