Skip to content

Commit

Permalink
Merge pull request #1 from mhzawadi/dev-php
Browse files Browse the repository at this point in the history
271/PHP rewrite
  • Loading branch information
mhzawadi authored May 15, 2023
2 parents 3d3b778 + c4a433d commit 1b16b05
Show file tree
Hide file tree
Showing 29 changed files with 2,595 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
.github
mqtt
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
5 changes: 3 additions & 2 deletions .github/workflows/image-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: build our image for dev

on:
push:
branches: dev
branches: dev-php

jobs:
build:
Expand All @@ -19,5 +19,6 @@ jobs:
- name: build the image
run: |
docker buildx build --push \
--tag mhzawadi/foxess-mqtt:dev \
--tag mhzawadi/foxess-mqtt:dev-php \
--file Dockerfile-php \
--platform linux/amd64,linux/arm64,linux/arm/v7 .
1 change: 1 addition & 0 deletions .github/workflows/image-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ jobs:
run: |
docker buildx build --push \
--tag mhzawadi/foxess-mqtt:latest \
--file Dockerfile-php \
--platform linux/amd64,linux/arm64,linux/arm/v7 .
1 change: 1 addition & 0 deletions .github/workflows/image-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ jobs:
run: |
docker buildx build --push \
--tag mhzawadi/foxess-mqtt:${{ steps.prepare.outputs.version }} \
--file Dockerfile-php \
--platform linux/amd64,linux/arm64,linux/arm/v7 .
68 changes: 68 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# ---> PhpStorm
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Ruby plugin and RubyMine
/.rakeTasks

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

.DS_Store

### PhpStorm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
.idea/sonarlint
vendor
data
19 changes: 19 additions & 0 deletions Dockerfile-php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM alpine:3.17
MAINTAINER Matthew Horwood <[email protected]>

# Install required deb packages
RUN apk update && apk upgrade && \
apk add php81-json php81-curl git php81 php81-phar php81-xml php81-tokenizer \
php81-sockets curl php81-openssl php81-mbstring php81-dom php81-xmlwriter \
&& rm -f /var/cache/apk/*; \
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php && \
php -r "unlink('composer-setup.php');" && \
mv composer.phar /usr/local/bin/composer;

COPY . /foxess-mqtt
WORKDIR /foxess-mqtt
RUN composer install;
VOLUME /foxess-mqtt/data
CMD ["/foxess-mqtt/run.sh"]
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
# Horwoods Foxess Cloud Data collector

This is a very simple tool to get the data out of foxesscloud and into MQTT, it has some very rough edges.
This is a very simple tool to get the data out of FoxEss-cloud and into MQTT, it has some very rough edges.

## Running

```bash
docker run --name foxescloud \
-e MQTT_HOST=192.168.0.2 \
-e MQTT_USERNAME=homeassistant \
-e MQTT_PASSWORD=ASecurePassword \
-e FOXESS_USERNAME=foxAccount \
-e FOXESS_PASSWORD=foxPassword \
-e DEVICE_ID=a-b-d-c-d \
-e - TIMEZONE=Europe/London \
-v /home/user/foxess_data:/foxess-mqtt/data \
mhzawadi/foxess-mqtt
```

## Docker environment variables

- MQTT_HOST the host or IP of your MQTT server
- MQTT_USERNAME - the username for MQTT
- MQTT_PASSWORD - the password for MQTT
- FOXESS_USERNAME - your Foxess Cloud login
- FOXESS_PASSWORD - your Foxess Cloud login
- DEVICE_ID - the UUID that can be found on foxesscloud in the url path on the Inverter Details page.
- Please make sure that this is exact value from inverter details page address between = and & character:
- TIMEZONE - This is the time your in, else use UTC [List of Supported Timezones](https://www.php.net/manual/en/timezones.php)

## Config file

The new PHP script uses json for the config,
you can copy the below code and paste into config.josn or run the image and wait for it spit out the files.

`device_id` - the UUID that can be found on FoxEss-cloud in the url path on the Inverter Details page.
Please make sure that this is exact value from inverter details page address between = and & character:

The json for the config.json file
```
{
"foxess_username": "username",
"foxess_password": "secretPassword",
"device_id": "device_id",
"mqtt_host": "mosquitto",
"mqtt_port": "1883",
"mqtt_user": "foxess",
"mqtt_pass": "foxess"
}
```
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "mhzawadi/foxess-mqtt",
"description": "Foxess Cloud data to MQTT",
"license": "MIT",
"keywords": ["foxess","mqtt"],
"authors": [
{
"name": "Matthew Horwood",
"email": "[email protected]"
}
],
"require" : {
"php-mqtt/client" : "*"
},
"require-dev": {
"phpunit/phpunit": "9.5.*"
},
"autoload": {
"psr-4": {
"MHorwood\\foxess_mqtt\\": "src",
"MHorwood\\loader\\": "."
}
}
}
Loading

0 comments on commit 1b16b05

Please sign in to comment.