Closed easyyu closed 1 year ago
Hi,
for setManualyBrigtnessLevel use sendBrightnessEvent
for setManualyPowerLevel use sendPowerLevelEvent
please check the documentation for more information here
Please send the new value to the server once when there is a significant change. If you exceed the rate limit, it will print a warning in the Arduino Serial / Portal Activity Log.
Hi, Thank you for your quick response. I know for this documentation. The problem is that I tried to implement it without success.
I do not understand how to construct the function, nor when to call it. Does it need to be in void setupSinricPro() or in the loop()? I couldn't find it on google or in your examples how to use function sendBrightnessEvent().
Can you please, help me how to modify my code to be able to set a new value on the Sinricpro server for powerState and powerLevel (brightness)?
Thank you in advance.
void setBrigtnessLevel(const String &deviceId, int &newPos) {
SinricProDimSwitch &myDimSwitch = SinricPro[DIMSWITCH_ID];
myDimSwitch.sendPowerLevelEvent(newPos);
}
void setPowerState(bool powerState) {
SinricProDimSwitch &myDimSwitch = SinricPro[DIMSWITCH_ID];
myDimSwitch.sendPowerStateEvent(powerState);
}
You can call setBrigtnessLevel
when the pos changed in rotaryEncoder
.
Hi,
Sorry for the delay. Thank you for your time. I tried it, and it works! Thank you for the code.
I would like to know if it is possible to get the power level value from the Sinric server. I would like to use a getBrightnessLevel(DEVICE_ID) function in one another function. The whole logic is to read the last value of brightness from a Sinric server when I use a rotary encoder switch. For example, if the brightness level is 25% (previously set with 2 clicks on the switch) what do I set with setBrigtnessLevel function, and if I do the single click (power off) how can I get the value of the brightness level from Sinric if I do the single click (that means power on)?
Can you please write me a function because I couldn't find it in the example code. Thank you in advance.
I recommend saving the current brightness value in a global variable. This way you can access the value at any time.
To get the last known brightness value (from the server) at start-up you can use the function SinricPro.restoreDeviceStates(true);
(see Documentation)
Hi,
Thx for your answer. Yes, I know for SinricPro.restoreDeviceStates(true);, but I thought there is a possibility to have even a value from getBrightnessLevel() function.. As I realized this function is void and doesn't return any value, therefore I can not set any variable with data. Correct?
Correct, there is no getBrightnessLevel
function inside the SDK.
The SinricPro devices are stateless.
The states (e.g. ) brightness level must be managed by your Sketch.
The easiest way to do this is to use a global variable.
If you use SinricPro.restoreDeviceStates(true);
, the respective callback function is called directly after establishing the connection to the SinricPro server with the last known value.
In this way you receive the last known value.
Hey again! It’s been 14 days since anything happened on this issue, so our friendly robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY
. Please feel free to comment on this issue or create a new one if you need anything else. As a friendly reminder, the best way to fix this or any other problem is to provide a detailed error description including a serial log. Thanks again for being a part of the SinricPro community!
Hi,
I would like to implement in code rotary encoder and to set the value from the rotary encoder as a powerLevel and the switch from the rotary encode as a powerState, and set those values to the Sinric server. Is this possible? What is the limitation? How many values I can send per minute? I tried to understand from examples but without success. How can I use functions: setManualyBrigtnessLevel and setManualyPowerLevel to interact with rotaryEncoder function? When is and how it is called function: onAdjustPowerLevel() ?
Thank you in advance for your help!