Members T.E. Posted December 5, 2023 Members Share Posted December 5, 2023 Thought a good start would be a very minimalistic script .. it is a boolean swtich to control a HuE Light Bulb via HuE-Bridge. to keep it simple currently just on and off. // CONFIG START let CONFIG = { ip: '192.168.178.168', //Hue Bridge IP user: 'Y0NXhTgbfcZYk0dSrTB70Va0XSZKFJdUYJcAj4bp', //Hue Bridge API user light: '4', // Hue Light ID input1: 200, // Shelly virtual switch ID }; Shelly.addStatusHandler(function (e) { if (e.delta.id === CONFIG.input1 && e.delta.value === false) { Toggle("false"); } else { Toggle("true"); } }); function Toggle(state) { let b = '{"on": ' + state + '}'; Shelly.call( "http.request", { method: "PUT", url: 'http://' + CONFIG.ip + '/api/' + CONFIG.user + '/lights/' + CONFIG.light + '/state', body: b }, function (r, e, m) {}, null ); } function CheckBridgeState() { Timer.set(1000, true, function () { Shelly.call( "http.request", { method: "GET", url: 'http://' + CONFIG.ip + '/api/' + CONFIG.user + '/lights/' + CONFIG.light, }, function (res, error_code, error_message, ud) { let st = JSON.parse(res.body); if (st.state.on === true) { Shelly.call("boolean.set", { id: CONFIG.input1, value: true }); } else { Shelly.call("boolean.set", { id: CONFIG.input1, value: false }); } }, null ); }, null); } CheckBridgeState(); 3 Quote Link to comment Share on other sites More sharing options...
Dimitar Posted December 6, 2023 Share Posted December 6, 2023 very good, you can control brightness with num components, 0% can swhich them off, any > 0% can switch them on and set a brightness. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.