@@ -68,56 +68,54 @@ async function handleSubscription(that) {
68
68
69
69
if ( that . subClient . listeners ( 'event' ) . length == 0 ) {
70
70
71
- try {
71
+ try {
72
72
73
- await that . subClient . subscribeCharacteristics ( subscribeAll )
73
+ await that . subClient . subscribeCharacteristics ( subscribeAll )
74
74
75
- } catch ( e ) {
75
+ } catch ( e ) {
76
76
77
- that . log . error ( "Unable to subscribe" )
78
- that . log . error ( e )
77
+ that . log . error ( "Unable to subscribe" )
78
+ that . log . error ( e )
79
79
80
- }
80
+ }
81
81
82
- }
82
+ }
83
83
84
- that . subClient . on ( 'event' , async ( event ) => {
84
+ that . subClient . on ( 'event' , async ( event ) => {
85
85
86
- if ( that . logUpdates ) {
86
+ if ( that . logUpdates ) {
87
87
88
- that . allEvents = event
88
+ that . allEvents = event
89
89
90
- that . allEvents . characteristics . forEach ( ev => {
90
+ that . allEvents . characteristics . forEach ( ev => {
91
91
92
- that . typeToUpdate = capitalizeFirstLetter ( getKeyByValue ( instanceId , ev . iid ) )
93
- that . log ( "received update for '" + that . typeToUpdate + "' => " + ev . value )
94
- that . savedStates [ getKeyByValue ( instanceId , ev . iid ) ] = ev . value
95
- that . service . getCharacteristic ( Characteristic [ that . typeToUpdate ] ) . updateValue ( ev . value )
92
+ that . typeToUpdate = capitalizeFirstLetter ( getKeyByValue ( instanceId , ev . iid ) )
93
+ that . log ( "received update for '" + that . typeToUpdate + "' => " + ev . value )
94
+ that . savedStates [ getKeyByValue ( instanceId , ev . iid ) ] = ev . value
95
+ that . service . getCharacteristic ( Characteristic [ that . typeToUpdate ] ) . updateValue ( ev . value )
96
96
97
- } )
97
+ } )
98
98
99
- }
100
-
101
- } )
99
+ }
102
100
103
- that . subClient . on ( 'event-disconnect' , async ( formerSubscribes ) => {
101
+ } )
104
102
105
- try {
103
+ that . subClient . on ( 'event-disconnect' , async ( formerSubscribes ) => {
106
104
107
- await that . subClient . unsubscribeCharacteristics ( subscribeAll )
108
- that . subClient . removeAllListeners ( 'event' )
109
- closeClient ( that , clientType . sub )
110
- handleSubscription ( that )
105
+ try {
111
106
112
- } catch ( e ) {
107
+ await that . subClient . unsubscribeCharacteristics ( subscribeAll )
108
+ that . subClient . removeAllListeners ( 'event' )
109
+ closeClient ( that , clientType . sub )
110
+ handleSubscription ( that )
113
111
114
- that . log . error ( e )
112
+ } catch ( e ) {
115
113
116
- }
114
+ that . log . error ( e )
117
115
118
- } )
116
+ }
119
117
120
- }
118
+ } )
121
119
122
120
}
123
121
0 commit comments