New oru/coned addon

This commit is contained in:
Bogdan Vlaicu
2020-09-11 19:50:34 -04:00
parent ac87c7e53f
commit ad87239214
13 changed files with 365 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
# Contributing
When contributing to this repository, please first discuss the change you wish
to make via issue, email, or any other method with the owners of this repository
before making a change.
Please note we have a code of conduct, please follow it in all your interactions
with the project.
## Issues and feature requests
You've found a bug in the source code, a mistake in the documentation or maybe
you'd like a new feature? You can help us by submitting an issue to our
[GitHub Repository][github]. Before you create an issue, make sure you search
the archive, maybe your question was already answered.
Even better: You could submit a pull request with a fix / new feature!
## Pull request process
1. Search our repository for open or closed [pull requests][prs] that relates
to your submission. You don't want to duplicate effort.
1. You may merge the pull request in once you have the sign-off of two other
developers, or if you do not have permission to do that, you may request
the second reviewer to merge it for you.
[github]: https://github.com/bvlaicu/home-assistant-addons/issues
[prs]: https://github.com/bvlaicu/home-assistant-addons/pulls
+21
View File
@@ -0,0 +1,21 @@
# MIT License
Copyright (c) 2019-2020 Bogdan Vlaicu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+78
View File
@@ -0,0 +1,78 @@
# Home Assistant Add-ons
## About
Home Assistant allows anyone to create add-on repositories to share their
add-ons for Home Assistant easily. This repository is one of those repositories,
providing extra Home Assistant add-ons for your installation.
## Installation
In the Home Assistant add-on store, a possibility to add a repository is provided.
Use the following URL to add this repository:
```txt
https://github.com/bvlaicu/home-assistant-addons
```
## Add-ons provided by this repository
### [PHP][addon-php]
### [Dashcast][addon-dashcast]
### [Meter Reader][addon-meter-reader]
## Releases
Releases are based on [Semantic Versioning][semver], and use the format
of ``MAJOR.MINOR.PATCH``. In a nutshell, the version will be incremented
based on the following:
- ``MAJOR``: Incompatible or major changes.
- ``MINOR``: Backwards-compatible new features and enhancements.
- ``PATCH``: Backwards-compatible bugfixes and package updates.
## Support
Got questions?
You have several options to get them answered:
- The Home Assistant Community Add-ons [Discord Chat Server][discord]
- The Home Assistant [Community Forum][forum].
- The Home Assistant [Discord Chat Server][discord-ha].
- Join the [Reddit subreddit][reddit] in [/r/homeassistant][reddit]
You could also open an issue here on GitHub. Note, we use a separate
GitHub repository for each add-on. Please ensure you are creating the issue
on the correct GitHub repository matching the add-on.
## License
MIT License
Copyright (c) 2019-2020 Bogdan Vlaicu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
[addon-php]: https://github.com/bvlaicu/home-assistant-addons/tree/master/php
[addon-dashcast]: https://github.com/bvlaicu/home-assistant-addons/tree/master/dashcast
[addon-meter-reader]: https://github.com/bvlaicu/home-assistant-addons/tree/master/meter-reader
[addon-minidlna]: https://github.com/bvlaicu/home-assistant-addons/tree/master/minidlna
Executable
+30
View File
@@ -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
View File
@@ -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`
+50
View File
@@ -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
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Executable
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

+5
View File
@@ -0,0 +1,5 @@
pyotp
requests
pyppeteer
paho-mqtt
coned
Executable
+28
View File
@@ -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
View File
@@ -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
+11
View File
@@ -0,0 +1,11 @@
{
"extends": [
"config:base"
],
"commitMessageAction": "Updates",
"commitMessageTopic": "{{depName}}",
"commitMessagePrefix": ":arrow_up:",
"labels": [
"Type: Maintenance"
]
}
+5
View File
@@ -0,0 +1,5 @@
{
"name": "bvlaicu's Home Assistant Addons",
"url": "https://github.com/bvlaicu/home-assistant-addons-repository",
"maintainer": "bogdanvlaicu@yahoo.com"
}