Need help copying "level" in a piston


#7

From what I can tell from the Amps Device Hander, the zone volume has a range of 00-38

  • Zone Volume level (00 - 38)

I do not know what the actual range is on the amp. I’d have to dig into that. If the Piston is doing the match for percentages based on range then I suppose it might translate but it seems to make sense to make both level ranges the same for the virtual dimmer and the device handler.

It would be great to make the virtual device range 00-38 but i’m at loss for doing that.

Making 100=38 would work I suppose. Thanks for the help with all this.


#8

Good point. To do a proper conversion we only need the min/max for the device handler.
(plus knowing if it accepts decimals, or must it be entirely integers)


#9

Here’s the entire section for volume control in the DH.

/*

  • Zone Volume level (00 - 38)
    */
    if (evt.containsKey(“volume”)) {
    log.debug “setting volume to ${volume - 1}”
    sendEvent(name: “volume”, value: evt.volume)

And here’s the DH section for the design description.

// Row 1
controlTile(“volume”, “device.volume”, “slider”, height: 1, width: 6, range:"(0…38)") {
state “volume”, label: “Volume”, action:“music Player.setLevel”, backgroundColor:"#00a0dc"

So it looks like the Amps DH wants a range or 00-38. The Amps range is definitely 00-38 so that makes sense.

So how would one translate the dimmers 00-99 range to the DH 00-38 range without a lot of math?

Keep in mind, I’m not using a custom DH for the virtual dimmer. It’s the ST stock virtual dimmer


#10

It’s gonna take math. I am working on it now, although I am doing it for 1-99%, not zero. To turn it off, you should use the switch, (other piston) and not a level 0.

Be back in a few


#11

I really need to know if it will accept a decimal command though before I can share this with you. The coding will be quite different based on your answer.

Try a test command to the Amp:

Set level to 12.9
and confirm if it worked or not


#12

Thanks. I’m wondering if even matters since the piston is translating the number value of the volume slider 00-99 to a percentage. Therefore. if I make the virtual dimmer 50, the piston sees that as 50% and then tells the amp DH to adjust volume to 50% within that DH handler range of 00-38. Which would be 19. Therefore, in the DH/Amp world, that would be half the volume. Does that makes sense?

I can test this when I’m home and can see the commands it sends to the amp. I’ll slide the virtual dimmer to a number and see what the piston does and how that translates to the amp. The amp cannot take decimals. Only whole numbers between 00-38. It’s taking ASCII commands over serial. That’s a whole different scenario I won’t get into.


#13

Cool… IF a webCoRE command:
Set Amp volume to 50
actually makes the volume 19, then no additional math will be required

I will put my partial math on the back burner for now until you have time to confirm.


#14

On the “volume=0” thing, you could put an additional test in the piston that says If the volume=0, then with Music Player turn Off. Of course, it would probably retain the volume so you wouldn’t hear anything when you turn it back on :frowning:


#15

That’s the thing though… He already has a turn on and off piston… In addition, often a “Set level to 0” is not seen as a level change. It is often seen as an off command, thereby activating the other piston.

The same applies to 100%… It is usually not seen as a level change.

Because of this, when it comes to changing levels as a trigger, I only program for 1-99


#16

My preliminary math is working good, should you need it…

temp

The first number is the Amp volume, the last number is the Dimmer level


#17

Ok. So I have some info. The value sent to the receiver is the actual value on the Dimmer Value. So if I set the slider to 19, that sets the volume level on the amp to 19. Which means that any number above 38 on the virtual dimmer slider will send a max volume level to the receiver. That’s dangerous! So, it looks like I either have to
A. Use a custom device handler for the virtual dimmer that designates the slider value to be from 00-38 or
B. Work some math magic to translate the virtual dimmer numbers to Amp DH numbers.

What do you think?


#18

“Math magic” is the way to go! I already have a test piston ready for you:

Sample results are shown in my last post

With this piston, you can set the level to an intuitive number, so for example, 50% on the SimDimmer would set the Amp volume to 19

(approx 5% on the Dimmer = 2 notches on the volume)


#19

Wow! That’s amazing. I will implement and report back. Thanks for this. Really appreciate it. Have to say, this kind of feedback and help really makes WebCoring fun.


#20

Glad to be able to help. Don’t forget the short pause between tests


#21

Works great! Thanks again. Now onto duplicating for 6 different zones.


#22

Excellent!!


#23

I know he has an on/off already. What I didn’t know is that it already sees level 100% as turn on and level 0% as turn off. That’s good to know. I wonder if it’s done in firmware. In some ways it makes more sense.


#24

Actually, I don’t think it does see 100% as turn on and 0% as turn off. The dimmer and on/off function are independent of each other but the simulated dimmer remembers the previous dimmer value from last on/off sequence.


#25

Thanks for the clarification.


#26

This is true only half of the time…

To avoid any confusion, here is what happens when we change the levels on a Simulated Dimmer Switch:


If the bulb is ON to begin with:

Changing any level to     0% = No Level changed, Switch changed to off
Changing   99% level to 100% = No Level changed, No Switch changed
Changing 1-98% level to 100% = Level changed,    No Switch changed

If the bulb is OFF to begin with:

Changing any level to     0% = No Level changed, No Switch changed
Changing   99% level to 100% = No Level changed, Switch changed to on
Changing 1-98% level to 100% = Level changed,    Switch changed to on

For the most part, the 0% and 100% levels act like switches (off/on), and occasionally they are registered as level changes. Basically, if the light changes from ON to 0%, or from OFF to any level, then the switch trigger will execute… but for level changes, we can’t rely on 0% or 100% because of the logic above.

This is why I said earlier:

That range is rock solid reliable…