ageurtse
(arnold)
April 1, 2018, 8:25pm
1
Hello,
I use ESPEASY and on one of the controllers i hooked up a nextion display, which sends a value through MQTT this is working fine for now.
But now i need to use this recieved value to control a mqtt dimmer on a differrent control.
how can i do this.
below are the both item lines
both lines may be merged together, but don’t know how to set this up.
Dimmer Dimmer_kleur "Stalamp Dimbaar" {mqtt=">[ajg:/ESP_Dimmer_kleur/dim/:command:*:default]"}
Dimmer Dimmer_Test "Test Dimbaar" {mqtt="<[ajg:/ESP_Easy_Test/test/value:state:default]"}
vzorglub
(Vincent Regaud)
April 1, 2018, 9:04pm
2
You don’t need to resend the value,
you can just have the dimmer subscribe the the topic sent by the espeasy.
/ESP_Easy_Test/test/value
Try to avoid starting MQTT topics with /
.
It adds a layer to the topics and can lead to confusion and errors
Good luck
vzorglub
(Vincent Regaud)
April 1, 2018, 9:09pm
3
Or if you really want to:
Dimmer Dimmer_Test "Test Dimbaar" {mqtt="<[ajg:/ESP_Easy_Test/test/value:state:default], >[ajg:/ESP_Dimmer_kleur/dim/:command:*:default]"}
ageurtse
(arnold)
April 1, 2018, 9:37pm
4
This i had, but the light isn,t dimming. The slider in the app was working.
vzorglub
(Vincent Regaud)
April 1, 2018, 9:54pm
5
There is a typo in the outbound topic:
Dimmer Dimmer_Test "Test Dimbaar" {mqtt="<[ajg:/ESP_Easy_Test/test/value:state:default], >[ajg:/ESP_Dimmer_kleur/dim:command:*:default]"}
Remove the / at the end of the topic
ageurtse
(arnold)
April 2, 2018, 6:40am
6
When i remove the trailing / my dimmer is not working
vzorglub
(Vincent Regaud)
April 2, 2018, 8:00am
7
What is your dimmer?
Have your checked that it subscribe to the correct topic?
ageurtse
(arnold)
April 2, 2018, 8:39am
8
Well, this is what i have for the dimmer, it’s a plugin for espeasy.
And it is connecting to the right topic, because the dimmer is working from the webpage.
and also stated in your first post, removing the fist / is also bot working.
//#######################################################################################################
//#################################### Plugin 200: Dimmer ##################################################
//#######################################################################################################
#define PLUGIN_200
#define PLUGIN_ID_200 20000
#define PLUGIN_NAME_200 "Dimmer 230V "
#define PLUGIN_VALUENAME1_200 "Dimmer"
boolean Plugin_200_init = false;
boolean Plugin_200(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_200;
Device[deviceCount].Type = DEVICE_TYPE_I2C;
Device[deviceCount].VType = SENSOR_TYPE_DIMMER;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = false;
Device[deviceCount].ValueCount = 0;
Device[deviceCount].SendDataOption = false;
Device[deviceCount].TimerOption = false;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_200);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_200));
break;
}
case PLUGIN_INIT:
{
Serial.begin(9600);
addLog(LOG_LEVEL_INFO, F("Dimmer: Init OK "));
break;
}
case PLUGIN_WRITE:
{
String log = "";
String command = parseString(string, 1);
if (command == F("dim"))
{
Plugin_200_Write(event->Par1);
log = String(F(" Set Dim level to ")) + String(event->Par1);
addLog(LOG_LEVEL_INFO, log);
}
}
}
return success;
}
//********************************************************************************
// Dimmer write
//********************************************************************************
void Plugin_200_Write(byte Par1)
{
Serial.write(Par1);
}
vzorglub
(Vincent Regaud)
April 2, 2018, 7:55pm
9
I don’t know espeasy
Did you check that the mqtt message gets sent?
Use a MQTT client like MQTT.fx
ageurtse
(arnold)
April 2, 2018, 8:55pm
10
I see the incomming message, but it isn’t resend to the correct topic.
Is this somthing within openhab.
And yes i have mqtt client softwre running.
vzorglub
(Vincent Regaud)
April 2, 2018, 9:05pm
11
It is not openHAB
The topic /ESP_Easy_Test/test/value
update the state of your item.
A state change is difference than a command
That is why there is a postUpdate
method and a sendCommand
method for items
If you change your dimmer item on a sitemap, the mqtt outbound binding will send a value on the topic /ESP_Dimmer_kleur/dim
If you also do Dimmer_Test.sendCommand(25)
in a rule it will send the mqtt.
See:
https://docs.openhab.org/configuration/rules-dsl.html#manipulating-item-states
ageurtse
(arnold)
April 4, 2018, 4:15pm
12
so if i’m right i have to make rule that send a command on a event update.
vzorglub
(Vincent Regaud)
April 4, 2018, 8:31pm
13
First you need to check the espeasy website to make double sure of what is the topic your device subcribes to.
It should work as it is.