diff --git a/cmd/lucifer4-server/main.go b/cmd/lucifer4-server/main.go index 555f7a6..f9bcdd8 100644 --- a/cmd/lucifer4-server/main.go +++ b/cmd/lucifer4-server/main.go @@ -9,6 +9,8 @@ import ( "git.aiterp.net/lucifer3/server/services/hue" "git.aiterp.net/lucifer3/server/services/mysqldb" "git.aiterp.net/lucifer3/server/services/nanoleaf" + "git.aiterp.net/lucifer3/server/services/script" + "git.aiterp.net/lucifer3/server/services/tradfri" "git.aiterp.net/lucifer3/server/services/uistate" "log" "os" @@ -21,7 +23,7 @@ func main() { bus := lucifer3.EventBus{} resolver := services.NewResolver() - sceneMap := services.NewSceneMap(resolver) + variables := script.NewVariables() database, err := mysqldb.Connect( env("LUCIFER4_DB_HOST"), @@ -40,13 +42,15 @@ func main() { } bus.JoinPrivileged(resolver) - bus.JoinPrivileged(sceneMap) - bus.Join(effectenforcer.NewService(resolver, sceneMap)) + bus.Join(effectenforcer.NewService(resolver)) bus.Join(nanoleaf.NewService()) bus.Join(hue.NewService()) + bus.Join(tradfri.NewService()) bus.Join(uistate.NewService()) + bus.Join(script.NewService(resolver, variables)) bus.Join(database) bus.Join(httpAPI) + bus.Join(variables) bus.RunEvent(events.Started{}) diff --git a/device/interfaces.go b/device/interfaces.go index 15f640a..a5a018c 100644 --- a/device/interfaces.go +++ b/device/interfaces.go @@ -2,6 +2,7 @@ package device type Resolver interface { Resolve(pattern string) []Pointer + CompileMatcher(pattern string) PointerMatcher } type SceneMap interface { diff --git a/device/pointer.go b/device/pointer.go index 4209ac7..7396309 100644 --- a/device/pointer.go +++ b/device/pointer.go @@ -2,6 +2,7 @@ package device import ( "git.aiterp.net/lucifer3/server/internal/gentools" + "log" "strings" ) @@ -69,6 +70,12 @@ func (p *Pointer) Name() string { } func (p *Pointer) Matches(matcher PointerMatcher) bool { + defer func() { + if err := recover(); err != nil { + log.Println("[PANIC]", err) + } + }() + if matcher.Match(p.ID) { return true } diff --git a/frontend/.gitignore b/frontend/.gitignore index 6635cf5..3d5639f 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -8,3 +8,4 @@ node_modules !.env.example vite.config.js.timestamp-* vite.config.ts.timestamp-* +/*.blend1 \ No newline at end of file diff --git a/frontend/icons.blend b/frontend/icons.blend new file mode 100644 index 0000000..bcd4a2c Binary files /dev/null and b/frontend/icons.blend differ diff --git a/frontend/src/lib/components/Icon.svelte b/frontend/src/lib/components/Icon.svelte new file mode 100644 index 0000000..facc9bb --- /dev/null +++ b/frontend/src/lib/components/Icon.svelte @@ -0,0 +1,70 @@ + + + + +
+ icon + +
+ + \ No newline at end of file diff --git a/frontend/src/lib/components/Lamp.svelte b/frontend/src/lib/components/Lamp.svelte index 23bed1b..ade68d8 100644 --- a/frontend/src/lib/components/Lamp.svelte +++ b/frontend/src/lib/components/Lamp.svelte @@ -1,8 +1,14 @@ + +
- {#if iconColor != null} -
- {:else} -
- {#if !!roundboiText} -
{roundboiText}
- {/if} -
- {/if} - +
+ {#if iconColor != null} + + {:else} + + {#if !!roundboiText} +
{roundboiText}
+ {/if} +
+ {/if} +
{displayTitle}
@@ -132,25 +142,26 @@ > div.row display: flex - > div.roundboi - width: 1.25em - height: 1.25em - margin-left: 0.25em - margin-top: 0.30em - border-radius: 2em - box-sizing: border-box - border: 0.5px solid #000 - - > div.roundboi-text - color: #abc - margin-top: 0.2em - font-size: 0.8em + > div.row-icon + font-size: 1.8em + position: absolute + width: 0 + height: 0 + + div.roundboi-text + width: 0 + height: 0 + left: 1.4ch + top: 0.9em + text-align: center + position: absolute + font-size: 0.333em > div.title font-size: 0.9em text-align: left margin-top: 0.4em - margin-left: 0.75ch + margin-left: 2em margin-right: 1ch height: 1.6em diff --git a/frontend/src/lib/components/icons/generic_ball.svg b/frontend/src/lib/components/icons/generic_ball.svg new file mode 100644 index 0000000..d1a2fb1 --- /dev/null +++ b/frontend/src/lib/components/icons/generic_ball.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/frontend/src/lib/components/icons/generic_boob.svg b/frontend/src/lib/components/icons/generic_boob.svg new file mode 100644 index 0000000..b583e87 --- /dev/null +++ b/frontend/src/lib/components/icons/generic_boob.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/frontend/src/lib/components/icons/generic_lamp.svg b/frontend/src/lib/components/icons/generic_lamp.svg new file mode 100644 index 0000000..d50d49c --- /dev/null +++ b/frontend/src/lib/components/icons/generic_lamp.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/frontend/src/lib/components/icons/generic_strip.svg b/frontend/src/lib/components/icons/generic_strip.svg new file mode 100644 index 0000000..1eebdba --- /dev/null +++ b/frontend/src/lib/components/icons/generic_strip.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/frontend/src/lib/components/icons/hue_adore_tube.svg b/frontend/src/lib/components/icons/hue_adore_tube.svg new file mode 100644 index 0000000..2e5db0f --- /dev/null +++ b/frontend/src/lib/components/icons/hue_adore_tube.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/frontend/src/lib/components/icons/hue_dimmerswitch.svg b/frontend/src/lib/components/icons/hue_dimmerswitch.svg new file mode 100644 index 0000000..8b4badd --- /dev/null +++ b/frontend/src/lib/components/icons/hue_dimmerswitch.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/frontend/src/lib/components/icons/hue_lightbulb_e14.svg b/frontend/src/lib/components/icons/hue_lightbulb_e14.svg new file mode 100644 index 0000000..97f0138 --- /dev/null +++ b/frontend/src/lib/components/icons/hue_lightbulb_e14.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/frontend/src/lib/components/icons/hue_lightbulb_e27.svg b/frontend/src/lib/components/icons/hue_lightbulb_e27.svg new file mode 100644 index 0000000..db9a016 --- /dev/null +++ b/frontend/src/lib/components/icons/hue_lightbulb_e27.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/frontend/src/lib/components/icons/hue_lightbulb_gu10.svg b/frontend/src/lib/components/icons/hue_lightbulb_gu10.svg new file mode 100644 index 0000000..b98e300 --- /dev/null +++ b/frontend/src/lib/components/icons/hue_lightbulb_gu10.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/frontend/src/lib/components/icons/hue_motionsensor.svg b/frontend/src/lib/components/icons/hue_motionsensor.svg new file mode 100644 index 0000000..4ac2a7c --- /dev/null +++ b/frontend/src/lib/components/icons/hue_motionsensor.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/frontend/src/lib/components/icons/hue_playbar.svg b/frontend/src/lib/components/icons/hue_playbar.svg new file mode 100644 index 0000000..53475bc --- /dev/null +++ b/frontend/src/lib/components/icons/hue_playbar.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/frontend/src/lib/components/icons/hue_signe.svg b/frontend/src/lib/components/icons/hue_signe.svg new file mode 100644 index 0000000..4a5812e --- /dev/null +++ b/frontend/src/lib/components/icons/hue_signe.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/frontend/src/lib/models/device.ts b/frontend/src/lib/models/device.ts index 93cb378..c040569 100644 --- a/frontend/src/lib/models/device.ts +++ b/frontend/src/lib/models/device.ts @@ -1,3 +1,4 @@ +import type { IconName } from "$lib/components/Icon.svelte" import type { ColorFlags, ColorRGB } from "./color" export default interface Device { @@ -30,6 +31,7 @@ export interface HardwareState { export interface HardwareMetadata { firmwareVersion?: string + icon?: IconName } export interface State { diff --git a/frontend/src/lib/utils/color.ts b/frontend/src/lib/utils/color.ts new file mode 100644 index 0000000..97279a2 --- /dev/null +++ b/frontend/src/lib/utils/color.ts @@ -0,0 +1,8 @@ +import type { ColorRGB } from "$lib/models/color"; + +export function rgbToHex(rgb: ColorRGB): string { + const r = Math.min(Math.round(rgb.red * 255), 255).toString(16).padStart(2, "0"); + const g = Math.min(Math.round(rgb.green * 255), 255).toString(16).padStart(2, "0"); + const b = Math.min(Math.round(rgb.blue * 255), 255).toString(16).padStart(2, "0"); + return ["#", r, g, b].join(""); +} \ No newline at end of file diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index 189676c..737400c 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -1,7 +1,9 @@ @@ -11,6 +13,20 @@ {/each}
+
+ + + + + + + + + + + + +