How to use %sysname% in Publish command?
Moderators: grovkillen, Stuntteam, TD-er
How to use %sysname% in Publish command?
Hi,
I was wondering how to use the %sysname% or other template variables in the Publish command in rules. It would be useful to reuse rules on several devices without having to replace stuff.
I tried the follwing in the Tools->Command section:
use in template:
"Publish /%sysname%/test 1" -> "/%sysname%/test 1"
maybe a relative path?
"Publish test 1" -> no publish
maybe as payload?
"Publish /test/ %sysname%" -> Publish /test/ %sysname%
Using the same commands in the Rules:
seems not to work:
"Publish /%sysname%/test 1" -> No publish
seems to work as expected:
"Publish /test/ %sysname%" -> /test/ WZ_Schrank
seems to do nothing (as before):
"Publish test 1" -> no publish
Any hints about how to use the template placeholders in Publish-Statements is appreciated. This is an awesome tool btw... Thanks a lot.
I was wondering how to use the %sysname% or other template variables in the Publish command in rules. It would be useful to reuse rules on several devices without having to replace stuff.
I tried the follwing in the Tools->Command section:
use in template:
"Publish /%sysname%/test 1" -> "/%sysname%/test 1"
maybe a relative path?
"Publish test 1" -> no publish
maybe as payload?
"Publish /test/ %sysname%" -> Publish /test/ %sysname%
Using the same commands in the Rules:
seems not to work:
"Publish /%sysname%/test 1" -> No publish
seems to work as expected:
"Publish /test/ %sysname%" -> /test/ WZ_Schrank
seems to do nothing (as before):
"Publish test 1" -> no publish
Any hints about how to use the template placeholders in Publish-Statements is appreciated. This is an awesome tool btw... Thanks a lot.
Re: How to use %sysname% in Publish command?
This is how I got publish to work to domoticz
Code: Select all
on Landing_PIR#Switch=1 do
if [Outside_lux#lux]<4
Publish domoticz/in,{"idx":42,"command":"switchlight","switchcmd":"On"}
timerSet,2,10
endon
On Rules#Timer=2 do
Publish domoticz/in,{"idx":42,"command":"switchlight","switchcmd":"Off"}
endon
Re: How to use %sysname% in Publish command?
Thanks, but publishing itself works just fine.
I want to template the system name into the topic. The template string seems to work fine in the payload but does not seem to work when used in the topic.
I want to template the system name into the topic. The template string seems to work fine in the payload but does not seem to work when used in the topic.
Re: How to use %sysname% in Publish command?
Try looking at how the Template for OpenHabMQTT looks,
Re: How to use %sysname% in Publish command?
Regarding the Webinterface: I did that. This is where the whole question regarding %sysname% was coming from. I saw it used in the MQTT template in the advanced settings and wondered if I could do something similar from the rules.
I will try looking at the source tomorrow. Maybe that will yield an answer.
I will try looking at the source tomorrow. Maybe that will yield an answer.
Re: How to use %sysname% in Publish command?
which firmware/version are you on? latest?
Re: How to use %sysname% in Publish command?
On that particular ESP I am on a R118 built from git. I can update to a current git snapshot no problem though and try my tests again.
Maybe it is better to rephrase my question: Using the Publish command in Rules - is %sysname% supposed to work in the topic? (it works in the payload)
Maybe it is better to rephrase my question: Using the Publish command in Rules - is %sysname% supposed to work in the topic? (it works in the payload)
Re: How to use %sysname% in Publish command?
One of the first steps before processing a rule line is to parse anything like %xxx% and [xxx#yyy]. So %sysname% should be replaced regardless of the actual position in the line before it's processed as an event or command. So it would be designed to work that way. Could be hitting a bug though...gibbon_ wrote:Maybe it is better to rephrase my question: Using the Publish command in Rules - is %sysname% supposed to work in the topic? (it works in the payload)
Re: How to use %sysname% in Publish command?
Thank you for the clarification. I will test some more and in case of any results get back to you here and file a bug report.
Re: How to use %sysname% in Publish command?
You can check the logging to see if parsing the variables has succeeded.
My demo unit is named: Unit_13
Created this demo rule:
Using tools/advanced, provide the 'event demo' command and check the log:
As you can see it has translated the action as expected.
My demo unit is named: Unit_13
Created this demo rule:
Code: Select all
on demo do
publish /%sysname%/test 1
endon
Code: Select all
165712055 : EVENT: demo
165712086 : ACT : publish /Unit_13/test 1
Re: How to use %sysname% in Publish command?
sounds like solved?
may the Threadstarter could mark his first post here as SOLVED...
thanks..
may the Threadstarter could mark his first post here as SOLVED...
thanks..
Re: How to use %sysname% in Publish command?
Is not this for the TopicStarter himself to decide if his issue is solved ?tozett wrote:sounds like solved?
may the Threadstarter could mark his first post here as SOLVED...
thanks..
thank you.
Re: How to use %sysname% in Publish command?
Normally,
But look here how many threads are not marked
(Some other Forums are a Bit more cared)
So it is difficult to See solved or still ipen Problem s
For newbies and others.
It was inteded as a polite help to keep the Forum overwiew easy to See Solutions for already solved Problem s
But youre right. This is not really up to me...

But look here how many threads are not marked
(Some other Forums are a Bit more cared)
So it is difficult to See solved or still ipen Problem s
For newbies and others.
It was inteded as a polite help to keep the Forum overwiew easy to See Solutions for already solved Problem s
But youre right. This is not really up to me...

Who is online
Users browsing this forum: No registered users and 10 guests