@@ -92,18 +92,18 @@ public void OnStart()
92
92
private void HandleLampsEvent ( object sender , LampsEventArgs lampsEvent )
93
93
{
94
94
foreach ( var lampEvent in lampsEvent . LampsChanged ) {
95
- Apply ( lampEvent . Id , lampEvent . Source , lampEvent . IsCoil , ( state , lamp , mapping ) => ApplyValue ( lampEvent . Id , lampEvent . Value , state , lamp , mapping ) ) ;
95
+ Apply ( lampEvent . Id , lampEvent . Source , lampEvent . IsCoil , ( state , lamp , mapping ) => ApplyValue ( lampEvent . Id , lampEvent . InternalId , lampEvent . Value , state , lamp , mapping ) ) ;
96
96
}
97
97
}
98
98
99
99
private void HandleLampEvent ( object sender , LampEventArgs lampEvent )
100
100
{
101
- Apply ( lampEvent . Id , lampEvent . Source , lampEvent . IsCoil , ( state , lamp , mapping ) => ApplyValue ( lampEvent . Id , lampEvent . Value , state , lamp , mapping ) ) ;
101
+ Apply ( lampEvent . Id , lampEvent . Source , lampEvent . IsCoil , ( state , lamp , mapping ) => ApplyValue ( lampEvent . Id , lampEvent . InternalId , lampEvent . Value , state , lamp , mapping ) ) ;
102
102
}
103
103
104
104
public void HandleLampEvent ( string id , float value )
105
105
{
106
- Apply ( id , LampSource . Lamp , false , ( state , lamp , mapping ) => ApplyValue ( id , value , state , lamp , mapping ) ) ;
106
+ Apply ( id , LampSource . Lamp , false , ( state , lamp , mapping ) => ApplyValue ( id , int . TryParse ( id , out var internalId ) ? internalId : 0 , value , state , lamp , mapping ) ) ;
107
107
}
108
108
109
109
public void HandleLampEvent ( string id , LampStatus status )
@@ -163,7 +163,7 @@ private void ApplyColor(string id, Color color, LampState state, IApiLamp? lamp)
163
163
lamp ? . OnLamp ( state . Color . ToUnityColor ( ) ) ;
164
164
}
165
165
166
- private void ApplyValue ( string id , float value , LampState state , IApiLamp ? lamp , LampMapping ? mapping )
166
+ private void ApplyValue ( string id , int internalId , float value , LampState state , IApiLamp ? lamp , LampMapping ? mapping )
167
167
{
168
168
if ( mapping == null ) {
169
169
// if not mapped, there is no lamp, so just save the state.
@@ -188,9 +188,11 @@ private void ApplyValue(string id, float value, LampState state, IApiLamp? lamp,
188
188
break ;
189
189
190
190
case LampType . RgbMulti :
191
- state . SetChannel ( mapping . Channel , value / 255f ) ; // todo test
192
- LampStates [ id ] = state ;
193
- lamp ? . OnLamp ( state . Color . ToUnityColor ( ) ) ;
191
+ if ( mapping . InternalId == internalId ) {
192
+ state . SetChannel ( mapping . Channel , value / 255f ) ;
193
+ LampStates [ id ] = state ;
194
+ lamp ? . OnLamp ( state . Color . ToUnityColor ( ) ) ;
195
+ }
194
196
break ;
195
197
196
198
case LampType . SingleFading :
0 commit comments