New oru/coned addon
This commit is contained in:
Executable
+30
@@ -0,0 +1,30 @@
|
||||
FROM debian:buster
|
||||
|
||||
USER root
|
||||
RUN apt-get update && apt-get upgrade -yq
|
||||
RUN apt-get install python3 python3-pip jq nano -y
|
||||
|
||||
# Install chrome and dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
--no-install-recommends \
|
||||
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
||||
&& echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
|
||||
&& apt-get update && apt-get install -y \
|
||||
google-chrome-stable \
|
||||
--no-install-recommends
|
||||
|
||||
# Chrome won't run from the root user.
|
||||
RUN groupadd chrome && useradd -g chrome -s /bin/bash -G audio,video chrome \
|
||||
&& mkdir -p /home/chrome && chown -R chrome:chrome /home/chrome
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip3 install -r requirements.txt
|
||||
|
||||
COPY run.py .
|
||||
COPY run.sh .
|
||||
|
||||
CMD cd / && chmod +x /run.sh && /run.sh
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
# Orange and Rockland Utility to MQTT Bridge hass.io addon
|
||||
|
||||
Add-on for retrieving the last meter read from [Orange and Rockland Utility](oru.com) or [ConEdison](coned.com) and publish the data via MQTT
|
||||
|
||||
## Configuration
|
||||
|
||||
Add-on configuration example:
|
||||
|
||||
```yaml
|
||||
email: example@email.com
|
||||
password: '!secret oru_password'
|
||||
mfa_type: TOTP
|
||||
mfa_secret: '!secret oru_mfa_secret'
|
||||
account_uuid: ef788d65-5380-11e8-8211-2655115779ac
|
||||
meter_number: 706438804
|
||||
site: oru
|
||||
mqtt_host: hassio.local
|
||||
mqtt_user: mqtt
|
||||
mqtt_password: '!secret mqtt_password'
|
||||
```
|
||||
### Option: `email`
|
||||
|
||||
The email address for the oru.com / coned.com account
|
||||
|
||||
### Option: `password`
|
||||
|
||||
The password for the oru.com / coned.com account
|
||||
|
||||
### Option: `mfa_type`
|
||||
|
||||
The MFA type for the oru.com / coned.com account. Can be either `SECURITY_QUESTION` or `TOTP` (e.g. Google Authenticator).
|
||||
|
||||
### Option: `mfa_secret`
|
||||
|
||||
The MFA secret for the oru.com / coned.com account. For MFA type Security Question, to set up your MFA secret (answer), log into oru.com / coned.com, go to your profile and reset your 2FA method. When setting up 2FA again, there will be option to say you do not have texting on your phone. Select this and you should be able to use a security question instead.
|
||||
For MFA type TOTP, choose Google Authenticator, choose a device type and when presented with the QR code, click on "Can't scan?". It should provide you with the MFA secret.
|
||||
|
||||
### Option: `account_uuid`
|
||||
|
||||
The Orange and Rockland Utility account uuid. To find it log into oru.com / coned.com then use the browser developer tools to search for `uuid` in the network tab.
|
||||
|
||||
### Option: `meter_number`
|
||||
|
||||
The Orange and Rockland Utility meter number. You can find it on a utility bill.
|
||||
|
||||
### Option: `site`
|
||||
|
||||
Either `oru` for Orange and Rockland Utility or `coned` for ConEdison
|
||||
|
||||
### Option: `mqtt_host`
|
||||
|
||||
Defines the hostname or ip of the MQTT server
|
||||
|
||||
### Option: `mqtt_user`
|
||||
|
||||
Defines the username for the MQTT server
|
||||
|
||||
### Option: `mqtt_password`
|
||||
|
||||
Defines the password for the MQTT server
|
||||
|
||||
|
||||
## MQTT Data
|
||||
|
||||
The addon will publish the latest meter read value and unit of measure to the following topics:
|
||||
|
||||
`electric_meter/startTime`
|
||||
|
||||
`electric_meter/endTime`
|
||||
|
||||
`electric_meter/value`
|
||||
|
||||
`electric_meter/uom`
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "Orange and Rockland Utility to MQTT Bridge",
|
||||
"version": "0.2.4",
|
||||
"slug": "oru",
|
||||
"description": "Orange and Rockland Utility meter reading to MQTT",
|
||||
"url": "https://github.com/bvlaicu/home-assistant-addons/tree/master/oru",
|
||||
"panel_icon": "mdi:chart-areaspline",
|
||||
"startup": "application",
|
||||
"homeassistant": "0.92.0b2",
|
||||
"boot": "auto",
|
||||
"map": ["share:rw", "ssl"],
|
||||
"devices": ["/dev/bus/usb:/dev/bus/usb:rwm"],
|
||||
"host_network": "False",
|
||||
"arch": [
|
||||
"aarch64",
|
||||
"amd64",
|
||||
"armv7",
|
||||
"i386"
|
||||
],
|
||||
"hassio_api": true,
|
||||
"auth_api": true,
|
||||
"hassio_role": "default",
|
||||
"homeassistant_api": false,
|
||||
"options":
|
||||
{
|
||||
"email": "",
|
||||
"password": "",
|
||||
"mfa_type": "",
|
||||
"mfa_secret": "",
|
||||
"account_uuid": "",
|
||||
"meter_number": "",
|
||||
"site": "",
|
||||
"mqtt_host": "hassio.local",
|
||||
"mqtt_user": "",
|
||||
"mqtt_password": ""
|
||||
},
|
||||
"schema":
|
||||
{
|
||||
"email": "str",
|
||||
"password": "str",
|
||||
"mfa_type": "str",
|
||||
"mfa_secret": "str",
|
||||
"account_uuid": "str",
|
||||
"meter_number": "str",
|
||||
"site": "str",
|
||||
"mqtt_host": "str",
|
||||
"mqtt_user": "str",
|
||||
"mqtt_password": "str"
|
||||
}
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Executable
+5
@@ -0,0 +1,5 @@
|
||||
pyotp
|
||||
requests
|
||||
pyppeteer
|
||||
paho-mqtt
|
||||
coned
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
import asyncio
|
||||
from coned import Meter
|
||||
from coned import MeterError
|
||||
import paho.mqtt.client as mqtt
|
||||
|
||||
meter = Meter(
|
||||
email=os.getenv("EMAIL"),
|
||||
password=os.getenv("PASSWORD"),
|
||||
mfa_type=os.getenv("MFA_TYPE"),
|
||||
mfa_secret=os.getenv("MFA_SECRET"),
|
||||
account_uuid=os.getenv("ACCOUNT_UUID"),
|
||||
meter_number=os.getenv("METER_NUMBER"),
|
||||
site=os.getenv("SITE"),
|
||||
browser_path="/usr/bin/google-chrome-stable"
|
||||
)
|
||||
startTime, endTime, val, uom = asyncio.get_event_loop().run_until_complete(meter.last_read())
|
||||
|
||||
print(f"startTime: {startTime}, endTime: {endTime}, val: {val}, uom: {uom}")
|
||||
|
||||
mqttc = mqtt.Client("oru_meter_reader")
|
||||
mqttc.username_pw_set(username=os.getenv("MQTT_USER"), password=os.getenv("MQTT_PASS"))
|
||||
mqttc.connect(os.getenv("MQTT_HOST"))
|
||||
mqttc.publish('electric_meter/startTime', startTime, retain=True)
|
||||
mqttc.publish('electric_meter/endTime', endTime, retain=True)
|
||||
mqttc.publish('electric_meter/value', val, retain=True)
|
||||
mqttc.publish('electric_meter/uom', uom, retain=True)
|
||||
mqttc.disconnect()
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONFIG_PATH=/data/options.json
|
||||
|
||||
export EMAIL="$(jq --raw-output '.email' $CONFIG_PATH)"
|
||||
export PASSWORD="$(jq --raw-output '.password' $CONFIG_PATH)"
|
||||
export MFA_TYPE="$(jq --raw-output '.mfa_type' $CONFIG_PATH)"
|
||||
export MFA_SECRET="$(jq --raw-output '.mfa_secret' $CONFIG_PATH)"
|
||||
export ACCOUNT_UUID="$(jq --raw-output '.account_uuid' $CONFIG_PATH)"
|
||||
export METER_NUMBER="$(jq --raw-output '.meter_number' $CONFIG_PATH)"
|
||||
export SITE="$(jq --raw-output '.site' $CONFIG_PATH)"
|
||||
export MQTT_HOST="$(jq --raw-output '.mqtt_host' $CONFIG_PATH)"
|
||||
export MQTT_USER="$(jq --raw-output '.mqtt_user' $CONFIG_PATH)"
|
||||
export MQTT_PASS="$(jq --raw-output '.mqtt_password' $CONFIG_PATH)"
|
||||
|
||||
echo "Params:"
|
||||
echo "EMAIL =" $EMAIL
|
||||
echo "PASSWORD =" $(sed 's/^........../**********/' <<<$PASSWORD)
|
||||
echo "MFA_TYPE =" $MFA_TYPE
|
||||
echo "MFA_SECRET =" $(sed 's/^........../**********/' <<<$MFA_SECRET)
|
||||
echo "ACCOUNT_UUID =" $ACCOUNT_UUID
|
||||
echo "METER_NUMBER =" $METER_NUMBER
|
||||
echo "SITE =" $SITE
|
||||
echo "MQTT_HOST =" $MQTT_HOST
|
||||
echo "MQTT_USER =" $MQTT_USER
|
||||
echo "MQTT_PASS =" $(sed 's/^........../**********/' <<<$MQTT_PASS)
|
||||
|
||||
# Start the listener and enter an endless loop
|
||||
echo "Starting endless loop.."
|
||||
while true; do
|
||||
python3 run.py
|
||||
#tail -f /dev/null
|
||||
|
||||
sleep 300
|
||||
done
|
||||
Reference in New Issue
Block a user