Browse Source

MQTT: added rfid-state and moved topicTrackCmnd to topicRfidCmnd

master
Torsten Stauder 5 years ago
parent
commit
ae8aac8e0f
  1. 6
      README.md
  2. 2
      openHAB/items/Home.items
  3. 3
      openHAB/sitemaps/Home.sitemap
  4. 2
      openHAB/things/mqttConntections.things
  5. 2
      src/logmessages.h
  6. 13
      src/main.cpp
  7. 3
      src/settings.h

6
README.md

@ -390,9 +390,9 @@ Feel free to use your own smarthome-environments (instead of openHAB). The MQTT-
| ----------------------- | --------------- | ------------------------------------------------------------------------------ |
| topicSleepCmnd | 0 or OFF | Power off Tonuino immediately |
| topicSleepState | ON or OFF | Sends Tonuino's current/last state |
| topicTrackCmnd | 12 digits | Set number of RFID-tag which 'emulates' an RFID-tag (e.g. `123789456089`) |
| topicTrackState | String | Sends current track number, total number of tracks and full path of current |
| | | track. E.g. "(2/10) /mp3/kinderlieder/Ri ra rutsch.mp3"
| topicRfidCmnd | 12 digits | Set number of RFID-tag which 'emulates' an RFID-tag (e.g. `123789456089`) |
| topicRfidState | 12 digits | ID of current RFID-tag (if not a modification-card) |
| topicTrackState | String | Sends current track number, total number of tracks and full path of curren track. E.g. "(2/10) /mp3/kinderlieder/Ri ra rutsch.mp3" |
| topicTrackControlCmnd | 1 -> 7 | `1`=stop; `2`=unused!; `3`=play/pause; `4`=next; `5`=prev; `6`=first; `7`=last |
| topicLoudnessCmnd | 0 -> 21 | Set loudness (depends on minVolume / maxVolume) |
| topicLoudnessState | 0 -> 21 | Sends loudness (depends on minVolume / maxVolume |

2
openHAB/items/Home.items

@ -7,7 +7,7 @@ Group ZimmerTim "Kinderzimmer Tim"
// Zimmer Kind
Switch Tonuino_Sleep { channel="mqtt:topic:MQTT:tonuino:tonuino_sleep_mqtt", autoupdate="true" }
String Tonuino_Track { channel="mqtt:topic:MQTT:tonuino:tonuino_track_mqtt", autoupdate="true" }
String Tonuino_Rfid { channel="mqtt:topic:MQTT:tonuino:rfid", autoupdate="true" }
Number Tonuino_Loudness "Lautstärke [%d]" { channel="mqtt:topic:MQTT:tonuino:tonuino_loudness_mqtt", autoupdate="true" }
String Tonuino_SleepTimer { channel="mqtt:topic:MQTT:tonuino:tonuino_sleeptimer_mqtt", autoupdate="true" }
String Tonuino_Status { channel="mqtt:topic:MQTT:tonuino:tonuino_status_mqtt", autoupdate="true", expire="2m, command=Offline" }

3
openHAB/sitemaps/Home.sitemap

@ -6,7 +6,7 @@ sitemap Home label="Home" {
Text item=Tonuino_Status label="Status" valuecolor=[Tonuino_Status==Online="green", ==Offline="red"] icon="network"
Switch item=Tonuino_Sleep label="Ausschalten" icon="wallswitch" mappings=[OFF="AUS"] visibility=[Tonuino_Status=="Online"]
Switch item=Tonuino_LockControls label="Sperren" icon="wallswitch" mappings=[OFF="AUS", ON="AN"] visibility=[Tonuino_Status=="Online"]
Selection item=Tonuino_Track label="Titelauswahl" icon="text" visibility=[Tonuino_Status=="Online"] mappings=[
Selection item=Tonuino_Rfid label="Titelauswahl" icon="text" visibility=[Tonuino_Status=="Online"] mappings=[
"244189084042"="Yakari und die Pferdediebe",
"244042007042"="Yakari - Der Gesang des Raben",
"004134024043"="Yakari - Schneeball in Gefahr",
@ -29,6 +29,7 @@ sitemap Home label="Home" {
Setpoint item=Tonuino_LedBrightness icon="lightbulb" label="LED-Helligkeit" visibility=[Tonuino_Status=="Online"] maxValue=64 step=2
Text item=Tonuino_IPv4 label="IP-Adresse" icon="network" visibility=[Tonuino_Status=="Online"]
Text item=Tonuino_CurrentTrack label="Aktuell:" icon="mediacontrol" visibility=[Tonuino_Status=="Online"]
Text item=Tonuino_Voltage label="Akkuspannung:" icon="batterylevel" visibility=[Tonuino_Status=="Online"]
}
}
}

2
openHAB/things/mqttConntections.things

@ -3,7 +3,7 @@ Bridge mqtt:broker:MQTT [ host="<mqttServerIP>", secure=false, username="<userna
Thing topic tonuino "Tonuino" {
Channels:
Type switch: tonuino_sleep_mqtt "Ausschalten" [ stateTopic="State/Tonuino/Sleep", commandTopic="Cmnd/Tonuino/Sleep", on="ON", off="OFF" ]
Type string: tonuino_track_mqtt "Track" [ stateTopic="State/Tonuino/Track", commandTopic="Cmnd/Tonuino/Track" ]
Type string: tonuino_rfid_mqtt "Track" [ stateTopic="State/Tonuino/Rfid", commandTopic="Cmnd/Tonuino/Rfid" ]
Type number: tonuino_loudness_mqtt "Lautstaerke" [ stateTopic="State/Tonuino/Loudness", commandTopic="Cmnd/Tonuino/Loudness" ]
Type string: tonuino_sleeptimer_mqtt "Sleep-Timer" [ stateTopic="State/Tonuino/SleepTimer", commandTopic="Cmnd/Tonuino/SleepTimer" ]
Type string: tonuino_status_mqtt "Status" [ stateTopic="State/Tonuino/State" ]

2
src/logmessages.h

@ -153,7 +153,7 @@ static const char warningLowVoltageFromNVS[] PROGMEM = "Spannungslevel (Batterie
static const char unableToRestoreLastRfidFromNVS[] PROGMEM = "Letzte RFID konnte nicht aus NVS geladen werden";
static const char restoredLastRfidFromNVS[] PROGMEM = "Letzte RFID wurde aus NVS geladen";
static const char failedOpenFileForWrite[] PROGMEM = "Öffnen der Datei für den Schreibvorgang fehlgeschlagen";
static const char fileWritten[] PROGMEM = "Schreibe Datei";
static const char fileWritten[] PROGMEM = "Datei geschrieben";
static const char writeFailed[] PROGMEM = "Schreibvorgang fehlgeschlagen";
static const char writingFile[] PROGMEM = "Schreibe Datei";
static const char failedToOpenFileForAppending[] PROGMEM = "Öffnen der Datei zum Schreiben der JSON-Datei fehlgeschlagen";

13
src/main.cpp

@ -835,8 +835,8 @@ bool reconnect() {
// Deepsleep-subscription
MQTTclient.subscribe((char *) FPSTR(topicSleepCmnd));
// Trackname-subscription
MQTTclient.subscribe((char *) FPSTR(topicTrackCmnd));
// RFID-Tag-ID-subscription
MQTTclient.subscribe((char *) FPSTR(topicRfidCmnd));
// Loudness-subscription
MQTTclient.subscribe((char *) FPSTR(topicLoudnessCmnd));
@ -896,7 +896,7 @@ void callback(const char *topic, const byte *payload, uint32_t length) {
}
// New track to play? Take RFID-ID as input
else if (strcmp_P(topic, topicTrackCmnd) == 0) {
else if (strcmp_P(topic, topicRfidCmnd) == 0) {
char *_rfidId = strdup(receivedString);
xQueueSend(rfidCardQueue, &_rfidId, 0);
//free(_rfidId);
@ -2985,6 +2985,9 @@ void rfidPreferenceLookupHandler (void) {
if (_playMode >= 100) {
doRfidCardModifications(_playMode);
} else {
#ifdef MQTT_ENABLE
publishMqtt((char *) FPSTR(topicRfidState), currentRfidTagId, false);
#endif
trackQueueDispatcher(_file, _lastPlayPos, _playMode, _trackLastPlayed);
}
}
@ -4131,10 +4134,6 @@ void audio_showstation(const char *info) {
publishMqtt((char *) FPSTR(topicTrackState), buf, false);
#endif
}
void audio_showstreaminfo(const char *info) {
snprintf(logBuf, serialLoglength, "streaminfo : %s", info);
loggerNl(logBuf, LOGLEVEL_INFO);
}
void audio_showstreamtitle(const char *info) {
snprintf(logBuf, serialLoglength, "streamtitle : %s", info);
loggerNl(logBuf, LOGLEVEL_INFO);

3
src/settings.h

@ -152,7 +152,8 @@ float voltageIndicatorHigh = 4.2; // Upper range for Neopixel-
#define DEVICE_HOSTNAME "ESP32-Tonuino" // Name that that is used for MQTT
static const char topicSleepCmnd[] PROGMEM = "Cmnd/Tonuino/Sleep";
static const char topicSleepState[] PROGMEM = "State/Tonuino/Sleep";
static const char topicTrackCmnd[] PROGMEM = "Cmnd/Tonuino/Track";
static const char topicRfidCmnd[] PROGMEM = "Cmnd/Tonuino/Rfid";
static const char topicRfidState[] PROGMEM = "State/Tonuino/Rfid";
static const char topicTrackState[] PROGMEM = "State/Tonuino/Track";
static const char topicTrackControlCmnd[] PROGMEM = "Cmnd/Tonuino/TrackControl";
static const char topicLoudnessCmnd[] PROGMEM = "Cmnd/Tonuino/Loudness";

Loading…
Cancel
Save