Jump to content

Push Variable from Pi to ISY994


LarryCRetired

Recommended Posts

Hoping someone can give me some direction as to where to look or even if it is possible to accomplish what I describe below.

I recently installed Version 5 and I have been reading/watching the excellent videos on how to install Polygot onto my pi and create a node server in the ISY.  However, being a newbie, I am not certain if the node server route is the way I should approach pushing a variable from the pi to the ISY.  I want to start a program in the ISY if the variable meets the appropriate criteria. 

This is what I am trying to accomplish. 

I have written a Python 3 program to obtain barometric pressure data from a BMP180 pressure sensor.  My wife suffers from migraines and barometric pressure changes impact the severity of her headaches.  The severity of the headache is a function of the starting point of the pressure when the pressure begins to drop and how fast the pressure is dropping.  I was able to use an Arduino to light some LED's based on some complex programming but the Arduino does not give me the flexibility of letting her know what is happening if she is not at home.

Medication does help her reduce the severity if she is aware of the weather environment prior to the beginning of the headache.

What I would like to do is push a variable from the pi to the ISY and then let it send a text message to make her aware that the barometric  pressure is changing and how aggressive she should be in taking her medication.

Any help and direction as to where to educate myself would be appreciated and even more so by my wife.

PS:  I have thought about using the climate module but unfortunately I have not had good luck getting reliable barometric data for my location. 

Link to comment

You can do this easily using the REST interface of your ISY and the utility 'curl'.  Try something like this:

curl -u USER:PASSWORD http://192.168.x.xx/rest/vars/set/1/3/16

This will set the value of variable type 1 (INTEGER), variable number 3 to the value of 16.  If you were changing a variable of type 2 (STATE), the script would look like .../rest/set/2/3/16.

Put that into a script and you're golden.

Link to comment

Check GitHub for PyISY; it provides many functions, including running programs and stuffing variables.

50 minutes ago, LarryCRetired said:

Hoping someone can give me some direction as to where to look or even if it is possible to accomplish what I describe below.

I recently installed Version 5 and I have been reading/watching the excellent videos on how to install Polygot onto my pi and create a node server in the ISY.  However, being a newbie, I am not certain if the node server route is the way I should approach pushing a variable from the pi to the ISY.  I want to start a program in the ISY if the variable meets the appropriate criteria. 

This is what I am trying to accomplish. 

I have written a Python 3 program to obtain barometric pressure data from a BMP180 pressure sensor.  My wife suffers from migraines and barometric pressure changes impact the severity of her headaches.  The severity of the headache is a function of the starting point of the pressure when the pressure begins to drop and how fast the pressure is dropping.  I was able to use an Arduino to light some LED's based on some complex programming but the Arduino does not give me the flexibility of letting her know what is happening if she is not at home.

Medication does help her reduce the severity if she is aware of the weather environment prior to the beginning of the headache.

What I would like to do is push a variable from the pi to the ISY and then let it send a text message to make her aware that the barometric  pressure is changing and how aggressive she should be in taking her medication.

Any help and direction as to where to educate myself would be appreciated and even more so by my wife.

PS:  I have thought about using the climate module but unfortunately I have not had good luck getting reliable barometric data for my location. 

 

Link to comment

I agree with @Bumbershootusing curl or if your script is python using python request is the easiest to push a variable to ISY.  PyISY is very complete and full featured but may be overkill for a simple single variable.

Also there's a couple (including my own) Ambient Weather nodeservers available that provide barometric pressure information from your own local sensors. 

Link to comment

Bumbershoot, GlowingHair and simplextech thanks so much for the direction and the options to pursue.  I am going to spend the day working on this and try the simple solution first.  I am intrigued by the other options and will take a look at them as well. 

Now to install curl on my pi and expand my program.

Also, we had snow this morning.  TV stations told us it was coming but my wife also told me on Saturday night what we could expect based on her headache. 

Link to comment

I am sorry that I have to go to the forum for what should be something easy to figure out, however, the past two afternoons of research has not gotten me closer to a solution.  I am getting a syntax error in Python3 running on my Pi for this statement.  I have tried a host of things but I continue to get this error.  For instance, I changed the curl statement to

curl -u, --user admin:Test http://192.xxx.x.xx/rest/vars/set/2/19/16, but no change in the location of the error.

pi@raspberrypi:~ $ python3 Test.py
  File "Test.py", line 22
    curl -u, admin:Test http://192.xxx.x.xx/rest/vars/set/2/19/16
                            ^
SyntaxError: invalid syntax

It is pointing to the ":" between the username and Password.  (Note:   If I copy the web address  into my browser, I do change the state variable value in my ISY so that part works by asking me for my credentials first)

Here is my simple program.  The program works fine without the curl statement.  Any help would be greatly appreciated. 

import RPi.GPIO as GPIO
import Adafruit_BMP.BMP085 as BMP085
import I2C_LCD_driver
import time
import pycurl

pressure_sensor = BMP085.BMP085()
sensor = BMP085.BMP085()

mylcd = I2C_LCD_driver.lcd()
mylcd.lcd_clear()

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.cleanup()

pressure = pressure_sensor.read_sealevel_pressure()
pressure = pressure / 100.0 # 1 mbar = 100 Pa.

if pressure > 700:
        mylcd.lcd_display_string("Pressure: %.1f%s hPa" % (pressure,chr(32)), 3)
        curl -u, admin:Test http://192.xxx.x.xx/rest/vars/set/2/19/16

 

 

Link to comment

Thank you so much simplextech for pointing me in the right direction.  I was able to push a state variable to the ISY using a  "request" command  in a python program using the authorization site you sent me to.  I had a little trouble at first thinking I had to use a "put or post" command but when I used "get" it worked fine.

You don't know how much I appreciate your help.  This opens up many new opportunities for use of my local environment sensors with the ISY.

Also, I want to again thank Bumbershoot for the format of the rest command.

This forum is the greatest.

 

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...