Trigging update without changing value?

I have a small problem that would be easiest to solve if I could trigger an update without changing an item value. The scenario is that I have one item “volume” that always has a value. When I set another item to “music mode” I would like to send this volume value to my amplifier (and some other stuff). The easiest way to do this in my rules would be if I could trick my volume changed rule that the volume has changed. I thought I might be able to do this with postUpdate(volume, volume.state), but I think the system is too smart and skips that because the value didn’t change? Any better way?

What is your amplifier and how is it interfacing with OH? From what you have said, I don’t see a need to update the volume Item. Just get the state of the volume in your rule and send that to your amplifier.

If your amplifier is tying into whatever binging is used for the volume, you probably want to use sendCommand rather than postUpdate. postUpdate does not trigger a change at the binding level.

The reason is to not have copies of the same code, I do calculations whenever the speaker volume is changed, to convert from a percentage volume to decibel (which is what my amplifier wants). It is sent over serial, but that is not the point. I just want to trigger a certain rule without changing the value, i.e. trick it to run.

The rule looks like this for the interested:

rule "Bluesound Volume Change"
when
        Item blueVolume changed
then
        if (Marantz_Mode.state == "Music") {
                var blueVol = (blueVolume.state as DecimalType).intValue
                var int volume = MIN_VOLUME + Math::round(blueVol * DELTA_VOLUME)
                if (volume > MAX_VOLUME)
                        volume = MAX_VOLUME

                sendCommand(marantzVolume, volume)
        }
end

I guess I’m still not seeing the problem. Your rule is only sending the volume if the mode is set to music. Why not just trigger the rule based on a change in Marantz_Mode rather than blueVolume?

Alternatively, put blueVolume and Marantz_Mode in a group and trigger your rule based on changes to the group. Then it will fire based on a change to either volume or mode.

Because there are two things that can happen that make me want to set the Marantz volume:

  1. The bluesound volume is changed (during music mode)
  2. The mode is changed to music mode, in that case I want to send an initial volume (based on the current bluesound volume. I know I could copy the whole calculation code (and probably will if no other solution), but it would be nicer to be able to trigger the same code instead of copy pasting an extra copy.

Probably way off here, but shouldn’t nested ‘if’ statements have their own parenthesis?

That’s what my assumption was, but I wasn’t putting all the pieces together. Should really start getting more sleep…

I think putting your two Items in a group and triggering off of an update to the group is going to be the easiest solution.

You will have to make sure to define a type for the group so that it receives state updates when a member item changes. It appears that you can just use the type Switch for a mixed group.

There rule isn’t working because you are using “changed” as your rule trigger. Obviously this only triggers the rule when the item state … changes.

To trigger the rule when it received an update, even if it is just an update to the same value, use “received update”.

Ah, ofc! Thanks a lot! :slight_smile: