diff --git a/bin/max b/bin/max index acfbbf2..a8026ba 100755 --- a/bin/max +++ b/bin/max @@ -102,10 +102,10 @@ sub do_set { my ($room_id, $setpoint) = @_; $room_id ||= 0; - my $usage = "Usage: $0 set \n"; + my $usage = "Usage: $0 set \n"; $room_id eq 'all' or _valid_uint8($room_id) && $room_id > 0 or die $usage; - $setpoint eq 'eco' or $setpoint eq 'comfort' + $setpoint eq 'eco' or $setpoint eq 'comfort' or $setpoint eq 'boost' or _valid_temperature($setpoint) or die $usage; $max ||= Max->connect($host); @@ -114,7 +114,28 @@ sub do_set { $room->devices or warn "No devices in " . $room->display_name . ".\n"; my $t = $setpoint =~ /eco|comfort/ ? $room->get_preset($setpoint) : $setpoint; printf "Setting %s temperature to %s.\n", $room->display_name, $t; - $room->setpoint($t) or die "Setting temperature failed.\n"; + if($setpoint eq 'boost'){ + $room->boost() or die "Boosting temperature failed.\n"; + }else{ + $room->setpoint($t) or die "Setting temperature failed.\n"; + } + } + print "Done.\n"; +} + +sub do_boost { + my ($room_id) = @_; + $room_id ||= 0; + + my $usage = "Usage: $0 boost \n"; + $room_id eq 'all' or _valid_uint8($room_id) && $room_id > 0 or die $usage; + + $max ||= Max->connect($host); + + for my $room ($room_id eq 'all' ? $max->rooms : $max->room($room_id)) { + $room->devices or warn "No devices in " . $room->display_name . ".\n"; + printf "Boosting %s.\n", $room->display_name; + $room->boost() or die "Boosting temperature failed.\n"; } print "Done.\n"; } diff --git a/lib/Max.pm b/lib/Max.pm index be9f387..06999f8 100644 --- a/lib/Max.pm +++ b/lib/Max.pm @@ -126,26 +126,28 @@ sub _process_L { my $device = $self->{devices}{$addr} or warn "Unexpected device " . unpack("H*", $addr); - $device->_set(flags => { - link_error => !! ($flags & 0x0040), - battery => !! ($flags & 0x0080), - uninitialized => ! ($flags & 0x0200), - error => !! ($flags & 0x0800), - invalid => ! ($flags & 0x1000), - }); - - if (defined $setpoint) { # not for button/shutter - $temp |= !!($setpoint & 0x80) << 8; - $setpoint &= 0x7F; - - $temp = $date if $temp == 0 and $date > 0 and $device->has_temperature; - - $device->_set( - mode => $flags & 0x0003, - setpoint => $setpoint / 2, - temperature => $temp / 10, - valve => $valve, - ); + if (defined $device) { + $device->_set(flags => { + link_error => !! ($flags & 0x0040), + battery => !! ($flags & 0x0080), + uninitialized => ! ($flags & 0x0200), + error => !! ($flags & 0x0800), + invalid => ! ($flags & 0x1000), + }); + + if (defined $setpoint) { # not for button/shutter + $temp |= !!($setpoint & 0x80) << 8; + $setpoint &= 0x7F; + + $temp = $date if $temp == 0 and $date > 0 and $device->has_temperature; + + $device->_set( + mode => $flags & 0x0003, + setpoint => $setpoint / 2, + temperature => $temp / 10, + valve => $valve, + ); + } } } } diff --git a/lib/Max/Room.pm b/lib/Max/Room.pm index b63042a..7ea6e72 100644 --- a/lib/Max/Room.pm +++ b/lib/Max/Room.pm @@ -94,6 +94,12 @@ sub setpoint { return $self->_send_radio(0x40, sprintf "%02x", $t2 | 0x40); } +sub boost { + my ($self) = @_; + my $t2 = $self->_get_setpoint * 2; + return $self->_send_radio(0x40, sprintf "%02x", $t2 | 0xc0); +} + sub too_cold { my ($self, $maxdelta) = @_; $maxdelta ||= 0;