Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdgeisler committed Nov 24, 2022
2 parents 60ce686 + a6343b7 commit b7e48dc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,16 @@ java -jar ./dirigera-client-dump/target/dirigera-client-dump-0.0.1-SNAPSHOT.jar
## Integration to Home Assistant

Lights and sockets can be integrated into Home Assistant via MQTT (more devices will follow).
Therefore, the application [dirigera-client-mqtt](dirigera-client-mqtt/src/main/java/de/dvdgeisler/iot/dirigera/client/mqtt/DirigeraClientMqttApplication.java)
is started as a service giving the hostnames of the Dirigera, and the MQTT broker, e.g.:
```bash
./mvnw package
java -jar dirigera-client-mqtt/target/dirigera-client-mqtt-0.0.1-SNAPSHOT.jar \
--dirigera.hostname=<DIRIGERA-IP-ADDRESS> \
--dirigera.mqtt.hostname=<MQTT-IP-ADDRESS (Default: localhost)> \
--dirigera.mqtt.port=<MQTT-PORT (Default: 1883)>
```
Home Assistant will create entities for supported devices, based on its MQTT auto discovery approach.

Add https://github.com/TheMrBooyah/hassio-repository to your home assistant.
Update the configuration to your setup.

In order to get your 'Token', run the [Dump Application](dirigera-client-dump/src/main/java/de/dvdgeisler/iot/dirigera/client/dump/DumpApplication.java). This will ask you to pair your gateway. After successfully pairing the gateway a file 'dirigera_access_token' will be created. Open the file with your favourite text editor and copy everything into the 'Token' field.

Start the addon, watch the logs for any errors and if everything went as expected, home assistant should have some new devices/entities from your IKEA Smart Hub.


![](img/hass-integration.png)

## Other repos to dig in
Expand Down
1 change: 1 addition & 0 deletions dirigera-client-mqtt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
</dependencies>

<build>
<finalName>dirigera-client-mqtt</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class MqttBridge extends org.eclipse.paho.client.mqttv3.MqttClient {
public MqttBridge(
@Value("${dirigera.mqtt.hostname:localhost}") final String host,
@Value("${dirigera.mqtt.port:1883}") final Short port,
@Value("${dirigera.mqtt.username:}") final String username,
@Value("${dirigera.mqtt.password:}") final String password,
@Value("${dirigera.mqtt.reconnect:true}") final Boolean reconnect,
@Value("${dirigera.mqtt.timeout:10}") final Integer timeout,
final DirigeraApi api) throws MqttException {
Expand All @@ -38,6 +40,11 @@ public MqttBridge(
options.setAutomaticReconnect(reconnect);
options.setCleanSession(true);
options.setConnectionTimeout(timeout);

if (!username.isEmpty() && !password.isEmpty()) {
options.setUserName(username);
options.setPassword(password.toCharArray());
}
this.connect(options);

log.info("Connection to MQTT broker successfully established");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
spring.application.name=Dirigera Dump
spring.application.name=Dirigera MQTT
logging.level.root=error
logging.level.de.dvdgeisler.iot.dirigera=debug
spring.main.web-application-type=none
Expand Down

0 comments on commit b7e48dc

Please sign in to comment.