@@ -31,6 +31,7 @@ AFRAME.registerComponent('homie-light-switch', {
31
31
toggleSwitch : function ( ) {
32
32
this . switchState = ! this . switchState ;
33
33
this . stateProperty . setValue ( this . switchState ) ;
34
+ const bulbComponent = document . querySelector ( '#bulb' ) . components [ "homie-light-bulb" ] . updateBulbState ( this . switchState ) ;
34
35
this . updateSwitchVisual ( ) ;
35
36
} ,
36
37
@@ -92,18 +93,11 @@ observer.updated$.subscribe(
92
93
if ( event . type == 'property' ) {
93
94
if ( event . device . id === 'switch' && event . node . id === 'switch' && event . property . id === 'state' ) {
94
95
document . getElementById ( 'switch-state' ) . textContent = `Switch State: ${ event . property . value } ` ;
95
- const switchComponent = document . querySelector ( '[homie-light- switch] ' ) . components [ "homie-light-switch" ] ;
96
+ const switchComponent = document . querySelector ( '# switch' ) . components [ "homie-light-switch" ] ;
96
97
switchComponent . toggleSwitch ( ) ;
97
98
switchComponent . updateSwitchVisual ( ) ;
98
- const bulbComponent = document . querySelector ( '[homie-light-bulb]' ) . components [ "homie-light-bulb" ] ;
99
- bulbComponent . updateBulbState ( event . property . value == 'true' ) ;
99
+
100
100
}
101
- // else if (event.device.id === 'bulb' && event.node.id === 'bulb' && event.property.id === 'state') {
102
- // document.getElementById('bulb-state').textContent = `Bulb State: ${event.property.value}`;
103
- // // Update the bulb entity in A-Frame
104
- // const bulbComponent = document.querySelector('[homie-light-bulb]').components["homie-light-bulb"];
105
- // bulbComponent.updateBulbState(event.property.value=='true');
106
- // }
107
101
}
108
102
} ,
109
103
( error ) => {
@@ -114,5 +108,3 @@ observer.updated$.subscribe(
114
108
115
109
116
110
observer . subscribe ( 'switch/switch/state' ) ;
117
- // observer.subscribe('bulb/bulb/state');
118
-
0 commit comments