mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-22 08:46:51 +00:00
Add mysensors remote (#25887)
This commit is contained in:
parent
be6deaf9de
commit
8f4f92b05b
@ -16,6 +16,7 @@ ha_platforms:
|
||||
- device_tracker
|
||||
- light
|
||||
- notify
|
||||
- remote
|
||||
- sensor
|
||||
- switch
|
||||
- text
|
||||
@ -927,6 +928,96 @@ void receive(const MyMessage &message) {
|
||||
}
|
||||
```
|
||||
|
||||
## Remote
|
||||
|
||||
The following type combinations are supported:
|
||||
|
||||
#### MySensors version 1.4 and higher
|
||||
|
||||
| S_TYPE | V_TYPE |
|
||||
| -------- | ------------------ |
|
||||
| S_IR | V_IR_SEND, V_LIGHT |
|
||||
|
||||
#### MySensors version 1.5 and higher
|
||||
|
||||
| S_TYPE | V_TYPE |
|
||||
| ------------ | --------------------- |
|
||||
| S_IR | V_IR_SEND, V_STATUS |
|
||||
|
||||
V_LIGHT or V_STATUS is required to report the on / off state of the remote. Use either V_LIGHT or V_STATUS depending on library version.
|
||||
|
||||
#### IR transceiver example sketch
|
||||
|
||||
```cpp
|
||||
/*
|
||||
* Documentation: https://www.mysensors.org
|
||||
* Support Forum: https://forum.mysensors.org
|
||||
*
|
||||
* https://www.mysensors.org/build/ir
|
||||
*/
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <SPI.h>
|
||||
#include <IRLib.h>
|
||||
|
||||
#define SN "IR Sensor"
|
||||
#define SV "1.0"
|
||||
#define CHILD_ID 1
|
||||
|
||||
MySensor gw;
|
||||
|
||||
char code[10] = "abcd01234";
|
||||
char oldCode[10] = "abcd01234";
|
||||
MyMessage msgCodeRec(CHILD_ID, V_IR_RECEIVE);
|
||||
MyMessage msgCode(CHILD_ID, V_IR_SEND);
|
||||
MyMessage msgSendCode(CHILD_ID, V_LIGHT);
|
||||
|
||||
void setup()
|
||||
{
|
||||
gw.begin(incomingMessage);
|
||||
gw.sendSketchInfo(SN, SV);
|
||||
gw.present(CHILD_ID, S_IR);
|
||||
// Send initial values.
|
||||
gw.send(msgCodeRec.set(code));
|
||||
gw.send(msgCode.set(code));
|
||||
gw.send(msgSendCode.set(0));
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
gw.process();
|
||||
// IR receiver not implemented, just a dummy report of code when it changes
|
||||
if (String(code) != String(oldCode)) {
|
||||
Serial.print("Code received ");
|
||||
Serial.println(code);
|
||||
gw.send(msgCodeRec.set(code));
|
||||
strcpy(oldCode, code);
|
||||
}
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
if (message.type==V_LIGHT) {
|
||||
// IR sender not implemented, just a dummy print.
|
||||
if (message.getBool()) {
|
||||
Serial.print("Sending code ");
|
||||
Serial.println(code);
|
||||
}
|
||||
gw.send(msgSendCode.set(message.getBool() ? 1 : 0));
|
||||
// Always turn off device
|
||||
gw.wait(100);
|
||||
gw.send(msgSendCode.set(0));
|
||||
}
|
||||
if (message.type == V_IR_SEND) {
|
||||
// Retrieve the IR code value from the incoming message.
|
||||
String codestring = message.getString();
|
||||
codestring.toCharArray(code, sizeof(code));
|
||||
Serial.print("Changing code to ");
|
||||
Serial.println(code);
|
||||
gw.send(msgCode.set(code));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Sensor
|
||||
|
||||
The following sensor types are supported:
|
||||
@ -972,6 +1063,7 @@ The following sensor types are supported:
|
||||
| S_INFO | V_TEXT |
|
||||
| S_GAS | V_FLOW, V_VOLUME |
|
||||
| S_GPS | V_POSITION |
|
||||
| S_IR | V_IR_RECORD |
|
||||
| S_WATER_QUALITY | V_TEMP, V_PH, V_ORP, V_EC |
|
||||
|
||||
### Custom unit of measurement
|
||||
@ -1058,7 +1150,6 @@ The following actuator types are supported:
|
||||
| S_SMOKE | V_ARMED |
|
||||
| S_LIGHT | V_LIGHT |
|
||||
| S_LOCK | V_LOCK_STATUS |
|
||||
| S_IR | V_IR_SEND, V_LIGHT |
|
||||
|
||||
#### MySensors version 1.5 and higher
|
||||
|
||||
@ -1080,42 +1171,6 @@ The following actuator types are supported:
|
||||
|
||||
All V_TYPES for each S_TYPE above are required to activate the actuator for the platform. Use either V_LIGHT or V_STATUS depending on library version for cases where that V_TYPE is required.
|
||||
|
||||
### Services
|
||||
|
||||
The MySensors switch platform exposes a service to change an IR code attribute for an IR switch device and turn the switch on. See the [example sketch](#ir-switch-sketch) for the IR switch below.
|
||||
|
||||
| Service | Description |
|
||||
| ---------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| mysensors.send_ir_code | Set an IR code as a state attribute for a MySensors IR device switch and turn the switch on. |
|
||||
|
||||
The service can be used as part of an automation script. For example:
|
||||
|
||||
```yaml
|
||||
# Example configuration.yaml automation entry
|
||||
automation:
|
||||
- alias: "Turn HVAC on"
|
||||
trigger:
|
||||
platform: time
|
||||
at: "5:30:00"
|
||||
action:
|
||||
service: mysensors.send_ir_code
|
||||
target:
|
||||
entity_id: switch.hvac_1_1
|
||||
data:
|
||||
V_IR_SEND: "0xC284" # the IR code to send
|
||||
|
||||
- alias: "Turn HVAC off"
|
||||
trigger:
|
||||
platform: time
|
||||
at: "0:30:00"
|
||||
action:
|
||||
service: mysensors.send_ir_code
|
||||
target:
|
||||
entity_id: switch.hvac_1_1
|
||||
data:
|
||||
V_IR_SEND: "0xC288" # the IR code to send
|
||||
```
|
||||
|
||||
#### Switch example sketch
|
||||
|
||||
```cpp
|
||||
@ -1162,78 +1217,6 @@ void incomingMessage(const MyMessage &message)
|
||||
}
|
||||
```
|
||||
|
||||
#### IR switch example sketch
|
||||
|
||||
```cpp
|
||||
/*
|
||||
* Documentation: https://www.mysensors.org
|
||||
* Support Forum: https://forum.mysensors.org
|
||||
*
|
||||
* https://www.mysensors.org/build/ir
|
||||
*/
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <SPI.h>
|
||||
#include <IRLib.h>
|
||||
|
||||
#define SN "IR Sensor"
|
||||
#define SV "1.0"
|
||||
#define CHILD_ID 1
|
||||
|
||||
MySensor gw;
|
||||
|
||||
char code[10] = "abcd01234";
|
||||
char oldCode[10] = "abcd01234";
|
||||
MyMessage msgCodeRec(CHILD_ID, V_IR_RECEIVE);
|
||||
MyMessage msgCode(CHILD_ID, V_IR_SEND);
|
||||
MyMessage msgSendCode(CHILD_ID, V_LIGHT);
|
||||
|
||||
void setup()
|
||||
{
|
||||
gw.begin(incomingMessage);
|
||||
gw.sendSketchInfo(SN, SV);
|
||||
gw.present(CHILD_ID, S_IR);
|
||||
// Send initial values.
|
||||
gw.send(msgCodeRec.set(code));
|
||||
gw.send(msgCode.set(code));
|
||||
gw.send(msgSendCode.set(0));
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
gw.process();
|
||||
// IR receiver not implemented, just a dummy report of code when it changes
|
||||
if (String(code) != String(oldCode)) {
|
||||
Serial.print("Code received ");
|
||||
Serial.println(code);
|
||||
gw.send(msgCodeRec.set(code));
|
||||
strcpy(oldCode, code);
|
||||
}
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
if (message.type==V_LIGHT) {
|
||||
// IR sender not implemented, just a dummy print.
|
||||
if (message.getBool()) {
|
||||
Serial.print("Sending code ");
|
||||
Serial.println(code);
|
||||
}
|
||||
gw.send(msgSendCode.set(message.getBool() ? 1 : 0));
|
||||
// Always turn off device
|
||||
gw.wait(100);
|
||||
gw.send(msgSendCode.set(0));
|
||||
}
|
||||
if (message.type == V_IR_SEND) {
|
||||
// Retrieve the IR code value from the incoming message.
|
||||
String codestring = message.getString();
|
||||
codestring.toCharArray(code, sizeof(code));
|
||||
Serial.print("Changing code to ");
|
||||
Serial.println(code);
|
||||
gw.send(msgCode.set(code));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Text
|
||||
|
||||
The following sensor types are supported:
|
||||
|
Loading…
x
Reference in New Issue
Block a user