Widget - Sensor custom buttons
-
@Takero1978 said:
Group Button for dashboard
Please create a request on Github. I will add group button for dashboard.
-
Looks like I will have a minimum of 50 buttons!
Is there any (easy) way to subdivide them within the same sensors window graphically (to allow naturally grouped controls to be more instinctively noticed)...
Just starting to test today
-
@skywatch In the current mode, you can specify only on sensor variable and different buttons with different payloads.
You can change a style of the button, but you cannot subdivide them. You may need to create multiple widgets to achieve this approach.
-
It looks like this is sending a string to the node.
If I want to send hex codes, would this be the most suitable way to do it and what should I add to the node to receive this?
For example I could send 0xDB12DA34 as a string and be able to send as a hex code from the node?
Would this work at the node to get the data?
receive(const MyMessage &message){ if (message.type == V_IR_SEND) { String code = message.getString() irsend.sendNEC(code, 32); }
Thanks
-
What I posted will not work, so here is the new code in full.....It compiles, but that doesn't mean it will do what I expect!
My aim is to remove most of the hex code #define statements and have those hex values sent in the button payload of mysensors custom button JSON setup.
This will save memory on the arduino./* Based on IRsendDemo Copyright 2009 Ken Shirriff http://arcfn.com */ #include <IRremote.h> /* Yamaha Amp DSP 592 Function Code Len */ #define YTime/Level- 0x5EA1CA35 #define YTime/Level+ 0x5EA14AB5 #define YData/Centre 0x5EA1619E #define YTest 0x5EA1A15E #define YEffect 0x5EA16A95 #define YProg- 0x5EA19A65 #define YProg+ 0x5EA11AE5 #define YProLogic 0x5EA111EE #define YEnhanced 0x5EA1916E #define YV-AUX 0x5EA1AA55 #define YVCR 0x5EA1F00F #define YTV/DBS 0x5EA12AD5 #define YDVD/LD 0x5EA1E817 #define Y2CH/6CH 0x5EA1E11E #define YTAPE 0x5EA118E7 #define YTUNER 0x5EA16897 #define YCD 0x5EA1A857 #define YPHONO 0x5EA128D7 #define YSleep 0x5EA1EA15 #define YPower 0x5EA1F807 #define YVOL+ 0x5EA158A7 #define YVOL- 0x5EA1D827 /* Optoma HD141X Projector Function Code Len */ #define Power_ON 0x4CB340BF #define Power_OFF 0x4CB3748B #define USER1 0x4CB36C93 #define USER2 0x4CB3A659 #define USER3 0x4CB36699 #define Brightness 0x4CB3827D #define Contrast 0x4CB342BD #define Mode 0x4CB3A05F #define Keystone 0x4CB3E01F #define Aspect 0x4CB326D9 #define Optoma3D 0x4CB3916E #define Mute 0x4CB34AB5 #define DB 0x4CB322DD #define OSleep 0x4CB3C639 #define VOL+ 0x4CB38877 #define VOL- 0x4CB328D7 #define Source 0x4CB308F7 #define Re-Sync 0x4CB348B7 #define Enter 0x4CB3F00F #define Menu 0x4CB3708F #define HDMI1 0x4CB36897 #define HDMI2 0x4CB30CF3 // #define power_ON_macro 1111 #define power_OFF_macro 2222 #define CHILD_ID_FAN 0 #define CHILD_ID_HEATER 1 #define CHILD_ID_IR 2 #define RELAY_ON 1 #define RELAY_OFF 0 #define Fan_ON 1 #define Fan_OFF 0 #define Heater_pin 4 #define Fan_pin 5 // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 #define MY_RF24_PA_LEVEL RF24_PA_LOW #define MY_NODE_ID 61 #define MY_RF24_CHANNEL (97) #define MY_PARENT_NODE_ID 0 #define MY_PARENT_NODE_IS_STATIC //#define MY_REPEATER_FEATURE //#define MY_SIGNING_ATSHA204 //#define MY_SIGNING_REQUEST_SIGNATURES unsigned long last_heartbeat_time = 0; unsigned long HEARTBEAT_TIME = 5 * 60000; unsigned long value = 000000000; IRsend irsend; #include <Wire.h> #include <MySensors.h> MyMessage msgFan(CHILD_ID_FAN, V_STATUS); MyMessage msgHeater(CHILD_ID_HEATER, V_STATUS); MyMessage msgCode(CHILD_ID_IR, V_IR_SEND); void presentation() { // Send the sketch version information to the gateway sendSketchInfo("MYS-CinemaControl", "0.1"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_FAN, S_BINARY, "Cinema Fan"); wait(100); present(CHILD_ID_HEATER, S_BINARY, "Cinema Heater"); wait(100); present(CHILD_ID_IR, S_IR, "Cinema IR Send"); } void setup() { pinMode(Fan_pin, OUTPUT); //pin 5 digitalWrite(Fan_pin, LOW); pinMode(Heater_pin, OUTPUT); //pin4 digitalWrite(Heater_pin, LOW); } void loop() { if ((millis() - last_heartbeat_time) > HEARTBEAT_TIME) { sendHeartbeat(); last_heartbeat_time = millis(); } } // process incoming message void receive(const MyMessage &message) { if (message.type == V_IR_SEND) { unsigned long code = message.getString(); value = strtoul(code, NULL, 16); Serial.print("code = "); Serial.print(code); Serial.print(" Value = "); Serial.println(value); } if (value == power_OFF_macro) { irsend.sendNEC(YPower, 32); delay(500); irsend.sendNEC(Power_OFF, 32); delay(1000); irsend.sendNEC(Power_OFF, 32); } else if (value == power_ON_macro) { irsend.sendNEC(YPower, 32); delay(500); irsend.sendNEC(Power_ON, 32); } else{ irsend.sendNEC(value, 32); } if (message.type == V_STATUS){ digitalWrite(message.sensor+4, message.getBool()?RELAY_ON:RELAY_OFF); } }
I'll be testing later today I hope!
-
I have this working now, but how do I deal with buttons that repeat the code (volume)?
-
@skywatch You have to release and click again and again. Also, handle the logic in your Arduino sketch.
-
@jkandasa I have thought about that, but it is sooo tedious without a servant to do it for one! - So I will try programming the arduino node to automatically repeat the signal on seeing the command for the first time, then, when volume is as you like it I can send second command that will stop the loop counting up or down. I guess the same would apply to lighting controls that require a button to be held down to dim or brighten lights via IR?
-
I guess the same would apply to lighting controls that require a button to be held down to dim or brighten lights via IR?
This one may not be performed from the MyController side. Again this should be handled by Arduino sketch. I do not get any idea to implement this one with MyController
-
I do not get any idea to implement this one with MyController
I have an idea - what about a option to select whether or not to 'repeat' the command on button push (tick box) and then with a variable to define how often the 'message' should be sent per second.
This needs to be achieved with a way to detect a button push and button release.
But not something to take your time away from more important things
-
@skywatch Kindly create a request on GitHub page, I will work on this when I get time.
Thank you!
-
@jkandasa Thanks - But I am the only one with use for this and it is better for your time to be spent on new MyController instead! I can manage with it how it is for a long time
-
@skywatch Thank you!
-
Just an update to show that you guys are awesome.... Here is an image of the current setup...
And in case anyone else is stuck with this type of thing, here is the final fully working code.
/* Based on IRsendDemo Copyright 2009 Ken Shirriff http://arcfn.com */ #include <IRremote.h> /* Yamaha Amp DSP 592 Function Code Len */ #define YPower 0x5EA1F807 /* Optoma HD141X Projector Function Code Len */ #define Power_ON 0x4CB340BF #define Power_OFF 0x4CB3748B // #define power_ON_macro 0x11111111 #define power_OFF_macro 0x22222222 #define CHILD_ID_FAN 0 #define CHILD_ID_HEATER 1 #define CHILD_ID_IR 2 #define RELAY_ON 0 #define RELAY_OFF 1 #define Fan_ON 0 #define Fan_OFF 1 #define Heater_pin 4 #define Fan_pin 5 // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 #define MY_RF24_PA_LEVEL RF24_PA_LOW #define MY_NODE_ID 61 #define MY_RF24_CHANNEL (97) #define MY_PARENT_NODE_ID 0 #define MY_PARENT_NODE_IS_STATIC //#define MY_REPEATER_FEATURE //#define MY_SIGNING_ATSHA204 //#define MY_SIGNING_REQUEST_SIGNATURES unsigned long last_heartbeat_time = 0; unsigned long HEARTBEAT_TIME = 5 * 60000; unsigned long code = 0x12345678; IRsend irsend; #include <Wire.h> #include <MySensors.h> MyMessage msgFan(CHILD_ID_FAN, V_STATUS); MyMessage msgHeater(CHILD_ID_HEATER, V_STATUS); MyMessage msgCode(CHILD_ID_IR, V_IR_SEND); void presentation() { // Send the sketch version information to the gateway sendSketchInfo("MYS-CinemaControl", "0.2"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_FAN, S_BINARY, "Cinema Fan"); wait(100); present(CHILD_ID_HEATER, S_BINARY, "Cinema Heater"); wait(100); present(CHILD_ID_IR, S_IR, "Cinema IR Send"); } void setup() { pinMode(Fan_pin, OUTPUT); //pin 5 digitalWrite(Fan_pin, HIGH); pinMode(Heater_pin, OUTPUT); //pin4 digitalWrite(Heater_pin, HIGH); } void loop() { if ((millis() - last_heartbeat_time) > HEARTBEAT_TIME) { sendHeartbeat(); last_heartbeat_time = millis(); } } // process incoming message void receive(const MyMessage &message) { if (message.type == V_IR_SEND){ unsigned long code = strtoul(message.getString(),NULL,0); if (code == power_OFF_macro) { irsend.sendNEC(Power_OFF, 32); delay(1500); irsend.sendNEC(YPower, 32); delay(1500); irsend.sendNEC(Power_OFF, 32); } if (code == Power_OFF) { irsend.sendNEC(Power_OFF, 32); delay(3000); irsend.sendNEC(Power_OFF, 32); } else if (code == power_ON_macro) { irsend.sendNEC(Power_ON, 32); delay(2000); irsend.sendNEC(YPower, 32); } else{ irsend.sendNEC(code, 32); } } if (message.type == V_STATUS){ digitalWrite(message.sensor+4, message.getBool()?RELAY_ON:RELAY_OFF); } }
I managed to get most of the ir code #define statements off the arduino and instead store them in the button code on the pi, which saves memory on the arduino for future expansion.
And here is the JSON code for the buttons, the hex codes will need to be changed to whatever you need...
[ { "name": "Power ON Macro", "payload": "0x11111111", "btnType": "danger" }, { "name": "Power OFF Macro", "payload": "0x22222222", "btnType": "danger" }, { "name": "Amp Power", "payload": "0x5EA1F807" }, { "name": "Amp Vol +", "payload": "0x5EA158A7" }, { "name": "Amp Vol -", "payload": "0x5EA1D827" }, { "name": "CD", "payload": "0x5EA1A857" }, { "name": "Phono", "payload": "0x5EA128D7" }, { "name": "Bluray", "payload": "0x5EA1E817" }, { "name": "Amp Kodi", "payload": "0x5EA12AD5" }, { "name": "Tape", "payload": "0x5EA118E7" }, { "name": "Tuner", "payload": "0x5EA16897" }, { "name": "V-Aux", "payload": "0x5EA1AA55" }, { "name": "Time/Level +", "payload": "0x5EA14AB5" }, { "name": "Time/Level -", "payload": "0x5EA14AB5" }, { "name": "Effect", "payload": "0x5EA16A95" }, { "name" : "2Ch/6Ch", "payload": "0x5EA1E11E" }, { "name" : "Prog+", "payload": "0x5EA11AE5" }, { "name" : "Prog -", "payload": "0x5EA19A65" }, { "name" : "Enhanced", "payload": "0x5EA1916E" }, { "name": "Data/Centre/Rear/Swfr", "payload": "0x5EA1619E" } ]
-
@skywatch Awesome!! great sharing. Thank you so much!
-
@jkandasa I've just added the JSON settings for the amp, it was missing in the first post....Opps!
Thank you for making it all possible!