Hello Everybody.
I've written a small perl script which connect MH to the fhem-server
LinkI can send data to fhem and i can receive data from fhem.
Now i would set the states of my MH-Items when i receive a fhem message.
The received message looks like this example:
06/09/2009 16:04:21 fhem received data: FS20 Fernseher off ---
FS20 is the object type
Fernseher is the object name
off is the object state
Here is my check for data sub:
sub check_for_data {
#Daten mitloggen----------------------------------------
if (my $data = said $FHZ_data) {
my @fhz1000_data = split (" ", $data);
if ($fhz1000_data[3] eq undef) {
$fhz1000_data[3] = '---'
}
&::print_log( "fhem received data: $fhz1000_data[0] $fhz1000_data[1] $fhz1000_data[2] $fhz1000_data[3] \n");
&FS20ST_Item::set_receive(('$'.$fhz1000_data[1]),$fhz1000_data[2],"fhem");
}
}and here the corrosponding set receive method:
sub set_receive {
my ($self, $state, $set_by) = @_;
&::print_log("set_receive:", $self, $state, $set_by);
return if &main::check_for_tied_filters($self, $state, $set_by);
&Generic_Item::set_states_for_next_pass($self, $state, $set_by);
}but i always get this error and MH restarts:
Can't use string ("$Fernseher") as a HASH ref
Exiting program: normal
I think the problem is this line:
&FS20ST_Item::set_receive(('$'.$fhz1000_data[1]),$fhz1000_data[2],"fhem");
I added the Dollar-sign as string to the name of the object so MH schould use it as Object reference, but it does not work...
My question ist :
How can i use my received Object name "Fernseher" to set the MH-Item $Fernseher to the received state?
Regards,
Thorsten Weiss