Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/issue-33
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdgeisler committed Nov 24, 2022
2 parents c6e0e80 + b7e48dc commit 2969b0d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 10 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ barely tested, and some are known as inoperable.
* Remote Control N2
* TRADFRI on/off switch
* TRADFRI remote control
* LEPTITER Recessed spot light
* Sound-Controller
* SYMFONISK Sound Controller
* Blinds-Controller
Expand Down Expand Up @@ -113,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
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package de.dvdgeisler.iot.dirigera.client.api.model.device.light;

import de.dvdgeisler.iot.dirigera.client.api.model.device.Device;
import de.dvdgeisler.iot.dirigera.client.api.model.device.DeviceTest;

import static org.junit.jupiter.api.Assertions.assertInstanceOf;

class LEPTITERRecessedspotlight extends DeviceTest {
final static String JSON = """
{
"id" : "7e69e364-17b6-4c15-9c18-1835d0e44d87_1",
"type" : "light",
"deviceType" : "light",
"createdAt" : "2022-11-13T12:58:16.000Z",
"isReachable" : true,
"lastSeen" : "2022-11-22T17:57:24.000Z",
"attributes" : {
"customName" : "Bathroom light",
"firmwareVersion" : "2.3.087",
"hardwareVersion" : "1",
"manufacturer" : "IKEA of Sweden",
"model" : "LEPTITER Recessed spot light",
"productCode" : "T1820",
"serialNumber" : "000D6FFFFE12EC29",
"isOn" : false,
"startupOnOff" : "startOn",
"lightLevel" : 20,
"colorMode" : "temperature",
"colorTemperature" : 2500,
"colorTemperatureMax" : 2202,
"colorTemperatureMin" : 4000,
"identifyPeriod" : 0,
"identifyStarted" : "2000-01-01T00:00:00.000Z",
"permittingJoin" : false,
"otaPolicy" : "autoUpdate",
"otaProgress" : 0,
"otaScheduleEnd" : "00:00",
"otaScheduleStart" : "00:00",
"otaState" : "readyToCheck",
"otaStatus" : "upToDate"
},
"capabilities" : {
"canSend" : [ ],
"canReceive" : [ "customName", "isOn", "lightLevel", "colorTemperature" ]
},
"room" : {
"id" : "90b00dc0-6a6a-477b-82f1-f7ac47c6cd6d",
"name" : "Bathroom",
"color" : "ikea_lilac_no_3",
"icon" : "rooms_bathtub"
},
"deviceSet" : [ ],
"remoteLinks" : [ "57e25312-9e04-4fcc-adc3-2e57c9c89be0_1" ],
"isHidden" : false
}
""";

public LEPTITERRecessedspotlight() {
super(JSON);
}

@Override
public void validateDeserialize(final Device<?,?> device) {
assertInstanceOf(LightDevice.class, device);
}
}
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 @@ -37,6 +39,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 2969b0d

Please sign in to comment.