[mh] Possible Bug in ia7_utilities.pl?

Tony Yates <[email protected]> Wed, 18 Feb 2026 12:02:08 +0000
Newsgroups gmane.comp.misc.misterhouse.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============0828963779304878037==
Content-Type: multipart/alternative;
 boundary="------------w4uCDFdVoH3PoKvmK0ah6W0c"
Content-Language: en-GB

This is a multi-part message in MIME format.
--------------w4uCDFdVoH3PoKvmK0ah6W0c
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi all,

I've been running MH proxies as consoles around the house for speech 
announcements etc. for many years, currently based on a Raspberry Pi 
3b+/Touchscreen setup.

While I quite regularly update the core MH on my main server, I've been 
using a very old MH sub-tree that I just copy across to each new 
generation of Operating System update when I redevelop the consoles.

This time around I decided to try and use a current MH tree on a new 
console build.  Mostly it went OK, but I was having trouble with speech 
and a blow up in IA7_Utilities.pl, even when trying to disable ia7 
completely as I don't use a MH GUI on the proxies, I use a web page with 
house data and buttons etc.

The error:

Can't use string ("ARRAY(0x55ff1e09d488)") as an ARRAY ref while "strict 
refs" in use at /usr/local/mh/mh-git/bin/../lib/ia7_utilities.pl line 21
  at mh line 31.

I initially worked around it by simply commenting out the two references 
to ia7 in the main mh code, but I didn't really like that as a fix.  So 
I asked ChatGPT to have a look:

"Yep — this is a classic Perl ref/structure mismatch, and the error 
message is actually pretty informative once you translate it 🙂"

It then suggested a fix in ia7_utilities.pl, which seems to be working 
OK at the moment and I will include it below in case useful to others:

✅ Correct, robust fix (this should be in the distribution)

Change only this subroutine to defensively normalise web_hook.

🔧 Replace this:
sub main::json_speech_enable {
     my ($parms) = @_;
     push( @{ $parms->{web_hook} }, \&main::file_ready_for_ia7);
}

✅ With this:
sub main::json_speech_enable {
     my ($parms) = @_;

     # Ensure web_hook is a real array reference
     if ( !defined $parms->{web_hook} or ref $parms->{web_hook} ne 
'ARRAY' ) {
         $parms->{web_hook} = [];
     }

     push @{ $parms->{web_hook} }, \&main::file_ready_for_ia7;
}

Regards,

Tony..

-- 
Tony [email protected]

--------------w4uCDFdVoH3PoKvmK0ah6W0c
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi all,</p>
    <p>I've been running MH proxies as consoles around the house for
      speech announcements etc. for many years, currently based on a
      Raspberry Pi 3b+/Touchscreen setup.</p>
    <p>While I quite regularly update the core MH on my main server,
      I've been using a very old MH sub-tree that I just copy across to
      each new generation of Operating System update when I redevelop
      the consoles.</p>
    <p>This time around I decided to try and use a current MH tree on a
      new console build.  Mostly it went OK, but I was having trouble
      with speech and a blow up in IA7_Utilities.pl, even when trying to
      disable ia7 completely as I don't use a MH GUI on the proxies, I
      use a web page with house data and buttons etc.</p>
    <p>The error:  </p>
    <p>Can't use string ("ARRAY(0x55ff1e09d488)") as an ARRAY ref while
      "strict refs" in use at
      /usr/local/mh/mh-git/bin/../lib/ia7_utilities.pl line 21<br>
       at mh line 31.<br>
      <br>
    </p>
    <p>I initially worked around it by simply commenting out the two
      references to ia7 in the main mh code, but I didn't really like
      that as a fix.  So I asked ChatGPT to have a look:</p>
    <p>"Yep — this is a classic Perl ref/structure mismatch, and the
      error message is actually pretty informative once you translate it
      🙂"</p>
    <p>It then suggested a fix in ia7_utilities.pl, which seems to be
      working OK at the moment and I will include it below in case
      useful to others:</p>
    <p>✅ Correct, robust fix (this should be in the distribution)<br>
      <br>
      Change only this subroutine to defensively normalise web_hook.<br>
      <br>
      🔧 Replace this:<br>
      sub main::json_speech_enable {<br>
          my ($parms) = @_;<br>
          push( @{ $parms-&gt;{web_hook} },
      \&amp;main::file_ready_for_ia7);<br>
      }<br>
      <br>
      ✅ With this:<br>
      sub main::json_speech_enable {<br>
          my ($parms) = @_;<br>
      <br>
          # Ensure web_hook is a real array reference<br>
          if ( !defined $parms-&gt;{web_hook} or ref
      $parms-&gt;{web_hook} ne 'ARRAY' ) {<br>
              $parms-&gt;{web_hook} = [];<br>
          }<br>
      <br>
          push @{ $parms-&gt;{web_hook} },
      \&amp;main::file_ready_for_ia7;<br>
      }<br>
      <br>
    </p>
    <p>Regards,</p>
    <p>Tony..</p>
    <p> </p>
    <pre class="moz-signature" cols="72">-- 
Tony Yates                           <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a></pre>
  </body>
</html>

--------------w4uCDFdVoH3PoKvmK0ah6W0c--


--===============0828963779304878037==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============0828963779304878037==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

________________________________________________________
To unsubscribe from this list, go to: https://lists.sourceforge.net/lists/listinfo/misterhouse-users


--===============0828963779304878037==--