beanz / xpl-perl

Perl modules for the xPL Home Automation Protocol
19 stars 12 forks source link

Problem with chacon module and rfxcom #7

Closed webextension closed 13 years ago

webextension commented 13 years ago

Hello, First of all, it's important to say that job is amazing! Thank you very much for this project !! But, I have a problem since I flashed my RFXLAN TX/RX to work with the xplperl firmware provide bu RFXCOM... :-( I would like to expose you my problem, because it's weird !! Every X10/oregon scientific events are received in the XPL-HUB, even chacon events. Chacon events ar recognized by a AC.BASIC SCHEMA, but since I flashed my RFXCOM, every chacon events cannot be catch into my xpl callback ... Here you will have an explanation of what I have done in order to detect this bug... Maybe that's my mistake .... in this case i will apologize for this useless issue...

My xpl callback catch only AC.BASIC schema from the xpl-hub :

$xpl->add_xpl_callback(id => "logger", self_skip => 0, targetted => 0, callback => &acmsg, filter => { message_type => 'xpl-trig', class => 'ac', class_type => 'basic', });

Run the main loop

$xpl->main_loop();

(***) The callback to log the incoming messages : I display every events with the name of the field and the field itself

sub acmsg { my %p = @_; my $msg = $p{message}; my %info;

        # Put field<->value relation in hash-table. Do not put fields with empty value in hash
        foreach my $field ($msg->body_fields) {

                    if (defined $msg->$field) {
                               $info{$field} = $msg->$field;         

                               print $field;
                               print " -> ";
                               print $info{$field};
                               print " | ";
                    }
        }
        print "\n";

return 1; };

The xpl-logger displays every events

xpl-logger -i lo -v -body ...

This is a oregon sensor.

127.0.0.1:47517 [xpl-trig/sensor.basic: rfxcom-lan.0004a31f625d -> * - th1 0xcb01[temp]=17.7] sensor.basic { device=th1 0xcb01 type=temp current=17.7 units=c } 127.0.0.1:47517 [xpl-trig/sensor.basic: rfxcom-lan.0004a31f625d -> * - th1 0xcb01[humidity]=59] sensor.basic { device=th1 0xcb01 type=humidity current=59 description=normal } 127.0.0.1:47517 [xpl-trig/sensor.basic: rfxcom-lan.0004a31f625d -> * - th1 0xcb01[battery]=100] sensor.basic { device=th1 0xcb01 type=battery current=100 } ...

This is my Chacon sensor.

Since I flashed the firmware, chacon events is detected as a 'ac' class module as described in http://www.rfxcom.com/documents/RFXCOM%20implementation%20xPL.pdf

Before I flashed the firmware Chacon events was detected as a "homeeasy" module

Chacon signals are detected but xpl-perl cannot display them anymore !! I have a blank line now !!!

127.0.0.1:47517 [xpl-trig/ac.basic: rfxcom-lan.0004a31f625d -> *] ac.basic { address=0x050a836 unit=10 command=off }

This is the output of my xpl-perl script described here (***)

xpl-trig-ac.basic -i lo -v Listening on 127.0.0.1:44693 Sending on 127.0.0.1 interval -> 5 | port -> 44693 | remote_ip -> 127.0.0.1 | <= Information about the connection to the hub <= When I use my chacon module I have a blank line and I can't see <= When I use my chacon module I have a blank line and I can't see device -> th1 0x6a01 | type -> temp | current -> 18.5 | units -> c | <= First information about my oregon sensor device -> th1 0x6a01 | type -> humidity | current -> 60 | <= First information about my oregon sensor device -> th1 0x6a01 | type -> battery | current -> 100 | <= First information about my oregon sensor <= When I use my chacon module I have a blank line and I can't see <= When I use my chacon module I have a blank line and I can't see

When I try to display address, unit or command value, my script doesn't work

sub acmsg { my %p = @_; my $msg = $p{message};

    my $command = $msg->command;
    my $address = $msg->address;
        my $unit = $msg->unit;

return 1; };

xpl-trig-ac.basic -i lo -v Listening on 127.0.0.1:49881 Sending on 127.0.0.1 Can't locate object method "command" via package "xPL::Message" at xpl-trig-ac.basic line .... ... Can't locate object method "unit" via package "xPL::Message" at xpl-trig-ac.basic line ... ... Can't locate object method "address" via package "xPL::Message" at xpl-trig-ac.basic line ...

webextension commented 13 years ago

Thanks to Rfxcom we found out the problem.

This 2 paths don't contain the AC.BASIC schema :

 /usr/share/perl5/xPL/schema
 /usr/local/share/perl/5.10.0/xPL/schema/

I copied HOMEEASY.BASIC.yaml to AC.BASIC.yaml and it works.

Thank you very much

beanz commented 13 years ago

Yes. I was about to reply with a similar suggestion. In the next release, due soon I am changing the code to avoid relying on the schema files and the API will change slightly ...

  $msg->$field

will become:

  $msg->field($field)

and class and class_type methods are combined into a single schema field.