Skip to content

Commit

Permalink
Handle newer decode_json treatement of booleans
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveNeudoerffer committed Apr 27, 2022
1 parent b8471d4 commit 70dcff1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/AoGSmartHome_Items.pm
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,16 @@ sub execute_OnOff {
my $response = ' {
"ids": [';

my $turn_on = $command->{'execution'}->[0]->{'params'}->{'on'} eq "true" ? 1 : 0;
my $turn_on;

&main::print_log( "Received execut command " . $command->{'execution'}->[0]->{'params'}->{'on'} );
if( $command->{'execution'}->[0]->{'params'}->{'on'} == 1
|| $command->{'execution'}->[0]->{'params'}->{'on'} eq "true"
) {
$turn_on = 1;
} else {
$turn_on = 0;
}

foreach my $device ( @{ $command->{'devices'} } ) {
set_state( $self, $device->{'id'}, $turn_on ? 'on' : 'off' );
Expand Down Expand Up @@ -1060,4 +1069,4 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
=cut
=cut

0 comments on commit 70dcff1

Please sign in to comment.