add necessary function after import ch5
import * as CrComLib from "@crestron/ch5-crcomlib/build_bundles/cjs/cr-com-lib.js";
//necessary function
window.bridgeReceiveIntegerFromNative=CrComLib.bridgeReceiveIntegerFromNative;
window.bridgeReceiveBooleanFromNative=CrComLib.bridgeReceiveBooleanFromNative;
window.bridgeReceiveStringFromNative=CrComLib.bridgeReceiveStringFromNative;
window.bridgeReceiveObjectFromNative=CrComLib.bridgeReceiveObjectFromNative;
//necessary function after import CrComLib
CrComLib.publishEvent('n','index.test1',5);
first parameter : tell crestron data type n->number(analog)|s->string(serial)|b->boolean(digital)
second parameter : 'index.test1'->is bulid by "ch5 contract edit" you can just use joinnumber
third parameter : the data u send ,analog use number , serial use "string" , digital use true/false
BTW
I not sure is has bug or not by use joinNumber , because crestron give us the "ch5 contract edit" ,
I'm not sure is crestron enginner think "hay we can make ch5 like smart object" or "hay joinNumber has some bug on ch5"
so use joinNumber be careful
const test = CrComLib.subscribeState('s','index.OutLet_1_energy',(value) =>{
$('#AQI').text(value);
});
first parameter : return data type
second parameter : JoinNumber or JoinName
third parameter : Function(ReturnValue){}
var s1=CrComLib.getState('n','index.test1_fb',0)
the third parameter is default number
var s3=CrComLib.getStringSignalValue('1');
var s4=CrComLib.getNumericSignalValue('index.test1_fb',0)
var s4=CrComLib.getBooleanSignalValue('1',0)
U can just call back Serial or digital or analog Join ,
I'm not sure why has those function , maybe it could make code more "readable" 😂?
first parameter : JoinName Or JoinNumber
second parameter : default return number when is empty or not avarible