Skip to content

Commit

Permalink
fix(wirepas): show update timestamp for node
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Feb 16, 2024
1 parent 61e75b9 commit 1f918ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/context/Devices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ export type WirepasGatewayNode = {
ts: string // e.g. '2024-02-05T13:44:06.050Z'
qos: WirepasMeshQOS // e.g. 1
payload?: {
temp?: number // e.g. 24.850000381469727
temp?: {
v: number // e.g. 24.850000381469727
ts: number
}
btn?: {
v: number
ts: number
Expand Down
21 changes: 18 additions & 3 deletions src/wirepas/WirepasGatewayTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ const Node = ({
g,
b,
})
const temp = node.payload?.temp?.v
const tempTs = node.payload?.temp?.ts

return (
<>
<tr style={{ fontSize: '80%' }}>
Expand Down Expand Up @@ -226,10 +229,22 @@ const Node = ({
</span>
</td>
<td>
{node.payload?.temp !== undefined && (
{temp !== undefined && (
<span>
<Thermometer strokeWidth={1} class={'me-1'} />
{node.payload.temp.toFixed(1)} °C
<span>
<Thermometer strokeWidth={1} />
<span>{temp.toFixed(1)} °C</span>
</span>
{tempTs !== undefined && (
<small class={'ms-2'} style={{ opacity: 0.75 }}>
<UploadCloud
strokeWidth={1}
style={{ width: '18px' }}
class={'me-1'}
/>
<RelativeTime time={new Date(tempTs)} />
</small>
)}
</span>
)}
</td>
Expand Down

0 comments on commit 1f918ba

Please sign in to comment.