Skip to content

Commit

Permalink
Add URL for Influx 2.x support
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonacox committed Feb 27, 2023
1 parent 1c50418 commit b8e48e8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
10 changes: 8 additions & 2 deletions weather/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Docker: docker pull [jasonacox/weather411](https://hub.docker.com/r/jasonacox/we

## Quick Start


1. Create a `weather411.conf` file (`cp weather411.conf.sample weather411.conf`) and update with your specific location details:

* Enter your OpenWeatherMap API Key (APIKEY) You can get a free account and key at [OpenWeatherMap.org](https://openweathermap.org/).
Expand Down Expand Up @@ -52,6 +51,13 @@ Docker: docker pull [jasonacox/weather411](https://hub.docker.com/r/jasonacox/we
# Leave blank if not used
USERNAME =
PASSWORD =
# Auth - Leave blank if not used
USERNAME =
PASSWORD =
# Influx 2.x - Leave blank if not used
TOKEN =
ORG =
URL =
```

2. Run the Docker Container to listen on port 8676.
Expand Down Expand Up @@ -143,7 +149,7 @@ docker start weather411

### 0.2.0 - Upgrade InfluxDB Client

* Upgrade end of life `influxdb` client library to `influxdb-client` (refer discussion #191 and issue #195)
* Upgrade end of life `influxdb` client library to `influxdb-client` (refer discussion #191 and issue #195), providing support for InfluxDB 1.8 and 2.x.

### 0.1.2 - Snow and Rain Data

Expand Down
16 changes: 13 additions & 3 deletions weather/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
PORT = 8086
DB = powerwall
FIELD = weather
# Auth - Leave blank if not used
USERNAME =
PASSWORD =
# Auth - Influx 2.x - Leave blank if not used
TOKEN =
ORG =
URL =
ENVIRONMENTAL:
WEATHERCONF = "Path to weather411.conf file"
Expand Down Expand Up @@ -114,7 +121,10 @@
# Check for InfluxDB 2.x settings
ITOKEN = config.get('InfluxDB', 'TOKEN', fallback="")
IORG = config.get('InfluxDB', 'ORG', fallback="")
IURL = config.get('InfluxDB', 'URL', fallback="")

if ITOKEN != "" and IURL == "":
IURL = "http://%s:%s" % (IHOST, IPORT)
else:
# No config file - Display Error
sys.stderr.write("Weather411 Server %s\nERROR: No config file. Fix and restart.\n" % BUILD)
Expand Down Expand Up @@ -266,7 +276,7 @@ def fetchWeather():
else :
# Influx 2.x
client = InfluxDBClient(
url="http://%s:%s" % (IHOST,IPORT),
url=IURL,
token=ITOKEN,
org=IORG)
output = [{}]
Expand Down Expand Up @@ -430,8 +440,8 @@ def api(port):
sys.stderr.write(" + InfluxDB - Enable: %s, Host: %s, Port: %s, DB: %s, Field: %s\n"
% (INFLUX, IHOST, IPORT, IDB, IFIELD))
if ITOKEN != "" or IORG != "":
sys.stderr.write(" + InfluxDB - Org: %s, Token: %s\n"
% (IORG, ITOKEN))
sys.stderr.write(" + InfluxDB - URL: %s, Org: %s, Token: %s\n"
% (IURL, IORG, ITOKEN))

# Start threads
sys.stderr.write("* Starting threads\n")
Expand Down
3 changes: 2 additions & 1 deletion weather/weather411.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ FIELD = weather
# Auth - Leave blank if not used
USERNAME =
PASSWORD =
# Auth - Influx 2.x - Leave blank if not used
# Influx 2.x - Leave blank if not used
TOKEN =
ORG =
URL =

0 comments on commit b8e48e8

Please sign in to comment.