Re: [mh] mqtt_Item not firing state_now/state_changed when state value is 0
Dave Neudoerffer <[email protected]> Tue, 22 Apr 2025 17:40:35 -0400
| Newsgroups | gmane.comp.misc.misterhouse.user |
|---|---|
| Message-ID | <CAOFx8LNAF2HUYfq-+paea_WCtXSJxz_GxntNZQ9P5bmHBfSs7Q@mail.gmail.com> |
--===============0891078761900421227== Content-Type: multipart/alternative; boundary="0000000000005d7474063364d6ba" --0000000000005d7474063364d6ba Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I suspect state_now is firing, but your if will return false since state_now returns the state which is 0.... On Tue, Apr 22, 2025, 5:02=E2=80=AFPM Brian Rudy via misterhouse-users < [email protected]> wrote: > Hi folks, > > I have run into a weird issue with an mqtt_Item which, when changed, > returns a raw value of 0 or 1 but only fires state_now and state_changed = if > the value is 1. However, in the object log I can see that the state is > actually changing between 0 and 1. > Code snippet: > *$outer_front_lawn_person_status =3D new mqtt_Item($mqtt1, > "frigate/Front_Lawn/person");* > *if (my $state =3D state_now $outer_front_lawn_person_status) {* > * print_log "[Frigate Front Lawn Person]: Status changed $state";* > *}* > > > With mqtt debug enabled, I see the following in the logs: > > > > > > *04/22/2025 10:55:35 [MQTT D1]: mqtt Rcv'd: R:0 > T:'frigate/Front_Lawn/person' M:'0' 04/22/2025 10:55:35 [MQTT D1]: > mqtt_Item nom to MQTT to MH $outer_front_lawn_person_status::set(0, > mqtt=3DHASH(0x5a0323b77138)) ... 04/22/2025 11:42:12 [MQTT D1]: mqtt Rcv= 'd: > R:0 T:'frigate/Front_Lawn/person' M:'1' 04/22/2025 11:42:12 [MQTT D1]: > mqtt_Item nom to MQTT to MH $outer_front_lawn_person_status::set(1, > mqtt=3DHASH(0x5a0323b77138)) 04/22/2025 11:42:12 [Frigate Front Lawn > Person]: Status changed 1* > > > In the object logs for *$outer_front_lawn_person_status* I have: > *04/22/2025 11:42:12 1* > *04/22/2025 10:55:35 0* > > > Has anyone run into this before, and if so, how did you work around it? > > > Cheers! > -Brian > ________________________________________________________ > To unsubscribe from this list, go to: > https://lists.sourceforge.net/lists/listinfo/misterhouse-users > > --0000000000005d7474063364d6ba Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto">I suspect state_now is firing, but your if will return fa= lse since state_now returns the state which is 0....</div><br><div class=3D= "gmail_quote gmail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">O= n Tue, Apr 22, 2025, 5:02=E2=80=AFPM Brian Rudy via misterhouse-users <<= a href=3D"mailto:[email protected]">misterhouse-users= @lists.sourceforge.net</a>> wrote:<br></div><blockquote class=3D"gmail_q= uote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1e= x"><u></u> =20 =20 =20 <div> <p>Hi folks,</p> <p>I have run into a weird issue with an mqtt_Item which, when changed, returns a raw value of 0 or 1 but only fires state_now and state_changed if the value is 1. However, in the object log I can see that the state is actually changing between 0 and 1.</p> Code snippet:<br> <i>$outer_front_lawn_person_status =3D new mqtt_Item($mqtt1, "frigate/Front_Lawn/person");</i><br> <i>if (my $state =3D state_now $outer_front_lawn_person_status) {</i><b= r> <i>=C2=A0=C2=A0=C2=A0 print_log "[Frigate Front Lawn Person]: Stat= us changed $state";</i><br> <i>}</i> <p><br> </p> With mqtt debug enabled, I see the following in the logs:<br> <i>04/22/2025 10:55:35=C2=A0 [MQTT D1]: mqtt Rcv'd: R:0 T:'frigate/Front_Lawn/person' M:'0'<br> 04/22/2025 10:55:35=C2=A0 [MQTT D1]: mqtt_Item nom to MQTT to MH $outer_front_lawn_person_status::set(0, mqtt=3DHASH(0x5a0323b77138))<= br> ...<br> 04/22/2025 11:42:12=C2=A0 [MQTT D1]: mqtt Rcv'd: R:0 T:'frigate/Front_Lawn/person' M:'1'<br> 04/22/2025 11:42:12=C2=A0 [MQTT D1]: mqtt_Item nom to MQTT to MH $outer_front_lawn_person_status::set(1, mqtt=3DHASH(0x5a0323b77138))<= br> 04/22/2025 11:42:12=C2=A0 [Frigate Front Lawn Person]: Status changed= 1</i> <p><br> </p> In the object logs for=C2=A0<i>$outer_front_lawn_person_status</i> I have:<br> <i>04/22/2025 11:42:12 1</i><br> <i>04/22/2025 10:55:35 0</i> <p><i><br> </i></p> <p>Has anyone run into this before, and if so, how did you work around it?</p> <p><br> </p> Cheers!<br> -Brian<br> </div> ________________________________________________________<br> To unsubscribe from this list, go to: <a href=3D"https://lists.sourceforge.= net/lists/listinfo/misterhouse-users" rel=3D"noreferrer noreferrer" target= =3D"_blank">https://lists.sourceforge.net/lists/listinfo/misterhouse-users<= /a><br> <br> </blockquote></div> --0000000000005d7474063364d6ba-- --===============0891078761900421227== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============0891078761900421227== 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 --===============0891078761900421227==--