Assign value to sensor on RHS of a rule

Hi

Is there a way to directly assign value to a sensor (with udpl command tied to it) on the RHS of a rule?

So if the value of sensor A is "xyz", then assign value "abc" to sensor B

Also for a udpl command- what is the purpose of the "regular expression " field?

Thanks!

Hi

What is it you're trying to achieve?

I don't really understand from your post.

You can create rules to match a sensor value and push whatever string you like into another command, which can then be picked up by another sensor command.

I use in memory commands to hold strings.

For example.

If an external sensor changes or is matched in a rule, a string will be pushed into an in-memory command for use later.

As for "regular expression", it's a dark art I don't understand, but it's a way of stripping out a required value from a longer bit of text.

For example, you might get a full XML formatted return from a device, where you only want a tiny part.

A regular expression will / can cause the sensor to only show that required part.

I'd suggest posting a copy of the full text your sensor is returning and ask for help formatting a regular expression.

(FYI, there are a number of posts on this subject already)

Good luck,

Stuart

Thanks for the inputs.
basically what i am trying to achieve is conceptually fairly simple. I have a UDP listener sensor that is taking values from Ha-bridge to turn on lights. That part is working fine. What i want to do is reset the value of that UDP sensor are 1800 seconds

I have have two rules as follows. The first one works fine. The second one does not give any errors but the value of the sensor does not change:

rule “Alexa mute on”

when

Event( source == “habridge mute on sensor”, value == “muteon”) --------->> This is a UDP listener sensor

then

execute.command( “Mute audio on” ); --------->> --------->> This is a in-memory virtual command

end

rule “Alexa mute audio reset”

timer (int: 1800s 0s)

when

Event( source == “Mute audio sensor”, value == “on” ) ---------------->> This is a in-memory virtual command sensor

then

execute.command( “habridge mute on”, “muteoff” ); ------------------->> This is a UDP listener Command tied to UDP listener sensor ( THIS PART IS NOT WORKING, after 1800s i want the UDPL sensor to get value “muteoff” assigned)

First of all, your timer expression should have only the delay, no repeat statement. Moreover, repeat of 0s is not valid. So it should look like:

timer(int: 1800s)

``

Moreover, you are using 2 sensors ( “habridge mute on sensor” and “Mute audio sensor”) and 2 commands (“Mute audio on” and “habridge mute on”). You are checking “Mute audio sensor” on value “on”, but it is case sensitive and could be also “ON”. Therefore, without seeing its command definition it is impossible to judge if the case is correct.

Usually, the best way to get an accurate answer is to send all relevant info. Beside of your not working rules snippet also commands and sensors definitions.

hi Michal

i tried changing the timer(int: 10s) and didn’t seem to make a difference. The command had “ON” and the in the rule i was using “on” so i changed them to match. However, it does not seem to be making a difference as well. I have attached a couple o f screen shots showing the commands and sensors. I am wondering if a value can be assigned to a udpl sensor from a rule

Here are modified rules:

rule “Alexa mute on”

when

Event( source == “habridge mute on sensor”, value == “muteon”)

then

execute.command( “Mute audio on” );

end

rule “Alexa mute off”

when

Event( source == “habridge mute on sensor”, value == “muteoff”)

then

execute.command( “Mute audio off” );

end

rule “Alexa mute audio reset”

timer (int: 10s)

when

Event( source == “Mute audio sensor”, value == “ON” )

then

execute.command( “habridge mute on”, “muteoff” );-------> “muteoff” IS NOT GETTING assigned to “habridge mute on sensor”

end

Mute audio sensor.png

Mute audio status command.png

Mute audio off command.png

Mute audio on command.png

habridge mute on command.png

habridge mute on senser.png

Hi Michal,

following up to see if you had a chance to look in to this.

Thanks