MQTT Import
Moderators: grovkillen, Stuntteam, TD-er
-
- New user
- Posts: 7
- Joined: 14 Dec 2022, 20:50
MQTT Import
Hi
I am having some issue's with relays not doing what I would like them to do. Domoticz controls the setting of some valves and ESPeasy carries out what domoticz would want via http commands. Unfortunately when this command fails or the esp reboots domoticz can assume the wrong state and everything fails so I would like to switch to mqtt.
Now I am having some issues with mqtt imports, I just can't get the plugin working.
Can somebody help with the settings?
this is the example switch butten I would like to implement; into this
I am having some issue's with relays not doing what I would like them to do. Domoticz controls the setting of some valves and ESPeasy carries out what domoticz would want via http commands. Unfortunately when this command fails or the esp reboots domoticz can assume the wrong state and everything fails so I would like to switch to mqtt.
Now I am having some issues with mqtt imports, I just can't get the plugin working.
Can somebody help with the settings?
this is the example switch butten I would like to implement; into this
Re: MQTT Import
Have you also looked at the Domoticz MQTT Helper plugin?
See: https://espeasy.readthedocs.io/en/lates ... #p029-page
See: https://espeasy.readthedocs.io/en/lates ... #p029-page
Re: MQTT Import
When you are not switching to the Domoticz MQTT Helper plugin: (that is much easier to set up and 'lighter' in use)
If you click the 'i' button, next to the Device name (and right from the question mark button), that will take you to the documentation, where is explained how to use these options...
In short:
- Set "Parse JSON messages" and "Apply filters" to Yes (the page will reload when changing such option)
- Set the JSON Attribute for Topic 'domoticz/out' to 'nvalue'
- Set the filter for topic 1: Name = 'idx', Operand = 'Equals', Value = '363'
- Optionally: Change the 'Value1' entry at Values, near the bottom, to 'testknop'
- You can remove the second topic 'testknop', that's not needed/used
NB: Don't copy the quotes for names or values, they are added here for readability.
If you click the 'i' button, next to the Device name (and right from the question mark button), that will take you to the documentation, where is explained how to use these options...
In short:
- Set "Parse JSON messages" and "Apply filters" to Yes (the page will reload when changing such option)
- Set the JSON Attribute for Topic 'domoticz/out' to 'nvalue'
- Set the filter for topic 1: Name = 'idx', Operand = 'Equals', Value = '363'
- Optionally: Change the 'Value1' entry at Values, near the bottom, to 'testknop'
- You can remove the second topic 'testknop', that's not needed/used
NB: Don't copy the quotes for names or values, they are added here for readability.
/Ton (PayPal.me)
-
- New user
- Posts: 7
- Joined: 14 Dec 2022, 20:50
Re: MQTT Import
thanks for the help, much appreciated.
I would like to give the mqtt import a try first because I assume it can do 4 devices at one? I have one ESP32 controlling ~20 relays via PCF8574 so with 1 mqtt import per relay that would fill up taskt quite fast?
Now, I've tried setting it up as per instructions above but unfortunately without success
No matter how many times I flip the "testknop" nothing happens in espeasy.
Any hints on what I did wrong?
I would like to give the mqtt import a try first because I assume it can do 4 devices at one? I have one ESP32 controlling ~20 relays via PCF8574 so with 1 mqtt import per relay that would fill up taskt quite fast?
Now, I've tried setting it up as per instructions above but unfortunately without success
No matter how many times I flip the "testknop" nothing happens in espeasy.
Any hints on what I did wrong?
Re: MQTT Import
You have configured the Domoticz MQTT Controller on the Controllers tab, right? (That's not explicitly mentioned...)
/Ton (PayPal.me)
-
- New user
- Posts: 7
- Joined: 14 Dec 2022, 20:50
Re: MQTT Import
sure
and this is tested and working for sensor data into domoticzRe: MQTT Import
Ah, now I see I misread the screenshot of your MQTT Import configuration you shared yesterday. "testknop" should indeed be part of the topic, like you initially had it, but I got the impression you entered 2 separate topics. Apologies for the mixup
Alternative would be to use the wildcard suffix "#", but then the ESP will be quite busy processing and filtering all (and that's quite a bit) domoticz outgoing topics.
With that explicit topic you shouldn't need the filtering either.
Alternative would be to use the wildcard suffix "#", but then the ESP will be quite busy processing and filtering all (and that's quite a bit) domoticz outgoing topics.
With that explicit topic you shouldn't need the filtering either.
/Ton (PayPal.me)
-
- New user
- Posts: 7
- Joined: 14 Dec 2022, 20:50
Re: MQTT Import
nice, this is working.
Now I see how "easy" it could be I would have tought I tried this setup already
thanks again for your help!
for future reference and anybody with the same sort of question;
Now I see how "easy" it could be I would have tought I tried this setup already
thanks again for your help!
for future reference and anybody with the same sort of question;
- Attachments
-
- Capture5.PNG (47.43 KiB) Viewed 1549 times
-
- New user
- Posts: 7
- Joined: 14 Dec 2022, 20:50
Re: MQTT Import
just as sanity check with random strangers from the internet
I now have up to 4 inputs per MQTT import device.
The rules set the corresponding GPIO every 20 seconds
Just to be sure, my goal is to always have the ESP follow domoticz. Even after restarting of domoticz, ESP, router, short power failure, etc the ESP should follow (within a minute or so).
With this setup this should work right?
secondly I assume there is no advantage in adding every individual GPIO as a switch device or am I forgetting something?
I now have up to 4 inputs per MQTT import device.
The rules set the corresponding GPIO every 20 seconds
Just to be sure, my goal is to always have the ESP follow domoticz. Even after restarting of domoticz, ESP, router, short power failure, etc the ESP should follow (within a minute or so).
With this setup this should work right?
secondly I assume there is no advantage in adding every individual GPIO as a switch device or am I forgetting something?
Code: Select all
On Rules#Timer=4 do
timerSet,4,20
LogEntry,'start setting'
if [MQTT2#KlepKachel]=1
pcfgpio,1,0
else
pcfgpio,1,1
endif
if [MQTT2#KlepRadiatoren]=1
pcfgpio,2,0
else
pcfgpio,2,1
endif
if [MQTT2#PompRadiatoren]=1
pcfgpio,3,0
else
pcfgpio,3,1
endif
etc etc for an other 8 devices
Re: MQTT Import
Please have a look at the documentation on how to format variables:
https://espeasy.readthedocs.io/en/lates ... red-values
Can be reduced to:
The `!` does "invert" the value.
https://espeasy.readthedocs.io/en/lates ... red-values
Code: Select all
if [MQTT2#KlepKachel]=1
pcfgpio,1,0
else
pcfgpio,1,1
endif
Code: Select all
pcfgpio,1,![MQTT2#KlepKachel]
Re: MQTT Import
And in addition to the above improvement:
Can be written as:
Code: Select all
On Rules#Timer=4 do
timerSet,4,20
...
Code: Select all
On System#Boot Do
LoopTimerSet,4,20 // Repeat the timer every 20 seconds, indefinitely
Endon
On Rules#Timer=4 do
LogEntry,'start setting'
...
Endon
/Ton (PayPal.me)
-
- New user
- Posts: 7
- Joined: 14 Dec 2022, 20:50
Re: MQTT Import
Thnaks for the tips.
I do seem to have some issue with the inverting;
below is are two smal parts of the log, switch was on during test and in the first few runs I removed the ! sign.
After reverting back to MCPGPIO,8,![MQTT2#testknop] the value does not change and it appears to try to set the value to !1 instead of 0 and does not switch regardless of the MQTT input.
Is there a syntax issue or is this just not supported?
I do seem to have some issue with the inverting;
below is are two smal parts of the log, switch was on during test and in the first few runs I removed the ! sign.
After reverting back to MCPGPIO,8,![MQTT2#testknop] the value does not change and it appears to try to set the value to !1 instead of 0 and does not switch regardless of the MQTT input.
Is there a syntax issue or is this just not supported?
Code: Select all
36133: IMPT : MQTT fetched json attribute: nvalue payload: 1
1436133: IMPT : [MQTT2#nvalue] : 1.00
1436135: EVENT: domoticz/out/testknop#nvalue=1.00
1436145: EVENT: MQTT2#testknop=1.00
1442439: EVENT: Rules#Timer=1,142
1442447: ACT : LogEntry,'start setting'
1442450: start setting
1442455: ACT : MCPGPIO,8,1
1442459: MCP : port#8: set to 1
1452439: EVENT: Rules#Timer=1,143
1452447: ACT : LogEntry,'start setting'
1452449: start setting
1452454: ACT : MCPGPIO,8,1
1452459: MCP : port#8: set to 1
1462440: EVENT: Rules#Timer=1,144
1462448: ACT : LogEntry,'start setting'
1462450: start setting
1462454: ACT : MCPGPIO,8,1
1462459: MCP : port#8: set to 1
1463777: WD : Uptime 24 ConnectFailures 0 FreeMem 201888 WiFiStatus WL_CONNECTED 3 ESPeasy internal wifi status: Conn. IP Init
1469732: Upload: START, filename: rules1.txt
1469807: Upload: WRITE, Bytes: 280
1469878: Upload: END, Size: 280
1469984: Webserver 1 Arguments: 0: 'enctype' length: 19
1469997: CRC : Settings CRC ...OK
1470011: CRC : SecuritySettings CRC ...OK
1472439: EVENT: Rules#Timer=1,145
1472554: ACT : LogEntry,'start setting'
1472556: start setting
1472607: ACT : MCPGPIO,8,!1
1472612: MCP : port#8: set to 1
2102454: ACT : MCPGPIO,8,!1
2102459: MCP : port#8: set to 1
2103871: IMPT : MQTT fetched json attribute: nvalue payload: 0
2103871: IMPT : [MQTT2#nvalue] : 0.00
2103873: EVENT: domoticz/out/testknop#nvalue=0.00
2103883: EVENT: MQTT2#testknop=0.00
2112440: EVENT: Rules#Timer=1,209
2112448: ACT : LogEntry,'start setting'
2112450: start setting
2112455: ACT : MCPGPIO,8,!0
2112460: MCP : port#8: set to 1
Re: MQTT Import
Hmm indeed.
It seems the invert doesn't work like I hoped it would (not 100% it did before, have to check the code...)
It seems the invert doesn't work like I hoped it would (not 100% it did before, have to check the code...)
-
- New user
- Posts: 7
- Joined: 14 Dec 2022, 20:50
Re: MQTT Import
it does!
thanks again!
for full reference if anyone might find it usefull;
thanks again!
for full reference if anyone might find it usefull;
Code: Select all
On System#Boot do
LoopTimerSet,1,10
Endon
On Rules#Timer=1 do
LogEntry,'start setting'
MCPGPIO,8,=![MQTT2#testknop]
Endon
Who is online
Users browsing this forum: No registered users and 32 guests