-
Notifications
You must be signed in to change notification settings - Fork 130
Hints and tips
In many cases you will want to add more parameters to MisterHouse objects, e.g. $Dining_room_radiator->{room_name} = "Dining room";
Unfortunately these parameters become undefined each time that MisterHouse starts, so need to be initialised each time. There is a number of ways to do this. If they are static, then you can do it in your items.mht
file e.g.
GENERIC, Back_hall_detector, variable
CODE, $Back_hall_detector->{address} = "192.168.100.225";
Or in an initialising perl script e.g.
if ( $Startup or $Reload ) {
$Back_hall_detector->{address} = "192.168.100.225";
}
If they are volatile, then each time they change you will have to save this away in a file, then on startup add the routine that reloads the values from this file to your initialisation script above.
Ìn order to be able to turn logging on and off without restarting MisterHouse, define a generic item GENERIC, logging_level, Variable
in items.mht
and create a new logger e.g.
#-----------------------------------------------------------------------
# write_log (text)
# writes a log message when logging_level > 0
#-----------------------------------------------------------------------
sub write_log {
my $message = $_[0];
if ( $logging_level->{state} > 0 ) {
print_log($message);
}
return;
}
Then use write_log(zzz)
instead of print_log(zzz)
and it will only fill your log when logging_level > 0