The latest version of Glasys includes the ability to display binary charts; that said, it is not possible to display a presence (therefore presumably binary) coming from the LAN manager.
Is it possible to make these presences appear? I imagine this is related to the fact that history is not managed for LAN manager objects?
It’s a smartphone on Wi‑Fi managing my presence. I did turn the Wi‑Fi on and off several times this morning but nothing changes on the graph. I didn’t understand your last point about there being no « 0 » sent — does that mean I need to send a 0 by another means?
No, nothing special to do, I’m just clarifying that the integration only sends a value when the device is detected; there is currently no « return to 0 » when the device is not detected.
So even if we manage to get the graph working on your side, you’ll only see a single band of color, not an alternation between presence/absence.
I’m on 4.47 — the fact that the integration doesn’t send 0 when not detected doesn’t prevent the graph from being displayed? Because I only have 1s despite manually turning off the Wi‑Fi on the smartphone?
@Terdious there’s an issue with the SQL query for binary devices, when it’s a « push » type device that only sends 1s it doesn’t work, it returns nothing
I think there’s a bug with the current query even for binary devices: the first value is never returned, because the query thinks the state hasn’t changed.
What do you think of a query like this:
WITH value_changes AS (
SELECT
created_at,
value,
LAG(value) OVER (ORDER BY created_at) AS prev_value
FROM
t_device_feature_state
WHERE
device_feature_id = ?
AND created_at > ?
),
state_transitions AS (
SELECT
created_at,
value
FROM
value_changes
WHERE
prev_value IS NULL OR value != prev_value
)
SELECT
value,
created_at
FROM
state_transitions
ORDER BY
created_at ASC
LIMIT ?
Hello,
Sorry I’ve only just seen the conversation!!
Indeed I agree (at the same time how could I judge otherwise ) that the 1st value is not taken into account. Too bad I didn’t see that, and I’m really sorry.
Indeed, regarding anything that never changes state except sending 1s… it can’t work.
That way I don’t really see how to resolve this point for presence (I’ve never liked this behavior anyway… there should be a timer associated to revert to 0) or for any detector that sends a single-state update.
So what do we do then? Do you have an idea in mind?
WITH value_changes AS (
SELECT
created_at,
value,
LAG(value) OVER (ORDER BY created_at) AS prev_value
FROM
t_device_feature_state
WHERE
device_feature_id = ?
AND created_at \u003e ?
),
state_transitions AS (
SELECT
created_at,
value,
LEAD(created_at) OVER (ORDER BY created_at) AS end_time
FROM
value_changes
WHERE
prev_value IS NULL OR value != prev_value
)
SELECT
value,
created_at,
end_time
FROM
state_transitions
ORDER BY
created_at ASC
LIMIT ?
The PR has been merged into Gladys Assistant 4.48 :
With this PR, @zedyxer you should see a continuous bar — it will only show the times when your device is detected, but not the times when your device is not detected (the infamous return-to-zero), so not very useful for now
I’ll try to look into adding that to the LAN Manager integration.