Skip to content

Commit

Permalink
fix: remove support for LEDs
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Oct 13, 2023
1 parent 9460db2 commit 34f93f7
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 367 deletions.
2 changes: 0 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Provider as SettingsProvider } from './context/Settings.js'
import { Provider as HistoryChartProvider } from './context/showHistoryChart.js'
import { Provider as WebsocketProvider } from './context/WebsocketConnection.js'
import { Dashboard } from './Dashboard.js'
import { FakeLight } from './test-device/FakeLight.js'
import { FakeTracker } from './test-device/FakeTracker.js'
import { WithCredentials as CredentialsProvider } from './WithCredentials.js'

Expand All @@ -22,7 +21,6 @@ export const App = () => (
</MapProvider>
</WebsocketProvider>
<FakeTracker />
<FakeLight />
</DevicesProvider>
</SettingsProvider>
)}
Expand Down
67 changes: 0 additions & 67 deletions src/CodeInput.tsx

This file was deleted.

34 changes: 2 additions & 32 deletions src/DeviceList.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import styled from 'styled-components'
import { DisconnectedWarning } from './DisconnectedWarning.js'
import { HistoryOnly } from './HistoryOnly.js'
import { LightbulbDevice } from './LightbulbDevice.js'
import { Tracker } from './Tracker.js'
import {
GeoLocationSource,
isLightBulb,
isTracker,
useDevices,
} from './context/Devices.js'
import { useMap } from './context/Map.js'
import { isTracker, useDevices } from './context/Devices.js'
import { useSettings } from './context/Settings.js'
import { useHistoryChart } from './context/showHistoryChart.js'

Expand Down Expand Up @@ -115,8 +108,7 @@ export const IssuerName = styled.dd`

export const DeviceList = () => {
const { devices, lastUpdateTs } = useDevices()
const map = useMap()
const { hide: hideHistoryChart, show: showHistoryChart } = useHistoryChart()
const { show: showHistoryChart } = useHistoryChart()
const {
settings: { showFavorites, favorites },
} = useSettings()
Expand Down Expand Up @@ -149,28 +141,6 @@ export const DeviceList = () => {
<Tracker key={`device:${device.id}`} device={device} />
</li>
)
if (isLightBulb(device))
return (
<li>
<LightbulbDevice
key={`device:${device.id}`}
device={device}
onClick={() => {
if (device.state?.geo !== undefined) {
map?.center(
{
...device.state.geo,
accuracy: 0,
source: GeoLocationSource.fixed,
},
16,
)
}
hideHistoryChart()
}}
/>
</li>
)
if (device.history !== undefined)
return (
<li>
Expand Down
65 changes: 0 additions & 65 deletions src/LightbulbDevice.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions src/OnOffControl.tsx

This file was deleted.

66 changes: 0 additions & 66 deletions src/RGBControl.tsx

This file was deleted.

23 changes: 2 additions & 21 deletions src/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ChevronUp, Settings2, Star, StarOff } from 'lucide-preact'
import styled from 'styled-components'
import { CodeInput } from './CodeInput.js'
import { isLightBulb, useDevices } from './context/Devices.js'
import { useDevices } from './context/Devices.js'
import { useSettings } from './context/Settings.js'

const SettingsPanel = styled.aside`
Expand All @@ -17,7 +16,6 @@ const SettingsPanel = styled.aside`
`

export const Settings = () => {
const { devices, alias } = useDevices()
const {
settings: {
showSettings,
Expand All @@ -27,7 +25,6 @@ export const Settings = () => {
showFavorites,
consumptionThreshold,
showUpdateWarning,
favorites,
},
update,
reset,
Expand Down Expand Up @@ -89,22 +86,6 @@ export const Settings = () => {
Show firmware update warning?
</label>
</div>
<h3 class="h5 mt-3">Management</h3>
<p>Below you can provide the device's code to manage it.</p>
{/* Code input for Lightbulbs */}
{Object.values(devices)
.filter(isLightBulb)
?.filter(({ id }) => {
if (!showFavorites) return true
return favorites.includes(id)
})
.map((device) => (
<CodeInput
device={device}
key={device.id}
alias={alias(device.id)}
/>
))}
<h2 class="h4 mt-4">Solar</h2>
<label htmlFor={'consumptionThreshold'}>
Above this value, charge is considered sufficiently high enough so
Expand Down Expand Up @@ -264,7 +245,7 @@ const FavoriteSelector = () => {
if (i2 === -1) return -Number.MAX_SAFE_INTEGER
return i1 - i2
})
.map(([id, device], i) => {
.map(([id], i) => {
const favorited = favorites.includes(id)
return (
<li class="list-group-item">
Expand Down
12 changes: 0 additions & 12 deletions src/context/Devices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,6 @@ export type Reported = Partial<{
ts: number // 1670245539000
}
sol: SolarInfo
// LED lights
led: {
v: {
type: 'rgb' | 'on/off'
color?: [number, number, number] // [0, 169, 206]
}
ts: number // 1670245539000
}
// Device has a fixed geo location
geo: {
lng: number // 10.4383147713927
Expand Down Expand Up @@ -196,9 +188,6 @@ export const isTracker = (device: Device): boolean => {
const { appV, brdV } = device.state?.dev?.v ?? {}
return appV !== undefined && brdV !== undefined
}
export const isLightBulb = (device: Device): boolean =>
device.state?.led !== undefined

export const hasSoftSIM = (device: Device): boolean =>
device.state?.dev?.v?.appV?.includes('softsim') ?? false

Expand Down Expand Up @@ -369,7 +358,6 @@ const getLastUpdateTime = (device?: Device): null | number => {
state?.dev?.ts,
state?.env?.ts,
state?.gnss?.ts,
state?.led?.ts,
state?.roam?.ts,
state?.sol?.ts,
].filter((s) => s !== undefined) as number[]
Expand Down
Loading

0 comments on commit 34f93f7

Please sign in to comment.