diff --git a/.github/workflows/docker-github.yml b/.github/workflows/docker-github.yml new file mode 100644 index 0000000..4624c42 --- /dev/null +++ b/.github/workflows/docker-github.yml @@ -0,0 +1,57 @@ +name: Docker - GitHub Registry + +on: + push: + branches: + - master + tags: + - '*' + paths-ignore: + - '**.md' + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: checkout code + uses: actions/checkout@v3 + + # this is a little bit of "dark magick"... + # Github Registry seems to hate Usernames Containing UpperCase... + # + # this metadata action normalizes the image tags into something useable. + # I'm not sure it's the _best_ set of Docker Tags to use. + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ghcr.io/${{ github.repository_owner }}/${{ github.repository }}${{ env.TAG }} + tags: | + type=raw,value=1.0.${{ github.run_number }},priority=1000 + type=ref,event=branch + type=sha + type=raw,value=latest + + - name: Log in to ghcr + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - if: startsWith(github.ref, 'refs/heads/master') + run: echo "TAG=latest" >> $GITHUB_ENV + + - if: startsWith(github.ref, 'refs/tags') + run: echo "TAG=$(git describe --tags)" >> $GITHUB_ENV + + - name: Build & Push + uses: docker/build-push-action@v4 + with: + context: ./ + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a4a0390..245092d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -34,7 +34,7 @@ jobs: images: michielpost/huelightdj - name: Build and push Docker image - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v4 with: context: . push: true diff --git a/HueLightDJ.Effects/Base/HueEffectAttribute.cs b/HueLightDJ.Effects/Base/HueEffectAttribute.cs index a4e9481..020eb8a 100644 --- a/HueLightDJ.Effects/Base/HueEffectAttribute.cs +++ b/HueLightDJ.Effects/Base/HueEffectAttribute.cs @@ -9,7 +9,7 @@ public class HueEffectAttribute : Attribute public int Order { get; set; } = 100; - public string Name { get; set; } + public required string Name { get; set; } public string Group { get; set; } = "Other"; /// @@ -19,6 +19,6 @@ public class HueEffectAttribute : Attribute public bool HasColorPicker { get; set; } = true; - public string DefaultColor { get; set; } + public string? DefaultColor { get; set; } } } diff --git a/HueLightDJ.Effects/Base/IHueEffect.cs b/HueLightDJ.Effects/Base/IHueEffect.cs index 966c5d9..619c26f 100644 --- a/HueLightDJ.Effects/Base/IHueEffect.cs +++ b/HueLightDJ.Effects/Base/IHueEffect.cs @@ -1,5 +1,5 @@ -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Models; using System; using System.Threading; using System.Threading.Tasks; diff --git a/HueLightDJ.Effects/Base/IHueGroupEffect.cs b/HueLightDJ.Effects/Base/IHueGroupEffect.cs index 69ce95c..ad79e56 100644 --- a/HueLightDJ.Effects/Base/IHueGroupEffect.cs +++ b/HueLightDJ.Effects/Base/IHueGroupEffect.cs @@ -1,6 +1,6 @@ -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Threading; diff --git a/HueLightDJ.Effects/Base/IHueTouchEffect.cs b/HueLightDJ.Effects/Base/IHueTouchEffect.cs index 9236f5e..e5dc7b5 100644 --- a/HueLightDJ.Effects/Base/IHueTouchEffect.cs +++ b/HueLightDJ.Effects/Base/IHueTouchEffect.cs @@ -1,5 +1,5 @@ -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Models; using System; using System.Threading; using System.Threading.Tasks; diff --git a/HueLightDJ.Effects/EffectSettings.cs b/HueLightDJ.Effects/EffectSettings.cs index 4f5dcd9..f332f17 100644 --- a/HueLightDJ.Effects/EffectSettings.cs +++ b/HueLightDJ.Effects/EffectSettings.cs @@ -1,4 +1,4 @@ -using Q42.HueApi.Models.Groups; +using HueApi.Models; using System; using System.Collections.Generic; using System.Text; @@ -7,7 +7,7 @@ namespace HueLightDJ.Effects { public static class EffectSettings { - public static LightLocation LocationCenter { get; set; } = new LightLocation() { 0, 0, 0 }; + public static HuePosition LocationCenter { get; set; } = new HuePosition(); } } diff --git a/HueLightDJ.Effects/Group/FlashFadeEffect.cs b/HueLightDJ.Effects/Group/FlashFadeEffect.cs index 61eaa1f..60f19be 100644 --- a/HueLightDJ.Effects/Group/FlashFadeEffect.cs +++ b/HueLightDJ.Effects/Group/FlashFadeEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Group/QuickFlashEffect.cs b/HueLightDJ.Effects/Group/QuickFlashEffect.cs index 7672b84..6b86b2f 100644 --- a/HueLightDJ.Effects/Group/QuickFlashEffect.cs +++ b/HueLightDJ.Effects/Group/QuickFlashEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Group/RandomColorloopEffect.cs b/HueLightDJ.Effects/Group/RandomColorloopEffect.cs index d04005e..9acaf36 100644 --- a/HueLightDJ.Effects/Group/RandomColorloopEffect.cs +++ b/HueLightDJ.Effects/Group/RandomColorloopEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Group/RandomColorsEffect.cs b/HueLightDJ.Effects/Group/RandomColorsEffect.cs index 3d700ab..ca79b27 100644 --- a/HueLightDJ.Effects/Group/RandomColorsEffect.cs +++ b/HueLightDJ.Effects/Group/RandomColorsEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Group/TrailingLightEffect.cs b/HueLightDJ.Effects/Group/TrailingLightEffect.cs index d2e9eb0..c57c18c 100644 --- a/HueLightDJ.Effects/Group/TrailingLightEffect.cs +++ b/HueLightDJ.Effects/Group/TrailingLightEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/HueLightDJ.Effects.csproj b/HueLightDJ.Effects/HueLightDJ.Effects.csproj index 671d700..32ce80f 100644 --- a/HueLightDJ.Effects/HueLightDJ.Effects.csproj +++ b/HueLightDJ.Effects/HueLightDJ.Effects.csproj @@ -3,13 +3,13 @@ net7.0 enable - CS8600;CS8601;CS8602;CS8603;CS8625;CS8613 + nullable - - - + + + diff --git a/HueLightDJ.Effects/Layers/DemoEffect.cs b/HueLightDJ.Effects/Layers/DemoEffect.cs index 39dbc2f..e16ed69 100644 --- a/HueLightDJ.Effects/Layers/DemoEffect.cs +++ b/HueLightDJ.Effects/Layers/DemoEffect.cs @@ -4,8 +4,8 @@ using System.Threading; using System.Threading.Tasks; using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Models; namespace HueLightDJ.Effects.Layers { diff --git a/HueLightDJ.Effects/Layers/Flashing/QuickFlashAllEffect.cs b/HueLightDJ.Effects/Layers/Flashing/QuickFlashAllEffect.cs index 8d9fb09..cc81642 100644 --- a/HueLightDJ.Effects/Layers/Flashing/QuickFlashAllEffect.cs +++ b/HueLightDJ.Effects/Layers/Flashing/QuickFlashAllEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; diff --git a/HueLightDJ.Effects/Layers/Flashing/QuickFlashEffect.cs b/HueLightDJ.Effects/Layers/Flashing/QuickFlashEffect.cs index 19c6c2a..116152c 100644 --- a/HueLightDJ.Effects/Layers/Flashing/QuickFlashEffect.cs +++ b/HueLightDJ.Effects/Layers/Flashing/QuickFlashEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Layers/Flashing/QuickFlashFrontBackEffect.cs b/HueLightDJ.Effects/Layers/Flashing/QuickFlashFrontBackEffect.cs index 739c77c..47195b5 100644 --- a/HueLightDJ.Effects/Layers/Flashing/QuickFlashFrontBackEffect.cs +++ b/HueLightDJ.Effects/Layers/Flashing/QuickFlashFrontBackEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Layers/Flashing/QuickFlashRandomEffect.cs b/HueLightDJ.Effects/Layers/Flashing/QuickFlashRandomEffect.cs index aa887d5..381b269 100644 --- a/HueLightDJ.Effects/Layers/Flashing/QuickFlashRandomEffect.cs +++ b/HueLightDJ.Effects/Layers/Flashing/QuickFlashRandomEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Layers/Party/ColorloopWheelDoubleEffect.cs b/HueLightDJ.Effects/Layers/Party/ColorloopWheelDoubleEffect.cs index 351a4bf..d368259 100644 --- a/HueLightDJ.Effects/Layers/Party/ColorloopWheelDoubleEffect.cs +++ b/HueLightDJ.Effects/Layers/Party/ColorloopWheelDoubleEffect.cs @@ -1,9 +1,9 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Effects.BasEffects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Effects.BasEffects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/HueLightDJ.Effects/Layers/Party/RainbowBottomTopEffect.cs b/HueLightDJ.Effects/Layers/Party/RainbowBottomTopEffect.cs index a06e8eb..b016b12 100644 --- a/HueLightDJ.Effects/Layers/Party/RainbowBottomTopEffect.cs +++ b/HueLightDJ.Effects/Layers/Party/RainbowBottomTopEffect.cs @@ -1,10 +1,10 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.ColorConverters.HSB; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Effects.BasEffects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.ColorConverters.HSB; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Effects.BasEffects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/HueLightDJ.Effects/Layers/Party/RandomBottomTopEffect.cs b/HueLightDJ.Effects/Layers/Party/RandomBottomTopEffect.cs index 79da519..1f1c985 100644 --- a/HueLightDJ.Effects/Layers/Party/RandomBottomTopEffect.cs +++ b/HueLightDJ.Effects/Layers/Party/RandomBottomTopEffect.cs @@ -1,10 +1,10 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.ColorConverters.HSB; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Effects.BasEffects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.ColorConverters.HSB; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Effects.BasEffects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/HueLightDJ.Effects/Layers/Party/RandomColorsEffect.cs b/HueLightDJ.Effects/Layers/Party/RandomColorsEffect.cs index e71ecaa..7a479a5 100644 --- a/HueLightDJ.Effects/Layers/Party/RandomColorsEffect.cs +++ b/HueLightDJ.Effects/Layers/Party/RandomColorsEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; diff --git a/HueLightDJ.Effects/Layers/Party/RandomPulseEffect.cs b/HueLightDJ.Effects/Layers/Party/RandomPulseEffect.cs index ee03991..44f6418 100644 --- a/HueLightDJ.Effects/Layers/Party/RandomPulseEffect.cs +++ b/HueLightDJ.Effects/Layers/Party/RandomPulseEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; @@ -19,7 +19,7 @@ public Task Start(EntertainmentLayer layer, Func waitTime, RGBColor? c Func customWaitTime = () => waitTime() / 10; var center = EffectSettings.LocationCenter; - var randomPulseEffect = new Q42.HueApi.Streaming.Effects.RandomPulseEffect(fadeToZero: false, waitTime: customWaitTime); + var randomPulseEffect = new HueApi.Entertainment.Effects.Examples.RandomPulseEffect(fadeToZero: false, waitTime: customWaitTime); randomPulseEffect.X = center.X; randomPulseEffect.Y = center.Y; layer.PlaceEffect(randomPulseEffect); diff --git a/HueLightDJ.Effects/Layers/Party/RandomPulseRetraceEffect.cs b/HueLightDJ.Effects/Layers/Party/RandomPulseRetraceEffect.cs index 602d11f..0b57180 100644 --- a/HueLightDJ.Effects/Layers/Party/RandomPulseRetraceEffect.cs +++ b/HueLightDJ.Effects/Layers/Party/RandomPulseRetraceEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; @@ -19,7 +19,7 @@ public Task Start(EntertainmentLayer layer, Func waitTime, RGBColor? c Func customWaitTime = () => waitTime() / 10; var center = EffectSettings.LocationCenter; - var randomPulseEffect = new Q42.HueApi.Streaming.Effects.RandomPulseEffect(waitTime: customWaitTime); + var randomPulseEffect = new HueApi.Entertainment.Effects.Examples.RandomPulseEffect(waitTime: customWaitTime); randomPulseEffect.X = center.X; randomPulseEffect.Y = center.Y; layer.PlaceEffect(randomPulseEffect); diff --git a/HueLightDJ.Effects/Layers/Party/RandomPulseTopBottomEffect.cs b/HueLightDJ.Effects/Layers/Party/RandomPulseTopBottomEffect.cs index fce1d16..389fa69 100644 --- a/HueLightDJ.Effects/Layers/Party/RandomPulseTopBottomEffect.cs +++ b/HueLightDJ.Effects/Layers/Party/RandomPulseTopBottomEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; @@ -18,12 +18,12 @@ public async Task Start(EntertainmentLayer layer, Func waitTime, RGBCo { Func customWaitTime = () => waitTime() / 10; - var bottomPulseEffect = new Q42.HueApi.Streaming.Effects.RandomPulseEffect(waitTime: customWaitTime); + var bottomPulseEffect = new HueApi.Entertainment.Effects.Examples.RandomPulseEffect(waitTime: customWaitTime); bottomPulseEffect.AutoRepeat = false; bottomPulseEffect.Y = -1; layer.PlaceEffect(bottomPulseEffect); - var topPulseEffect = new Q42.HueApi.Streaming.Effects.RandomPulseEffect(waitTime: customWaitTime); + var topPulseEffect = new HueApi.Entertainment.Effects.Examples.RandomPulseEffect(waitTime: customWaitTime); topPulseEffect.AutoRepeat = false; topPulseEffect.Y = 1; layer.PlaceEffect(topPulseEffect); diff --git a/HueLightDJ.Effects/Layers/Party/RandomSingleRowBottomTopEffect.cs b/HueLightDJ.Effects/Layers/Party/RandomSingleRowBottomTopEffect.cs index d809b14..2f99197 100644 --- a/HueLightDJ.Effects/Layers/Party/RandomSingleRowBottomTopEffect.cs +++ b/HueLightDJ.Effects/Layers/Party/RandomSingleRowBottomTopEffect.cs @@ -1,10 +1,10 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.ColorConverters.HSB; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Effects.BasEffects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.ColorConverters.HSB; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Effects.BasEffects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/HueLightDJ.Effects/Layers/Party/SkippingEffect.cs b/HueLightDJ.Effects/Layers/Party/SkippingEffect.cs index c0c87ae..1899580 100644 --- a/HueLightDJ.Effects/Layers/Party/SkippingEffect.cs +++ b/HueLightDJ.Effects/Layers/Party/SkippingEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Layers/Rotating/CircleLightEffect.cs b/HueLightDJ.Effects/Layers/Rotating/CircleLightEffect.cs index 9145621..d1145c4 100644 --- a/HueLightDJ.Effects/Layers/Rotating/CircleLightEffect.cs +++ b/HueLightDJ.Effects/Layers/Rotating/CircleLightEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Layers/Rotating/ColorWheelEffect.cs b/HueLightDJ.Effects/Layers/Rotating/ColorWheelEffect.cs index a84df1e..4bb38c2 100644 --- a/HueLightDJ.Effects/Layers/Rotating/ColorWheelEffect.cs +++ b/HueLightDJ.Effects/Layers/Rotating/ColorWheelEffect.cs @@ -1,10 +1,10 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.ColorConverters.HSB; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Effects.BasEffects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.ColorConverters.HSB; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Effects.BasEffects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/HueLightDJ.Effects/Layers/Rotating/ColorloopWheelEffect.cs b/HueLightDJ.Effects/Layers/Rotating/ColorloopWheelEffect.cs index 753f4e5..9bbaef9 100644 --- a/HueLightDJ.Effects/Layers/Rotating/ColorloopWheelEffect.cs +++ b/HueLightDJ.Effects/Layers/Rotating/ColorloopWheelEffect.cs @@ -1,9 +1,9 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Effects.BasEffects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Effects.BasEffects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/HueLightDJ.Effects/Layers/Rotating/GradientWheelEffect.cs b/HueLightDJ.Effects/Layers/Rotating/GradientWheelEffect.cs index 911be67..a645287 100644 --- a/HueLightDJ.Effects/Layers/Rotating/GradientWheelEffect.cs +++ b/HueLightDJ.Effects/Layers/Rotating/GradientWheelEffect.cs @@ -1,10 +1,10 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.ColorConverters.HSB; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Effects.BasEffects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.ColorConverters.HSB; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Effects.BasEffects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/HueLightDJ.Effects/Layers/Rotating/RainbowWheelEffect.cs b/HueLightDJ.Effects/Layers/Rotating/RainbowWheelEffect.cs index 13195f9..fbddbc1 100644 --- a/HueLightDJ.Effects/Layers/Rotating/RainbowWheelEffect.cs +++ b/HueLightDJ.Effects/Layers/Rotating/RainbowWheelEffect.cs @@ -1,10 +1,10 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.ColorConverters.HSB; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Effects.BasEffects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.ColorConverters.HSB; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Effects.BasEffects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/HueLightDJ.Effects/Layers/Rotating/RotatingEffect.cs b/HueLightDJ.Effects/Layers/Rotating/RotatingEffect.cs index a55de32..6fe3ade 100644 --- a/HueLightDJ.Effects/Layers/Rotating/RotatingEffect.cs +++ b/HueLightDJ.Effects/Layers/Rotating/RotatingEffect.cs @@ -1,7 +1,7 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects.BasEffects; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects.BasEffects; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; @@ -58,7 +58,7 @@ public override void Start() CurrentAngle = 90; - var state = new Q42.HueApi.Streaming.Models.StreamingState(); + var state = new HueApi.Entertainment.Models.StreamingState(); state.SetBrightness(1); state.SetRGBColor(_color); diff --git a/HueLightDJ.Effects/Layers/Slow/ColorloopEffect.cs b/HueLightDJ.Effects/Layers/Slow/ColorloopEffect.cs index b62cbd4..afab8f7 100644 --- a/HueLightDJ.Effects/Layers/Slow/ColorloopEffect.cs +++ b/HueLightDJ.Effects/Layers/Slow/ColorloopEffect.cs @@ -1,9 +1,9 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Effects.BasEffects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Effects.BasEffects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; diff --git a/HueLightDJ.Effects/Layers/Slow/HsbLoopEffect.cs b/HueLightDJ.Effects/Layers/Slow/HsbLoopEffect.cs index 5b210ef..b8bca20 100644 --- a/HueLightDJ.Effects/Layers/Slow/HsbLoopEffect.cs +++ b/HueLightDJ.Effects/Layers/Slow/HsbLoopEffect.cs @@ -1,10 +1,10 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.ColorConverters.HSB; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Effects.BasEffects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.ColorConverters.HSB; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Effects.BasEffects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; diff --git a/HueLightDJ.Effects/Layers/Slow/RandomColorRangeEffect.cs b/HueLightDJ.Effects/Layers/Slow/RandomColorRangeEffect.cs index cb314de..54217f5 100644 --- a/HueLightDJ.Effects/Layers/Slow/RandomColorRangeEffect.cs +++ b/HueLightDJ.Effects/Layers/Slow/RandomColorRangeEffect.cs @@ -1,9 +1,9 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.ColorConverters.HSB; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.ColorConverters.HSB; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; diff --git a/HueLightDJ.Effects/Layers/Slow/RandomColorsSameEffect.cs b/HueLightDJ.Effects/Layers/Slow/RandomColorsSameEffect.cs index 3a338f9..a4dfc67 100644 --- a/HueLightDJ.Effects/Layers/Slow/RandomColorsSameEffect.cs +++ b/HueLightDJ.Effects/Layers/Slow/RandomColorsSameEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; diff --git a/HueLightDJ.Effects/Layers/Tentacles/Tentacle2RandomColorsEffect.cs b/HueLightDJ.Effects/Layers/Tentacles/Tentacle2RandomColorsEffect.cs index d69922e..33b90bd 100644 --- a/HueLightDJ.Effects/Layers/Tentacles/Tentacle2RandomColorsEffect.cs +++ b/HueLightDJ.Effects/Layers/Tentacles/Tentacle2RandomColorsEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Layers/Tentacles/Tentacle2RandomFlashEffect.cs b/HueLightDJ.Effects/Layers/Tentacles/Tentacle2RandomFlashEffect.cs index 8e53485..86642e6 100644 --- a/HueLightDJ.Effects/Layers/Tentacles/Tentacle2RandomFlashEffect.cs +++ b/HueLightDJ.Effects/Layers/Tentacles/Tentacle2RandomFlashEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Layers/Tentacles/Tentacle3RandomColorsEffect.cs b/HueLightDJ.Effects/Layers/Tentacles/Tentacle3RandomColorsEffect.cs index 209c1e9..34c99fc 100644 --- a/HueLightDJ.Effects/Layers/Tentacles/Tentacle3RandomColorsEffect.cs +++ b/HueLightDJ.Effects/Layers/Tentacles/Tentacle3RandomColorsEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Layers/Tentacles/Tentacle3RandomFlashEffect.cs b/HueLightDJ.Effects/Layers/Tentacles/Tentacle3RandomFlashEffect.cs index 93dc53e..b3959a9 100644 --- a/HueLightDJ.Effects/Layers/Tentacles/Tentacle3RandomFlashEffect.cs +++ b/HueLightDJ.Effects/Layers/Tentacles/Tentacle3RandomFlashEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Layers/Utils/AllOffEffect.cs b/HueLightDJ.Effects/Layers/Utils/AllOffEffect.cs index 0ae6291..379ed22 100644 --- a/HueLightDJ.Effects/Layers/Utils/AllOffEffect.cs +++ b/HueLightDJ.Effects/Layers/Utils/AllOffEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; diff --git a/HueLightDJ.Effects/Layers/Utils/ChristmasEffect.cs b/HueLightDJ.Effects/Layers/Utils/ChristmasEffect.cs index f141e92..2e1bd95 100644 --- a/HueLightDJ.Effects/Layers/Utils/ChristmasEffect.cs +++ b/HueLightDJ.Effects/Layers/Utils/ChristmasEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; diff --git a/HueLightDJ.Effects/Layers/Utils/ChristmasFadeEffect.cs b/HueLightDJ.Effects/Layers/Utils/ChristmasFadeEffect.cs index 02194ae..fb7a9a0 100644 --- a/HueLightDJ.Effects/Layers/Utils/ChristmasFadeEffect.cs +++ b/HueLightDJ.Effects/Layers/Utils/ChristmasFadeEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; @@ -44,9 +44,9 @@ private static Task SetChristmas(this IEnumerable { if (startGreen) - current.SetState(ct, new Q42.HueApi.ColorConverters.RGBColor("00FF00"), 1, TimeSpan.FromMilliseconds(waitTime().TotalMilliseconds / 6 * r.Next(1,5))); + current.SetState(ct, new HueApi.ColorConverters.RGBColor("00FF00"), 1, TimeSpan.FromMilliseconds(waitTime().TotalMilliseconds / 6 * r.Next(1,5))); else - current.SetState(ct, new Q42.HueApi.ColorConverters.RGBColor("FF0000"), 1, TimeSpan.FromMilliseconds(waitTime().TotalMilliseconds / 6 * r.Next(1, 5))); + current.SetState(ct, new HueApi.ColorConverters.RGBColor("FF0000"), 1, TimeSpan.FromMilliseconds(waitTime().TotalMilliseconds / 6 * r.Next(1, 5))); startGreen = !startGreen; }, IteratorEffectMode.RandomOrdered, IteratorEffectMode.RandomOrdered, () => TimeSpan.FromMilliseconds(r.Next(10, 50))); diff --git a/HueLightDJ.Effects/Layers/Utils/SetColorEffect.cs b/HueLightDJ.Effects/Layers/Utils/SetColorEffect.cs index 84ddb8b..7fa0b96 100644 --- a/HueLightDJ.Effects/Layers/Utils/SetColorEffect.cs +++ b/HueLightDJ.Effects/Layers/Utils/SetColorEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; diff --git a/HueLightDJ.Effects/Singles/BackFrontFlashEffect.cs b/HueLightDJ.Effects/Singles/BackFrontFlashEffect.cs index a7c769e..00bbcdf 100644 --- a/HueLightDJ.Effects/Singles/BackFrontFlashEffect.cs +++ b/HueLightDJ.Effects/Singles/BackFrontFlashEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Singles/FillFromCenterEffect.cs b/HueLightDJ.Effects/Singles/FillFromCenterEffect.cs index 23c80ee..9f3b95c 100644 --- a/HueLightDJ.Effects/Singles/FillFromCenterEffect.cs +++ b/HueLightDJ.Effects/Singles/FillFromCenterEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Singles/FlashFadeEffect.cs b/HueLightDJ.Effects/Singles/FlashFadeEffect.cs index 61a981f..cee98cd 100644 --- a/HueLightDJ.Effects/Singles/FlashFadeEffect.cs +++ b/HueLightDJ.Effects/Singles/FlashFadeEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; diff --git a/HueLightDJ.Effects/Singles/FlashFadeInvereEffect.cs b/HueLightDJ.Effects/Singles/FlashFadeInvereEffect.cs index 5e51e7b..8491afb 100644 --- a/HueLightDJ.Effects/Singles/FlashFadeInvereEffect.cs +++ b/HueLightDJ.Effects/Singles/FlashFadeInvereEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; diff --git a/HueLightDJ.Effects/Singles/RandomFlashEffect.cs b/HueLightDJ.Effects/Singles/RandomFlashEffect.cs index abac88d..1192385 100644 --- a/HueLightDJ.Effects/Singles/RandomFlashEffect.cs +++ b/HueLightDJ.Effects/Singles/RandomFlashEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/HueLightDJ.Effects/Singles/SinglePulseEffect.cs b/HueLightDJ.Effects/Singles/SinglePulseEffect.cs index 33e9ae9..0bd7eed 100644 --- a/HueLightDJ.Effects/Singles/SinglePulseEffect.cs +++ b/HueLightDJ.Effects/Singles/SinglePulseEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; @@ -23,7 +23,7 @@ public async Task Start(EntertainmentLayer layer, Func waitTime, RGBCo Func customWaitTime = () => waitTime() / 10; var center = EffectSettings.LocationCenter; - var randomPulseEffect = new Q42.HueApi.Streaming.Effects.RandomPulseEffect(fadeToZero: false, waitTime: customWaitTime); + var randomPulseEffect = new HueApi.Entertainment.Effects.Examples.RandomPulseEffect(fadeToZero: false, waitTime: customWaitTime); randomPulseEffect.X = center.X; randomPulseEffect.Y = center.Y; cancellationToken.Register(() => { diff --git a/HueLightDJ.Effects/Touch/CrossTouchEffect.cs b/HueLightDJ.Effects/Touch/CrossTouchEffect.cs index 95e94f6..0165987 100644 --- a/HueLightDJ.Effects/Touch/CrossTouchEffect.cs +++ b/HueLightDJ.Effects/Touch/CrossTouchEffect.cs @@ -1,8 +1,8 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Effects.Examples; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Effects.Examples; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; diff --git a/HueLightDJ.Effects/Touch/RedDotTouchEffect.cs b/HueLightDJ.Effects/Touch/RedDotTouchEffect.cs index 3557959..d1b58e0 100644 --- a/HueLightDJ.Effects/Touch/RedDotTouchEffect.cs +++ b/HueLightDJ.Effects/Touch/RedDotTouchEffect.cs @@ -1,12 +1,13 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; using System.Threading; using System.Threading.Tasks; +using HueApi.Entertainment.Effects.Examples; namespace HueLightDJ.Effects.Touch { diff --git a/HueLightDJ.Effects/Touch/RippleTouchEffect.cs b/HueLightDJ.Effects/Touch/RippleTouchEffect.cs index 8215796..d28ab48 100644 --- a/HueLightDJ.Effects/Touch/RippleTouchEffect.cs +++ b/HueLightDJ.Effects/Touch/RippleTouchEffect.cs @@ -1,7 +1,7 @@ using HueLightDJ.Effects.Base; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Effects; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Text; @@ -17,7 +17,7 @@ public Task Start(EntertainmentLayer layer, Func waitTime, RGBColor? c { Func customWaitTime = () => waitTime() / 10; - Q42.HueApi.Streaming.Effects.RandomPulseEffect effect = new Q42.HueApi.Streaming.Effects.RandomPulseEffect(false, customWaitTime); + HueApi.Entertainment.Effects.Examples.RandomPulseEffect effect = new HueApi.Entertainment.Effects.Examples.RandomPulseEffect(false, customWaitTime); effect.X = x; effect.Y = y; effect.AutoRepeat = false; diff --git a/HueLightDJ.Web/Streaming/EffectService.cs b/HueLightDJ.Services/EffectService.cs similarity index 81% rename from HueLightDJ.Web/Streaming/EffectService.cs rename to HueLightDJ.Services/EffectService.cs index 3ba1c65..2095e81 100644 --- a/HueLightDJ.Web/Streaming/EffectService.cs +++ b/HueLightDJ.Services/EffectService.cs @@ -1,22 +1,20 @@ using HueLightDJ.Effects; using HueLightDJ.Effects.Base; using HueLightDJ.Effects.Layers; -using HueLightDJ.Web.Hubs; -using HueLightDJ.Web.Models; -using Microsoft.AspNetCore.SignalR; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.ColorConverters; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Threading; using System.Threading.Tasks; +using HueLightDJ.Services.Models; -namespace HueLightDJ.Web.Streaming +namespace HueLightDJ.Services { - public static class EffectService + public class EffectService { private static List EffectTypes { get; set; } = new List(); private static List GroupEffectTypes { get; set; } = new List(); @@ -25,6 +23,12 @@ public static class EffectService private static CancellationTokenSource? autoModeCts; public static bool AutoModeHasRandomEffects = true; + private readonly IHubService hub; + + public EffectService(IHubService hub) + { + this.hub = hub; + } public static List GetEffectTypes() { @@ -74,9 +78,11 @@ public static EffectsVM GetEffectViewModels() if (hueEffectAtt == null) continue; - var effect = new EffectViewModel(); - effect.Name = hueEffectAtt.Name; - effect.TypeName = type.Name; + var effect = new EffectViewModel() + { + Name = hueEffectAtt.Name, + TypeName = type.Name, + }; effect.HasColorPicker = hueEffectAtt.HasColorPicker; if(!string.IsNullOrEmpty(hueEffectAtt.DefaultColor)) @@ -102,9 +108,11 @@ public static EffectsVM GetEffectViewModels() if (hueEffectAtt == null) continue; - var effect = new EffectViewModel(); - effect.Name = hueEffectAtt.Name; - effect.TypeName = type.Name; + var effect = new EffectViewModel() + { + Name = hueEffectAtt.Name, + TypeName = type.Name + }; effect.HasColorPicker = hueEffectAtt.HasColorPicker; if (!string.IsNullOrEmpty(hueEffectAtt.DefaultColor)) @@ -149,7 +157,7 @@ public static void StopEffects() } } - public static void StartAutoMode() + public void StartAutoMode() { autoModeCts?.Cancel(); autoModeCts = new CancellationTokenSource(); @@ -186,12 +194,8 @@ public static bool IsAutoModeRunning() return true; } - public static void StartEffect(string typeName, string colorHex, string? group = null, IteratorEffectMode iteratorMode = IteratorEffectMode.All, IteratorEffectMode secondaryIteratorMode = IteratorEffectMode.All) + public void StartEffect(string typeName, string colorHex, string? group = null, IteratorEffectMode iteratorMode = IteratorEffectMode.All, IteratorEffectMode secondaryIteratorMode = IteratorEffectMode.All) { - var hub = (IHubContext?)Startup.ServiceProvider.GetService(typeof(IHubContext)); - if (hub == null) - throw new Exception("Unable to get PreviewHub from ServiceProvider"); - var all = GetEffectTypes(); var allGroup = GetGroupEffectTypes(); @@ -230,7 +234,8 @@ public static void StartEffect(string typeName, string colorHex, string? group = //get group var selectedGroup = GroupService.GetAll(layer).Where(x => x.Name == group).Select(x => x.Lights).FirstOrDefault(); - StartEffect(cts.Token, selectedEffect, selectedGroup.SelectMany(x => x), group, waitTime, color, iteratorMode, secondaryIteratorMode); + if(selectedGroup!= null) + StartEffect(cts.Token, selectedEffect, selectedGroup.SelectMany(x => x), group!, waitTime, color, iteratorMode, secondaryIteratorMode); } else { @@ -240,7 +245,7 @@ public static void StartEffect(string typeName, string colorHex, string? group = } } - private static void StartEffect(CancellationToken ctsToken, TypeInfo selectedEffect, IEnumerable> group, string groupName, Func waitTime, RGBColor? color, IteratorEffectMode iteratorMode = IteratorEffectMode.All, IteratorEffectMode secondaryIteratorMode = IteratorEffectMode.All) + private void StartEffect(CancellationToken ctsToken, TypeInfo selectedEffect, IEnumerable> group, string groupName, Func waitTime, RGBColor? color, IteratorEffectMode iteratorMode = IteratorEffectMode.All, IteratorEffectMode secondaryIteratorMode = IteratorEffectMode.All) { MethodInfo? methodInfo = selectedEffect.GetMethod("Start"); if (methodInfo == null) @@ -255,11 +260,7 @@ private static void StartEffect(CancellationToken ctsToken, TypeInfo selectedEff object? classInstance = Activator.CreateInstance(selectedEffect, null); methodInfo.Invoke(classInstance, parametersArray); - var hub = (IHubContext?)Startup.ServiceProvider.GetService(typeof(IHubContext)); - if (hub == null) - throw new Exception("Unable to get PreviewHub from ServiceProvider"); - - hub.Clients.All.SendAsync("StartingEffect", $"Starting: {selectedEffect.Name} {groupName}, {iteratorMode}-{secondaryIteratorMode} {color?.ToHex()}", + hub.SendAsync("StartingEffect", $"Starting: {selectedEffect.Name} {groupName}, {iteratorMode}-{secondaryIteratorMode} {color?.ToHex()}", new EffectLogMsg() { EffectType = "group", @@ -273,7 +274,7 @@ private static void StartEffect(CancellationToken ctsToken, TypeInfo selectedEff } - private static void StartTouchEffect(CancellationToken ctsToken, TypeInfo selectedEffect, Func waitTime, RGBColor? color, double x, double y) + private void StartTouchEffect(CancellationToken ctsToken, TypeInfo selectedEffect, Func waitTime, RGBColor? color, double x, double y) { MethodInfo? methodInfo = selectedEffect.GetMethod("Start"); if (methodInfo == null) @@ -287,7 +288,7 @@ private static void StartTouchEffect(CancellationToken ctsToken, TypeInfo select methodInfo.Invoke(classInstance, parametersArray); } - private static void StartEffect(CancellationToken ctsToken, TypeInfo selectedEffect, EntertainmentLayer layer, Func waitTime, RGBColor? color) + private void StartEffect(CancellationToken ctsToken, TypeInfo selectedEffect, EntertainmentLayer layer, Func waitTime, RGBColor? color) { MethodInfo? methodInfo = selectedEffect.GetMethod("Start"); if (methodInfo == null) @@ -298,15 +299,11 @@ private static void StartEffect(CancellationToken ctsToken, TypeInfo selectedEff object? classInstance = Activator.CreateInstance(selectedEffect, null); methodInfo.Invoke(classInstance, parametersArray); - var hub = (IHubContext?)Startup.ServiceProvider.GetService(typeof(IHubContext)); - if (hub == null) - throw new Exception("Unable to get PreviewHub from ServiceProvider"); - - hub.Clients.All.SendAsync("StartingEffect", $"Starting: {selectedEffect.Name} {color?.ToHex()}", new EffectLogMsg() { Name = selectedEffect.Name, RGBColor = color?.ToHex() }); + hub.SendAsync("StartingEffect", $"Starting: {selectedEffect.Name} {color?.ToHex()}", new EffectLogMsg() { Name = selectedEffect.Name, RGBColor = color?.ToHex() }); } - public static void StartRandomEffect(bool withRandomEffects = true) + public void StartRandomEffect(bool withRandomEffects = true) { var r = new Random(); @@ -335,7 +332,7 @@ public static void StartRandomEffect(bool withRandomEffects = true) } - private static void StartRandomGroupEffect(bool useMultipleEffects = true) + private void StartRandomGroupEffect(bool useMultipleEffects = true) { Func waitTime = () => StreamingSetup.WaitTime; @@ -393,8 +390,8 @@ private static void GenerateRandomEffectSettings(out RGBColor hexColor, out Iter hexColor = RGBColor.Random(r); Array values = Enum.GetValues(typeof(IteratorEffectMode)); - iteratorMode = (IteratorEffectMode)values.GetValue(r.Next(values.Length)); - iteratorSecondaryMode = (IteratorEffectMode)values.GetValue(r.Next(values.Length)); + iteratorMode = (IteratorEffectMode?)values.GetValue(r.Next(values.Length)) ?? IteratorEffectMode.All; + iteratorSecondaryMode = (IteratorEffectMode?)values.GetValue(r.Next(values.Length)) ?? IteratorEffectMode.Random; //Bounce and Single are no fun for random mode if (iteratorMode == IteratorEffectMode.Bounce || iteratorMode == IteratorEffectMode.Single) @@ -405,6 +402,9 @@ private static void GenerateRandomEffectSettings(out RGBColor hexColor, out Iter private static EntertainmentLayer GetLayer(bool isBaseLayer) { + if (StreamingSetup.Layers == null || !StreamingSetup.Layers.Any()) + throw new Exception("No layers found."); + if (isBaseLayer) return StreamingSetup.Layers.First(); @@ -444,18 +444,20 @@ public static void CancelAllEffects() } } - public static void StartRandomTouchEffect(double x, double y) + public void StartRandomTouchEffect(double x, double y) { var effectLayer = GetLayer(isBaseLayer: false); var randomTouch = GetTouchEffectTypes().OrderBy(_ => Guid.NewGuid()).FirstOrDefault(); + if (randomTouch == null) + return; Func waitTime = () => StreamingSetup.WaitTime; StartTouchEffect(CancellationToken.None, randomTouch, waitTime, null, x, y); } - public static void Beat(double intensity) + public void Beat(double intensity) { var effectLayer = GetLayer(isBaseLayer: false); diff --git a/HueLightDJ.Web/Streaming/GroupService.cs b/HueLightDJ.Services/GroupService.cs similarity index 91% rename from HueLightDJ.Web/Streaming/GroupService.cs rename to HueLightDJ.Services/GroupService.cs index 43bcd40..f998850 100644 --- a/HueLightDJ.Web/Streaming/GroupService.cs +++ b/HueLightDJ.Services/GroupService.cs @@ -1,21 +1,19 @@ using HueLightDJ.Effects; -using HueLightDJ.Web.Models; -using Q42.HueApi.Streaming.Effects; -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; +using HueLightDJ.Services.Models; -namespace HueLightDJ.Web.Streaming +namespace HueLightDJ.Services { public static class GroupService { public static List GetAll(EntertainmentLayer? layer = null) { if (layer == null) - layer = StreamingSetup.Layers.First(); + layer = StreamingSetup.GetFirstLayer(); var center = EffectSettings.LocationCenter; @@ -63,7 +61,7 @@ public static List GetAll(EntertainmentLayer? layer = null) public static IEnumerable> GetRandomGroup() { - var layer = StreamingSetup.Layers.First(); + var layer = StreamingSetup.GetFirstLayer(); var orderRandom = layer.OrderBy(x => Guid.NewGuid()); var min = 2; diff --git a/HueLightDJ.Services/HueLightDJ.Services.csproj b/HueLightDJ.Services/HueLightDJ.Services.csproj new file mode 100644 index 0000000..0ac3045 --- /dev/null +++ b/HueLightDJ.Services/HueLightDJ.Services.csproj @@ -0,0 +1,21 @@ + + + + net7.0 + enable + nullable + + + + + + + + + + + + + + + diff --git a/HueLightDJ.Services/IHubService.cs b/HueLightDJ.Services/IHubService.cs new file mode 100644 index 0000000..f83f0ca --- /dev/null +++ b/HueLightDJ.Services/IHubService.cs @@ -0,0 +1,15 @@ +using HueLightDJ.Services.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HueLightDJ.Services +{ + public interface IHubService + { + Task SendAsync(string method, object? arg1); + Task SendAsync(string method, object? arg1, object? arg2); + } +} diff --git a/HueLightDJ.Services/LightDJStreamingHueClient.cs b/HueLightDJ.Services/LightDJStreamingHueClient.cs new file mode 100644 index 0000000..afda284 --- /dev/null +++ b/HueLightDJ.Services/LightDJStreamingHueClient.cs @@ -0,0 +1,43 @@ +using HueApi.Entertainment; +using HueApi.Entertainment.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using HueLightDJ.Services.Models; + +namespace HueLightDJ.Services +{ + public class LightDJStreamingHueClient : StreamingHueClient + { + private bool _demoMode; + private readonly IHubService _hub; + private string _bridgeIp; + + public LightDJStreamingHueClient(IHubService hub, string ip, string appKey, string clientKey, bool demoMode) : base(ip, appKey, clientKey) + { + this._hub = hub; + _bridgeIp = ip; + _demoMode = demoMode; + + } + + protected override void Send(IEnumerable> chunks) + { + if(!_demoMode) + base.Send(chunks); + + var flatten = chunks.SelectMany(x => x); + + _hub.SendAsync("preview", flatten.Select(x => new PreviewModel() + { + Bridge = _bridgeIp, + Id = x.Id, + X = x.ChannelLocation.X, + Y = x.ChannelLocation.Y, + Hex = x.State.RGBColor.ToHex(), + Bri = x.State.Brightness + })); + } + } +} diff --git a/HueLightDJ.Web/Streaming/ManualControlService.cs b/HueLightDJ.Services/ManualControlService.cs similarity index 76% rename from HueLightDJ.Web/Streaming/ManualControlService.cs rename to HueLightDJ.Services/ManualControlService.cs index 29f9512..7b29c3d 100644 --- a/HueLightDJ.Web/Streaming/ManualControlService.cs +++ b/HueLightDJ.Services/ManualControlService.cs @@ -1,11 +1,11 @@ -using Q42.HueApi.Models.Groups; -using Q42.HueApi.Streaming.Models; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using HueApi.Models; -namespace HueLightDJ.Web.Streaming +namespace HueLightDJ.Services { public static class ManualControlService { @@ -16,7 +16,7 @@ public static void SetColors(string[,] matrix) var lightsMatrix = new List[heightIndex + 1, widthIndex + 1]; - var allLights = StreamingSetup.Layers.First(); + var allLights = StreamingSetup.GetFirstLayer(); foreach (var light in allLights) { int x = GetMatrixPositionY(light.LightLocation, heightIndex + 1); @@ -40,7 +40,7 @@ public static void SetColors(string[,] matrix) var color = matrix[x, y]; foreach (var current in lightsMatrix[x, y]) { - current.State.SetRGBColor(new Q42.HueApi.ColorConverters.RGBColor(color)); + current.State.SetRGBColor(new HueApi.ColorConverters.RGBColor(color)); current.State.SetBrightness(1); } } @@ -70,14 +70,14 @@ public static void SetColors(List> matrix) SetColors(array); } - private static int GetMatrixPositionX(LightLocation lightLocation, int matrixSize) + private static int GetMatrixPositionX(HuePosition HuePosition, int matrixSize) { - double pos = ((lightLocation.X +1) / 2) * matrixSize; + double pos = ((HuePosition.X +1) / 2) * matrixSize; return (int)pos; } - private static int GetMatrixPositionY(LightLocation lightLocation, int matrixSize) + private static int GetMatrixPositionY(HuePosition HuePosition, int matrixSize) { - double pos = ((1 - (lightLocation.Y + 1) / 2)) * matrixSize; + double pos = ((1 - (HuePosition.Y + 1) / 2)) * matrixSize; return (int)pos; } } diff --git a/HueLightDJ.Services/Models/ConnectionConfiguration.cs b/HueLightDJ.Services/Models/ConnectionConfiguration.cs new file mode 100644 index 0000000..c898761 --- /dev/null +++ b/HueLightDJ.Services/Models/ConnectionConfiguration.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace HueLightDJ.Services.Models +{ + public class ConnectionConfiguration + { + public required string Ip { get; set; } + public required string Key { get; set; } + public required string EntertainmentKey { get; set; } + public Guid GroupId { get; set; } + public bool UseSimulator { get; set; } + } +} diff --git a/HueLightDJ.Services/Models/EffectLogMsg.cs b/HueLightDJ.Services/Models/EffectLogMsg.cs new file mode 100644 index 0000000..9bcef6b --- /dev/null +++ b/HueLightDJ.Services/Models/EffectLogMsg.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using HueApi.Entertainment.Extensions; + +namespace HueLightDJ.Services.Models +{ + public class EffectLogMsg + { + public required string Name { get; set; } + + public string? EffectType { get; set; } + public string? RGBColor { get; set; } + public string? Group { get; set; } + public string? IteratorMode { get; set; } + public string? SecondaryIteratorMode { get; set; } + } +} diff --git a/HueLightDJ.Services/Models/EffectViewModel.cs b/HueLightDJ.Services/Models/EffectViewModel.cs new file mode 100644 index 0000000..0d7e527 --- /dev/null +++ b/HueLightDJ.Services/Models/EffectViewModel.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace HueLightDJ.Services.Models +{ + public class EffectsVM + { + public Dictionary> BaseEffects { get; set; } = new(); + public List ShortEffects { get; set; } = new(); + public List GroupEffects { get; set; } = new(); + public List Groups { get; set; } = new(); + public List IteratorModes { get; set; } = new(); + public List SecondaryIteratorModes { get; set; } = new(); + + } + + public class EffectViewModel + { + public required string Name { get; set; } + + public required string TypeName { get; set; } + public bool HasColorPicker { get; set; } + + + //VueJS properties: + public string? Color { get; set; } + + public bool IsRandom { get; set; } = true; + + } + + public class GroupInfoViewModel + { + public required string Name { get; set; } + + } +} diff --git a/HueLightDJ.Web/Models/GroupConfiguration.cs b/HueLightDJ.Services/Models/GroupConfiguration.cs similarity index 63% rename from HueLightDJ.Web/Models/GroupConfiguration.cs rename to HueLightDJ.Services/Models/GroupConfiguration.cs index d4b540a..2aae531 100644 --- a/HueLightDJ.Web/Models/GroupConfiguration.cs +++ b/HueLightDJ.Services/Models/GroupConfiguration.cs @@ -2,15 +2,15 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Q42.HueApi.Models.Groups; +using HueApi.Models; -namespace HueLightDJ.Web.Models +namespace HueLightDJ.Services.Models { public class GroupConfiguration { - public string Name { get; set; } - public List Connections { get; set; } - public LightLocation LocationCenter { get; set; } + public required string Name { get; set; } + public List Connections { get; set; } = new(); + public HuePosition? LocationCenter { get; set; } public bool IsAlwaysVisible { get; set; } public bool HideDisconnect { get; set; } } diff --git a/HueLightDJ.Web/Models/GroupModel.cs b/HueLightDJ.Services/Models/GroupModel.cs similarity index 93% rename from HueLightDJ.Web/Models/GroupModel.cs rename to HueLightDJ.Services/Models/GroupModel.cs index 56dd351..faf0962 100644 --- a/HueLightDJ.Web/Models/GroupModel.cs +++ b/HueLightDJ.Services/Models/GroupModel.cs @@ -1,11 +1,11 @@ -using Q42.HueApi.Streaming.Extensions; -using Q42.HueApi.Streaming.Models; +using HueApi.Entertainment.Extensions; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace HueLightDJ.Web.Models +namespace HueLightDJ.Services.Models { public class GroupModel { diff --git a/HueLightDJ.Services/Models/MultiBridgeLightLocation.cs b/HueLightDJ.Services/Models/MultiBridgeLightLocation.cs new file mode 100644 index 0000000..a20a2f5 --- /dev/null +++ b/HueLightDJ.Services/Models/MultiBridgeLightLocation.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace HueLightDJ.Services.Models +{ + public class MultiBridgeHuePosition + { + public required string Bridge { get; set; } + public Guid GroupId { get; set; } + + public Guid Id { get; set; } + + public int PositionIndex { get; set; } + public double X { get; set; } + public double Y { get; set; } + } +} diff --git a/HueLightDJ.Web/Models/PreviewModel.cs b/HueLightDJ.Services/Models/PreviewModel.cs similarity index 60% rename from HueLightDJ.Web/Models/PreviewModel.cs rename to HueLightDJ.Services/Models/PreviewModel.cs index 2c43464..a0417d5 100644 --- a/HueLightDJ.Web/Models/PreviewModel.cs +++ b/HueLightDJ.Services/Models/PreviewModel.cs @@ -3,15 +3,15 @@ using System.Linq; using System.Threading.Tasks; -namespace HueLightDJ.Web.Models +namespace HueLightDJ.Services.Models { - public class PreviewModel - { - public string Bridge { get; set; } + public class PreviewModel + { + public required string Bridge { get; set; } public byte Id { get; set; } public double X { get; set; } public double Y { get; set; } - public string Hex { get; set; } + public required string Hex { get; set; } public double Bri { get; set; } } } diff --git a/HueLightDJ.Web/Models/RunningEffectInfo.cs b/HueLightDJ.Services/Models/RunningEffectInfo.cs similarity index 52% rename from HueLightDJ.Web/Models/RunningEffectInfo.cs rename to HueLightDJ.Services/Models/RunningEffectInfo.cs index 64efb55..578f635 100644 --- a/HueLightDJ.Web/Models/RunningEffectInfo.cs +++ b/HueLightDJ.Services/Models/RunningEffectInfo.cs @@ -4,11 +4,11 @@ using System.Threading; using System.Threading.Tasks; -namespace HueLightDJ.Web.Models +namespace HueLightDJ.Services.Models { public class RunningEffectInfo { - public CancellationTokenSource CancellationTokenSource { get; set; } - public string Name { get; set; } + public CancellationTokenSource? CancellationTokenSource { get; set; } + public required string Name { get; set; } } } diff --git a/HueLightDJ.Services/ServiceRegistrationExtension.cs b/HueLightDJ.Services/ServiceRegistrationExtension.cs new file mode 100644 index 0000000..d9d137b --- /dev/null +++ b/HueLightDJ.Services/ServiceRegistrationExtension.cs @@ -0,0 +1,19 @@ +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace HueLightDJ.Services +{ + public static class ServiceRegistrationExtension + { + public static void AddHueLightDJServices(this IServiceCollection services) + { + services.AddSingleton(); + services.AddSingleton(); + } + } +} diff --git a/HueLightDJ.Web/Streaming/StreamingSetup.cs b/HueLightDJ.Services/StreamingSetup.cs similarity index 50% rename from HueLightDJ.Web/Streaming/StreamingSetup.cs rename to HueLightDJ.Services/StreamingSetup.cs index 1c82f9e..3182f75 100644 --- a/HueLightDJ.Web/Streaming/StreamingSetup.cs +++ b/HueLightDJ.Services/StreamingSetup.cs @@ -1,27 +1,25 @@ using HueLightDJ.Effects; -using HueLightDJ.Web.Hubs; -using HueLightDJ.Web.Models; -using Microsoft.AspNetCore.SignalR; -using Microsoft.Extensions.Configuration; -using Newtonsoft.Json; -using Q42.HueApi; -using Q42.HueApi.ColorConverters; -using Q42.HueApi.ColorConverters.Original; -using Q42.HueApi.Interfaces; -using Q42.HueApi.Models.Bridge; -using Q42.HueApi.Models.Groups; -using Q42.HueApi.Streaming; -using Q42.HueApi.Streaming.Models; +using HueApi; +using HueApi.ColorConverters; +using HueApi.Entertainment.Models; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; - -namespace HueLightDJ.Web.Streaming +using HueApi.Models; +using HueApi.BridgeLocator; +using HueApi.Models.Requests; +using HueApi.ColorConverters.Original.Extensions; +using HueApi.Extensions; +using HueLightDJ.Services.Models; +using System.Text.Json; +using Microsoft.Extensions.Options; + +namespace HueLightDJ.Services { - public static class StreamingSetup + public class StreamingSetup { private static List StreamingGroups { get; set; } = new List(); private static List StreamingHueClients { get; set; } = new List(); @@ -35,41 +33,57 @@ public static class StreamingSetup - private static string _groupId; - private static CancellationTokenSource _cts; + private static Guid _groupId; + private static CancellationTokenSource _cts = new(); + private readonly IHubService hub; + private readonly List fullConfig; - public static async Task> GetLocationsAsync(string groupName) + public StreamingSetup(IHubService hub, IOptions> fullConfig) + { + this.hub = hub; + this.fullConfig = fullConfig.Value; + } + + public async Task> GetLocationsAsync(string groupName) { var configSection = await GetGroupConfigurationsAsync(); var currentGroup = configSection.Where(x => x.Name == groupName).FirstOrDefault(); - var locations = new List(); + var locations = new List(); if (currentGroup == null) return locations; foreach (var bridgeConfig in currentGroup.Connections) { - var localClient = new LocalHueClient(bridgeConfig.Ip, bridgeConfig.Key); - var group = await localClient.GetGroupAsync(bridgeConfig.GroupId); + var localClient = new LocalHueApi(bridgeConfig.Ip, bridgeConfig.Key); + var group = await localClient.GetEntertainmentConfigurationAsync(bridgeConfig.GroupId); - if (group?.Type != GroupType.Entertainment) - continue; + var serviceLocations = group.Data.First().Locations.ServiceLocations; - locations.AddRange(group.Locations.Select(x => new MultiBridgeLightLocation() + foreach(var serviceLocation in serviceLocations) { - Bridge = bridgeConfig.Ip, - GroupId = bridgeConfig.GroupId, - Id = x.Key, - X = x.Value.X, - Y = x.Value.Y - })); + for (int i = 0; i < serviceLocation.Positions.Count; i++) + { + locations.Add(new MultiBridgeHuePosition() + { + Bridge = bridgeConfig.Ip, + GroupId = bridgeConfig.GroupId, + Id = serviceLocation.Service!.Rid, + PositionIndex = i, + X = serviceLocation.Positions[i].X, + Y = serviceLocation.Positions[i].Y + }); + } + } + + } return locations; } - public static async Task SetLocations(List locations) + public async Task SetLocations(List locations) { var configSection = await GetGroupConfigurationsAsync(); @@ -82,14 +96,33 @@ public static async Task SetLocations(List locations) var config = configSection.SelectMany(x => x.Connections).Where(x => x.Ip == ip && x.GroupId == groupId).FirstOrDefault(); if(config != null) { - var client = new LocalHueClient(config.Ip, config.Key); - var bridgeLocations = group.ToDictionary(x => x.Id, l => new LightLocation() { l.X, l.Y, 0 }); - await client.UpdateGroupLocationsAsync(groupId, bridgeLocations); + var serviceLocations = group.GroupBy(x => x.Id); + + var client = new LocalHueApi(config.Ip, config.Key); + UpdateEntertainmentConfiguration updateReq = new UpdateEntertainmentConfiguration(); + updateReq.Locations = new Locations(); + + foreach (var location in serviceLocations) + { + var serviceLoc = new HueServiceLocation + { + Service = new ResourceIdentifier() { Rid = location.Key, Rtype = "entertainment" } + }; + + foreach(var pos in location) + { + serviceLoc.Positions.Add(new HuePosition(pos.X, pos.Y, 0)); + } + + updateReq.Locations.ServiceLocations.Add(serviceLoc); + } + + await client.UpdateEntertainmentConfigurationAsync(groupId, updateReq); } } } - public static async Task AlertLight(MultiBridgeLightLocation light) + public async Task AlertLight(MultiBridgeHuePosition light) { var configSection = await GetGroupConfigurationsAsync(); @@ -98,22 +131,41 @@ public static async Task AlertLight(MultiBridgeLightLocation light) { foreach (var conn in config.Connections) { - var client = new LocalHueClient(conn.Ip, conn.Key); + var client = new LocalHueApi(conn.Ip, conn.Key); var allCommand = new LightCommand().TurnOn().SetColor(new RGBColor("0000FF")); //All blue - await client.SendGroupCommandAsync(allCommand, conn.GroupId); + + var result = await client.GetEntertainmentConfigurationAsync(conn.GroupId); + + //Turn all lights in this entertainment group on + var entServices = result.Data.First().Locations.ServiceLocations.Select(x => x.Service?.Rid).ToList(); + var allResources = await client.GetResourcesAsync(); + + var devices = allResources.Data.Where(x => entServices.Contains(x.Id)).Select(x => x.Owner?.Rid).ToList(); + var lights = allResources.Data.Where(x => devices.Contains(x.Id)).Select(x => x.Services?.Where(x => x.Rtype == "light").FirstOrDefault()?.Rid).ToList(); + + foreach (var singleLightId in lights.Where(x => x.HasValue)) + { + await client.UpdateLightAsync(singleLightId!.Value, allCommand); + } + //Only selected light red if (conn.Ip == light.Bridge) { var alertCommand = new LightCommand().TurnOn().SetColor(new RGBColor("FF0000")); ; - alertCommand.Alert = Alert.Once; - await client.SendCommandAsync(alertCommand, new List { light.Id }); + alertCommand.Alert = new UpdateAlert(); + + var device = allResources.Data.Where(x => x.Id == light.Id).Select(x => x.Owner?.Rid).FirstOrDefault(); + var lightDeviceId = allResources.Data.Where(x => x.Id == device).Select(x => x.Services?.Where(x => x.Rtype == "light").FirstOrDefault()?.Rid).FirstOrDefault(); + + if(lightDeviceId.HasValue) + await client.UpdateLightAsync(lightDeviceId.Value, alertCommand); } } } } - public static async Task SetupAndReturnGroupAsync(string groupName) + public async Task SetupAndReturnGroupAsync(string groupName) { var configSection = await GetGroupConfigurationsAsync(); var currentGroup = configSection.Where(x => x.Name == groupName).FirstOrDefault(); @@ -141,49 +193,45 @@ public static async Task SetupAndReturnGroupAsync(string groupName) Layers = new List() { baseLayer, effectLayer }; CurrentConnection = currentGroup; - EffectSettings.LocationCenter = currentGroup.LocationCenter ?? new LightLocation() { 0,0,0}; + EffectSettings.LocationCenter = currentGroup.LocationCenter ?? new HuePosition(0,0,0); //Optional: calculated effects that are placed on this layer baseLayer.AutoCalculateEffectUpdate(_cts.Token); effectLayer.AutoCalculateEffectUpdate(_cts.Token); } - private static async Task Connect(bool demoMode, bool useSimulator, ConnectionConfiguration bridgeConfig) + private async Task Connect(bool demoMode, bool useSimulator, ConnectionConfiguration bridgeConfig) { - var hub = (IHubContext?)Startup.ServiceProvider.GetService(typeof(IHubContext)); - if (hub == null) - throw new Exception("Unable to get PreviewHub from ServiceProvider"); - - await hub.Clients.All.SendAsync("StatusMsg", $"Connecting to bridge {bridgeConfig.Ip}"); + await hub.SendAsync("StatusMsg", $"Connecting to bridge {bridgeConfig.Ip}"); try { //Initialize streaming client - var client = new LightDJStreamingHueClient(bridgeConfig.Ip, bridgeConfig.Key, bridgeConfig.EntertainmentKey, demoMode); + var client = new LightDJStreamingHueClient(hub, bridgeConfig.Ip, bridgeConfig.Key, bridgeConfig.EntertainmentKey, demoMode); //Get the entertainment group - Dictionary? locations = new Dictionary(); + Dictionary? locations = new Dictionary(); if (demoMode) { string demoJson = await File.ReadAllTextAsync($"{bridgeConfig.Ip}_{bridgeConfig.GroupId}.json"); - locations = JsonConvert.DeserializeObject>(demoJson); + locations = JsonSerializer.Deserialize>(demoJson); _groupId = bridgeConfig.GroupId; } else { - var all = await client.LocalHueClient.GetEntertainmentGroups(); - var group = all.Where(x => x.Id == bridgeConfig.GroupId).FirstOrDefault(); + var all = await client.LocalHueApi.GetEntertainmentConfigurationsAsync(); + var group = all.Data.Where(x => x.Id == bridgeConfig.GroupId).FirstOrDefault(); if (group == null) - throw new Exception($"No Entertainment Group found with id {bridgeConfig.GroupId}. Create one using the Philips Hue App or the Q42.HueApi.UniversalWindows.Sample"); + throw new Exception($"No Entertainment Group found with id {bridgeConfig.GroupId}. Create one using the Philips Hue App or the HueApi.UniversalWindows.Sample"); else { - await hub.Clients.All.SendAsync("StatusMsg", $"Using Entertainment Group {group.Id} for bridge {bridgeConfig.Ip}"); + await hub.SendAsync("StatusMsg", $"Using Entertainment Group {group.Id} for bridge {bridgeConfig.Ip}"); Console.WriteLine($"Using Entertainment Group {group.Id}"); _groupId = group.Id; } - locations = group.Locations; + locations = group.Channels.ToDictionary(x => x.ChannelId, x => x.Position); } if (locations == null) @@ -196,27 +244,27 @@ private static async Task Connect(bool demoMode, bool useSimulator, ConnectionCo //Connect to the streaming group if (!demoMode) - await client.Connect(_groupId, simulator: useSimulator); + await client.ConnectAsync(_groupId, simulator: useSimulator); //Start auto updating this entertainment group - client.AutoUpdate(stream, _cts.Token, 50, onlySendDirtyStates: false); + client.AutoUpdateAsync(stream, _cts.Token, 50, onlySendDirtyStates: false); StreamingHueClients.Add(client); StreamingGroups.Add(stream); - await hub.Clients.All.SendAsync("StatusMsg", $"Succesfully connected to bridge {bridgeConfig.Ip}"); + await hub.SendAsync("StatusMsg", $"Succesfully connected to bridge {bridgeConfig.Ip}"); } catch (Exception ex) { - await hub.Clients.All.SendAsync("StatusMsg", $"Failed to connect to bridge {bridgeConfig.Ip}, exception: " + ex); + await hub.SendAsync("StatusMsg", $"Failed to connect to bridge {bridgeConfig.Ip}, exception: " + ex); throw; } } - public async static Task> GetGroupConfigurationsAsync() + public async Task> GetGroupConfigurationsAsync() { IEnumerable bridges = new List(); try @@ -226,13 +274,11 @@ public async static Task> GetGroupConfigurationsAsync() } catch { } - var allConfig = Startup.Configuration.GetSection("HueSetup").Get>(); - if (bridges == null || !bridges.Any()) - return allConfig ?? new(); + return fullConfig ?? new(); else { - return allConfig.Where(x => + return fullConfig.Where(x => x.Connections.Select(c => c.Ip).Intersect(bridges.Select(b => b.IpAddress)).Any() || x.IsAlwaysVisible ).ToList(); @@ -267,7 +313,7 @@ public static void Disconnect() { try { - client.LocalHueClient.SetStreamingAsync(_groupId, active: false); + client.LocalHueApi.SetStreamingAsync(_groupId, active: false); client.Close(); } catch { } @@ -282,16 +328,34 @@ public static void Disconnect() } + public static EntertainmentLayer GetFirstLayer() + { + if (Layers == null || !Layers.Any()) + throw new Exception("No layers found."); + + return Layers.First(); + } + public async static Task IsStreamingActive() { //Optional: Check if streaming is currently active - var bridgeInfo = await StreamingHueClients.First().LocalHueClient.GetBridgeAsync(); - if (bridgeInfo == null) + var entServices = await StreamingHueClients.First().LocalHueApi.GetEntertainmentServicesAsync(); + if (!entServices.Data.Any()) + return false; + + var numSupported = entServices.Data.Sum(x => x.MaxStreams); + + var entConfigs = await StreamingHueClients.First().LocalHueApi.GetEntertainmentConfigurationsAsync(); + if (!entConfigs.Data.Any()) return false; - Console.WriteLine(bridgeInfo.IsStreamingActive ? "Streaming is active" : "Streaming is not active"); + var active = entConfigs.Data.Where(x => x.Status == EntertainmentConfigurationStatus.active).Count(); + + var streamingChannelsLeft = numSupported - active; + + Console.WriteLine($"{streamingChannelsLeft} our of {numSupported} streaming channels left"); - return bridgeInfo.IsStreamingActive; + return streamingChannelsLeft <= 0; } diff --git a/HueLightDJ.Web/Controllers/ApiController.cs b/HueLightDJ.Web/Controllers/ApiController.cs index 850ce78..be4abc7 100644 --- a/HueLightDJ.Web/Controllers/ApiController.cs +++ b/HueLightDJ.Web/Controllers/ApiController.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using HueLightDJ.Web.Streaming; +using HueLightDJ.Services; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -12,6 +12,15 @@ namespace HueLightDJ.Web.Controllers [ApiController] public class ApiController : ControllerBase { + private readonly IHubService hub; + private readonly EffectService effectService; + + public ApiController(IHubService hub, EffectService effectService) + { + this.hub = hub; + this.effectService = effectService; + } + [HttpPost("setcolors")] public void SetColors([FromBody]string[,] matrix) { @@ -27,7 +36,7 @@ public void SetColors([FromBody]List> matrix) [HttpPost("beat")] public void Beat([FromBody]double intensity) { - EffectService.Beat(intensity); + effectService.Beat(intensity); } [HttpPost("test")] diff --git a/HueLightDJ.Web/Controllers/HomeController.cs b/HueLightDJ.Web/Controllers/HomeController.cs index 5fb5d11..8cf9e55 100644 --- a/HueLightDJ.Web/Controllers/HomeController.cs +++ b/HueLightDJ.Web/Controllers/HomeController.cs @@ -4,16 +4,28 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; +using HueLightDJ.Services.Models; +using HueLightDJ.Services; +using HueApi; +using HueApi.Models; +using HueApi.BridgeLocator; +using Org.BouncyCastle.Ocsp; +using HueApi.Extensions.cs; using HueLightDJ.Web.Models; -using HueLightDJ.Web.Streaming; -using Q42.HueApi; -using Q42.HueApi.Models.Bridge; -using Q42.HueApi.Models.Groups; +using HueLightDJ.Web; +using Microsoft.Extensions.Configuration; -namespace HueLightDJ.Web.Controllers +namespace HueLightDJ.Services.Controllers { public class HomeController : Controller { + private readonly StreamingSetup streamingSetup; + + public HomeController(StreamingSetup streamingSetup) + { + this.streamingSetup = streamingSetup; + } + [HttpGet] public IActionResult Index(bool isAdmin) { @@ -42,43 +54,67 @@ public async Task Setup() [Route("Configure")] public async Task Configure() { - var config = await StreamingSetup.GetGroupConfigurationsAsync(); + var config = await streamingSetup.GetGroupConfigurationsAsync(); return View(config); } [HttpGet] [Route("export/{groupName}")] - public async Task>> ExportJson([FromRoute]string groupName) + public async Task>> ExportJson([FromRoute]string groupName) { - var locations = await StreamingSetup.GetLocationsAsync(groupName); + var locations = await streamingSetup.GetLocationsAsync(groupName); return locations.GroupBy(x => x.Bridge) - .Select(x => x.ToDictionary(l => l.Id, loc => new LightLocation() { loc.X, loc.Y, 0 })).ToList(); + .Select(x => x.ToDictionary(l => l.Id, loc => new HuePosition(loc.X, loc.Y, 0))).ToList(); } [HttpGet] [Route("fullexport/{groupName}")] - public Task> FullExportJson([FromRoute]string groupName) + public Task> FullExportJson([FromRoute]string groupName) { - return StreamingSetup.GetLocationsAsync(groupName); + return streamingSetup.GetLocationsAsync(groupName); } [HttpPost] [Route("Register")] public async Task Register([FromForm]string ip) { - var hueClient = new LocalHueClient(ip); - var result = await hueClient.RegisterAsync("HueLightDJ", "Web", generateClientKey: true); + var result = await LocalHueApi.RegisterAsync(ip, "HueLightDJ", "Web", generateClientKey: true); - if (result == null) + if (result == null || result.Username == null || string.IsNullOrEmpty(result.StreamingClientKey)) throw new Exception("No result from bridge"); - var allLights = await hueClient.GetLightsAsync(); - string? groupId = "GroupId"; + var hueClient = new LocalHueApi(ip, result.Username); + var allLights = await hueClient.GetEntertainmentServicesAsync(); + + var createReq = new HueApi.Models.Requests.UpdateEntertainmentConfiguration() + { + Metadata = new Metadata() { Name = "Hue Light DJ group " }, + ConfigurationType = EntertainmentConfigurationType.music, + Locations = new Locations() + }; + + foreach (var light in allLights.Data.Where(x => x.Renderer)) + { + var lightPosition = new HueServiceLocation + { + Service = light.ToResourceIdentifier(), + Positions = new System.Collections.Generic.List + { + new HuePosition + { + X = 0.42, Y = 0.5, Z = 0 + } + } + }; + + createReq.Locations.ServiceLocations.Add(lightPosition); + } + + var createResult = await hueClient.CreateEntertainmentConfigurationAsync(createReq); - if(allLights.Any()) - groupId = await hueClient.CreateGroupAsync(allLights.Take(10).Select(x => x.Id), "Hue Light DJ group", Q42.HueApi.Models.Groups.RoomClass.TV, Q42.HueApi.Models.Groups.GroupType.Entertainment); + var groupId = createResult.Data.First().Rid; var connection = new ConnectionConfiguration() { @@ -86,7 +122,7 @@ public async Task Register([FromForm]string ip) UseSimulator = false, Key = result.Username, EntertainmentKey = result.StreamingClientKey, - GroupId = groupId ?? "unknown" + GroupId = groupId }; return connection; diff --git a/HueLightDJ.Web/Hubs/PreviewHub.cs b/HueLightDJ.Web/Hubs/PreviewHub.cs index 19d928f..746f4c2 100644 --- a/HueLightDJ.Web/Hubs/PreviewHub.cs +++ b/HueLightDJ.Web/Hubs/PreviewHub.cs @@ -1,16 +1,25 @@ -using HueLightDJ.Web.Models; -using HueLightDJ.Web.Streaming; using Microsoft.AspNetCore.SignalR; -using Q42.HueApi.Streaming.Extensions; +using HueApi.Entertainment.Extensions; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using HueLightDJ.Services.Models; +using HueLightDJ.Services; +using Microsoft.Extensions.Configuration; namespace HueLightDJ.Web.Hubs { public class PreviewHub : Hub { + private readonly StreamingSetup streamingSetup; + private readonly EffectService effectService; + + public PreviewHub(StreamingSetup streamingSetup, EffectService effectService) + { + this.streamingSetup = streamingSetup; + this.effectService = effectService; + } public async Task Connect() { @@ -19,23 +28,23 @@ public async Task Connect() public async Task Touch(double x, double y) { - EffectService.StartRandomTouchEffect(x, y); + effectService.StartRandomTouchEffect(x, y); } public async Task GetLocations(string groupName) { - var locations = await StreamingSetup.GetLocationsAsync(groupName); + var locations = await streamingSetup.GetLocationsAsync(groupName); Clients.Caller.SendAsync("newLocations", locations); } - public Task SetLocations(List locations) + public Task SetLocations(List locations) { - return StreamingSetup.SetLocations(locations); + return streamingSetup.SetLocations(locations); } - public Task Locate(MultiBridgeLightLocation light) + public Task Locate(MultiBridgeHuePosition light) { - return StreamingSetup.AlertLight(light); + return streamingSetup.AlertLight(light); } } diff --git a/HueLightDJ.Web/Hubs/StatusHub.cs b/HueLightDJ.Web/Hubs/StatusHub.cs index 98a5b32..6b24c22 100644 --- a/HueLightDJ.Web/Hubs/StatusHub.cs +++ b/HueLightDJ.Web/Hubs/StatusHub.cs @@ -1,16 +1,26 @@ -using HueLightDJ.Web.Models; -using HueLightDJ.Web.Streaming; using Microsoft.AspNetCore.SignalR; -using Q42.HueApi.Streaming.Extensions; +using HueApi.Entertainment.Extensions; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using HueLightDJ.Services.Models; +using HueLightDJ.Services; +using HueLightDJ.Web.Models; +using Microsoft.Extensions.Configuration; namespace HueLightDJ.Web.Hubs { public class StatusHub : Hub { + private readonly EffectService effectService; + private readonly StreamingSetup streamingSetup; + + public StatusHub(EffectService effectService, StreamingSetup streamingSetup) + { + this.effectService = effectService; + this.streamingSetup = streamingSetup; + } public async Task Connect(string groupName) { @@ -19,7 +29,7 @@ public async Task Connect(string groupName) try { //Connect - await StreamingSetup.SetupAndReturnGroupAsync(groupName); + await streamingSetup.SetupAndReturnGroupAsync(groupName); await Clients.All.SendAsync("StatusMsg", "Connected to bridge"); await GetEffects(true); @@ -34,7 +44,7 @@ public async Task Connect(string groupName) public async Task GetStatus() { - var configs = await StreamingSetup.GetGroupConfigurationsAsync(); + var configs = await streamingSetup.GetGroupConfigurationsAsync(); StatusViewModel vm = new StatusViewModel(); vm.bpm = StreamingSetup.GetBPM(); vm.IsAutoMode = EffectService.IsAutoModeRunning(); @@ -64,12 +74,12 @@ public Task GetEffects(bool forAll) public void StartEffect(string typeName, string colorHex) { - EffectService.StartEffect(typeName, colorHex); + effectService.StartEffect(typeName, colorHex); } public void StartGroupEffect(string typeName, string colorHex, string groupName, string iteratorMode, string secondaryIteratorMode) { - EffectService.StartEffect(typeName, colorHex, groupName, Enum.Parse(iteratorMode), Enum.Parse(secondaryIteratorMode)); + effectService.StartEffect(typeName, colorHex, groupName, Enum.Parse(iteratorMode), Enum.Parse(secondaryIteratorMode)); } public Task IncreaseBPM(int value) @@ -96,12 +106,12 @@ public void SetBri(double value) public void StartRandom() { - EffectService.StartRandomEffect(); + effectService.StartRandomEffect(); } public Task StartAutoMode() { - EffectService.StartAutoMode(); + effectService.StartAutoMode(); return GetStatus(); } @@ -139,7 +149,7 @@ public void SetColorsList(List> matrix) } public void Beat(double intensity) { - EffectService.Beat(intensity); + effectService.Beat(intensity); } public async Task Disconnect() diff --git a/HueLightDJ.Web/HueLightDJ.Web.csproj b/HueLightDJ.Web/HueLightDJ.Web.csproj index 431e801..eba2ce7 100644 --- a/HueLightDJ.Web/HueLightDJ.Web.csproj +++ b/HueLightDJ.Web/HueLightDJ.Web.csproj @@ -3,19 +3,18 @@ net7.0 enable - CS8600;CS8601;CS8602;CS8603;CS8625;CS8613 + nullable Linux 5ddec17f-0b90-4870-a798-2662ddae9f15 - - - - - - + + + + + @@ -23,16 +22,17 @@ + - + PreserveNewest - + PreserveNewest - + PreserveNewest diff --git a/HueLightDJ.Web/Models/ConnectionConfiguration.cs b/HueLightDJ.Web/Models/ConnectionConfiguration.cs deleted file mode 100644 index d99cc8b..0000000 --- a/HueLightDJ.Web/Models/ConnectionConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace HueLightDJ.Web.Models -{ - public class ConnectionConfiguration - { - public string Ip { get; set; } - public string Key { get; set; } - public string? EntertainmentKey { get; set; } - public string GroupId { get; set; } - public bool UseSimulator { get; set; } - } -} diff --git a/HueLightDJ.Web/Models/EffectLogMsg.cs b/HueLightDJ.Web/Models/EffectLogMsg.cs deleted file mode 100644 index 8617b56..0000000 --- a/HueLightDJ.Web/Models/EffectLogMsg.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Q42.HueApi.Streaming.Extensions; - -namespace HueLightDJ.Web.Models -{ - public class EffectLogMsg - { - public string EffectType { get; set; } - public string Name { get; set; } - public string? RGBColor { get; set; } - public string Group { get; set; } - public string IteratorMode { get; set; } - public string SecondaryIteratorMode { get; set; } - } -} diff --git a/HueLightDJ.Web/Models/EffectViewModel.cs b/HueLightDJ.Web/Models/EffectViewModel.cs deleted file mode 100644 index d5973a9..0000000 --- a/HueLightDJ.Web/Models/EffectViewModel.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace HueLightDJ.Web.Models -{ - public class EffectsVM - { - public Dictionary> BaseEffects { get; set; } - public List ShortEffects { get; set; } - public List GroupEffects { get; set; } - public List Groups { get; set; } - public List IteratorModes { get; set; } - public List SecondaryIteratorModes { get; set; } - - } - - public class EffectViewModel - { - public string Name { get; set; } - - public string TypeName { get; set; } - public bool HasColorPicker { get; set; } - - - //VueJS properties: - public string Color { get; set; } - - public bool IsRandom { get; set; } = true; - - } - - public class GroupInfoViewModel - { - public string Name { get; set; } - - } -} diff --git a/HueLightDJ.Web/Models/ErrorViewModel.cs b/HueLightDJ.Web/Models/ErrorViewModel.cs index 9876f04..6e5cf0c 100644 --- a/HueLightDJ.Web/Models/ErrorViewModel.cs +++ b/HueLightDJ.Web/Models/ErrorViewModel.cs @@ -4,8 +4,8 @@ namespace HueLightDJ.Web.Models { public class ErrorViewModel { - public string RequestId { get; set; } + public string? RequestId { get; set; } public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); } -} \ No newline at end of file +} diff --git a/HueLightDJ.Web/Models/MultiBridgeLightLocation.cs b/HueLightDJ.Web/Models/MultiBridgeLightLocation.cs deleted file mode 100644 index 12c98c6..0000000 --- a/HueLightDJ.Web/Models/MultiBridgeLightLocation.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace HueLightDJ.Web.Models -{ - public class MultiBridgeLightLocation - { - public string Bridge { get; set; } - public string GroupId { get; set; } - - public string Id { get; set; } - public double X { get; set; } - public double Y { get; set; } - } -} diff --git a/HueLightDJ.Web/Models/StatusViewModel.cs b/HueLightDJ.Web/Models/StatusViewModel.cs index 6f5fc42..1b16b3a 100644 --- a/HueLightDJ.Web/Models/StatusViewModel.cs +++ b/HueLightDJ.Web/Models/StatusViewModel.cs @@ -7,13 +7,13 @@ namespace HueLightDJ.Web.Models { public class StatusViewModel { - public string Status { get; set; } + public string? Status { get; set; } public int bpm { get; set; } public bool IsAutoMode { get; set; } public bool AutoModeHasRandomEffects { get; set; } public bool ShowDisconnect { get; internal set; } - public List GroupNames { get; internal set; } + public List GroupNames { get; internal set; } = new(); public string? CurrentGroup { get; set; } } } diff --git a/HueLightDJ.Web/Services/HubService.cs b/HueLightDJ.Web/Services/HubService.cs new file mode 100644 index 0000000..c00e088 --- /dev/null +++ b/HueLightDJ.Web/Services/HubService.cs @@ -0,0 +1,28 @@ +using HueLightDJ.Services; +using HueLightDJ.Web.Hubs; +using Microsoft.AspNetCore.SignalR; +using System; +using System.Threading.Tasks; + +namespace HueLightDJ.Web.Services +{ + public class HubService : IHubService + { + private IHubContext _hub; + + public HubService(IHubContext hub) + { + _hub = hub; + } + + public Task SendAsync(string method, object? arg1) + { + return _hub.Clients.All.SendAsync(method, arg1); + } + + public Task SendAsync(string method, object? arg1, object? arg2) + { + return _hub.Clients.All.SendAsync(method, arg1, arg2); + } + } +} diff --git a/HueLightDJ.Web/Startup.cs b/HueLightDJ.Web/Startup.cs index 3af0bc7..fcaf669 100644 --- a/HueLightDJ.Web/Startup.cs +++ b/HueLightDJ.Web/Startup.cs @@ -11,6 +11,9 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using HueLightDJ.Services; +using HueLightDJ.Web.Services; +using HueLightDJ.Services.Models; namespace HueLightDJ.Web { @@ -21,9 +24,9 @@ public Startup(IConfiguration configuration) Configuration = configuration; } - public static IConfiguration Configuration { get; set; } + public static IConfiguration Configuration { get; set; } = default!; - public static IServiceProvider ServiceProvider { get; set; } + public static IServiceProvider ServiceProvider { get; set; } = default!; // This method gets called by the runtime. Use this method to add services to the container. @@ -37,12 +40,14 @@ public void ConfigureServices(IServiceCollection services) }); - services.AddControllersWithViews() - .AddNewtonsoftJson() - .SetCompatibilityVersion(CompatibilityVersion.Version_3_0); + services.AddControllersWithViews(); services.AddSignalR(); + services.AddTransient(); + services.Configure>(Configuration.GetSection("HueSetup")); + services.AddHueLightDJServices(); + services.AddCors(options => options.AddPolicy("CorsPolicy", builder => { diff --git a/HueLightDJ.Web/Streaming/LightDJStreamingHueClient.cs b/HueLightDJ.Web/Streaming/LightDJStreamingHueClient.cs deleted file mode 100644 index 7181552..0000000 --- a/HueLightDJ.Web/Streaming/LightDJStreamingHueClient.cs +++ /dev/null @@ -1,48 +0,0 @@ -using HueLightDJ.Web.Hubs; -using HueLightDJ.Web.Models; -using Microsoft.AspNetCore.SignalR; -using Q42.HueApi.Streaming; -using Q42.HueApi.Streaming.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace HueLightDJ.Web.Streaming -{ - public class LightDJStreamingHueClient : StreamingHueClient - { - private IHubContext _hub; - private bool _demoMode; - private string _bridgeIp; - - public LightDJStreamingHueClient(string ip, string appKey, string clientKey, bool demoMode) : base(ip, appKey, clientKey) - { - _bridgeIp = ip; - _demoMode = demoMode; - var hub = (IHubContext?)Startup.ServiceProvider.GetService(typeof(IHubContext)); - if (hub == null) - throw new Exception("Unable to get PreviewHub from ServiceProvider"); - - _hub = hub; - } - - protected override void Send(IEnumerable> chunks) - { - if(!_demoMode) - base.Send(chunks); - - var flatten = chunks.SelectMany(x => x); - - _hub.Clients.All.SendAsync("preview", flatten.Select(x => new PreviewModel() - { - Bridge = _bridgeIp, - Id = x.Id, - X = x.LightLocation.X, - Y = x.LightLocation.Y, - Hex = x.State.RGBColor.ToHex(), - Bri = x.State.Brightness - })); - } - } -} diff --git a/HueLightDJ.Web/Views/Home/Setup.cshtml b/HueLightDJ.Web/Views/Home/Setup.cshtml index b484f0c..13f5c19 100644 --- a/HueLightDJ.Web/Views/Home/Setup.cshtml +++ b/HueLightDJ.Web/Views/Home/Setup.cshtml @@ -1,4 +1,4 @@ -@model IEnumerable +@model IEnumerable @{ if (Model == null) { diff --git a/HueLightDJ.Web/Views/_ViewImports.cshtml b/HueLightDJ.Web/Views/_ViewImports.cshtml index c5fd31b..389a0cc 100644 --- a/HueLightDJ.Web/Views/_ViewImports.cshtml +++ b/HueLightDJ.Web/Views/_ViewImports.cshtml @@ -1,3 +1,4 @@ -@using HueLightDJ.Web +@using HueLightDJ.Web @using HueLightDJ.Web.Models +@using HueLightDJ.Services.Models @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/HueLightDJ.Web/appsettings.json b/HueLightDJ.Web/appsettings.json index 7e8e0c3..5445155 100644 --- a/HueLightDJ.Web/appsettings.json +++ b/HueLightDJ.Web/appsettings.json @@ -14,31 +14,31 @@ "ip": "10.70.16.8", "key": "dpzXfw8NvafvCCvtLkQLUET-6Kc4jT4RovPg59Rx", "entertainmentKey": "260FE0B7251DF783CFB9FBAB1D1E8B0C", - "groupId": "1" + "groupId": "00000000-0000-0000-0000-000000000000" }, { "ip": "10.70.16.5", "key": "XnkNCmUG5BhnWhM7OkdVflU2sN1sDncuALwSNzjp", "entertainmentKey": "6A153F5D44822F671F7FB03090AA59CC", - "groupId": "1" + "groupId": "00000000-0000-0000-0000-000000000000" }, { "ip": "10.70.16.4", "key": "o1fN1q-9afQLAiT1KBHKrVfQiF1UVptfWkSgfLbp", "entertainmentKey": "CC0708397B419629908628DB1C22F343", - "groupId": "1" + "groupId": "00000000-0000-0000-0000-000000000000" }, { "ip": "10.70.16.6", "key": "sHF1fVp2mQeYROHl7Tpau268HPeKHm7CKSJ5ZAGX", "entertainmentKey": "1D434DDB3279586D3B1F9FCF919424B4", - "groupId": "1" + "groupId": "00000000-0000-0000-0000-000000000000" }, { "ip": "10.70.16.7", "key": "WzWypCKxLFGvmC8xRyaANsSsrbMX7NXitFO6wXru", "entertainmentKey": "77168F2CCF453508EC6D5A37EC1F4B09", - "groupId": "12" + "groupId": "00000000-0000-0000-0000-000000000000" } ] }, @@ -49,7 +49,7 @@ "ip": "10.70.16.7", "key": "WzWypCKxLFGvmC8xRyaANsSsrbMX7NXitFO6wXru", "entertainmentKey": "77168F2CCF453508EC6D5A37EC1F4B09", - "groupId": "5" + "groupId": "00000000-0000-0000-0000-000000000000" } ] }, @@ -60,7 +60,7 @@ "ip": "192.168.0.4", "key": "im5PBqU--4CJq2N2t8xMVNvZ2qxOtgzLcfVTkwzP", "entertainmentKey": "32C1FEB5439F313891C44369FF71388C", - "groupId": "1" + "groupId": "1b9e4f91-d0de-45a6-b525-1e3a1c140399" } ] }, @@ -72,7 +72,7 @@ "ip": "127.0.0.1", "key": "aSimulatedUser", "entertainmentKey": "01234567890123456789012345678901", - "groupId": "1", + "groupId": "00000000-0000-0000-0000-000000000000", "useSimulator": true } ] @@ -86,13 +86,13 @@ "ip": "demoLocations1", "key": "DEMO", "entertainmentKey": "DEMO", - "groupId": "1" + "groupId": "00000000-0000-0000-0000-000000000000" }, { "ip": "demoLocations2", "key": "DEMO", "entertainmentKey": "DEMO", - "groupId": "1" + "groupId": "00000000-0000-0000-0000-000000000000" } ] }, @@ -105,7 +105,7 @@ "ip": "sterDemoLocations1", "key": "DEMO", "entertainmentKey": "DEMO", - "groupId": "1" + "groupId": "00000000-0000-0000-0000-000000000000" } ] } diff --git a/HueLightDJ.Web/demoLocations1_00000000-0000-0000-0000-000000000000.json b/HueLightDJ.Web/demoLocations1_00000000-0000-0000-0000-000000000000.json new file mode 100644 index 0000000..01f9b25 --- /dev/null +++ b/HueLightDJ.Web/demoLocations1_00000000-0000-0000-0000-000000000000.json @@ -0,0 +1,72 @@ +{ + "1": { + "x": -0.8, + "y": 0.8, + "z": 0 + }, + "2": { + "x": -0.3, + "y": 0.8, + "z": 0 + }, + "3": { + "x": 0, + "y": 0.8, + "z": 0 + }, + "4": { + "x": 0.3, + "y": 0.8, + "z": 0 + }, + "5": { + "x": 0.8, + "y": 0.8, + "z": 0 + }, + "6": { + "x": -0.8, + "y": 0.4, + "z": 0 + }, + "7": { + "x": -0.5, + "y": 0.4, + "z": 0 + }, + "8": { + "x": 0, + "y": 0.4, + "z": 0 + }, + "9": { + "x": 0.5, + "y": 0.4, + "z": 0 + }, + "10": { + "x": 0.8, + "y": 0.4, + "z": 0 + }, + "11": { + "x": -0.8, + "y": 0, + "z": 0 + }, + "12": { + "x": -0.5, + "y": 0, + "z": 0 + }, + "14": { + "x": 0.5, + "y": 0, + "z": 0 + }, + "15": { + "x": 0.8, + "y": 0, + "z": 0 + } +} diff --git a/HueLightDJ.Web/demoLocations1_1.json b/HueLightDJ.Web/demoLocations1_1.json deleted file mode 100644 index 4e34390..0000000 --- a/HueLightDJ.Web/demoLocations1_1.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "1": [ - -0.8, - 0.8, - 0 - ], - "2": [ - -0.3, - 0.8, - 0 - ], - "3": [ - 0, - 0.8, - 0 - ], - "4": [ - 0.3, - 0.8, - 0 - ], - "5": [ - 0.8, - 0.8, - 0 - ], - "6": [ - -0.8, - 0.4, - 0 - ], - "7": [ - -0.5, - 0.4, - 0 - ], - "8": [ - 0, - 0.4, - 0 - ], - "9": [ - 0.5, - 0.4, - 0 - ], - "10": [ - 0.8, - 0.4, - 0 - ], - "11": [ - -0.8, - 0, - 0 - ], - "12": [ - -0.5, - 0, - 0 - ], - "14": [ - 0.5, - 0, - 0 - ], - "15": [ - 0.8, - 0, - 0 - ] -} diff --git a/HueLightDJ.Web/demoLocations2_00000000-0000-0000-0000-000000000000.json b/HueLightDJ.Web/demoLocations2_00000000-0000-0000-0000-000000000000.json new file mode 100644 index 0000000..5097908 --- /dev/null +++ b/HueLightDJ.Web/demoLocations2_00000000-0000-0000-0000-000000000000.json @@ -0,0 +1,52 @@ +{ + "1": { + "x": -0.8, + "y": -0.4, + "z": 0 + }, + "2": { + "x": -0.5, + "y": -0.4, + "z": 0 + }, + "3": { + "x": 0, + "y": -0.4, + "z": 0 + }, + "4": { + "x": 0.5, + "y": -0.4, + "z": 0 + }, + "5": { + "x": 0.8, + "y": -0.4, + "z": 0 + }, + "6": { + "x": -0.8, + "y": -0.8, + "z": 0 + }, + "7": { + "x": -0.3, + "y": -0.8, + "z": 0 + }, + "8": { + "x": 0, + "y": -0.8, + "z": 0 + }, + "9": { + "x": 0.3, + "y": -0.8, + "z": 0 + }, + "10": { + "x": 0.8, + "y": -0.8, + "z": 0 + } +} diff --git a/HueLightDJ.Web/demoLocations2_1.json b/HueLightDJ.Web/demoLocations2_1.json deleted file mode 100644 index 5739886..0000000 --- a/HueLightDJ.Web/demoLocations2_1.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "1": [ - -0.8, - -0.4, - 0 - ], - "2": [ - -0.5, - -0.4, - 0 - ], - "3": [ - 0, - -0.4, - 0 - ], - "4": [ - 0.5, - -0.4, - 0 - ], - "5": [ - 0.8, - -0.4, - 0 - ], - "6": [ - -0.8, - -0.8, - 0 - ], - "7": [ - -0.3, - -0.8, - 0 - ], - "8": [ - 0, - -0.8, - 0 - ], - "9": [ - 0.3, - -0.8, - 0 - ], - "10": [ - 0.8, - -0.8, - 0 - ] -} diff --git a/HueLightDJ.Web/sterDemoLocations1_00000000-0000-0000-0000-000000000000.json b/HueLightDJ.Web/sterDemoLocations1_00000000-0000-0000-0000-000000000000.json new file mode 100644 index 0000000..43052d1 --- /dev/null +++ b/HueLightDJ.Web/sterDemoLocations1_00000000-0000-0000-0000-000000000000.json @@ -0,0 +1,162 @@ +{ + "2": { + "x": -0.58, + "y": -0.96, + "z": 0.0 + }, + "3": { + "x": 0.41, + "y": -0.39, + "z": 0.0 + }, + "4": { + "x": 0.56, + "y": -0.94, + "z": 0.0 + }, + "5": { + "x": -0.35, + "y": -0.59, + "z": 0.0 + }, + "6": { + "x": 0.37, + "y": -0.61, + "z": 0.0 + }, + "7": { + "x": -0.66, + "y": -0.65, + "z": 0.0 + }, + "8": { + "x": -0.01, + "y": -0.59, + "z": 0.0 + }, + "24": { + "x": -0.81, + "y": -0.03, + "z": 0.0 + }, + "25": { + "x": -0.76, + "y": -0.32, + "z": 0.0 + }, + "26": { + "x": 0.72, + "y": -0.13, + "z": 0.0 + }, + "29": { + "x": -0.79, + "y": -0.17, + "z": 0.0 + }, + "30": { + "x": 0.0, + "y": -0.3, + "z": 0.0 + }, + "31": { + "x": 0.49, + "y": -0.2, + "z": 0.0 + }, + "16": { + "x": 0.25, + "y": 0.31, + "z": 0.0 + }, + "17": { + "x": -0.49, + "y": 0.62, + "z": 0.0 + }, + "18": { + "x": -0.01, + "y": 0.34, + "z": 0.0 + }, + "19": { + "x": 0.96, + "y": -0.02, + "z": 0.0 + }, + "20": { + "x": -0.89, + "y": 0.37, + "z": 0.0 + }, + "21": { + "x": 0.81, + "y": 0.66, + "z": 0.0 + }, + "14": { + "x": -0.35, + "y": 0.59, + "z": 0.0 + }, + "15": { + "x": 0.16, + "y": 0.83, + "z": 0.0 + }, + "46": { + "x": 0.79, + "y": 0.8, + "z": 0.0 + }, + "37": { + "x": -0.01, + "y": -0.96, + "z": 0.0 + }, + "9": { + "x": -0.58, + "y": 0.97, + "z": 0.0 + }, + "27": { + "x": 0.16, + "y": -0.15, + "z": 0.0 + }, + "130": { + "x": 0.6, + "y": 0.04, + "z": 0.0 + }, + "36": { + "x": -0.39, + "y": 0.16, + "z": 0.0 + }, + "38": { + "x": -0.02, + "y": 0.87, + "z": 0.0 + }, + "40": { + "x": 0.34, + "y": 0.85, + "z": 0.0 + }, + "41": { + "x": -0.33, + "y": -0.32, + "z": 0.0 + }, + "55": { + "x": 0.76, + "y": 0.96, + "z": 0.0 + }, + "56": { + "x": 0.67, + "y": 0.28, + "z": 0.0 + } +} diff --git a/HueLightDJ.Web/sterDemoLocations1_1.json b/HueLightDJ.Web/sterDemoLocations1_1.json deleted file mode 100644 index 9c92f4a..0000000 --- a/HueLightDJ.Web/sterDemoLocations1_1.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "2": [ -0.58, -0.96, 0.0 ], - "3": [ 0.41, -0.39, 0.0 ], - "4": [ 0.56, -0.94, 0.0 ], - "5": [ -0.35, -0.59, 0.0 ], - "6": [ 0.37, -0.61, 0.0 ], - "7": [ -0.66, -0.65, 0.0 ], - "8": [ -0.01, -0.59, 0.0 ], - "24": [ -0.81, -0.03, 0.0 ], - "25": [ -0.76, -0.32, 0.0 ], - "26": [ 0.72, -0.13, 0.0 ], - "29": [ -0.79, -0.17, 0.0 ], - "30": [ 0.0, -0.3, 0.0 ], - "31": [ 0.49, -0.2, 0.0 ], - "16": [ 0.25, 0.31, 0.0 ], - "17": [ -0.49, 0.62, 0.0 ], - "18": [ -0.01, 0.34, 0.0 ], - "19": [ 0.96, -0.02, 0.0 ], - "20": [ -0.89, 0.37, 0.0 ], - "21": [ 0.81, 0.66, 0.0 ], - "14": [ -0.35, 0.59, 0.0 ], - "15": [ 0.16, 0.83, 0.0 ], - "46": [ 0.79, 0.8, 0.0 ], - "37": [ -0.01, -0.96, 0.0 ], - "9": [ -0.58, 0.97, 0.0 ], - "27": [ 0.16, -0.15, 0.0 ], - "130": [ 0.6, 0.04, 0.0 ], - "36": [ -0.39, 0.16, 0.0 ], - "38": [ -0.02, 0.87, 0.0 ], - "40": [ 0.34, 0.85, 0.0 ], - "41": [ -0.33, -0.32, 0.0 ], - "55": [ 0.76, 0.96, 0.0 ], - "56": [ 0.67, 0.28, 0.0 ] -} diff --git a/HueLightDJ.Web/wwwroot/js/preview.js b/HueLightDJ.Web/wwwroot/js/preview.js index 5b7e496..1edf8e8 100644 --- a/HueLightDJ.Web/wwwroot/js/preview.js +++ b/HueLightDJ.Web/wwwroot/js/preview.js @@ -29,7 +29,7 @@ function renderPreviewGrid(size, allowEdit) { previewConnection.on("newLocations", (preview) => { for (var i = 0; i < preview.length; i++) { var light = preview[i]; - placeLight(light.bridge, light.id, light.x, light.y, light.hex, light.bri, light.groupId) + placeLight(light.bridge, light.id, light.x, light.y, light.hex, light.bri, light.groupId, light.positionIndex) } }); } @@ -100,15 +100,17 @@ function renderPreviewGrid(size, allowEdit) { function saveLocations() { var result = []; - for (const [key, value] of Object.entries(lights)) { - for (var i = 0; i < value.length; i++) { - var l = value[i]; + for (const [key, values] of Object.entries(lights)) { + for (var i = 0; i < Object.keys(lights[key]).length; i++) { + var prop = Object.keys(lights[key])[i]; + var l = lights[key][prop]; if (l != undefined && l != null) { var pos = getXYPosition(l.label); result.push({ - Id: i, + Id: l.lightId, Bridge: key, GroupId: l.groupId, + PositionIndex: l.positionIndex, X: pos.x, Y: pos.y }); @@ -138,7 +140,7 @@ function renderPreviewGrid(size, allowEdit) { return xypos; } - function placeLight(bridgeIp, id, x, y, hex, bri, groupId) { + function placeLight(bridgeIp, lightId, x, y, hex, bri, groupId, positionIndex) { var bridgeArray = lights[bridgeIp]; var rad = 30 * bri; var xPos = xyToPosition(x); @@ -148,6 +150,10 @@ function renderPreviewGrid(size, allowEdit) { lights[bridgeIp] = []; } + var id = lightId + '_' + positionIndex; + if (positionIndex === undefined || positionIndex == null) { + id = lightId; + } var current = lights[bridgeIp][id]; if (current === undefined || current == null) { @@ -155,7 +161,9 @@ function renderPreviewGrid(size, allowEdit) { lights[bridgeIp][id] = { glow: createGlowRing(xPos, yPos), label: createLightLabel(xPos, yPos, id, bridgeIp), - groupId: groupId + groupId: groupId, + lightId: lightId, + positionIndex: positionIndex }; updateGlowRing(bridgeIp, id, hex, bri); addLightToContainer(lights[bridgeIp][id]); diff --git a/HueLightDJ.sln b/HueLightDJ.sln index 767d1d1..36856ff 100644 --- a/HueLightDJ.sln +++ b/HueLightDJ.sln @@ -1,12 +1,14 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30709.132 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33213.308 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HueLightDJ.Web", "HueLightDJ.Web\HueLightDJ.Web.csproj", "{29C86DC9-6C75-4468-9A22-A2C8E7DA419B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HueLightDJ.Effects", "HueLightDJ.Effects\HueLightDJ.Effects.csproj", "{7F07C78A-1FCF-4451-9312-2A70DD0328E6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HueLightDJ.Services", "HueLightDJ.Services\HueLightDJ.Services.csproj", "{ABAE567B-5BDF-4129-987C-312B9246A38E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {7F07C78A-1FCF-4451-9312-2A70DD0328E6}.Debug|Any CPU.Build.0 = Debug|Any CPU {7F07C78A-1FCF-4451-9312-2A70DD0328E6}.Release|Any CPU.ActiveCfg = Release|Any CPU {7F07C78A-1FCF-4451-9312-2A70DD0328E6}.Release|Any CPU.Build.0 = Release|Any CPU + {ABAE567B-5BDF-4129-987C-312B9246A38E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ABAE567B-5BDF-4129-987C-312B9246A38E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ABAE567B-5BDF-4129-987C-312B9246A38E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ABAE567B-5BDF-4129-987C-312B9246A38E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/README.md b/README.md index 3c55a21..50c4ea1 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,9 @@ Hue Light DJ using Hue Entertainment API This web app connects to a Philips Hue Bridge over the local network. It uses the Hue Entertainment API to update the lights almost instantly. Hue Light DJ is meant for setups with 20+ Hue Lights. Don't use this app for your personal setup with less than 5 lights. Things might get interesting with 10 lights, you can try it out. There is also a DEMO mode build in so you see how it would look like on a 20+ light setup. -NOTE: [Hue Entertainment](https://developers.meethue.com/entertainment-blog) supports max 10 lights in an Entertainment Group. To get this to work with more than 10 lights, you need to have 1 bridge for every 10 lights. +NOTE: [Hue Entertainment](https://developers.meethue.com/entertainment-blog) supports max 20 lights in an Entertainment Group using the v2 API. To get this to work with more than 20 addressable lights, you need to have 1 bridge for every 20 lights. A led strip contains more than 1 addressable light (for example 3 or 5). +### Demo with 32 Hue Light Strips on 5 bridges [![Hue Entertainment demo with 32 Hue Light Strips](screenshots/vimeo_preview2.png)](https://vimeo.com/292273983) [![Hue Light DJ with 32 Hue LED strips](screenshots/vimeo_preview.png)](https://vimeo.com/290011309) ## Features @@ -30,15 +31,15 @@ NOTE: [Hue Entertainment](https://developers.meethue.com/entertainment-blog) sup ## Tech - ASP.Net Core 7.0 backend - SignalR for realtime communication between frontend and backend -- Q42.HueApi for communicating with the Hue Bridge +- [HueApi](https://github.com/michielpost/Q42.HueApi) for communicating with the Hue Bridge - Vue.js frontend - PixiJS for WebGL preview window - Mousetrap for keyboard shortcuts -## Build and Install Instructions +## **Build and Install Instructions** - Make sure to have [.Net 7.0](https://dotnet.microsoft.com/download) installed to build this project (`dotnet build`) - Get the IP, Key and EntertainmentKey for your Hue Bridge using the API or the included /Setup page (run the project and navigate to /setup) -- Enter the IP, Key and EntertainmentKey in appsettings.json +- Enter the IP, Key EntertainmentKey and groupId in appsettings.json - Run the HueLightDJ.Web project(`cd HueLightDJ.Web && dotnet run`) ## Docker