Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dafik committed Nov 15, 2023
1 parent 082739a commit e19283d
Show file tree
Hide file tree
Showing 23 changed files with 221 additions and 2,215 deletions.
File renamed without changes.
22 changes: 19 additions & 3 deletions .github/workflows/deploy.yml → .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Publish package to GitHub Packages
name: Package
on:
release:
types: [created]
types: [ created ]
jobs:
publish:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -45,4 +45,20 @@ jobs:
- name: Publish package
run: mvn --batch-mode -DskipTests deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,riscv64,arm

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Run Buildx
run: |
cp ./app/target/app-0.0.5-dep.jar ./docker/std/sbc2ha.jar
docker buildx build \
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/riscv64 \
--output "type=image,push=false" \
--file ./docker/std/Dockerfile ./docker/std
1,937 changes: 2 additions & 1,935 deletions .gitignore

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@
<artifactId>nifty-modbus-rtu</artifactId>
<version>${nifty-modbus.version}</version>
</dependency>
<!-- <dependency>
<groupId>net.solarnetwork.common</groupId>
<artifactId>nifty-modbus-rtu-jsc</artifactId>
<version>0.5.0</version>
</dependency>-->
<!-- <dependency>
<groupId>net.solarnetwork.common</groupId>
<artifactId>nifty-modbus-rtu-jsc</artifactId>
<version>0.5.0</version>
</dependency>-->
<dependency>
<groupId>org.tinylog</groupId>
<artifactId>tinylog-impl</artifactId>
Expand Down Expand Up @@ -228,8 +228,6 @@
<skip>false</skip>
</configuration>
</plugin>

</plugins>
</build>

</project>
3 changes: 3 additions & 0 deletions app/src/main/java/com/dfi/sbc2ha/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@

public class Version {
public static final String VERSION = "java-0.0.4";
public static String getVersion(){
return Version.class.getPackage().getImplementationVersion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Display(SH1106 displayDevice, Button inputDelegate, OledConfig config, St
String dejavu = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf";
String dejavuMono = "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf";

InputStream systemResource = ClassLoader.getSystemResourceAsStream("danube__.ttf");
InputStream systemResource = ClassLoader.getSystemResourceAsStream("font/danube__.ttf");


try {
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions app/src/main/resources/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=${project.version}
13 changes: 13 additions & 0 deletions docker/ha/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM eclipse-temurin:17-jre

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates telnet iputils-ping curl netbase net-tools iproute2 wget \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY sbc2ha.jar ./
COPY sbc.yaml ./config.yaml

CMD java -Ddiozero.devicefactory=com.diozero.internal.provider.pigpioj.PigpioJDeviceFactory -DusePwmFadingLed=true -jar sbc2ha.jar /app/config.yaml

15 changes: 15 additions & 0 deletions docker/ha/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "sbc2ha"
description: "Single board computer 2 home assistant"
version: "0.0.3"
slug: "sbc2ha"
init: false
arch:
- aarch64
- amd64
- armhf
- armv7
- i386
ports:
5005/tcp: 5005
schema:
config: "str?"
Binary file added docker/ha/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docker/ha/icon_r.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions docker/ha/sbc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
platform:
- platform: mqtt
host: 192.168.1.10
username: boneio
password: boneio
port: 1883
topic_prefix: pi-1
ha_discovery:
enabled: true
topic_prefix: homeassistant
actuator:
- name: Salon klima led
kind: gpiopwm
output: 12
output_type: led
restore_state: true
- name: Salon okno led
kind: gpiopwm
output: 13
output_type: led
restore_state: true
- name: Salon obraz led
kind: gpiopwm
output: 29
output_type: led
restore_state: true
- name: Salon kanapa led
kind: gpiopwm
output: 15
output_type: led
restore_state: true
- name: Hall led
kind: gpiopwm
output: 37
output_type: led
restore_state: true
- name: Wc led
kind: gpiopwm
output: 35
output_type: led
restore_state: true
- name: Kuchnia led
kind: gpiopwm
output: 33
output_type: led
restore_state: true
- name: Łazienka led
kind: gpiopwm
output: 31
output_type: led
restore_state: true
logger:
default: info
logs:
com.dfi: trace
com.dfi.sbc2ha.platform.mqtt: debug
com.diozero.sbc.LocalSystemInfo: error
com.dfi.sbc2ha.actuator.Led: trace
com.diozero.devices.PwmLed: trace
com.dfi.sbc2ha.actuator.LedFading: trace
com.diozero.devices.PwmFadingLed: debug
writer:
format: "{ date:HH:mm:ss } {level|size=5} {class-name} {message}"
extension_boards:
vendor: rpi
inputBoard: nohat
outputBoard: nohat
15 changes: 15 additions & 0 deletions docker/std/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM eclipse-temurin:17-jre

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates telnet iputils-ping curl netbase net-tools iproute2 wget \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY sbc2ha.jar ./
COPY config.yaml ./config.yaml

EXPOSE 8080

CMD java -DusePwmFadingLed=true -jar sbc2ha.jar /app/config.yaml

65 changes: 65 additions & 0 deletions docker/std/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
platform: [ ]
sensor:
- platform: analog
name: analog 1
filters: [ ]
analog: 1
- platform: analog
name: Analog 2
filters: [ ]
analog: 2
- platform: resistance
name: resistance 1
filters: [ ]
sensor: analog 1
direction: DOWNSTREAM
resistor: "10000"
reference_voltage: "1.8"
- platform: digital
name: digital 1
input: 1
device_class: DOOR
- platform: digital
name: Digital 2
input: 2
device_class: MOTION
- platform: switch
name: switch 1
input: 3
click_detection: double
actions:
single:
- action: output
output: 1
action_output: toggle
double:
- action: output
output: 1
action_output: toggle
- action: output
output: 2
action_output: toggle
- platform: switch
name: switch 2
input: 4
actions:
single:
- action: output
output: 2
action_output: toggle

actuator:
- restore_state: true
kind: gpio
name: out 1
output_type: switch
output: 1
- restore_state: true
kind: gpio
name: out 2
output_type: switch
output: 2
extension_boards:
vendor: fake
input_board: in
output_board: out
32 changes: 0 additions & 32 deletions helper/src/main/java/com/dfi/sbc2ha/helper/Scheduler.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,5 @@
package com.dfi.sbc2ha.helper;

/*
* #%L
* Organisation: diozero
* Project: diozero - Core
* Filename: Scheduler.java
*
* This file is part of the diozero project. More information about this project
* can be found at https://www.diozero.com/.
* %%
* Copyright (C) 2016 - 2023 diozero
* %%
* 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.
* #L%
*/


import lombok.extern.slf4j.Slf4j;

import java.util.Map;
Expand Down
31 changes: 1 addition & 30 deletions lib/diozero/src/main/java/com/diozero/devices/PwmFadingLed.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,6 @@
package com.diozero.devices;

/*
* #%L
* Organisation: diozero
* Project: diozero - Core
* Filename: PwmLed.java
*
* This file is part of the diozero project. More information about this project
* can be found at https://www.diozero.com/.
* %%
* Copyright (C) 2016 - 2023 diozero
* %%
* 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.
* #L%
*/


import com.dfi.sbc2ha.Easing;
import com.dfi.sbc2ha.EasingType;
Expand Down
30 changes: 0 additions & 30 deletions lib/diozero/src/main/java/com/diozero/devices/PwmLed.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,5 @@
package com.diozero.devices;

/*
* #%L
* Organisation: diozero
* Project: diozero - Core
* Filename: PwmLed.java
*
* This file is part of the diozero project. More information about this project
* can be found at https://www.diozero.com/.
* %%
* Copyright (C) 2016 - 2023 diozero
* %%
* 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.
* #L%
*/

import com.dfi.sbc2ha.EasingOld;
import com.dfi.sbc2ha.helper.Scheduler;
Expand Down
Loading

0 comments on commit e19283d

Please sign in to comment.