Upcoming OWServer Plugin Update

Posted on
Thu Jan 21, 2016 12:09 pm
DaveL17 offline
User avatar
Posts: 3427
Joined: Aug 20, 2013

Re: Upcoming OWServer Plugin Update

Thanks Bill.



Sent from my iPhone using Tapatalk

Posted on
Mon Feb 01, 2016 6:08 pm
4billl offline
Posts: 50
Joined: Jan 30, 2013
Location: Dripping Springs TX

Re: Upcoming OWServer Plugin Update

Dave -

Got my 4-chan analog 0-10V boards working along with several temperature sensors. I have one question/request:
Is there a simple script (Python or AppleScript) to multiply the values of my analog boards by 10 to get a range of 0.0 to 99.9?
I have a simple Applescript that just multiplies by 10, but rounding is another problem.
I tried AppleScript "round as taught in school" but while it actually works, it reports errors working on the Indigo variables.

If you know of good script I'd appreciate it.
Better yet, maybe you could build in a simple scaling field in the analog device driver.

Thanks,

Posted on
Mon Feb 01, 2016 7:51 pm
DaveL17 offline
User avatar
Posts: 3427
Joined: Aug 20, 2013

Re: Upcoming OWServer Plugin Update

4billl wrote:
If you know of good script I'd appreciate it.
Better yet, maybe you could build in a simple scaling field in the analog device driver.

Hi Bill - thanks for the message.

I'm happy to help with a script to tide you over, and will look to build in a scaler option for the Gen 2 version. Here is a stab at a simple Python script that you can run via an Indigo trigger--whenever your OWS value changes, run the embedded script and put the new value in a variable.

Code: Select all
# Get the original device state value. You must change this to match your device ID and state name.
var = indigo.devices[514960551].states["thing1"]

# Round off the value after multiplying it by your scaling factor. Change the '10' to whatever value you like.
new_var = round(var * 10.0)

# Convert it to an integer.
new_var_int = int(new_var)

# Make it a string, because Indigo variables are always strings.
new_var_str = str(new_var_int)

# Write the value to the variable. You must change this to match your variable ID.
indigo.variable.updateValue(314742858, new_var_str)

Please let me know if you have any questions.
Dave

Posted on
Mon Feb 01, 2016 8:34 pm
DaveL17 offline
User avatar
Posts: 3427
Joined: Aug 20, 2013

Re: Upcoming OWServer Plugin Update

Wanted to give an update on Gen2 development. Effort continues. -- OWS provide a couple of different ways to communicate with the server:

• HTTP—service provides delivery of html and xml data files via http get, a method of writing data to 1-Wire devices
• SNMP—provides access to data from all connected sensors, and pushes SNMP traps to remote listeners for alarming capabilities
• Telnet—service provides login to monitor some of the OW-SERVER-ENET-2’s communication activities for diagnostic purposes
• UDP Broadcast—listener on port number 30303 will respond to properly formatted pack- ets broadcast to this port number, allowing other devices and applications to discover OW-SERVER-ENET-2s that exist on the same network.
• 1-Wire Interface—service provides a TCP client that implements a command / response low level interface that may be used to directly control the 1-Wire bus
• POST Client—provides a method of pushing XML data about connected 1-Wire devices to a server.


I took some time to reconnoiter SNMP as the base engine driving plugin updates (not withstanding its alarming capabilities :D ) The short version of that story can be found in a quote from Jay somewhere else on the boards--SNMP is not for the faint of heart. Anyway, I found an SNMP-to-Python module that might work, but that alone is 15,000 lines of code which gives some idea of the complexity of the calculus. Suffice it to say, the SNMP path was a cul de sac. If anyone knows a sure-fire way to incorporate SNMP traps into an Indigo plugin, I'm all ears. :D

Dave

Posted on
Tue Feb 02, 2016 2:20 am
4billl offline
Posts: 50
Joined: Jan 30, 2013
Location: Dripping Springs TX

Re: Upcoming OWServer Plugin Update

Thanks, Dave.
Actually, I want to keep it as a float with one decimal "12.3".
But with your suggested code, I will try to just leave out the new_val_int part.
I don't do Python, so I forgot about the string requirement.

Posted on
Tue Feb 02, 2016 4:38 pm
4billl offline
Posts: 50
Joined: Jan 30, 2013
Location: Dripping Springs TX

Re: Upcoming OWServer Plugin Update

Dave - What should I put into the "state name"?
I filled in the device ID but when I tried to put the Deice name into the state name, I get the error "not found in dict".
The only thing I find in the Devices window under State is the current value.

Posted on
Tue Feb 02, 2016 4:42 pm
DaveL17 offline
User avatar
Posts: 3427
Joined: Aug 20, 2013

Re: Upcoming OWServer Plugin Update

Hi Bill - you need to scroll down in the lower panel. There you will find a list of all the states available for that device. When Apple hid the scroll bars in OS X, this became much less obvious. It's a source of frustration for us here.


Sent from my iPhone using Tapatalk

Posted on
Tue Feb 02, 2016 7:03 pm
4billl offline
Posts: 50
Joined: Jan 30, 2013
Location: Dripping Springs TX

Re: Upcoming OWServer Plugin Update

Dave I tried the following code:

# Get the original device state value. You must change this to match your device ID and state name.
var = indigo.devices[115794742].states["owsv0to10VoltInput1Instant"]

# Round off the value after multiplying it by your scaling factor. Change the '10' to whatever value you like.
new_var = round(var * 10.0)

# Convert it to an integer.
new_var_int = int(new_var)

# Make it a string, because Indigo variables are always strings.
new_var_str = str(new_var_int)

# Write the value to the variable. You must change this to match your variable ID.
indigo.variable.updateValue(817410106, new_var_str)
~~~~~~~
But I got the following error:
Script Error embedded script: can't multiply sequence by non-int of type 'float'
Script Error Exception Traceback (most recent call shown last):

embedded script, line 5, at top level
TypeError: can't multiply sequence by non-int of type 'float'

What I want is a raw value like 2.34 to become 23.4.
So I also tried commenting out the new_var_int and keeping the new_var as a float - got the same error.

Posted on
Tue Feb 02, 2016 7:27 pm
DaveL17 offline
User avatar
Posts: 3427
Joined: Aug 20, 2013

Re: Upcoming OWServer Plugin Update

4billl wrote:
So I also tried commenting out the new_var_int and keeping the new_var as a float - got the same error.

Nuts. I should've accounted for that. My fault. Use the code below which converts the value in the device state into an integer. This should get rid of the error.

Sorry about that.
Dave

Code: Select all
# Get the original device state value. You must change this to match your device ID and state name.
var = int(indigo.devices[115794742].states["owsv0to10VoltInput1Instant"])

# Round off the value after multiplying it by your scaling factor. Change the '10' to whatever value you like.
new_var = round(var * 10.0)

# Convert it to an integer.
new_var_int = int(new_var)

# Make it a string, because Indigo variables are always strings.
new_var_str = str(new_var_int)

# Write the value to the variable. You must change this to match your variable ID.
indigo.variable.updateValue(817410106, new_var_str)

Posted on
Tue Feb 02, 2016 10:36 pm
4billl offline
Posts: 50
Joined: Jan 30, 2013
Location: Dripping Springs TX

Re: Upcoming OWServer Plugin Update

Now the error message is:
Script Error embedded script: invalid literal for int() with base 10: '6.905'
Script Error Exception Traceback (most recent call shown last):

embedded script, line 2, at top level
ValueError: invalid literal for int() with base 10: '6.905'

Posted on
Wed Feb 03, 2016 6:52 am
DaveL17 offline
User avatar
Posts: 3427
Joined: Aug 20, 2013

Re: Upcoming OWServer Plugin Update

Hmmm. It looks like the value in question is being stored as a string. I'll have to take a look at that. In the interim, this code *should* work for you.
Code: Select all
# Get the original device state value. You must change this to match your device ID and state name.
var = float(indigo.devices[115794742].states["owsv0to10VoltInput1Instant"])

# Round off the value after multiplying it by your scaling factor. Change the '10' to whatever value you like.
new_var = round(var * 10.0)

# Convert it to an integer.
new_var_int = int(new_var)

# Make it a string, because Indigo variables are always strings.
new_var_str = str(new_var_int)

# Write the value to the variable. You must change this to match your variable ID.
indigo.variable.updateValue(817410106, new_var_str)


Dave

Posted on
Wed Feb 03, 2016 9:42 am
4billl offline
Posts: 50
Joined: Jan 30, 2013
Location: Dripping Springs TX

Re: Upcoming OWServer Plugin Update

Dave - the good news is it runs. The bad news is it now loses the precision of the decimal place. 3.35 raw input becomes 33
I can live with that for the pressure readings, but I may stay with the 33.49999999 in the tank levels for the present.
I've used Python a little, but not as embedded scripts in Indigo. Guess I'll have to experiment some.

Posted on
Wed Feb 03, 2016 9:57 am
DaveL17 offline
User avatar
Posts: 3427
Joined: Aug 20, 2013

Re: Upcoming OWServer Plugin Update

Good deal. We can deal with the precision issue easily. Please let me know what you want the output value to look like.

I think I misunderstood your OP where you talked about rounding.


Sent from my iPhone using Tapatalk

Posted on
Wed Feb 03, 2016 10:14 am
4billl offline
Posts: 50
Joined: Jan 30, 2013
Location: Dripping Springs TX

Re: Upcoming OWServer Plugin Update

For my application, I just want one decimal place after scaling up by 10. I set the raw analog input precision to 2 decimal places so I get readings like 7.56. Then I need to multiply that by 10 to get 75.6.
One use of this is a 0-100 inches of water pressure sensor that puts out 0-10 volts. It matches perfectly with the OW analog input device that accepts 0-10 volts. But the result needs to be multiplied by 10 to get back to the 0-100 reported result. Placing this sensor at the bottom of the water tank allows me to measure the tank levels accurately.
The other sensor I am using is a 0-100 PSI pressure sensor. 0-10 volts translates directly to the water pressure, again with a simple 10X conversion.

Posted on
Wed Feb 03, 2016 10:26 am
DaveL17 offline
User avatar
Posts: 3427
Joined: Aug 20, 2013

Re: Upcoming OWServer Plugin Update

Got it. Here's the script (without the comments.)
Code: Select all
var = float(indigo.devices[115794742].states["owsv0to10VoltInput1Instant"])

new_var = var * 10.0

new_var_str = str("%0.1f" % new_var)

indigo.variable.updateValue(817410106, new_var_str)

The "%0.1f" part is redundant here, but it will ensure that the output value is always to 1 decimal point.
Dave

Who is online

Users browsing this forum: No registered users and 1 guest

cron