mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-19 08:28:46 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
409c93bfb2 | ||
|
|
543a79bb66 | ||
|
|
16d1054b96 | ||
|
|
165b6ef9bb | ||
|
|
fb94b858f6 | ||
|
|
ea80925533 | ||
|
|
62b896ee07 | ||
|
|
8657ea6704 | ||
|
|
05bd6b6d77 | ||
|
|
19256e4eaa | ||
|
|
905f6aa9ec | ||
|
|
daa0dac5b9 | ||
|
|
0478fc69f4 | ||
|
|
b99e74823c | ||
|
|
ebeb6be7a7 | ||
|
|
d3979da2b4 | ||
|
|
f276f66991 | ||
|
|
3ac5c10f08 |
99
README.md
99
README.md
@@ -1,5 +1,5 @@
|
|||||||
# ha-bridge
|
# ha-bridge
|
||||||
Emulates Philips Hue api to other home automation gateways such as an Amazon Echo or Google Home. The Bridge handles basic commands such as "On", "Off" and "brightness" commands of the hue protocol. This bridge can control most devices that have a distinct API.
|
Emulates Philips Hue API to other home automation gateways such as an Amazon Echo or other systems that support Philips Hue. The Bridge handles basic commands such as "On", "Off" and "brightness" commands of the hue protocol. This bridge can control most devices that have a distinct API.
|
||||||
|
|
||||||
Here are some diagrams to put this software in perspective.
|
Here are some diagrams to put this software in perspective.
|
||||||
|
|
||||||
@@ -35,9 +35,11 @@ THe Harmony Hub Path looks like this:
|
|||||||
|
|
||||||
**NOTE: This software does not control Philips Hue devices directly. A physical Philips Hue Hub is required for that, by which the ha-bridge can then proxy all of your real Hue bridges behind this bridge.**
|
**NOTE: This software does not control Philips Hue devices directly. A physical Philips Hue Hub is required for that, by which the ha-bridge can then proxy all of your real Hue bridges behind this bridge.**
|
||||||
|
|
||||||
|
**ISSUE: Google Home now seems to not support local connection to Philips Hue Hubs and requires that it connect to meethue.com. Since the ha-bridge only emulates the local API, and is not associated with Philips, this method will not work. If you have an older Google Home application, this may still work. YMMV.**
|
||||||
|
|
||||||
**FAQ: Please look here for the current FAQs! https://github.com/bwssytems/ha-bridge/wiki/HA-Bridge-FAQs**
|
**FAQ: Please look here for the current FAQs! https://github.com/bwssytems/ha-bridge/wiki/HA-Bridge-FAQs**
|
||||||
|
|
||||||
In the cases of systems that require authorization and/or have API's that cannot be handled in the current method, a module may need to be built. The Harmony Hub is such a module and so is the Nest module. The Bridge has helpers to build devices for the gateway for the Logitech Harmony Hub, Vera, Vera Lite or Vera Edge, Nest, Somfy Tahoma and the ability to proxy all of your real Hue bridges behind this bridge.
|
In the cases of systems that require authorization and/or have APIs that cannot be handled in the current method, a module may need to be built. The Harmony Hub is such a module and so is the Nest module. The Bridge has helpers to build devices for the gateway for the Logitech Harmony Hub, Vera, Vera Lite or Vera Edge, Nest, Somfy Tahoma and the ability to proxy all of your real Hue bridges behind this bridge.
|
||||||
|
|
||||||
Alternatively the Bridge supports custom calls as well using http/https/udp and tcp such as the LimitlessLED/MiLight bulbs using the UDP protocol. Binary data is supported with UDP/TCP.
|
Alternatively the Bridge supports custom calls as well using http/https/udp and tcp such as the LimitlessLED/MiLight bulbs using the UDP protocol. Binary data is supported with UDP/TCP.
|
||||||
|
|
||||||
@@ -59,24 +61,19 @@ ATTENTION: This requires JDK 1.8 to run
|
|||||||
ATTENTION: Due to port 80 being the default, Linux restricts this to super user. Use the instructions below.
|
ATTENTION: Due to port 80 being the default, Linux restricts this to super user. Use the instructions below.
|
||||||
|
|
||||||
```
|
```
|
||||||
java -jar ha-bridge-4.5.0.jar
|
java -jar ha-bridge-4.5.1.jar
|
||||||
```
|
```
|
||||||
### Automation on Linux systems
|
### Automation on Linux systems
|
||||||
To have this configured and running automatically there are a few resources to use. One is using Docker and a docker container has been built for this and can be gotten here: https://github.com/aptalca/docker-ha-bridge
|
To have this configured and running automatically there are a few resources to use. One is using Docker and a docker container has been built for this and can be gotten here: https://github.com/aptalca/docker-ha-bridge
|
||||||
|
|
||||||
Create the directory and make sure that ha-bridge-4.5.0.jar is in your /home/pi/habridge directory.
|
Create the directory and make sure that ha-bridge-4.5.1.jar is in your /home/pi/habridge directory.
|
||||||
```
|
```
|
||||||
pi@raspberrypi:~ $ mkdir habridge
|
pi@raspberrypi:~ $ mkdir habridge
|
||||||
pi@raspberrypi:~ $ cd habridge
|
pi@raspberrypi:~ $ cd habridge
|
||||||
|
|
||||||
pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v4.5.0/ha-bridge-4.5.0.jar
|
pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v4.5.1/ha-bridge-4.5.1.jar
|
||||||
```
|
|
||||||
Create the directory and make sure that ha-bridge-4.5.0.jar is in your /home/pi/habridge directory.
|
|
||||||
```
|
|
||||||
pi@raspberrypi:~ $ mkdir habridge
|
|
||||||
pi@raspberrypi:~ $ cd habridge
|
|
||||||
pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v4.5.0/ha-bridge-4.5.0.jar
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### System Control Setup on a pi (preferred)
|
#### System Control Setup on a pi (preferred)
|
||||||
For next gen Linux systems (this includes the Raspberry Pi), here is a systemctl unit file that you can install. Here is a link on how to do this: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
|
For next gen Linux systems (this includes the Raspberry Pi), here is a systemctl unit file that you can install. Here is a link on how to do this: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
|
||||||
|
|
||||||
@@ -95,7 +92,7 @@ After=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
WorkingDirectory=/home/pi/habridge
|
WorkingDirectory=/home/pi/habridge
|
||||||
ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.5.0.jar
|
ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.5.1.jar
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
@@ -130,7 +127,7 @@ Then cut and past this, modify any locations that are not correct
|
|||||||
```
|
```
|
||||||
cd /home/pi/habridge
|
cd /home/pi/habridge
|
||||||
rm /home/pi/habridge/habridge-log.txt
|
rm /home/pi/habridge/habridge-log.txt
|
||||||
nohup java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.5.0.jar > /home/pi/habridge/habridge-log.txt 2>&1 &
|
nohup java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.5.1.jar > /home/pi/habridge/habridge-log.txt 2>&1 &
|
||||||
|
|
||||||
chmod 777 /home/pi/habridge/habridge-log.txt
|
chmod 777 /home/pi/habridge/habridge-log.txt
|
||||||
```
|
```
|
||||||
@@ -148,12 +145,14 @@ pi@raspberrypi:~/habridge $ tail -f habridge-log.txt
|
|||||||
```
|
```
|
||||||
## Run ha-bridge alongside web server already on port 80
|
## Run ha-bridge alongside web server already on port 80
|
||||||
These examples will help you proxy your current webserver requests to the ha-bridge running on a different port, such as 8080.
|
These examples will help you proxy your current webserver requests to the ha-bridge running on a different port, such as 8080.
|
||||||
|
|
||||||
### Apache Example
|
### Apache Example
|
||||||
|
|
||||||
Reverse proxy with Apache on Ubuntu linux:
|
Reverse proxy with Apache on Ubuntu linux:
|
||||||
|
|
||||||
a2enmod proxy
|
Enable the required Apache modules:
|
||||||
a2enmod proxy_http
|
|
||||||
a2enmod headers
|
`a2enmod proxy proxy_http headers`
|
||||||
|
|
||||||
Added the following lines to my Apache config file “000-default”
|
Added the following lines to my Apache config file “000-default”
|
||||||
|
|
||||||
@@ -175,7 +174,10 @@ Added the following lines to my Apache config file “000-default”
|
|||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
```
|
```
|
||||||
|
|
||||||
service apache2 restart
|
Restart apache for the changes to take effect.
|
||||||
|
|
||||||
|
`service apache2 restart`
|
||||||
|
|
||||||
### lighthttpd Example
|
### lighthttpd Example
|
||||||
```
|
```
|
||||||
server.modules += ( "mod_proxy" )
|
server.modules += ( "mod_proxy" )
|
||||||
@@ -214,12 +216,12 @@ The default ip address for the bridge to listen on is all interfaces (0.0.0.0).
|
|||||||
java -jar -Dserver.ip=192.168.1.1 ha-bridge-W.X.Y.jar
|
java -jar -Dserver.ip=192.168.1.1 ha-bridge-W.X.Y.jar
|
||||||
```
|
```
|
||||||
### -Dsecurity.key=`<Your Key To Encrypt Security Data>`
|
### -Dsecurity.key=`<Your Key To Encrypt Security Data>`
|
||||||
The default security key is encoded into the Java code. The default should not be used as anyone with access to the code can decode your password. To override what the default , specify -Dsecurity.key=`<Your Key To Encrypt Security Data>` explicitly on the command line. This is will prevent any issues if your config file gets hacked. The command line example:
|
This option is very important to set if you will be using username/passwords to secure the ha-bridge. The ha-bridge needs to encrypt the settings in the config file and to make sure they are secured specifically to you is to provide this key. Otherwise a default key is used and it is available in the code on github for the ha-bridge here, so not very secure in that sense. **It is very important provide this if you are using username/password.** To override the default, specify -Dsecurity.key=`<Your Key To Encrypt Security Data>` explicitly on the command line. This is will prevent any issues if your config file gets hacked. The command line example:
|
||||||
```
|
```
|
||||||
java -jar -Dsecurity.key=Xfawer354WertSdf321234asd ha-bridge-W.X.Y.jar
|
java -jar -Dsecurity.key=Xfawer354WertSdf321234asd ha-bridge-W.X.Y.jar
|
||||||
```
|
```
|
||||||
### -Dexec.garden=`<The path to your scripts and program directory>`
|
### -Dexec.garden=`<The path to your scripts and program directory>`
|
||||||
The default exec garden path is not set which allows any program or script to be called. The default should not be used as anyone with access to the your system can create a exec command call and execute it from the api. To override what the default , specify -Dexec.garden=`<The path to your scripts and program directory>` explicitly on the command line. This is will prevent any issues if your system file gets hacked. The command line example:
|
This sets a directory of your choosing to have a walled area for what can be executed by the Exec Command type. This is a good feature to use if you use the capabilities of executing a script or program from the ha-bridge. The default is not set which allows any program or script to be called and anyone with access to the your system could create an exec command call and execute it from the API. This is will prevent any issues if your system gets hacked. To override the default, specify -Dexec.garden=`<The path to your scripts and program directory>` explicitly on the command line. The command line example:
|
||||||
```
|
```
|
||||||
java -jar -Dexec.garden=C:\Users\John\bin
|
java -jar -Dexec.garden=C:\Users\John\bin
|
||||||
```
|
```
|
||||||
@@ -241,7 +243,7 @@ This field is used to test the bridge server with the UPNP IP Address and to mak
|
|||||||
#### Bridge Control Buttons
|
#### Bridge Control Buttons
|
||||||
These buttons are for managing the bridge. The Save button is enabled when there is a change to the configuration. The Bridge Reinitialize button will recycle the internal running of the bridge in the java process. The Stop button will stop the java process. The Refresh button will refresh the page and settings.
|
These buttons are for managing the bridge. The Save button is enabled when there is a change to the configuration. The Bridge Reinitialize button will recycle the internal running of the bridge in the java process. The Stop button will stop the java process. The Refresh button will refresh the page and settings.
|
||||||
#### The Security Dialog
|
#### The Security Dialog
|
||||||
This is where you can set the different security settings for the ha-bridge. There are two settings, one for enabling Hue like operation to secure the Hue api with the internally generated user for the calls that are done after the link button. The other is to secure the hue api with a username/password that is created as well. The other fields are to add and delete users and to set and change passwords for those users. If there are no users in the system, the system will not require a username/password to operate.
|
This is where you can set the different security settings for the ha-bridge. There are two settings, one for enabling Hue like operation to secure the Hue API with the internally generated user for the calls that are done after the link button. The other is to secure the hue API with a username/password that is created as well. The other fields are to add and delete users and to set and change passwords for those users. If there are no users in the system, the system will not require a username/password to operate.
|
||||||
#### Configuration Path and File
|
#### Configuration Path and File
|
||||||
The default location for the configuration file to contain the settings for the bridge is the relative path from where the bridge is started in "data/habridge.config". If you would like a different filename or directory, specify `<directory>/<filename>` explicitly.
|
The default location for the configuration file to contain the settings for the bridge is the relative path from where the bridge is started in "data/habridge.config". If you would like a different filename or directory, specify `<directory>/<filename>` explicitly.
|
||||||
#### Device DB Path and File
|
#### Device DB Path and File
|
||||||
@@ -419,7 +421,7 @@ e.g.
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Also, you may want to use the REST API's listed below to configure your devices.
|
Also, you may want to use the REST APIs listed below to configure your devices.
|
||||||
## Ask Alexa
|
## Ask Alexa
|
||||||
After this Tell Alexa: "Alexa, discover my devices". If there is an issue you can go to the `Menu / Settings / Connected Home` for the echo on the mobile app or your browser and have Alexa forget all devices and then do the discovery again.
|
After this Tell Alexa: "Alexa, discover my devices". If there is an issue you can go to the `Menu / Settings / Connected Home` for the echo on the mobile app or your browser and have Alexa forget all devices and then do the discovery again.
|
||||||
|
|
||||||
@@ -429,16 +431,13 @@ Here is the table of items to use to tell Alexa what you want to do, this has ch
|
|||||||
|
|
||||||
To do this... | Say this...
|
To do this... | Say this...
|
||||||
--------------|------------
|
--------------|------------
|
||||||
ON Commands |
|
ON Commands | Alexa, turn on `<Device Name>`
|
||||||
| Alexa, turn on `<Device Name>`
|
OFF Commands | Alexa, turn off `<Device Name>`
|
||||||
OFF Commands |
|
DIM Commands | Alexa, brighten `<Device Name>` to `<Position>`
|
||||||
| Alexa, turn off `<Device Name>`
|
DIM Commands| Alexa, dim `<Device Name>` to `<Position>`
|
||||||
DIM Commands |
|
DIM Commands| Alexa, brighten `<Device Name>`
|
||||||
| Alexa, brighten `<Device Name>` to `<Position>`
|
DIM Commands| Alexa, dim `<Device Name>`
|
||||||
| Alexa, dim `<Device Name>` to `<Position>`
|
DIM Commands| Alexa, set `<Device Name>` to `<Position>`
|
||||||
| Alexa, brighten `<Device Name>`
|
|
||||||
| Alexa, dim `<Device Name>`
|
|
||||||
| Alexa, set `<Device Name>` to `<Position>`
|
|
||||||
|
|
||||||
To see what Alexa thinks you said, you can check in the home page for your Alexa.
|
To see what Alexa thinks you said, you can check in the home page for your Alexa.
|
||||||
|
|
||||||
@@ -447,6 +446,8 @@ To view or remove devices that Alexa knows about, you can use the mobile app `Me
|
|||||||
## Google Assistant
|
## Google Assistant
|
||||||
Google Home is supported as of v3.2.0 and forward, but only if the bridge is running on port 80.
|
Google Home is supported as of v3.2.0 and forward, but only if the bridge is running on port 80.
|
||||||
|
|
||||||
|
**ISSUE: Google Home now seems to not support local connection to Philips Hue Hubs and requires that it connect to meethue.com. Since the ha-bridge only emulates the local API, and is not associated with Philips, this method will not work. If you have an older Google Home application, this may still work. YMMV.**
|
||||||
|
|
||||||
Use the Google Home app on a phone to add new "home control" devices by going into `Settings / Home Control / +`
|
Use the Google Home app on a phone to add new "home control" devices by going into `Settings / Home Control / +`
|
||||||
as described [here](https://support.google.com/googlehome/answer/7124115?hl=en&ref_topic=7125624#homecontrol).
|
as described [here](https://support.google.com/googlehome/answer/7124115?hl=en&ref_topic=7125624#homecontrol).
|
||||||
Click on `Philips Hue` under the `Add new` section. If ha-bridge is on the same network as the
|
Click on `Philips Hue` under the `Add new` section. If ha-bridge is on the same network as the
|
||||||
@@ -477,7 +478,7 @@ New or removed devices are picked up automatically as soon as they are added/rem
|
|||||||
No re-discovery step is necessary.
|
No re-discovery step is necessary.
|
||||||
|
|
||||||
## Configuration REST API Usage
|
## Configuration REST API Usage
|
||||||
This section will describe the REST api available for configuration. The REST body examples are all formatted for easy reading, the actual body usage should be like this:
|
This section will describe the REST API available for configuration. The REST body examples are all formatted for easy reading, the actual body usage should be like this:
|
||||||
```
|
```
|
||||||
{"var1":"value1","var2":"value2","var3:"value3"}
|
{"var1":"value1","var2":"value2","var3:"value3"}
|
||||||
```
|
```
|
||||||
@@ -509,8 +510,8 @@ contentBodyOff | string | This is the content body that you would like to send w
|
|||||||
{
|
{
|
||||||
"name" : "bedroom light",
|
"name" : "bedroom light",
|
||||||
"deviceType" : "switch",
|
"deviceType" : "switch",
|
||||||
"onUrl" : [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=41","type":"veraDevice"}],
|
"onUrl" : "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=41\",\"type\":\"veraDevice\"}]",
|
||||||
"offUrl" : [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=41","type":"veraDevice"}]
|
"offUrl" : "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=41\",\"type\":\"veraDevice\"}]"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
#### Dimming Control Example
|
#### Dimming Control Example
|
||||||
@@ -520,8 +521,8 @@ e.g.
|
|||||||
{
|
{
|
||||||
"name": "entry light",
|
"name": "entry light",
|
||||||
"deviceType": "switch",
|
"deviceType": "switch",
|
||||||
"offUrl": [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=31","type":"veraDevice"}],
|
"offUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=31\",\"type\":\"veraDevice\"}]",
|
||||||
"onUrl": [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=31&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.percent}","type":"veraDevice"}]
|
"onUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=31&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.percent}\",\"type\":\"veraDevice\"}]"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
See the echo's documentation for the dimming phrase.
|
See the echo's documentation for the dimming phrase.
|
||||||
@@ -533,8 +534,8 @@ e.g.
|
|||||||
{
|
{
|
||||||
"name": "Thermostat,
|
"name": "Thermostat,
|
||||||
"deviceType": "custom",
|
"deviceType": "custom",
|
||||||
"offUrl": [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=10","type":"veraDevice"}],
|
"offUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=10\",\"type\":\"veraDevice\"}]",
|
||||||
"onUrl": [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=10&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.math(X/4)}","type":"veraDevice"}]
|
"onUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=10&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.math(X/4)}\",\"type\":\"veraDevice\"}]"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
See the echo's documentation for the dimming phrase.
|
See the echo's documentation for the dimming phrase.
|
||||||
@@ -546,8 +547,8 @@ e.g:
|
|||||||
{
|
{
|
||||||
"name": "test device",
|
"name": "test device",
|
||||||
"deviceType": "custom",
|
"deviceType": "custom",
|
||||||
"offUrl": [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=31","httpVerb":"POST","contentType" : "application/json","httpBody" : "{\"fooBar\":\"baz_off\"}],
|
"offUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=31\",\"httpVerb\":\"POST\",\"contentType\" : \"application/json\",\"httpBody\" : \"{\"fooBar\":\"baz_off\"}]",
|
||||||
"onUrl": [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=31&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.percent}","type":"httpDevice","httpVerb":"POST","contentType" : "application/json","httpBody" : "{\"fooBar\":\"baz_on\"}]
|
"onUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=31&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.percent}\",\"type\":\"httpDevice\",\"httpVerb\":\"POST\",\"contentType\" : \"application/json\",\"httpBody\" : \"{\"fooBar\":\"baz_on\"}]"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
#### Custom Usage URLs Example
|
#### Custom Usage URLs Example
|
||||||
@@ -556,8 +557,8 @@ Anything that takes an action as a result of an HTTP request will probably work
|
|||||||
{
|
{
|
||||||
"name": "night mode",
|
"name": "night mode",
|
||||||
"deviceType": ""custom",
|
"deviceType": ""custom",
|
||||||
"offUrl": [{"item":"http://192.168.1.201:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=SetHouseMode&Mode=1","type":"httpDevice"}],
|
"offUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=SetHouseMode&Mode=1\",\"type\":\"httpDevice\"}]",
|
||||||
"onUrl": [{"item":"http://192.168.1.201:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=SetHouseMode&Mode=3","type":"httpDevice"}]
|
"onUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=SetHouseMode&Mode=3\",\"type\":\"httpDevice\"}]"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Here is a UDP example that can send binary data.
|
Here is a UDP example that can send binary data.
|
||||||
@@ -565,8 +566,8 @@ Here is a UDP example that can send binary data.
|
|||||||
{
|
{
|
||||||
"name": "UDPPacket",
|
"name": "UDPPacket",
|
||||||
"deviceType": "custom",
|
"deviceType": "custom",
|
||||||
"offUrl": [{"item":"udp://192.168.1.1:8899/0x460055","type":"udpDevice"}],
|
"offUrl": "[{\"item\":\"udp://192.168.1.1:8899/0x460055\",\"type\":\"udpDevice\"}]",
|
||||||
"onUrl": [{"item":"udp://192.168.1.1:8899/0x450055","type":"udpDevice"}]
|
"onUrl": "[{\"item\":\"udp://192.168.1.1:8899/0x450055\",\"type\":\"udpDevice\"}]"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
#### Response
|
#### Response
|
||||||
@@ -625,8 +626,8 @@ contentBodyOff | string | This is the content body that you would like to send w
|
|||||||
"id" : "6789",
|
"id" : "6789",
|
||||||
"name" : "table light",
|
"name" : "table light",
|
||||||
"deviceType" : "switch",
|
"deviceType" : "switch",
|
||||||
"onUrl" : [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=41","type":"veraDevice"}],
|
"onUrl" : "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=41\",\"type\":\"veraDevice\"}]",
|
||||||
"offUrl" : [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=41","type":"veraDevice"}]
|
"offUrl" : "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=41\",\"type\":\"veraDevice\"}]"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
#### Response
|
#### Response
|
||||||
@@ -879,7 +880,7 @@ The example below is representative of some HUE device responses.
|
|||||||
|
|
||||||
Name | Type | Description
|
Name | Type | Description
|
||||||
-----|-------|-------------
|
-----|-------|-------------
|
||||||
device | HUE lights object | The HUE light detail descriptor, see api for lights response below.
|
device | HUE lights object | The HUE light detail descriptor, see API for lights response below.
|
||||||
huedeviceid | string | The id of the actual passthru HUE light id.
|
huedeviceid | string | The id of the actual passthru HUE light id.
|
||||||
hueaddress | string | The address of the target HUE bridge.
|
hueaddress | string | The address of the target HUE bridge.
|
||||||
huename | string | A name given to the target HUE bridge.
|
huename | string | A name given to the target HUE bridge.
|
||||||
@@ -888,7 +889,7 @@ huename | string | A name given to the target HUE bridge.
|
|||||||
[{"device":{"state":{"on":true,"bri":254,"hue":4444,"sat":254,"effect":"none","ct":0,"alert":"none","colormode":"hs","reachable":true,"xy":[0.0,0.0]},"type":"Extended color light","name":"Hue Lamp 1","modelid":"LCT001","uniqueid":"00:17:88:01:00:d4:12:08-0a","swversion":"65003148"},"huedeviceid":"1","hueaddress":"192.168.0.118:8000","huename":"HueEmul"},{"device":{"state":{"on":true,"bri":254,"hue":23536,"sat":144,"effect":"none","ct":201,"alert":"none","colormode":"hs","reachable":true,"xy":[0.346,0.3568]},"type":"Extended color light","name":"Hue Lamp 2","modelid":"LCT001","uniqueid":"00:17:88:01:00:d4:12:08-0b","swversion":"65003148"},"huedeviceid":"2","hueaddress":"192.168.0.118:8000","huename":"HueEmul"},{"device":{"state":{"on":true,"bri":254,"hue":65136,"sat":254,"effect":"none","ct":201,"alert":"none","colormode":"hs","reachable":true,"xy":[0.346,0.3568]},"type":"Extended color light","name":"Hue Lamp 3","modelid":"LCT001","uniqueid":"00:17:88:01:00:d4:12:08-0c","swversion":"65003148"},"huedeviceid":"3","hueaddress":"192.168.0.118:8000","huename":"HueEmul"}]
|
[{"device":{"state":{"on":true,"bri":254,"hue":4444,"sat":254,"effect":"none","ct":0,"alert":"none","colormode":"hs","reachable":true,"xy":[0.0,0.0]},"type":"Extended color light","name":"Hue Lamp 1","modelid":"LCT001","uniqueid":"00:17:88:01:00:d4:12:08-0a","swversion":"65003148"},"huedeviceid":"1","hueaddress":"192.168.0.118:8000","huename":"HueEmul"},{"device":{"state":{"on":true,"bri":254,"hue":23536,"sat":144,"effect":"none","ct":201,"alert":"none","colormode":"hs","reachable":true,"xy":[0.346,0.3568]},"type":"Extended color light","name":"Hue Lamp 2","modelid":"LCT001","uniqueid":"00:17:88:01:00:d4:12:08-0b","swversion":"65003148"},"huedeviceid":"2","hueaddress":"192.168.0.118:8000","huename":"HueEmul"},{"device":{"state":{"on":true,"bri":254,"hue":65136,"sat":254,"effect":"none","ct":201,"alert":"none","colormode":"hs","reachable":true,"xy":[0.346,0.3568]},"type":"Extended color light","name":"Hue Lamp 3","modelid":"LCT001","uniqueid":"00:17:88:01:00:d4:12:08-0c","swversion":"65003148"},"huedeviceid":"3","hueaddress":"192.168.0.118:8000","huename":"HueEmul"}]
|
||||||
```
|
```
|
||||||
## HUE REST API usage
|
## HUE REST API usage
|
||||||
This section will describe the REST api available for controlling the bridge based off of the HUE API. This Bridge does not support the full HUE API, only the calls that are supported with the HA Bridge are shown. The REST body examples are all formatted for easy reading, the actual body usage should be like this:
|
This section will describe the REST API available for controlling the bridge based off of the HUE API. This Bridge does not support the full HUE API, only the calls that are supported with the HA Bridge are shown. The REST body examples are all formatted for easy reading, the actual body usage should be like this:
|
||||||
```
|
```
|
||||||
{"var1":"value1","var2":"value2","var3:"value3"}
|
{"var1":"value1","var2":"value2","var3:"value3"}
|
||||||
```
|
```
|
||||||
@@ -997,7 +998,7 @@ A response to a successful PUT request contains confirmation of the arguments pa
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
### Update bridge internal light state
|
### Update bridge internal light state
|
||||||
Allows the user to set the internal state of the light on and off, modify the brightness. This is not a HUE API call and is special to the bridge as it keeps track of the state changes to the light from the api. It is intended to allow you to sync the bridge state with your HA system state.
|
Allows the user to set the internal state of the light on and off, modify the brightness. This is not a HUE API call and is special to the bridge as it keeps track of the state changes to the light from the API. It is intended to allow you to sync the bridge state with your HA system state.
|
||||||
```
|
```
|
||||||
PUT http://host:port/api/<username>/lights/<id>/bridgeupdatestate
|
PUT http://host:port/api/<username>/lights/<id>/bridgeupdatestate
|
||||||
```
|
```
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.bwssystems.HABridge</groupId>
|
<groupId>com.bwssystems.HABridge</groupId>
|
||||||
<artifactId>ha-bridge</artifactId>
|
<artifactId>ha-bridge</artifactId>
|
||||||
<version>4.5.0rc3</version>
|
<version>4.5.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HA Bridge</name>
|
<name>HA Bridge</name>
|
||||||
|
|||||||
@@ -212,26 +212,26 @@ public class BridgeSecurity {
|
|||||||
Iterator<String> userIterator = theUserIds.iterator();
|
Iterator<String> userIterator = theUserIds.iterator();
|
||||||
while (userIterator.hasNext()) {
|
while (userIterator.hasNext()) {
|
||||||
validUser = userIterator.next();
|
validUser = userIterator.next();
|
||||||
if (validUser.equals(aUser))
|
if (validUser.equals(aUser)) {
|
||||||
found = true;
|
found = true;
|
||||||
|
log.debug("validateWhitelistUser: found a user <" + aUser + ">");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!found && !strict) {
|
if(!found && !strict) {
|
||||||
|
log.debug("validateWhitelistUser: a user was not found and it is not strict rules <" + aUser + "> being created");
|
||||||
newWhitelistUser(aUser, userDescription);
|
newWhitelistUser(aUser, userDescription);
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
return HueErrorResponse.createResponse("1", "/api/" + aUser, "unauthorized user", null, null, null).getTheErrors();
|
log.debug("validateWhitelistUser: a user was not found and it is strict rules <" + aUser + ">");
|
||||||
|
return HueErrorResponse.createResponse("1", "/api/" + aUser == null ? "" : aUser, "unauthorized user", null, null, null).getTheErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
Object anUser = securityDescriptor.getWhitelist().remove(DEPRACATED_INTERNAL_USER);
|
|
||||||
if(anUser != null)
|
|
||||||
setSettingsChanged(true);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class HABridge {
|
|||||||
staticFileLocation("/public");
|
staticFileLocation("/public");
|
||||||
while(!bridgeSettings.getBridgeControl().isStop()) {
|
while(!bridgeSettings.getBridgeControl().isStop()) {
|
||||||
bridgeSettings.buildSettings();
|
bridgeSettings.buildSettings();
|
||||||
|
bridgeSettings.getBridgeSecurity().removeTestUsers();
|
||||||
log.info("HA Bridge initializing....");
|
log.info("HA Bridge initializing....");
|
||||||
// sparkjava config directive to set ip address for the web server to listen on
|
// sparkjava config directive to set ip address for the web server to listen on
|
||||||
ipAddress(bridgeSettings.getBridgeSettingsDescriptor().getWebaddress());
|
ipAddress(bridgeSettings.getBridgeSettingsDescriptor().getWebaddress());
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.bwssystems.HABridge.hue;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang3.Conversion;
|
import org.apache.commons.lang3.Conversion;
|
||||||
@@ -83,7 +84,7 @@ public class BrightnessDecode {
|
|||||||
replaceTarget = INTENSITY_PERCENT_HEX;
|
replaceTarget = INTENSITY_PERCENT_HEX;
|
||||||
notDone = true;
|
notDone = true;
|
||||||
} else if (request.contains(INTENSITY_DECIMAL_PERCENT)) {
|
} else if (request.contains(INTENSITY_DECIMAL_PERCENT)) {
|
||||||
replaceValue = String.format("%1.2f", decimalBrightness);
|
replaceValue = String.format(Locale.ROOT, "%1.2f", decimalBrightness);
|
||||||
replaceTarget = INTENSITY_DECIMAL_PERCENT;
|
replaceTarget = INTENSITY_DECIMAL_PERCENT;
|
||||||
notDone = true;
|
notDone = true;
|
||||||
} else if (request.contains(INTENSITY_MATH_CLOSE)) {
|
} else if (request.contains(INTENSITY_MATH_CLOSE)) {
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public class HueMulator {
|
|||||||
public void setupServer() {
|
public void setupServer() {
|
||||||
log.info("Hue emulator service started....");
|
log.info("Hue emulator service started....");
|
||||||
before(HUE_CONTEXT + "/*", (request, response) -> {
|
before(HUE_CONTEXT + "/*", (request, response) -> {
|
||||||
|
log.debug("HueMulator GET called on api/* with request <" + request.pathInfo() + ">");
|
||||||
if(bridgeSettingMaster.getBridgeSecurity().isSecure()) {
|
if(bridgeSettingMaster.getBridgeSecurity().isSecure()) {
|
||||||
String pathInfo = request.pathInfo();
|
String pathInfo = request.pathInfo();
|
||||||
if(pathInfo != null && pathInfo.contains(HUE_CONTEXT + "/devices")) {
|
if(pathInfo != null && pathInfo.contains(HUE_CONTEXT + "/devices")) {
|
||||||
@@ -118,6 +119,17 @@ public class HueMulator {
|
|||||||
log.debug("group add requested from " + request.ip() + " user " + request.params(":userid") + " with body " + request.body());
|
log.debug("group add requested from " + request.ip() + " user " + request.params(":userid") + " with body " + request.body());
|
||||||
return "[{\"success\":{\"id\":\"1\"}}]";
|
return "[{\"success\":{\"id\":\"1\"}}]";
|
||||||
});
|
});
|
||||||
|
// http://ip_address:port/api/:userid/groups/<groupid>/action
|
||||||
|
// Dummy handler
|
||||||
|
// Error forces Logitech Pop to fall back to individual light control
|
||||||
|
// instead of scene-based control.
|
||||||
|
put(HUE_CONTEXT + "/:userid/groups/:groupid/action", "application/json", (request, response) -> {
|
||||||
|
response.header("Access-Control-Allow-Origin", request.headers("Origin"));
|
||||||
|
response.type("application/json");
|
||||||
|
response.status(HttpStatus.SC_OK);
|
||||||
|
log.debug("put action to groups API from " + request.ip() + " user " + request.params(":userid") + " with body " + request.body());
|
||||||
|
return "[{\"error\":{\"address\": \"/groups/0/action/scene\", \"type\":7, \"description\": \"invalid value, dummy for parameter, scene\"}}]";
|
||||||
|
});
|
||||||
// http://ip_address:port/api/{userId}/scenes returns json objects of
|
// http://ip_address:port/api/{userId}/scenes returns json objects of
|
||||||
// all scenes configured
|
// all scenes configured
|
||||||
get(HUE_CONTEXT + "/:userid/scenes", "application/json", (request, response) -> {
|
get(HUE_CONTEXT + "/:userid/scenes", "application/json", (request, response) -> {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ public class HalDevice {
|
|||||||
private String haldevicename;
|
private String haldevicename;
|
||||||
private String haladdress;
|
private String haladdress;
|
||||||
private String halname;
|
private String halname;
|
||||||
|
private Boolean secure;
|
||||||
private DeviceElements buttons;
|
private DeviceElements buttons;
|
||||||
public String getHaldevicetype() {
|
public String getHaldevicetype() {
|
||||||
return haldevicetype;
|
return haldevicetype;
|
||||||
@@ -30,6 +31,12 @@ public class HalDevice {
|
|||||||
public void setHalname(String halname) {
|
public void setHalname(String halname) {
|
||||||
this.halname = halname;
|
this.halname = halname;
|
||||||
}
|
}
|
||||||
|
public Boolean getSecure() {
|
||||||
|
return secure;
|
||||||
|
}
|
||||||
|
public void setSecure(Boolean secure) {
|
||||||
|
this.secure = secure;
|
||||||
|
}
|
||||||
public DeviceElements getButtons() {
|
public DeviceElements getButtons() {
|
||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,14 @@ import com.bwssystems.HABridge.BridgeSettings;
|
|||||||
import com.bwssystems.HABridge.Home;
|
import com.bwssystems.HABridge.Home;
|
||||||
import com.bwssystems.HABridge.NamedIP;
|
import com.bwssystems.HABridge.NamedIP;
|
||||||
import com.bwssystems.HABridge.api.CallItem;
|
import com.bwssystems.HABridge.api.CallItem;
|
||||||
|
import com.bwssystems.HABridge.api.hue.HueError;
|
||||||
|
import com.bwssystems.HABridge.api.hue.HueErrorResponse;
|
||||||
import com.bwssystems.HABridge.dao.DeviceDescriptor;
|
import com.bwssystems.HABridge.dao.DeviceDescriptor;
|
||||||
|
import com.bwssystems.HABridge.hue.BrightnessDecode;
|
||||||
|
import com.bwssystems.HABridge.hue.DeviceDataDecode;
|
||||||
import com.bwssystems.HABridge.hue.MultiCommandUtil;
|
import com.bwssystems.HABridge.hue.MultiCommandUtil;
|
||||||
|
import com.bwssystems.HABridge.hue.TimeDecode;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
public class HalHome implements Home {
|
public class HalHome implements Home {
|
||||||
private static final Logger log = LoggerFactory.getLogger(HalHome.class);
|
private static final Logger log = LoggerFactory.getLogger(HalHome.class);
|
||||||
@@ -30,7 +36,7 @@ public class HalHome implements Home {
|
|||||||
public Object getItems(String type) {
|
public Object getItems(String type) {
|
||||||
if(!validHal)
|
if(!validHal)
|
||||||
return null;
|
return null;
|
||||||
log.debug("consolidating devices for hues");
|
log.debug("consolidating devices for HALs");
|
||||||
List<HalDevice> theResponse = null;
|
List<HalDevice> theResponse = null;
|
||||||
Iterator<String> keys = hals.keySet().iterator();
|
Iterator<String> keys = hals.keySet().iterator();
|
||||||
List<HalDevice> deviceList = new ArrayList<HalDevice>();
|
List<HalDevice> deviceList = new ArrayList<HalDevice>();
|
||||||
@@ -106,8 +112,41 @@ public class HalHome implements Home {
|
|||||||
@Override
|
@Override
|
||||||
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
||||||
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
||||||
// Not a device handler
|
String responseString = null;
|
||||||
return null;
|
String theUrl = anItem.getItem().getAsString();
|
||||||
|
if(theUrl != null && !theUrl.isEmpty () && theUrl.contains("http://")) {
|
||||||
|
String intermediate = theUrl.substring(theUrl.indexOf("://") + 3);
|
||||||
|
String hostPortion = intermediate.substring(0, intermediate.indexOf('/'));
|
||||||
|
// String theUrlBody = intermediate.substring(intermediate.indexOf('/') + 1);
|
||||||
|
String hostAddr = null;
|
||||||
|
// String port = null;
|
||||||
|
if (hostPortion.contains(":")) {
|
||||||
|
hostAddr = hostPortion.substring(0, intermediate.indexOf(':'));
|
||||||
|
// port = hostPortion.substring(intermediate.indexOf(':') + 1);
|
||||||
|
} else
|
||||||
|
hostAddr = hostPortion;
|
||||||
|
log.debug("executing HUE api request to Http "
|
||||||
|
+ (anItem.getHttpVerb() == null ? "GET" : anItem.getHttpVerb()) + ": "
|
||||||
|
+ anItem.getItem().getAsString());
|
||||||
|
|
||||||
|
String anUrl = BrightnessDecode.calculateReplaceIntensityValue(theUrl,
|
||||||
|
intensity, targetBri, targetBriInc, false);
|
||||||
|
anUrl = DeviceDataDecode.replaceDeviceData(anUrl, device);
|
||||||
|
anUrl = TimeDecode.replaceTimeValue(anUrl);
|
||||||
|
|
||||||
|
for (Map.Entry<String, HalInfo> entry : hals.entrySet())
|
||||||
|
{
|
||||||
|
if(entry.getValue().getHalAddress().getIp().equals(hostAddr)) {
|
||||||
|
if (entry.getValue().deviceCommand(anUrl) == null) {
|
||||||
|
log.warn("Error on calling hal to change device state: " + anUrl);
|
||||||
|
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
|
||||||
|
"Error on calling url to change device state", "/lights/"
|
||||||
|
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return responseString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -98,7 +98,11 @@ public class HalInfo {
|
|||||||
|
|
||||||
String theUrl = null;
|
String theUrl = null;
|
||||||
String theData;
|
String theData;
|
||||||
theUrl = "http://" + halAddress.getIp() + apiType + theToken;
|
if(halAddress.getSecure())
|
||||||
|
theUrl = "https://";
|
||||||
|
else
|
||||||
|
theUrl = "http://";
|
||||||
|
theUrl = theUrl + halAddress.getIp() + apiType + theToken;
|
||||||
theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
|
theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
|
||||||
if(theData != null) {
|
if(theData != null) {
|
||||||
log.debug("GET " + deviceType + " HalApiResponse - data: " + theData);
|
log.debug("GET " + deviceType + " HalApiResponse - data: " + theData);
|
||||||
@@ -123,6 +127,7 @@ public class HalInfo {
|
|||||||
aNewHalDevice.setHaldevicename(theDevice.getDeviceName());
|
aNewHalDevice.setHaldevicename(theDevice.getDeviceName());
|
||||||
aNewHalDevice.setHaladdress(halAddress.getIp());
|
aNewHalDevice.setHaladdress(halAddress.getIp());
|
||||||
aNewHalDevice.setHalname(halAddress.getName());
|
aNewHalDevice.setHalname(halAddress.getName());
|
||||||
|
aNewHalDevice.setSecure(halAddress.getSecure());
|
||||||
deviceList.add(aNewHalDevice);
|
deviceList.add(aNewHalDevice);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -145,7 +150,11 @@ public class HalInfo {
|
|||||||
deviceList = new ArrayList<HalDevice>();
|
deviceList = new ArrayList<HalDevice>();
|
||||||
while (theHalDevices.hasNext()) {
|
while (theHalDevices.hasNext()) {
|
||||||
HalDevice theHalDevice = theHalDevices.next();
|
HalDevice theHalDevice = theHalDevices.next();
|
||||||
theUrl = "http://" + halAddress.getIp() + IRBUTTON_REQUEST + TextStringFormatter.forQuerySpaceUrl(theHalDevice.getHaldevicename()) + TOKEN_REQUEST + theToken;
|
if(halAddress.getSecure())
|
||||||
|
theUrl = "https://";
|
||||||
|
else
|
||||||
|
theUrl = "http://";
|
||||||
|
theUrl = theUrl + halAddress.getIp() + IRBUTTON_REQUEST + TextStringFormatter.forQuerySpaceUrl(theHalDevice.getHaldevicename()) + TOKEN_REQUEST + theToken;
|
||||||
theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
|
theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
|
||||||
if (theData != null) {
|
if (theData != null) {
|
||||||
log.debug("GET IrData for IR Device " + theHalDevice.getHaldevicename() + " HalApiResponse - data: " + theData);
|
log.debug("GET IrData for IR Device " + theHalDevice.getHaldevicename() + " HalApiResponse - data: " + theData);
|
||||||
@@ -177,6 +186,12 @@ public class HalInfo {
|
|||||||
return deviceList;
|
return deviceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String deviceCommand(String theUrl) {
|
||||||
|
String theData = null;
|
||||||
|
theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
|
||||||
|
return theData;
|
||||||
|
}
|
||||||
|
|
||||||
public NamedIP getHalAddress() {
|
public NamedIP getHalAddress() {
|
||||||
return halAddress;
|
return halAddress;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -77,7 +77,7 @@ app.config (function ($locationProvider, $routeProvider) {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
app.run( async function ($rootScope, $location, Auth, bridgeService) {
|
app.run(function ($rootScope, $location, Auth, bridgeService) {
|
||||||
bridgeService.getHABridgeVersion();
|
bridgeService.getHABridgeVersion();
|
||||||
|
|
||||||
$rootScope.$on('securitySetupReceived', function(event, data) {
|
$rootScope.$on('securitySetupReceived', function(event, data) {
|
||||||
@@ -1285,11 +1285,11 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$scope.addHarmonytoSettings = function (newharmonyname, newharmonyip) {
|
$scope.addHarmonytoSettings = function (newharmonyname, newharmonyip, newharmonywebhook) {
|
||||||
if($scope.bridge.settings.harmonyaddress === undefined || $scope.bridge.settings.harmonyaddress === null) {
|
if($scope.bridge.settings.harmonyaddress === undefined || $scope.bridge.settings.harmonyaddress === null) {
|
||||||
$scope.bridge.settings.harmonyaddress = { devices: [] };
|
$scope.bridge.settings.harmonyaddress = { devices: [] };
|
||||||
}
|
}
|
||||||
var newharmony = {name: newharmonyname, ip: newharmonyip }
|
var newharmony = {name: newharmonyname, ip: newharmonyip, webhook: newharmonywebhook}
|
||||||
$scope.bridge.settings.harmonyaddress.devices.push(newharmony);
|
$scope.bridge.settings.harmonyaddress.devices.push(newharmony);
|
||||||
$scope.newharmonyname = null;
|
$scope.newharmonyname = null;
|
||||||
$scope.newharmonyip = null;
|
$scope.newharmonyip = null;
|
||||||
@@ -3383,7 +3383,6 @@ app.controller('LoginController', function ($scope, $location, Auth) {
|
|||||||
$scope.logout = function() {
|
$scope.logout = function() {
|
||||||
Auth.logout();
|
Auth.logout();
|
||||||
$scope.loggedIn = Auth.isLoggedIn();
|
$scope.loggedIn = Auth.isLoggedIn();
|
||||||
bridgeService.displaySuccess("User Logged Out");
|
|
||||||
$location.path("/login");
|
$location.path("/login");
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
type="text" ng-model="newUser"
|
type="text" ng-model="newUser"
|
||||||
placeholder="someone" nu-check="new-user" />
|
placeholder="someone" nu-check="new-user" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div ng-if="isSecure" class="form-group">
|
||||||
<button type="button" class="btn btn-danger" ng-click="delUser(newUser)">Delete</button>
|
<button type="button" class="btn btn-danger" ng-click="delUser(newUser)">Delete</button>
|
||||||
</div>
|
</div>
|
||||||
<div ng-if="showPassword" postrender-action="setBlankPassword('password-1')">
|
<div ng-if="showPassword" postrender-action="setBlankPassword('password-1')">
|
||||||
|
|||||||
@@ -147,7 +147,7 @@
|
|||||||
<td>{{harmony.ip}}</td>
|
<td>{{harmony.ip}}</td>
|
||||||
<td>{{harmony.webhook}}</td>
|
<td>{{harmony.webhook}}</td>
|
||||||
<td><button class="btn btn-danger" type="submit"
|
<td><button class="btn btn-danger" type="submit"
|
||||||
ng-click="removeHarmonytoSettings(harmony.name, harmony.ip, harmony.webhook)">Del</button></td>
|
ng-click="removeHarmonytoSettings(harmony.name, harmony.ip)">Del</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><input id="bridge-settings-next-harmony-name"
|
<td><input id="bridge-settings-next-harmony-name"
|
||||||
@@ -201,12 +201,14 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>IP</th>
|
<th>IP</th>
|
||||||
|
<th>Use SSL</th>
|
||||||
<th>Manage</th>
|
<th>Manage</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tr ng-repeat="hal in bridge.settings.haladdress.devices">
|
<tr ng-repeat="hal in bridge.settings.haladdress.devices">
|
||||||
<td>{{hal.name}}</td>
|
<td>{{hal.name}}</td>
|
||||||
<td>{{hal.ip}}</td>
|
<td>{{hal.ip}}</td>
|
||||||
|
<td>{{hal.secure}}</td>
|
||||||
<td><button class="btn btn-danger" type="submit"
|
<td><button class="btn btn-danger" type="submit"
|
||||||
ng-click="removeHaltoSettings(hal.name, hal.ip)">Del</button></td>
|
ng-click="removeHaltoSettings(hal.name, hal.ip)">Del</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -217,8 +219,11 @@
|
|||||||
<td><input id="bridge-settings-next-hal-ip"
|
<td><input id="bridge-settings-next-hal-ip"
|
||||||
class="form-control" type="text" ng-model="newhalip"
|
class="form-control" type="text" ng-model="newhalip"
|
||||||
placeholder="192.168.1.3:82"></td>
|
placeholder="192.168.1.3:82"></td>
|
||||||
|
<td><input type="checkbox"
|
||||||
|
ng-model="newhalsecure" ng-true-value=true
|
||||||
|
ng-false-value=false></td>
|
||||||
<td><button class="btn btn-success" type="submit"
|
<td><button class="btn btn-success" type="submit"
|
||||||
ng-click="addHaltoSettings(newhalname, newhalip)">Add</button></td>
|
ng-click="addHaltoSettings(newhalname, newhalip, newhalsecure)">Add</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table></td>
|
</table></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user