Re: [mh] mqtt_Item not firing state_now/state_changed when state value is 0
Brian Rudy via misterhouse-users <[email protected]> Wed, 23 Apr 2025 10:19:12 -0700
| Newsgroups | gmane.comp.misc.misterhouse.user |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--===============3697314250532198393==
Content-Type: multipart/alternative;
boundary="------------00C0OcGdcM5hQpSYVzxfF9Yb"
Content-Language: en-US
This is a multi-part message in MIME format.
--------------00C0OcGdcM5hQpSYVzxfF9Yb
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Thanks! That was it.
Since state_now/state_changed are null when there is no change, I just
check if it is defined.
The following snippet shows what I ended up with:
/if (defined(state_changed $outer_front_lawn_person_status)) {
print_log "[Frigate Front Lawn Person]: Status changed " . state
$outer_front_lawn_person_status;
}/
On 4/22/2025 2:40 PM, Dave Neudoerffer wrote:
> 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 PM 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 = new mqtt_Item($mqtt1,
> "frigate/Front_Lawn/person");/
> /if (my $state = 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=HASH(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=HASH(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
>
>
>
> ________________________________________________________
> To unsubscribe from this list, go to:https://lists.sourceforge.net/lists/listinfo/misterhouse-users
>
--------------00C0OcGdcM5hQpSYVzxfF9Yb
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>Thanks! That was it. </p>
<p>Since state_now/state_changed are null when there is no change, I
just check if it is defined.<br>
</p>
<p>The following snippet shows what I ended up with:</p>
<i>if (defined(state_changed $outer_front_lawn_person_status)) {<br>
print_log "[Frigate Front Lawn Person]: Status changed " .
state $outer_front_lawn_person_status;<br>
}</i><br>
<p><br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 4/22/2025 2:40 PM, Dave Neudoerffer
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAOFx8LNAF2HUYfq-+paea_WCtXSJxz_GxntNZQ9P5bmHBfSs7Q@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="auto">I suspect state_now is firing, but your if will
return false since state_now returns the state which is 0....</div>
<br>
<div class="gmail_quote gmail_quote_container">
<div dir="ltr" class="gmail_attr">On Tue, Apr 22, 2025, 5:02 PM
Brian Rudy via misterhouse-users <<a
href="mailto:[email protected]"
moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote"
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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 = new mqtt_Item($mqtt1,
"frigate/Front_Lawn/person");</i><br>
<i>if (my $state = state_now
$outer_front_lawn_person_status) {</i><br>
<i> print_log "[Frigate Front Lawn Person]: Status
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 [MQTT D1]: mqtt Rcv'd: R:0
T:'frigate/Front_Lawn/person' M:'0'<br>
04/22/2025 10:55:35 [MQTT D1]: mqtt_Item nom to MQTT to
MH $outer_front_lawn_person_status::set(0,
mqtt=HASH(0x5a0323b77138))<br>
...<br>
04/22/2025 11:42:12 [MQTT D1]: mqtt Rcv'd: R:0
T:'frigate/Front_Lawn/person' M:'1'<br>
04/22/2025 11:42:12 [MQTT D1]: mqtt_Item nom to MQTT to
MH $outer_front_lawn_person_status::set(1,
mqtt=HASH(0x5a0323b77138))<br>
04/22/2025 11:42:12 [Frigate Front Lawn Person]: Status
changed 1</i>
<p><br>
</p>
In the object logs for <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="https://lists.sourceforge.net/lists/listinfo/misterhouse-users"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true" class="moz-txt-link-freetext">https://lists.sourceforge.net/lists/listinfo/misterhouse-users</a><br>
<br>
</blockquote>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre wrap="" class="moz-quote-pre">________________________________________________________
To unsubscribe from this list, go to: <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/misterhouse-users">https://lists.sourceforge.net/lists/listinfo/misterhouse-users</a>
</pre>
</blockquote>
</body>
</html>
--------------00C0OcGdcM5hQpSYVzxfF9Yb--
--===============3697314250532198393==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--===============3697314250532198393==
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
--===============3697314250532198393==--