mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 16:17:30 +00:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78d39325b0 | ||
|
|
208b1cad2a | ||
|
|
998450af4e | ||
|
|
d78c7c536d | ||
|
|
fb9cc64839 | ||
|
|
409c93bfb2 | ||
|
|
543a79bb66 | ||
|
|
16d1054b96 | ||
|
|
165b6ef9bb | ||
|
|
fb94b858f6 | ||
|
|
ea80925533 | ||
|
|
62b896ee07 | ||
|
|
8657ea6704 | ||
|
|
05bd6b6d77 | ||
|
|
19256e4eaa | ||
|
|
905f6aa9ec | ||
|
|
daa0dac5b9 | ||
|
|
0478fc69f4 | ||
|
|
b99e74823c | ||
|
|
ebeb6be7a7 | ||
|
|
d3979da2b4 | ||
|
|
f276f66991 | ||
|
|
3ac5c10f08 | ||
|
|
13c84ba174 |
103
README.md
103
README.md
@@ -1,5 +1,5 @@
|
||||
# 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.
|
||||
|
||||
@@ -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.**
|
||||
|
||||
**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**
|
||||
|
||||
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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
```
|
||||
java -jar ha-bridge-4.5.0.jar
|
||||
java -jar ha-bridge-4.5.1.jar
|
||||
```
|
||||
### 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
|
||||
|
||||
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:~ $ cd habridge
|
||||
|
||||
pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v4.5.0/ha-bridge-4.5.0.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
|
||||
pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v4.5.1/ha-bridge-4.5.1.jar
|
||||
```
|
||||
|
||||
#### 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
|
||||
|
||||
@@ -95,7 +92,7 @@ After=network.target
|
||||
[Service]
|
||||
Type=simple
|
||||
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]
|
||||
WantedBy=multi-user.target
|
||||
@@ -130,7 +127,7 @@ Then cut and past this, modify any locations that are not correct
|
||||
```
|
||||
cd /home/pi/habridge
|
||||
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
|
||||
```
|
||||
@@ -148,12 +145,14 @@ pi@raspberrypi:~/habridge $ tail -f habridge-log.txt
|
||||
```
|
||||
## 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.
|
||||
|
||||
### Apache Example
|
||||
|
||||
Reverse proxy with Apache on Ubuntu linux:
|
||||
|
||||
a2enmod proxy
|
||||
a2enmod proxy_http
|
||||
a2enmod headers
|
||||
Enable the required Apache modules:
|
||||
|
||||
`a2enmod proxy proxy_http headers`
|
||||
|
||||
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>
|
||||
```
|
||||
|
||||
service apache2 restart
|
||||
Restart apache for the changes to take effect.
|
||||
|
||||
`service apache2 restart`
|
||||
|
||||
### lighthttpd Example
|
||||
```
|
||||
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
|
||||
```
|
||||
### -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
|
||||
```
|
||||
### -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
|
||||
```
|
||||
@@ -241,13 +243,15 @@ This field is used to test the bridge server with the UPNP IP Address and to mak
|
||||
#### 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.
|
||||
#### 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
|
||||
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
|
||||
The default location for the db to contain the devices as they are added is "data/devices.db". If you would like a different filename or directory, specify `<directory>/<filename> explicitly.
|
||||
#### UPNP IP Address
|
||||
The server defaults to the first available address on the host if this is not given. This default may NOT be the correct IP that is your public IP for your host on the network. It is best to set this parameter to not have discovery issues. Replace this value with the server ipv4 address you would like to use as the address that any upnp device will call after discovery.
|
||||
#### Use UPNP Address Interface
|
||||
The server tries to bind to all interfaces to respond to UPNP request. Setting this to `true` will make the binding to the interface that has the `UPNP IP Address`. The default is to be all interfaces which is set as false.
|
||||
#### Web Server IP Address
|
||||
The server defaults to all interfaces on the machine (0.0.0.0). Replace this value with the server ipv4 address you would like to use as the address that will bind to a specific ip address on an interface if you would like. This is only necessary if you want to isolate how access is handled to the web UI.
|
||||
#### Web Server Port
|
||||
@@ -406,7 +410,7 @@ You can control items that require special calculated values using ${intensity.m
|
||||
|
||||
For the items that want to have a date time put into the message, utilize ${time.format(yyyy-MM-ddTHH:mm:ssXXX)} where "yyyy-MM-ddTHH:mm:ssXXX" can be any format from the Java SimpleDateFormat documented here: https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
|
||||
|
||||
Also, device data can be inserted into your payloads by the use of "${device.name}", "${device.id}", "${device.uniqueid}", "${device.targetDevice}", "${device.mapId}", "${device.mapType}" and "${device.deviceType}". These work just like the dimming value replacements.
|
||||
Also, device data can be inserted into your payloads by the use of "${device.name}", "${device.id}", "${device.uniqueid}", "${device.targetDevice}", "${device.mapId}", "${device.mapType}", "${device.deviceType}", "${device.requesterAddress}", "${device.description}" and "${device.comments}". These work just like the dimming value replacements.
|
||||
e.g.
|
||||
```
|
||||
[{"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":"httpDevice"}]
|
||||
@@ -419,7 +423,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
|
||||
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 +433,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...
|
||||
--------------|------------
|
||||
ON Commands |
|
||||
| Alexa, turn on `<Device Name>`
|
||||
OFF Commands |
|
||||
| Alexa, turn off `<Device Name>`
|
||||
DIM Commands |
|
||||
| Alexa, brighten `<Device Name>` to `<Position>`
|
||||
| Alexa, dim `<Device Name>` to `<Position>`
|
||||
| Alexa, brighten `<Device Name>`
|
||||
| Alexa, dim `<Device Name>`
|
||||
| Alexa, set `<Device Name>` to `<Position>`
|
||||
ON Commands | Alexa, turn on `<Device Name>`
|
||||
OFF Commands | Alexa, turn off `<Device Name>`
|
||||
DIM Commands | Alexa, brighten `<Device Name>` to `<Position>`
|
||||
DIM Commands| Alexa, dim `<Device Name>` to `<Position>`
|
||||
DIM Commands| Alexa, brighten `<Device Name>`
|
||||
DIM Commands| Alexa, dim `<Device Name>`
|
||||
DIM Commands| Alexa, set `<Device Name>` to `<Position>`
|
||||
|
||||
To see what Alexa thinks you said, you can check in the home page for your Alexa.
|
||||
|
||||
@@ -447,6 +448,8 @@ To view or remove devices that Alexa knows about, you can use the mobile app `Me
|
||||
## Google Assistant
|
||||
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 / +`
|
||||
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
|
||||
@@ -477,7 +480,7 @@ New or removed devices are picked up automatically as soon as they are added/rem
|
||||
No re-discovery step is necessary.
|
||||
|
||||
## 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"}
|
||||
```
|
||||
@@ -509,8 +512,8 @@ contentBodyOff | string | This is the content body that you would like to send w
|
||||
{
|
||||
"name" : "bedroom light",
|
||||
"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"}],
|
||||
"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"}]
|
||||
"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\"}]"
|
||||
}
|
||||
```
|
||||
#### Dimming Control Example
|
||||
@@ -520,8 +523,8 @@ e.g.
|
||||
{
|
||||
"name": "entry light",
|
||||
"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"}],
|
||||
"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"}]
|
||||
"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\"}]"
|
||||
}
|
||||
```
|
||||
See the echo's documentation for the dimming phrase.
|
||||
@@ -533,8 +536,8 @@ e.g.
|
||||
{
|
||||
"name": "Thermostat,
|
||||
"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"}],
|
||||
"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"}]
|
||||
"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\"}]"
|
||||
}
|
||||
```
|
||||
See the echo's documentation for the dimming phrase.
|
||||
@@ -546,8 +549,8 @@ e.g:
|
||||
{
|
||||
"name": "test device",
|
||||
"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\"}],
|
||||
"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\"}]
|
||||
"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\"}]"
|
||||
}
|
||||
```
|
||||
#### Custom Usage URLs Example
|
||||
@@ -556,8 +559,8 @@ Anything that takes an action as a result of an HTTP request will probably work
|
||||
{
|
||||
"name": "night mode",
|
||||
"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"}],
|
||||
"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"}]
|
||||
"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\"}]"
|
||||
}
|
||||
```
|
||||
Here is a UDP example that can send binary data.
|
||||
@@ -565,8 +568,8 @@ Here is a UDP example that can send binary data.
|
||||
{
|
||||
"name": "UDPPacket",
|
||||
"deviceType": "custom",
|
||||
"offUrl": [{"item":"udp://192.168.1.1:8899/0x460055","type":"udpDevice"}],
|
||||
"onUrl": [{"item":"udp://192.168.1.1:8899/0x450055","type":"udpDevice"}]
|
||||
"offUrl": "[{\"item\":\"udp://192.168.1.1:8899/0x460055\",\"type\":\"udpDevice\"}]",
|
||||
"onUrl": "[{\"item\":\"udp://192.168.1.1:8899/0x450055\",\"type\":\"udpDevice\"}]"
|
||||
}
|
||||
```
|
||||
#### Response
|
||||
@@ -625,8 +628,8 @@ contentBodyOff | string | This is the content body that you would like to send w
|
||||
"id" : "6789",
|
||||
"name" : "table light",
|
||||
"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"}],
|
||||
"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"}]
|
||||
"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\"}]"
|
||||
}
|
||||
```
|
||||
#### Response
|
||||
@@ -879,7 +882,7 @@ The example below is representative of some HUE device responses.
|
||||
|
||||
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.
|
||||
hueaddress | string | The address of the target HUE bridge.
|
||||
huename | string | A name given to the target HUE bridge.
|
||||
@@ -888,7 +891,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"}]
|
||||
```
|
||||
## 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"}
|
||||
```
|
||||
@@ -997,7 +1000,7 @@ A response to a successful PUT request contains confirmation of the arguments pa
|
||||
]
|
||||
```
|
||||
### 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
|
||||
```
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.bwssystems.HABridge</groupId>
|
||||
<artifactId>ha-bridge</artifactId>
|
||||
<version>4.5.0rc2</version>
|
||||
<version>4.5.5</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HA Bridge</name>
|
||||
|
||||
@@ -5,6 +5,12 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
@@ -15,6 +21,9 @@ import javax.crypto.spec.PBEParameterSpec;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.bwssystems.HABridge.api.hue.HueError;
|
||||
import com.bwssystems.HABridge.api.hue.HueErrorResponse;
|
||||
import com.bwssystems.HABridge.api.hue.WhitelistEntry;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
@@ -23,6 +32,8 @@ import spark.Request;
|
||||
public class BridgeSecurity {
|
||||
private static final Logger log = LoggerFactory.getLogger(BridgeSecurity.class);
|
||||
private static final String USER_SESSION_ID = "user";
|
||||
private static final String DEPRACATED_INTERNAL_USER = "thehabridgeuser";
|
||||
private static final String TEST_USER_TYPE = "test_ha_bridge";
|
||||
private static final byte[] SALT = {
|
||||
(byte) 0xde, (byte) 0x33, (byte) 0x10, (byte) 0x12,
|
||||
(byte) 0xde, (byte) 0x33, (byte) 0x10, (byte) 0x12,
|
||||
@@ -191,6 +202,91 @@ public class BridgeSecurity {
|
||||
this.settingsChanged = settingsChanged;
|
||||
}
|
||||
|
||||
public HueError[] validateWhitelistUser(String aUser, String userDescription, boolean strict) {
|
||||
String validUser = null;
|
||||
boolean found = false;
|
||||
if (aUser != null && !aUser.equalsIgnoreCase("undefined") && !aUser.equalsIgnoreCase("null")
|
||||
&& !aUser.equalsIgnoreCase("")) {
|
||||
if (securityDescriptor.getWhitelist() != null) {
|
||||
Set<String> theUserIds = securityDescriptor.getWhitelist().keySet();
|
||||
Iterator<String> userIterator = theUserIds.iterator();
|
||||
while (userIterator.hasNext()) {
|
||||
validUser = userIterator.next();
|
||||
if (validUser.equals(aUser)) {
|
||||
found = true;
|
||||
log.debug("validateWhitelistUser: found a user <" + aUser + ">");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!found && !strict) {
|
||||
log.debug("validateWhitelistUser: a user was not found and it is not strict rules <" + aUser + "> being created");
|
||||
newWhitelistUser(aUser, userDescription);
|
||||
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
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();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void newWhitelistUser(String aUser, String userDescription) {
|
||||
if(aUser.equals(DEPRACATED_INTERNAL_USER))
|
||||
return;
|
||||
if (securityDescriptor.getWhitelist() == null) {
|
||||
securityDescriptor.setWhitelist(new HashMap<>());
|
||||
}
|
||||
if(userDescription == null)
|
||||
userDescription = "auto insert user";
|
||||
|
||||
securityDescriptor.getWhitelist().put(aUser, WhitelistEntry.createEntry(userDescription));
|
||||
setSettingsChanged(true);
|
||||
}
|
||||
|
||||
public String createWhitelistUser(String userDescription) {
|
||||
String aUser = getNewUserID();
|
||||
newWhitelistUser(aUser, userDescription);
|
||||
return aUser;
|
||||
}
|
||||
|
||||
public void convertWhitelist(Map<String, WhitelistEntry> whitelist) {
|
||||
securityDescriptor.setWhitelist(whitelist);
|
||||
}
|
||||
|
||||
private String getNewUserID() {
|
||||
UUID uid = UUID.randomUUID();
|
||||
StringTokenizer st = new StringTokenizer(uid.toString(), "-");
|
||||
String newUser = "";
|
||||
while (st.hasMoreTokens()) {
|
||||
newUser = newUser + st.nextToken();
|
||||
}
|
||||
|
||||
return newUser;
|
||||
}
|
||||
|
||||
public void removeTestUsers() {
|
||||
if (securityDescriptor.getWhitelist() != null) {
|
||||
Object anUser = securityDescriptor.getWhitelist().remove(DEPRACATED_INTERNAL_USER);
|
||||
if(anUser != null)
|
||||
setSettingsChanged(true);
|
||||
|
||||
Iterator<Entry<String, WhitelistEntry>> it = securityDescriptor.getWhitelist().entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, WhitelistEntry> pair = it.next();
|
||||
it.remove(); // avoids a ConcurrentModificationException
|
||||
if(pair.getValue().getName().equals(TEST_USER_TYPE)) {
|
||||
securityDescriptor.getWhitelist().remove(pair.getKey());
|
||||
setSettingsChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String encrypt(String property) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
|
||||
SecretKey key = keyFactory.generateSecret(new PBEKeySpec(habridgeKey));
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.bwssystems.HABridge;
|
||||
|
||||
import java.util.Map;
|
||||
import com.bwssystems.HABridge.api.hue.WhitelistEntry;
|
||||
|
||||
public class BridgeSecurityDescriptor {
|
||||
private Map<String, User> users;
|
||||
private boolean useLinkButton;
|
||||
private String execGarden;
|
||||
private boolean secureHueApi;
|
||||
private Map<String, WhitelistEntry> whitelist;
|
||||
|
||||
public BridgeSecurityDescriptor() {
|
||||
super();
|
||||
@@ -44,6 +46,12 @@ public class BridgeSecurityDescriptor {
|
||||
public void setSecureHueApi(boolean secureHueApi) {
|
||||
this.secureHueApi = secureHueApi;
|
||||
}
|
||||
public Map<String, WhitelistEntry> getWhitelist() {
|
||||
return whitelist;
|
||||
}
|
||||
public void setWhitelist(Map<String, WhitelistEntry> whitelist) {
|
||||
this.whitelist = whitelist;
|
||||
}
|
||||
|
||||
public boolean isSecure() {
|
||||
boolean secureFlag = false;
|
||||
|
||||
@@ -12,6 +12,8 @@ import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -29,6 +31,7 @@ public class BridgeSettings extends BackupHandler {
|
||||
private BridgeSettingsDescriptor theBridgeSettings;
|
||||
private BridgeControlDescriptor bridgeControl;
|
||||
private BridgeSecurity bridgeSecurity;
|
||||
private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
|
||||
|
||||
public BridgeSettings() {
|
||||
super();
|
||||
@@ -55,6 +58,10 @@ public class BridgeSettings extends BackupHandler {
|
||||
public BridgeSecurity getBridgeSecurity() {
|
||||
return bridgeSecurity;
|
||||
}
|
||||
public static String getCurrentDate() {
|
||||
return dateFormat.format(new Date());
|
||||
}
|
||||
|
||||
public void buildSettings() {
|
||||
String addressString = null;
|
||||
String theVeraAddress = null;
|
||||
@@ -140,7 +147,7 @@ public class BridgeSettings extends BackupHandler {
|
||||
theBridgeSettings.setNestpwd(System.getProperty("nest.pwd"));
|
||||
}
|
||||
|
||||
if(theBridgeSettings.getUpnpConfigAddress() == null || theBridgeSettings.getUpnpConfigAddress().equals("")) {
|
||||
if(theBridgeSettings.getUpnpConfigAddress() == null || theBridgeSettings.getUpnpConfigAddress().trim().equals("") || theBridgeSettings.getUpnpConfigAddress().trim().equals("0.0.0.0")) {
|
||||
addressString = checkIpAddress(null, true);
|
||||
if(addressString != null) {
|
||||
theBridgeSettings.setUpnpConfigAddress(addressString);
|
||||
@@ -187,6 +194,11 @@ public class BridgeSettings extends BackupHandler {
|
||||
setupParams(Paths.get(theBridgeSettings.getConfigfile()), ".cfgbk", "habridge.config-");
|
||||
|
||||
bridgeSecurity.setSecurityData(theBridgeSettings.getSecurityData());
|
||||
if(theBridgeSettings.getWhitelist() != null) {
|
||||
bridgeSecurity.convertWhitelist(theBridgeSettings.getWhitelist());
|
||||
theBridgeSettings.removeWhitelist();
|
||||
updateConfigFile();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadConfig() {
|
||||
@@ -219,11 +231,11 @@ public class BridgeSettings extends BackupHandler {
|
||||
try {
|
||||
newBridgeSettings.setSecurityData(bridgeSecurity.getSecurityDescriptorData());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.warn("could not get encoded security data: " + e.getMessage());
|
||||
return;
|
||||
} catch (GeneralSecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
log.warn("could not get encoded security data: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
bridgeSecurity.setSettingsChanged(false);
|
||||
}
|
||||
@@ -237,6 +249,18 @@ public class BridgeSettings extends BackupHandler {
|
||||
log.debug("Save HA Bridge settings.");
|
||||
Path configPath = Paths.get(theBridgeSettings.getConfigfile());
|
||||
JsonTransformer aRenderer = new JsonTransformer();
|
||||
if(bridgeSecurity.isSettingsChanged()) {
|
||||
try {
|
||||
theBridgeSettings.setSecurityData(bridgeSecurity.getSecurityDescriptorData());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
log.warn("could not get encoded security data: " + e.getMessage());
|
||||
return;
|
||||
} catch (GeneralSecurityException e) {
|
||||
log.warn("could not get encoded security data: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
bridgeSecurity.setSettingsChanged(false);
|
||||
}
|
||||
String jsonValue = aRenderer.render(theBridgeSettings);
|
||||
configWriter(jsonValue, configPath);
|
||||
_loadConfig(configPath);
|
||||
@@ -260,7 +284,7 @@ public class BridgeSettings extends BackupHandler {
|
||||
try {
|
||||
Path target = null;
|
||||
if(Files.exists(filePath)) {
|
||||
target = FileSystems.getDefault().getPath(filePath.getParent().toString(), "habridge.config.old");
|
||||
target = FileSystems.getDefault().getPath(filePath.getParent().toString(), "habridge.config.old." + getCurrentDate());
|
||||
Files.move(filePath, target);
|
||||
}
|
||||
Files.write(filePath, content.getBytes(), StandardOpenOption.CREATE);
|
||||
@@ -310,6 +334,7 @@ public class BridgeSettings extends BackupHandler {
|
||||
log.error("checkIpAddress cannot get ip address of this host, Exiting with message: " + e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
|
||||
String addressString = null;
|
||||
InetAddress address = null;
|
||||
while (ifs.hasMoreElements() && addressString == null) {
|
||||
|
||||
@@ -1,63 +1,113 @@
|
||||
package com.bwssystems.HABridge;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.UUID;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import com.bwssystems.HABridge.api.hue.HueConstants;
|
||||
import com.bwssystems.HABridge.api.hue.HueError;
|
||||
import com.bwssystems.HABridge.api.hue.HueErrorResponse;
|
||||
import com.bwssystems.HABridge.api.hue.WhitelistEntry;
|
||||
|
||||
public class BridgeSettingsDescriptor {
|
||||
private static final String DEPRACATED_INTERNAL_USER = "thehabridgeuser";
|
||||
private static final String TEST_USER_TYPE = "test_ha_bridge";
|
||||
@SerializedName("upnpconfigaddress")
|
||||
@Expose
|
||||
private String upnpconfigaddress;
|
||||
@SerializedName("useupnpiface")
|
||||
@Expose
|
||||
private boolean useupnpiface;
|
||||
@SerializedName("serverport")
|
||||
@Expose
|
||||
private Integer serverport;
|
||||
@SerializedName("upnpresponseport")
|
||||
@Expose
|
||||
private Integer upnpresponseport;
|
||||
@SerializedName("upnpdevicedb")
|
||||
@Expose
|
||||
private String upnpdevicedb;
|
||||
@SerializedName("veraaddress")
|
||||
@Expose
|
||||
private IpList veraaddress;
|
||||
@SerializedName("harmonyaddress")
|
||||
@Expose
|
||||
private IpList harmonyaddress;
|
||||
@SerializedName("buttonsleep")
|
||||
@Expose
|
||||
private Integer buttonsleep;
|
||||
@SerializedName("upnpstrict")
|
||||
@Expose
|
||||
private boolean upnpstrict;
|
||||
@SerializedName("traceupnp")
|
||||
@Expose
|
||||
private boolean traceupnp;
|
||||
@SerializedName("nestuser")
|
||||
@Expose
|
||||
private String nestuser;
|
||||
@SerializedName("nestpwd")
|
||||
@Expose
|
||||
private String nestpwd;
|
||||
@SerializedName("farenheit")
|
||||
@Expose
|
||||
private boolean farenheit;
|
||||
@SerializedName("configfile")
|
||||
@Expose
|
||||
private String configfile;
|
||||
@SerializedName("numberoflogmessages")
|
||||
@Expose
|
||||
private Integer numberoflogmessages;
|
||||
@SerializedName("hueaddress")
|
||||
@Expose
|
||||
private IpList hueaddress;
|
||||
@SerializedName("haladdress")
|
||||
@Expose
|
||||
private IpList haladdress;
|
||||
@SerializedName("haltoken")
|
||||
@Expose
|
||||
private String haltoken;
|
||||
@SerializedName("whitelist")
|
||||
@Expose
|
||||
private Map<String, WhitelistEntry> whitelist;
|
||||
@SerializedName("myechourl")
|
||||
@Expose
|
||||
private String myechourl;
|
||||
@SerializedName("webaddress")
|
||||
@Expose
|
||||
private String webaddress;
|
||||
@SerializedName("mqttaddress")
|
||||
@Expose
|
||||
private IpList mqttaddress;
|
||||
@SerializedName("hassaddress")
|
||||
@Expose
|
||||
private IpList hassaddress;
|
||||
@SerializedName("domoticzaddress")
|
||||
@Expose
|
||||
private IpList domoticzaddress;
|
||||
@SerializedName("somfyaddress")
|
||||
@Expose
|
||||
private IpList somfyaddress;
|
||||
@SerializedName("hubversion")
|
||||
@Expose
|
||||
private String hubversion;
|
||||
@SerializedName("securityData")
|
||||
@Expose
|
||||
private String securityData;
|
||||
|
||||
|
||||
private boolean settingsChanged;
|
||||
private boolean veraconfigured;
|
||||
private boolean harmonyconfigured;
|
||||
private boolean nestconfigured;
|
||||
private boolean farenheit;
|
||||
private String configfile;
|
||||
private Integer numberoflogmessages;
|
||||
private IpList hueaddress;
|
||||
private boolean hueconfigured;
|
||||
private IpList haladdress;
|
||||
private String haltoken;
|
||||
private boolean nestconfigured;
|
||||
private boolean halconfigured;
|
||||
private Map<String, WhitelistEntry> whitelist;
|
||||
private boolean settingsChanged;
|
||||
private String myechourl;
|
||||
private String webaddress;
|
||||
private IpList mqttaddress;
|
||||
private boolean mqttconfigured;
|
||||
private IpList hassaddress;
|
||||
private boolean hassconfigured;
|
||||
private String hubversion;
|
||||
private IpList domoticzaddress;
|
||||
private boolean domoticzconfigured;
|
||||
private IpList somfyaddress;
|
||||
private boolean somfyconfigured;
|
||||
private boolean lifxconfigured;
|
||||
private String securityData;
|
||||
|
||||
public BridgeSettingsDescriptor() {
|
||||
super();
|
||||
this.upnpstrict = true;
|
||||
this.useupnpiface = false;
|
||||
this.traceupnp = false;
|
||||
this.nestconfigured = false;
|
||||
this.veraconfigured = false;
|
||||
@@ -67,8 +117,12 @@ public class BridgeSettingsDescriptor {
|
||||
this.halconfigured = false;
|
||||
this.mqttconfigured = false;
|
||||
this.hassconfigured = false;
|
||||
this.domoticzconfigured = false;
|
||||
this.somfyconfigured = false;
|
||||
this.lifxconfigured = false;
|
||||
this.farenheit = true;
|
||||
this.whitelist = null;
|
||||
this.securityData = null;
|
||||
this.settingsChanged = false;
|
||||
this.myechourl = "echo.amazon.com/#cards";
|
||||
this.webaddress = "0.0.0.0";
|
||||
@@ -80,6 +134,12 @@ public class BridgeSettingsDescriptor {
|
||||
public void setUpnpConfigAddress(String upnpConfigAddress) {
|
||||
this.upnpconfigaddress = upnpConfigAddress;
|
||||
}
|
||||
public boolean isUseupnpiface() {
|
||||
return useupnpiface;
|
||||
}
|
||||
public void setUseupnpiface(boolean useupnpiface) {
|
||||
this.useupnpiface = useupnpiface;
|
||||
}
|
||||
public Integer getServerPort() {
|
||||
return serverport;
|
||||
}
|
||||
@@ -227,8 +287,8 @@ public class BridgeSettingsDescriptor {
|
||||
public Map<String, WhitelistEntry> getWhitelist() {
|
||||
return whitelist;
|
||||
}
|
||||
public void setWhitelist(Map<String, WhitelistEntry> whitelist) {
|
||||
this.whitelist = whitelist;
|
||||
protected void removeWhitelist() {
|
||||
whitelist = null;
|
||||
}
|
||||
public boolean isSettingsChanged() {
|
||||
return settingsChanged;
|
||||
@@ -339,8 +399,10 @@ public class BridgeSettingsDescriptor {
|
||||
List<NamedIP> devicesList = this.getHaladdress().getDevices();
|
||||
if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS))
|
||||
return false;
|
||||
if(this.getHaltoken() == null || this.getHaltoken().equals(""))
|
||||
return false;
|
||||
if(devicesList.get(0).getPassword() == null || devicesList.get(0).getPassword().trim().isEmpty()) {
|
||||
if(this.getHaltoken() == null || this.getHaltoken().equals(""))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public Boolean isValidMQTT() {
|
||||
@@ -378,85 +440,4 @@ public class BridgeSettingsDescriptor {
|
||||
public Boolean isValidLifx() {
|
||||
return this.isLifxconfigured();
|
||||
}
|
||||
|
||||
public HueError[] validateWhitelistUser(String aUser, String userDescription, boolean strict) {
|
||||
String validUser = null;
|
||||
boolean found = false;
|
||||
if (aUser != null && !aUser.equalsIgnoreCase("undefined") && !aUser.equalsIgnoreCase("null")
|
||||
&& !aUser.equalsIgnoreCase("")) {
|
||||
if (whitelist != null) {
|
||||
Set<String> theUserIds = whitelist.keySet();
|
||||
Iterator<String> userIterator = theUserIds.iterator();
|
||||
while (userIterator.hasNext()) {
|
||||
validUser = userIterator.next();
|
||||
if (validUser.equals(aUser))
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!found && !strict) {
|
||||
newWhitelistUser(aUser, userDescription);
|
||||
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
return HueErrorResponse.createResponse("1", "/api/" + aUser, "unauthorized user", null, null, null).getTheErrors();
|
||||
}
|
||||
|
||||
Object anUser = whitelist.remove(DEPRACATED_INTERNAL_USER);
|
||||
if(anUser != null)
|
||||
setSettingsChanged(true);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void newWhitelistUser(String aUser, String userDescription) {
|
||||
if(aUser.equals(DEPRACATED_INTERNAL_USER))
|
||||
return;
|
||||
if (whitelist == null) {
|
||||
whitelist = new HashMap<>();
|
||||
}
|
||||
if(userDescription == null)
|
||||
userDescription = "auto insert user";
|
||||
|
||||
whitelist.put(aUser, WhitelistEntry.createEntry(userDescription));
|
||||
setSettingsChanged(true);
|
||||
}
|
||||
|
||||
public String createWhitelistUser(String userDescription) {
|
||||
String aUser = getNewUserID();
|
||||
newWhitelistUser(aUser, userDescription);
|
||||
return aUser;
|
||||
}
|
||||
|
||||
private String getNewUserID() {
|
||||
UUID uid = UUID.randomUUID();
|
||||
StringTokenizer st = new StringTokenizer(uid.toString(), "-");
|
||||
String newUser = "";
|
||||
while (st.hasMoreTokens()) {
|
||||
newUser = newUser + st.nextToken();
|
||||
}
|
||||
|
||||
return newUser;
|
||||
}
|
||||
|
||||
public void removeTestUsers() {
|
||||
if (whitelist != null) {
|
||||
Object anUser = whitelist.remove(DEPRACATED_INTERNAL_USER);
|
||||
if(anUser != null)
|
||||
setSettingsChanged(true);
|
||||
|
||||
Iterator<Entry<String, WhitelistEntry>> it = whitelist.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, WhitelistEntry> pair = it.next();
|
||||
it.remove(); // avoids a ConcurrentModificationException
|
||||
if(pair.getValue().getName().equals(TEST_USER_TYPE)) {
|
||||
whitelist.remove(pair.getKey());
|
||||
setSettingsChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ public class HABridge {
|
||||
staticFileLocation("/public");
|
||||
while(!bridgeSettings.getBridgeControl().isStop()) {
|
||||
bridgeSettings.buildSettings();
|
||||
bridgeSettings.getBridgeSecurity().removeTestUsers();
|
||||
log.info("HA Bridge initializing....");
|
||||
// sparkjava config directive to set ip address for the web server to listen on
|
||||
ipAddress(bridgeSettings.getBridgeSettingsDescriptor().getWebaddress());
|
||||
@@ -102,8 +103,8 @@ public class HABridge {
|
||||
}
|
||||
}
|
||||
}
|
||||
bridgeSettings.getBridgeSettingsDescriptor().removeTestUsers();
|
||||
if(bridgeSettings.getBridgeSettingsDescriptor().isSettingsChanged())
|
||||
bridgeSettings.getBridgeSecurity().removeTestUsers();
|
||||
if(bridgeSettings.getBridgeSecurity().isSettingsChanged())
|
||||
bridgeSettings.updateConfigFile();
|
||||
log.info("HA Bridge (v" + theVersion.getVersion() + ") exiting....");
|
||||
System.exit(0);
|
||||
|
||||
@@ -74,7 +74,8 @@ public class DeviceDescriptor{
|
||||
@SerializedName("comments")
|
||||
@Expose
|
||||
private String comments;
|
||||
|
||||
@SerializedName("deviceState")
|
||||
@Expose
|
||||
private DeviceState deviceState;
|
||||
|
||||
public String getName() {
|
||||
|
||||
@@ -61,6 +61,7 @@ public class DeviceRepository extends BackupHandler {
|
||||
{
|
||||
DeviceDescriptor list[] = gson.fromJson(jsonContent, DeviceDescriptor[].class);
|
||||
for(int i = 0; i < list.length; i++) {
|
||||
list[i].setDeviceState(null);
|
||||
put(list[i].getId(), list[i]);
|
||||
if(Integer.decode(list[i].getId()) > nextId) {
|
||||
nextId = Integer.decode(list[i].getId());
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.bwssystems.HABridge.hue;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.Conversion;
|
||||
@@ -83,7 +84,7 @@ public class BrightnessDecode {
|
||||
replaceTarget = INTENSITY_PERCENT_HEX;
|
||||
notDone = true;
|
||||
} 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;
|
||||
notDone = true;
|
||||
} else if (request.contains(INTENSITY_MATH_CLOSE)) {
|
||||
|
||||
@@ -14,6 +14,9 @@ public class DeviceDataDecode {
|
||||
private static final String DEVICE_MAPTYPE = "${device.mapType}";
|
||||
private static final String DEVICE_DEVICETYPE = "${device.deviceType}";
|
||||
private static final String DEVICE_TARGETDEVICE = "${device.targetDevice}";
|
||||
private static final String DEVICE_REQUESTERADDRESS = "${device.requesterAddress}";
|
||||
private static final String DEVICE_DESCRIPTION = "${device.description}";
|
||||
private static final String DEVICE_COMMENTS = "${device.comments}";
|
||||
|
||||
public static String replaceDeviceData(String request, DeviceDescriptor device) {
|
||||
if (request == null) {
|
||||
@@ -58,6 +61,21 @@ public class DeviceDataDecode {
|
||||
notDone = true;
|
||||
}
|
||||
|
||||
if (request.contains(DEVICE_REQUESTERADDRESS)) {
|
||||
request = request.replace(DEVICE_REQUESTERADDRESS, device.getRequesterAddress());
|
||||
notDone = true;
|
||||
}
|
||||
|
||||
if (request.contains(DEVICE_DESCRIPTION)) {
|
||||
request = request.replace(DEVICE_DESCRIPTION, device.getDescription());
|
||||
notDone = true;
|
||||
}
|
||||
|
||||
if (request.contains(DEVICE_COMMENTS)) {
|
||||
request = request.replace(DEVICE_COMMENTS, device.getComments());
|
||||
notDone = true;
|
||||
}
|
||||
|
||||
log.debug("Request <<" + request + ">>, not done: " + notDone);
|
||||
}
|
||||
return request;
|
||||
|
||||
@@ -69,6 +69,7 @@ public class HueMulator {
|
||||
public void setupServer() {
|
||||
log.info("Hue emulator service started....");
|
||||
before(HUE_CONTEXT + "/*", (request, response) -> {
|
||||
log.debug("HueMulator GET called on api/* with request <" + request.pathInfo() + ">");
|
||||
if(bridgeSettingMaster.getBridgeSecurity().isSecure()) {
|
||||
String pathInfo = request.pathInfo();
|
||||
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());
|
||||
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
|
||||
// all scenes configured
|
||||
get(HUE_CONTEXT + "/:userid/scenes", "application/json", (request, response) -> {
|
||||
@@ -595,9 +607,9 @@ public class HueMulator {
|
||||
|
||||
private String basicListHandler(String type, String userId, String requestIp) {
|
||||
log.debug("hue " + type + " list requested: " + userId + " from " + requestIp);
|
||||
HueError[] theErrors = bridgeSettings.validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
HueError[] theErrors = bridgeSettingMaster.getBridgeSecurity().validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
if (theErrors != null) {
|
||||
if(bridgeSettings.isSettingsChanged())
|
||||
if(bridgeSettingMaster.getBridgeSecurity().isSettingsChanged())
|
||||
bridgeSettingMaster.updateConfigFile();
|
||||
|
||||
return aGsonHandler.toJson(theErrors);
|
||||
@@ -609,9 +621,9 @@ public class HueMulator {
|
||||
log.debug("hue group list requested: " + userId + " from " + requestIp);
|
||||
HueError[] theErrors = null;
|
||||
Map<String, GroupResponse> groupResponseMap = null;
|
||||
theErrors = bridgeSettings.validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
theErrors = bridgeSettingMaster.getBridgeSecurity().validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
if (theErrors == null) {
|
||||
if(bridgeSettings.isSettingsChanged())
|
||||
if(bridgeSettingMaster.getBridgeSecurity().isSettingsChanged())
|
||||
bridgeSettingMaster.updateConfigFile();
|
||||
|
||||
groupResponseMap = new HashMap<String, GroupResponse>();
|
||||
@@ -626,9 +638,9 @@ public class HueMulator {
|
||||
private Object groupsIdHandler(String groupId, String userId, String requestIp) {
|
||||
log.debug("hue group id: <" + groupId + "> requested: " + userId + " from " + requestIp);
|
||||
HueError[] theErrors = null;
|
||||
theErrors = bridgeSettings.validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
theErrors = bridgeSettingMaster.getBridgeSecurity().validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
if (theErrors == null) {
|
||||
if(bridgeSettings.isSettingsChanged())
|
||||
if(bridgeSettingMaster.getBridgeSecurity().isSettingsChanged())
|
||||
bridgeSettingMaster.updateConfigFile();
|
||||
|
||||
if (groupId.equalsIgnoreCase("0")) {
|
||||
@@ -651,9 +663,9 @@ public class HueMulator {
|
||||
if (bridgeSettings.isTraceupnp())
|
||||
log.info("Traceupnp: hue lights list requested: " + userId + " from " + requestIp);
|
||||
log.debug("hue lights list requested: " + userId + " from " + requestIp);
|
||||
theErrors = bridgeSettings.validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
theErrors = bridgeSettingMaster.getBridgeSecurity().validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
if (theErrors == null) {
|
||||
if(bridgeSettings.isSettingsChanged())
|
||||
if(bridgeSettingMaster.getBridgeSecurity().isSettingsChanged())
|
||||
bridgeSettingMaster.updateConfigFile();
|
||||
|
||||
List<DeviceDescriptor> deviceList = repository.findAllByRequester(requestIp);
|
||||
@@ -727,13 +739,13 @@ public class HueMulator {
|
||||
aDeviceType = "<not given>";
|
||||
|
||||
if (newUser == null) {
|
||||
newUser = bridgeSettings.createWhitelistUser(aDeviceType);
|
||||
newUser = bridgeSettingMaster.getBridgeSecurity().createWhitelistUser(aDeviceType);
|
||||
}
|
||||
else {
|
||||
bridgeSettings.validateWhitelistUser(newUser, aDeviceType, false);
|
||||
bridgeSettingMaster.getBridgeSecurity().validateWhitelistUser(newUser, aDeviceType, false);
|
||||
}
|
||||
|
||||
if(bridgeSettings.isSettingsChanged())
|
||||
if(bridgeSettingMaster.getBridgeSecurity().isSettingsChanged())
|
||||
bridgeSettingMaster.updateConfigFile();
|
||||
|
||||
if (bridgeSettings.isTraceupnp())
|
||||
@@ -749,7 +761,7 @@ public class HueMulator {
|
||||
if (bridgeSettings.isTraceupnp())
|
||||
log.info("Traceupnp: hue api/:userid/config config requested: " + userId + " from " + ipAddress);
|
||||
log.debug("hue api config requested: " + userId + " from " + ipAddress);
|
||||
if (bridgeSettings.validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton()) != null) {
|
||||
if (bridgeSettingMaster.getBridgeSecurity().validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton()) != null) {
|
||||
log.debug("hue api config requested, No User supplied, returning public config");
|
||||
HuePublicConfig apiResponse = HuePublicConfig.createConfig("Philips hue",
|
||||
bridgeSettings.getUpnpConfigAddress(), bridgeSettings.getHubversion());
|
||||
@@ -765,7 +777,7 @@ public class HueMulator {
|
||||
@SuppressWarnings("unchecked")
|
||||
private Object getFullState(String userId, String ipAddress) {
|
||||
log.debug("hue api full state requested: " + userId + " from " + ipAddress);
|
||||
HueError[] theErrors = bridgeSettings.validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
HueError[] theErrors = bridgeSettingMaster.getBridgeSecurity().validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
if (theErrors != null)
|
||||
return theErrors;
|
||||
|
||||
@@ -779,7 +791,7 @@ public class HueMulator {
|
||||
|
||||
private Object getLight(String userId, String lightId, String ipAddress) {
|
||||
log.debug("hue light requested: " + lightId + " for user: " + userId + " from " + ipAddress);
|
||||
HueError[] theErrors = bridgeSettings.validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
HueError[] theErrors = bridgeSettingMaster.getBridgeSecurity().validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
if (theErrors != null)
|
||||
return theErrors;
|
||||
|
||||
@@ -823,7 +835,7 @@ public class HueMulator {
|
||||
Integer targetBri = null;
|
||||
Integer targetBriInc = null;
|
||||
log.debug("Update state requested: " + userId + " from " + ipAddress + " body: " + body);
|
||||
HueError[] theErrors = bridgeSettings.validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
HueError[] theErrors = bridgeSettingMaster.getBridgeSecurity().validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
if (theErrors != null)
|
||||
return aGsonHandler.toJson(theErrors);
|
||||
try {
|
||||
@@ -873,7 +885,7 @@ public class HueMulator {
|
||||
aMultiUtil.setDelayDefault(bridgeSettings.getButtonsleep());
|
||||
aMultiUtil.setSetCount(1);
|
||||
log.debug("hue state change requested: " + userId + " from " + ipAddress + " body: " + body);
|
||||
HueError[] theErrors = bridgeSettings.validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
HueError[] theErrors = bridgeSettingMaster.getBridgeSecurity().validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
|
||||
if (theErrors != null)
|
||||
return aGsonHandler.toJson(theErrors);
|
||||
try {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.bwssystems.HABridge.plugins.hal;
|
||||
|
||||
import com.bwssystems.HABridge.NamedIP;
|
||||
|
||||
public class HalDevice {
|
||||
private String haldevicetype;
|
||||
private String haldevicename;
|
||||
private String haladdress;
|
||||
private String halname;
|
||||
private NamedIP haladdress;
|
||||
private DeviceElements buttons;
|
||||
public String getHaldevicetype() {
|
||||
return haldevicetype;
|
||||
@@ -18,18 +19,12 @@ public class HalDevice {
|
||||
public void setHaldevicename(String haldevicename) {
|
||||
this.haldevicename = haldevicename;
|
||||
}
|
||||
public String getHaladdress() {
|
||||
public NamedIP getHaladdress() {
|
||||
return haladdress;
|
||||
}
|
||||
public void setHaladdress(String haladdress) {
|
||||
public void setHaladdress(NamedIP haladdress) {
|
||||
this.haladdress = haladdress;
|
||||
}
|
||||
public String getHalname() {
|
||||
return halname;
|
||||
}
|
||||
public void setHalname(String halname) {
|
||||
this.halname = halname;
|
||||
}
|
||||
public DeviceElements getButtons() {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,14 @@ import com.bwssystems.HABridge.BridgeSettings;
|
||||
import com.bwssystems.HABridge.Home;
|
||||
import com.bwssystems.HABridge.NamedIP;
|
||||
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.hue.BrightnessDecode;
|
||||
import com.bwssystems.HABridge.hue.DeviceDataDecode;
|
||||
import com.bwssystems.HABridge.hue.MultiCommandUtil;
|
||||
import com.bwssystems.HABridge.hue.TimeDecode;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class HalHome implements Home {
|
||||
private static final Logger log = LoggerFactory.getLogger(HalHome.class);
|
||||
@@ -30,7 +36,7 @@ public class HalHome implements Home {
|
||||
public Object getItems(String type) {
|
||||
if(!validHal)
|
||||
return null;
|
||||
log.debug("consolidating devices for hues");
|
||||
log.debug("consolidating devices for HALs");
|
||||
List<HalDevice> theResponse = null;
|
||||
Iterator<String> keys = hals.keySet().iterator();
|
||||
List<HalDevice> deviceList = new ArrayList<HalDevice>();
|
||||
@@ -106,8 +112,63 @@ public class HalHome implements Home {
|
||||
@Override
|
||||
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
||||
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
||||
// Not a device handler
|
||||
return null;
|
||||
boolean halFound = false;
|
||||
String responseString = 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 = null;
|
||||
|
||||
anUrl = BrightnessDecode.calculateReplaceIntensityValue(intermediate, 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(hostPortion)) {
|
||||
halFound = true;
|
||||
if(entry.getValue().getHalAddress().getSecure()!= null && entry.getValue().getHalAddress().getSecure())
|
||||
anUrl = "https://" + anUrl;
|
||||
else
|
||||
anUrl = "http://" + anUrl;
|
||||
|
||||
if(!anUrl.contains("?Token="))
|
||||
anUrl = anUrl + "?Token=" + entry.getValue().getHalAddress().getPassword();
|
||||
|
||||
log.debug("executing HUE api request to Http "
|
||||
+ (anItem.getHttpVerb() == null ? "GET" : anItem.getHttpVerb()) + ": "
|
||||
+ anUrl);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!halFound) {
|
||||
log.warn("No HAL found to call: " + theUrl);
|
||||
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
|
||||
"No HAL found.", "/lights/"
|
||||
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
|
||||
}
|
||||
return responseString;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,13 +35,13 @@ public class HalInfo {
|
||||
private static final String IRDATA_TYPE = "IrData";
|
||||
private HTTPHandler httpClient;
|
||||
private NamedIP halAddress;
|
||||
private String theToken;
|
||||
|
||||
public HalInfo(NamedIP addressName, String aGivenToken) {
|
||||
super();
|
||||
httpClient = new HTTPHandler();
|
||||
halAddress = addressName;
|
||||
theToken = aGivenToken;
|
||||
if(halAddress.getPassword() == null || halAddress.getPassword().trim().isEmpty())
|
||||
halAddress.setPassword(aGivenToken);
|
||||
}
|
||||
|
||||
public List<HalDevice> getLights() {
|
||||
@@ -98,12 +98,16 @@ public class HalInfo {
|
||||
|
||||
String theUrl = null;
|
||||
String theData;
|
||||
theUrl = "http://" + halAddress.getIp() + apiType + theToken;
|
||||
if(halAddress.getSecure()!= null && halAddress.getSecure())
|
||||
theUrl = "https://";
|
||||
else
|
||||
theUrl = "http://";
|
||||
theUrl = theUrl + halAddress.getIp() + apiType + halAddress.getPassword();
|
||||
theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
|
||||
if(theData != null) {
|
||||
log.debug("GET " + deviceType + " HalApiResponse - data: " + theData);
|
||||
theHalApiResponse = new Gson().fromJson(theData, DeviceElements.class);
|
||||
if(theHalApiResponse.getDeviceElements() == null) {
|
||||
if(theHalApiResponse == null || theHalApiResponse.getDeviceElements() == null) {
|
||||
StatusDescription theStatus = new Gson().fromJson(theData, StatusDescription.class);
|
||||
if(theStatus.getStatus() == null) {
|
||||
log.warn("Cannot get an devices for type " + deviceType + " for hal " + halAddress.getName() + " as response is not parsable.");
|
||||
@@ -121,8 +125,10 @@ public class HalInfo {
|
||||
HalDevice aNewHalDevice = new HalDevice();
|
||||
aNewHalDevice.setHaldevicetype(deviceType);
|
||||
aNewHalDevice.setHaldevicename(theDevice.getDeviceName());
|
||||
aNewHalDevice.setHaladdress(halAddress.getIp());
|
||||
aNewHalDevice.setHalname(halAddress.getName());
|
||||
NamedIP theaddress = new NamedIP();
|
||||
theaddress.setIp(halAddress.getIp());
|
||||
theaddress.setName(halAddress.getName());
|
||||
aNewHalDevice.setHaladdress(theaddress);
|
||||
deviceList.add(aNewHalDevice);
|
||||
|
||||
}
|
||||
@@ -145,7 +151,11 @@ public class HalInfo {
|
||||
deviceList = new ArrayList<HalDevice>();
|
||||
while (theHalDevices.hasNext()) {
|
||||
HalDevice theHalDevice = theHalDevices.next();
|
||||
theUrl = "http://" + halAddress.getIp() + IRBUTTON_REQUEST + TextStringFormatter.forQuerySpaceUrl(theHalDevice.getHaldevicename()) + TOKEN_REQUEST + theToken;
|
||||
if(halAddress.getSecure()!= null && halAddress.getSecure())
|
||||
theUrl = "https://";
|
||||
else
|
||||
theUrl = "http://";
|
||||
theUrl = theUrl + halAddress.getIp() + IRBUTTON_REQUEST + TextStringFormatter.forQuerySpaceUrl(theHalDevice.getHaldevicename()) + TOKEN_REQUEST + halAddress.getPassword();
|
||||
theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
|
||||
if (theData != null) {
|
||||
log.debug("GET IrData for IR Device " + theHalDevice.getHaldevicename() + " HalApiResponse - data: " + theData);
|
||||
@@ -177,6 +187,12 @@ public class HalInfo {
|
||||
return deviceList;
|
||||
}
|
||||
|
||||
public String deviceCommand(String theUrl) {
|
||||
String theData = null;
|
||||
theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
|
||||
return theData;
|
||||
}
|
||||
|
||||
public NamedIP getHalAddress() {
|
||||
return halAddress;
|
||||
}
|
||||
@@ -190,6 +206,5 @@ public class HalInfo {
|
||||
httpClient.closeHandler();
|
||||
httpClient = null;
|
||||
halAddress = null;
|
||||
theToken = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public class UpnpListener {
|
||||
private String responseAddress;
|
||||
private boolean strict;
|
||||
private boolean traceupnp;
|
||||
private boolean useUpnpIface;
|
||||
private BridgeControlDescriptor bridgeControl;
|
||||
private String bridgeId;
|
||||
private String bridgeSNUUID;
|
||||
@@ -74,6 +75,7 @@ public class UpnpListener {
|
||||
responseAddress = theSettings.getUpnpConfigAddress();
|
||||
strict = theSettings.isUpnpStrict();
|
||||
traceupnp = theSettings.isTraceupnp();
|
||||
useUpnpIface = theSettings.isUseupnpiface();
|
||||
bridgeControl = theControl;
|
||||
aHueConfig = HuePublicConfig.createConfig("temp", responseAddress, HueConstants.HUB_VERSION);
|
||||
bridgeId = aHueConfig.getBridgeid();
|
||||
@@ -114,7 +116,10 @@ public class UpnpListener {
|
||||
else
|
||||
log.debug(name + " ... has addr " + addr);
|
||||
if (InetAddressUtils.isIPv4Address(addr.getHostAddress())) {
|
||||
IPsPerNic++;
|
||||
if(!useUpnpIface)
|
||||
IPsPerNic++;
|
||||
else if(addr.getHostAddress().equals(responseAddress))
|
||||
IPsPerNic++;
|
||||
}
|
||||
}
|
||||
log.debug("Checking " + name + " to our interface set");
|
||||
|
||||
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();
|
||||
|
||||
$rootScope.$on('securitySetupReceived', function(event, data) {
|
||||
@@ -93,13 +93,10 @@ app.run( async function ($rootScope, $location, Auth, bridgeService) {
|
||||
}
|
||||
});
|
||||
|
||||
$rootScope.$on('securityReview', function(event, data) {
|
||||
if(Auth.isLoggedIn()) {
|
||||
$location.path("/");
|
||||
} else {
|
||||
event.preventDefault();
|
||||
$location.path("/login");
|
||||
}
|
||||
$rootScope.$on('securityError', function(event, data) {
|
||||
Auth.logout();
|
||||
event.preventDefault();
|
||||
$location.path("/login");
|
||||
});
|
||||
|
||||
$rootScope.$on('securityReinit', function(event, data) {
|
||||
@@ -193,7 +190,10 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.devices = response.data;
|
||||
},
|
||||
function (error) {
|
||||
self.displayError("Cannot get devices from habridge: ", error);
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayError("Cannot get devices from habridge: ", error);
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -204,6 +204,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.viewDevices();
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayError("Cannot renumber devices from habridge: ", error);
|
||||
}
|
||||
);
|
||||
@@ -242,7 +245,10 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.getAUser();
|
||||
},
|
||||
function (error) {
|
||||
self.displayWarn("Cannot get testuser: ", error);
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Cannot get testuser: ", error);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -254,7 +260,10 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.testuser = response.data[0].success.username;
|
||||
},
|
||||
function (error) {
|
||||
self.displayWarn("Cannot get a user: ", error);
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Cannot get a user: ", error);
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -266,6 +275,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.getTestUser();
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Cannot get security info: ", error);
|
||||
}
|
||||
);
|
||||
@@ -284,6 +296,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.displaySuccess("Updated security settings.")
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Update ecurity settings Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -311,6 +326,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.displaySuccess("Password updated")
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Update password Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -332,6 +350,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
}
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("User add Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -348,6 +369,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.displaySuccess("User deleted")
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("User add Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -359,6 +383,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.displayTimer("Link your device", 30000);
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Cannot get security info: ", error);
|
||||
}
|
||||
);
|
||||
@@ -490,6 +517,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.updateShowLifx();
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Load Bridge Settings Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -501,6 +531,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.backups = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Backups Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -512,6 +545,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.configs = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Configs Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -523,6 +559,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.logMsgs = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get log messages Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -534,6 +573,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.loggerInfo = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get logger info Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -547,6 +589,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.nestitems = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Nest Items Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -560,6 +605,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.huedevices = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Hue Items Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -573,6 +621,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.veradevices = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Vera Devices Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -586,6 +637,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.verascenes = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Vera Scenes Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -599,6 +653,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.harmonyactivities = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Harmony Activities Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -612,6 +669,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.harmonydevices = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Harmony Devices Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -625,6 +685,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.haldevices = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Hal Devices Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -638,6 +701,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.mqttbrokers = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get MQTT Devices Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -651,6 +717,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.hassdevices = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Hass Devices Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -664,6 +733,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.domoticzdevices = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Domoticz Devices Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -677,6 +749,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.somfydevices = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Somfy Devices Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -691,6 +766,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.lifxdevices = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get Lifx Devices Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -763,6 +841,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.state.mapTypes = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Get mapTypes Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -786,6 +867,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.displaySuccess("Updated " + logComponents.length + " loggers for log levels.")
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Update Log components Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -814,6 +898,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.displaySuccess("Bulk device add successful.");
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Bulk Add new Device Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -832,6 +919,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
function (response) {
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Edit Device Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -842,6 +932,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
function (response) {
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Add new Device Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -856,6 +949,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.viewBackups();
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Backup Device Db Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -870,6 +966,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.viewDevices();
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Backup Db Restore Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -883,6 +982,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.viewBackups();
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Delete Backup Db File Error:", error);
|
||||
}
|
||||
);
|
||||
@@ -912,6 +1014,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.displayError("HABridge is now stopped. Restart must occur from the server.", null);
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayError("HABRidge Stop Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -931,6 +1036,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
}, 2000);
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("HABRidge Reinit Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -942,6 +1050,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.reinit();
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Save Settings Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -956,6 +1067,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.viewConfigs();
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Backup Settings Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -971,6 +1085,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.viewDevices();
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Backup Settings Restore Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -984,6 +1101,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.viewConfigs();
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Delete Backup Settings File Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -995,6 +1115,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
self.viewDevices();
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Delete Device Error: ", error);
|
||||
}
|
||||
);
|
||||
@@ -1011,6 +1134,7 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
|
||||
this.testUrl = function (device, type, value) {
|
||||
var msgDescription = "unknown";
|
||||
self.getTestUser();
|
||||
var testUrl = this.state.huebase + "/" + this.state.testuser + "/lights/" + device.id + "/state";
|
||||
var testBody = "{\"on\":";
|
||||
if (type === "off") {
|
||||
@@ -1028,14 +1152,22 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
msgDescription = "success " + angular.toJson(response.data);
|
||||
}
|
||||
if (typeof(response.data[0].error) !== 'undefined') {
|
||||
msgDescription = "error " + angular.toJson(response.data[0].error);
|
||||
self.displayErrorMessage("Request Error, Pleae look in your habridge log: ", msgDescription);
|
||||
if(reponse.data[0].error.indexOf("unauthorized") > -1) {
|
||||
self.displayWarn("Authorization error, please retry...", null);
|
||||
}
|
||||
else {
|
||||
msgDescription = "error " + angular.toJson(response.data[0].error);
|
||||
self.displayErrorMessage("Request Error, Please look in your habridge log: ", msgDescription);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
self.displaySuccess("Request Executed: " + msgDescription);
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
$rootScope.$broadcast('securityReinit', 'done');
|
||||
else
|
||||
self.displayWarn("Request Error, Pleae look in your habridge log: ", error);
|
||||
}
|
||||
);
|
||||
@@ -1159,11 +1291,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) {
|
||||
$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.newharmonyname = null;
|
||||
$scope.newharmonyip = null;
|
||||
@@ -1191,11 +1323,11 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
}
|
||||
}
|
||||
};
|
||||
$scope.addHaltoSettings = function (newhalname, newhalip) {
|
||||
$scope.addHaltoSettings = function (newhalname, newhalip, newhalsecure, newhaltoken) {
|
||||
if($scope.bridge.settings.haladdress === undefined || $scope.bridge.settings.haladdress === null) {
|
||||
$scope.bridge.settings.haladdress = { devices: [] };
|
||||
}
|
||||
var newhal = {name: newhalname, ip: newhalip }
|
||||
var newhal = {name: newhalname, ip: newhalip, secure: newhalsecure, password: newhaltoken }
|
||||
$scope.bridge.settings.haladdress.devices.push(newhal);
|
||||
$scope.newhalname = null;
|
||||
$scope.newhalip = null;
|
||||
@@ -2076,7 +2208,6 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
var preOffCmd = "";
|
||||
var nameCmd = "";
|
||||
var aDeviceType;
|
||||
var postCmd = "?Token=" + $scope.bridge.settings.haltoken;
|
||||
if(haldevice.haldevicetype === "Group") {
|
||||
aDeviceType = "group";
|
||||
preOnCmd = "/GroupService!GroupCmd=On";
|
||||
@@ -2101,29 +2232,25 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
nameCmd = "!DeviceName=";
|
||||
}
|
||||
if((dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) && aDeviceType === "switch")
|
||||
dimpayload = "http://" + haldevice.haladdress
|
||||
dimpayload = "http://" + haldevice.haladdress.ip
|
||||
+ preDimCmd
|
||||
+ dim_control
|
||||
+ nameCmd
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ postCmd;
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20");
|
||||
else
|
||||
dimpayload = "http://" + haldevice.haladdress
|
||||
dimpayload = "http://" + haldevice.haladdress.ip
|
||||
+ preOnCmd
|
||||
+ nameCmd
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ postCmd;
|
||||
onpayload = "http://" + haldevice.haladdress
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20");
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ preOnCmd
|
||||
+ nameCmd
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ postCmd;
|
||||
offpayload = "http://" + haldevice.haladdress
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20");
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ preOffCmd
|
||||
+ nameCmd
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ postCmd;
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname, haldevice.haldevicename, haldevice.halname, aDeviceType, "halDevice", null, null);
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20");
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name, haldevice.haldevicename, haldevice.haladdress.name, aDeviceType, "halDevice", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2134,10 +2261,10 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
$scope.buildButtonUrls = function (haldevice, onbutton, offbutton, buildonly) {
|
||||
var actionOn = angular.fromJson(onbutton);
|
||||
var actionOff = angular.fromJson(offbutton);
|
||||
onpayload = "http://" + haldevice.haladdress + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOn.DeviceName.replaceAll(" ", "%20") + "?Token=" + $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOff.DeviceName.replaceAll(" ", "%20") + "?Token=" + $scope.bridge.settings.haltoken;
|
||||
onpayload = "http://" + haldevice.haladdress.ip + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOn.DeviceName.replaceAll(" ", "%20");
|
||||
offpayload = "http://" + haldevice.haladdress.ip + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOff.DeviceName.replaceAll(" ", "%20");
|
||||
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-" + actionOn.DeviceName, haldevice.haldevicename, haldevice.halname, "button", "halButton", null, null);
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-" + actionOn.DeviceName, haldevice.haldevicename, haldevice.haladdress.name, "button", "halButton", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2146,9 +2273,9 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALHomeUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress + "/ModeService!ModeCmd=Set!ModeName=Home?Token=" + $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress + "/ModeService!ModeCmd=Set!ModeName=Away?Token=" + $scope.bridge.settings.haltoken;
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-HomeAway", haldevice.haldevicename, haldevice.halname, "home", "halHome", null, null);
|
||||
onpayload = "http://" + haldevice.haladdress.ip + "/ModeService!ModeCmd=Set!ModeName=Home";
|
||||
offpayload = "http://" + haldevice.haladdress.ip + "/ModeService!ModeCmd=Set!ModeName=Away";
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-HomeAway", haldevice.haldevicename, haldevice.haladdress.name, "home", "halHome", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2157,22 +2284,19 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALHeatUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Heat?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
dimpayload = "http://" + haldevice.haladdress
|
||||
+ "!HVACMode=Heat";
|
||||
dimpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Heat!HeatSpValue=${intensity.percent}?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress
|
||||
+ "!HVACMode=Heat!HeatSpValue=${intensity.percent}";
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Off?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetHeat", haldevice.haldevicename + " Heat", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||
+ "!HVACMode=Off";
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetHeat", haldevice.haldevicename + " Heat", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2181,22 +2305,19 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALCoolUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Cool?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
dimpayload = "http://" + haldevice.haladdress
|
||||
+ "!HVACMode=Cool";
|
||||
dimpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Cool!CoolSpValue=${intensity.percent}?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress
|
||||
+ "!HVACMode=Cool!CoolSpValue=${intensity.percent}";
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Off?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetCool", haldevice.haldevicename + " Cool", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||
+ "!HVACMode=Off";
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetCool", haldevice.haldevicename + " Cool", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2205,16 +2326,15 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALAutoUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Auto?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress
|
||||
+ "!HVACMode=Auto";
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Off?Token="
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetAuto", haldevice.haldevicename + " Auto", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||
+ "!HVACMode=Off";
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetAuto", haldevice.haldevicename + " Auto", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2223,17 +2343,15 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALOffUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Auto?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress
|
||||
+ "!HVACMode=Auto";
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Off?Token="
|
||||
$scope.device.offUrl = "http://" + haldevice.haladdress
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-TurnOff", haldevice.haldevicename + " Thermostat", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||
+ "!HVACMode=Off";
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-TurnOff", haldevice.haldevicename + " Thermostat", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2242,17 +2360,15 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALFanUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!FanMode=On?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress
|
||||
+ "!FanMode=On";
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!FanMode=Auto?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetFan", haldevice.haldevicename + " Fan", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||
+ "!FanMode=Auto";
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetFan", haldevice.haldevicename + " Fan", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -3322,7 +3438,6 @@ app.factory('Auth', function($resource, $rootScope, $sessionStorage, $http, $bas
|
||||
delete $sessionStorage.user;
|
||||
delete $rootScope.user;
|
||||
delete bridgeService.state.loggedInUser;
|
||||
bridgeService.displaySuccess("User Logged Out");
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
<th sortable-header col="id" comparator-fn="comparatorUniqueId">ID</th>
|
||||
<th sortable-header col="name">Name</th>
|
||||
<th sortable-header col="description">Description</th>
|
||||
<th sortable-header col="devicestate">Device State</th>
|
||||
<th sortable-header col="deviceType">Type</th>
|
||||
<th sortable-header col="targetDevice">Target</th>
|
||||
<th sortable-header col="inactive">Inactive</th>
|
||||
@@ -55,6 +56,7 @@
|
||||
<td>{{device.id}}</td>
|
||||
<td>{{device.name}}</td>
|
||||
<td class="cr">{{device.description}}</td>
|
||||
<td class="cr">on={{device.deviceState.on}},bri={{device.deviceState.on}},hue={{device.deviceState.hue}},sat={{device.deviceState.sat}},effect={{device.deviceState.effect}},ct={{device.deviceState.ct}},alert={{device.deviceState.alert}},colormode={{device.deviceState.colormode}},reachable={{device.deviceState.reachable}},XYList={{device.deviceState.xy}}</td>
|
||||
<td>{{device.deviceType}}</td>
|
||||
<td>{{device.targetDevice}}</td>
|
||||
<td>{{device.inactive}}</td>
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
ng-click="toggleSelection(haldevice.haldevicename)">
|
||||
{{haldevice.haldevicename}}</td>
|
||||
<td>{{haldevice.haldevicetype}}</td>
|
||||
<td>{{haldevice.halname}}</td>
|
||||
<td>{{haldevice.haladdress.name}}</td>
|
||||
<td>
|
||||
<select name="button-on" id="button-on" ng-model="button_on">
|
||||
<option ng-repeat="aButtonOn in haldevice.buttons.DeviceElements"
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
type="text" ng-model="newUser"
|
||||
placeholder="someone" nu-check="new-user" />
|
||||
</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>
|
||||
</div>
|
||||
<div ng-if="showPassword" postrender-action="setBlankPassword('password-1')">
|
||||
|
||||
@@ -82,6 +82,12 @@
|
||||
ng-model="bridge.settings.upnpconfigaddress"
|
||||
placeholder="192.168.1.1"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Use UPNP Address Interface Only</td>
|
||||
<td><input type="checkbox"
|
||||
ng-model="bridge.settings.useupnpiface" ng-true-value=true
|
||||
ng-false-value=false> {{bridge.settings.useupnpiface}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Web Server IP Address</td>
|
||||
<td><input id="bridge-settings-webaddress"
|
||||
@@ -113,16 +119,20 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tr ng-repeat="vera in bridge.settings.veraaddress.devices">
|
||||
<td>{{vera.name}}</td>
|
||||
<td>{{vera.ip}}</td>
|
||||
<td><input id="bridge-settings-next-vera-name"
|
||||
class="form-control" type="text" ng-model="vera.name"
|
||||
placeholder="A Vera"></td>
|
||||
<td><input id="bridge-settings-next-vera-ip"
|
||||
class="form-control" type="text" ng-model="vera.ip"
|
||||
placeholder="192.168.1.2"></td>
|
||||
<td><button class="btn btn-danger" type="submit"
|
||||
ng-click="removeVeratoSettings(vera.name, vera.ip)">Del</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="bridge-settings-next-vera-name"
|
||||
<td><input id="bridge-settings-new-vera-name"
|
||||
class="form-control" type="text" ng-model="newveraname"
|
||||
placeholder="A Vera"></td>
|
||||
<td><input id="bridge-settings-next-vera-ip"
|
||||
<td><input id="bridge-settings-new-vera-ip"
|
||||
class="form-control" type="text" ng-model="newveraip"
|
||||
placeholder="192.168.1.2"></td>
|
||||
<td><button class="btn btn-success" type="submit"
|
||||
@@ -137,30 +147,36 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>IP</th>
|
||||
<th>Webhook</th>
|
||||
<th>IP</th>
|
||||
<th>Webhook</th>
|
||||
<th>Manage</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr ng-repeat="harmony in bridge.settings.harmonyaddress.devices">
|
||||
<td>{{harmony.name}}</td>
|
||||
<td>{{harmony.ip}}</td>
|
||||
<td>{{harmony.webhook}}</td>
|
||||
<td><input id="bridge-settings-next-harmony-name"
|
||||
class="form-control" type="text" ng-model="harmony.name"
|
||||
placeholder="A Harmony"></td>
|
||||
<td><input id="bridge-settings-next-harmony-ip"
|
||||
class="form-control" type="text" ng-model="harmony.ip"
|
||||
placeholder="192.168.1.3"></td>
|
||||
<td><input id="bridge-settings-next-harmony-webhook"
|
||||
class="form-control" type="text" ng-model="harmony.webhook"
|
||||
placeholder="http://hook?a=${activity.label}"></td>
|
||||
<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>
|
||||
<td><input id="bridge-settings-next-harmony-name"
|
||||
<td><input id="bridge-settings-new-harmony-name"
|
||||
class="form-control" type="text" ng-model="newharmonyname"
|
||||
placeholder="A Harmony"></td>
|
||||
<td><input id="bridge-settings-next-harmony-ip"
|
||||
class="form-control" type="text" ng-model="newharmonyip"
|
||||
placeholder="192.168.1.3"></td>
|
||||
<td><input id="bridge-settings-next-harmony-webhook"
|
||||
class="form-control" type="text" ng-model="newharmonywebhook"
|
||||
placeholder="http://hook?a=${activity.label}"></td>
|
||||
<td><input id="bridge-settings-new-harmony-ip"
|
||||
class="form-control" type="text" ng-model="newharmonyip"
|
||||
placeholder="192.168.1.3"></td>
|
||||
<td><input id="bridge-settings-new-harmony-webhook"
|
||||
class="form-control" type="text" ng-model="newharmonywebhook"
|
||||
placeholder="http://hook?a=${activity.label}"></td>
|
||||
<td><button class="btn btn-success" type="submit"
|
||||
ng-click="addHarmonytoSettings(newharmonyname, newharmonyip, newharmonywebhook)">Add</button></td>
|
||||
ng-click="addHarmonytoSettings(newharmonyname, newharmonyip, newharmonywebhook)">Add</button></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
@@ -176,20 +192,24 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tr ng-repeat="hue in bridge.settings.hueaddress.devices">
|
||||
<td>{{hue.name}}</td>
|
||||
<td>{{hue.ip}}</td>
|
||||
<td><button class="btn btn-danger" type="submit"
|
||||
ng-click="removeHuetoSettings(hue.name, hue.ip)">Del</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="bridge-settings-next-hue-name"
|
||||
class="form-control" type="text" ng-model="newhuename"
|
||||
class="form-control" type="text" ng-model="hue.name"
|
||||
placeholder="A Hue"></td>
|
||||
<td><input id="bridge-settings-next-hue-ip"
|
||||
class="form-control" type="text" ng-model="hue.ip"
|
||||
placeholder="192.168.1.3"></td>
|
||||
<td><button class="btn btn-danger" type="submit"
|
||||
ng-click="removeHuetoSettings(hue.name, hue.ip)">Del</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="bridge-settings-new-hue-name"
|
||||
class="form-control" type="text" ng-model="newhuename"
|
||||
placeholder="A Hue"></td>
|
||||
<td><input id="bridge-settings-new-hue-ip"
|
||||
class="form-control" type="text" ng-model="newhueip"
|
||||
placeholder="192.168.1.3"></td>
|
||||
<td><button class="btn btn-success" type="submit"
|
||||
ng-click="addHuetoSettings(newhuename, newhueip)">Add</button></td>
|
||||
ng-click="addHuetoSettings(newhuename, newhueip)">Add</button></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
@@ -201,29 +221,47 @@
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>IP</th>
|
||||
<th>Token</th>
|
||||
<th>Use SSL</th>
|
||||
<th>Manage</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr ng-repeat="hal in bridge.settings.haladdress.devices">
|
||||
<td>{{hal.name}}</td>
|
||||
<td>{{hal.ip}}</td>
|
||||
<td><input id="bridge-settings-next-hal-name"
|
||||
class="form-control" type="text" ng-model="hal.name"
|
||||
placeholder="A Hal"></td>
|
||||
<td><input id="bridge-settings-next-hal-ip"
|
||||
class="form-control" type="text" ng-model="hal.ip"
|
||||
placeholder="192.168.1.3:82"></td>
|
||||
<td><input id="bridge-settings-next-haltoken" class="form-control"
|
||||
type="password" ng-model="hal.password"
|
||||
placeholder="thetoken"></td>
|
||||
<td><input type="checkbox"
|
||||
ng-model="hal.secure" ng-true-value=true
|
||||
ng-false-value=false></td>
|
||||
<td><button class="btn btn-danger" type="submit"
|
||||
ng-click="removeHaltoSettings(hal.name, hal.ip)">Del</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="bridge-settings-next-hal-name"
|
||||
<td><input id="bridge-settings-new-hal-name"
|
||||
class="form-control" type="text" ng-model="newhalname"
|
||||
placeholder="A Hal"></td>
|
||||
<td><input id="bridge-settings-next-hal-ip"
|
||||
<td><input id="bridge-settings-new-hal-ip"
|
||||
class="form-control" type="text" ng-model="newhalip"
|
||||
placeholder="192.168.1.3:82"></td>
|
||||
<td><input id="bridge-settings-new-haltoken" class="form-control"
|
||||
type="password" ng-model="newhaltoken"
|
||||
placeholder="thetoken"></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"
|
||||
ng-click="addHaltoSettings(newhalname, newhalip)">Add</button></td>
|
||||
ng-click="addHaltoSettings(newhalname, newhalip, newhalsecure, newhaltoken)">Add</button></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>HAL Token</td>
|
||||
<td>HAL Token (please use token on individual HAL entry)</td>
|
||||
<td><input id="bridge-settings-haltoken" class="form-control"
|
||||
type="password" ng-model="bridge.settings.haltoken"
|
||||
placeholder="thetoken"></td>
|
||||
@@ -242,26 +280,32 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tr ng-repeat="mqtt in bridge.settings.mqttaddress.devices">
|
||||
<td>{{mqtt.name}}</td>
|
||||
<td>{{mqtt.ip}}</td>
|
||||
<td>{{mqtt.username}}</td>
|
||||
<td ng-if="mqtt.password">*******</td>
|
||||
<td ng-if="!mqtt.password"> </td>
|
||||
|
||||
<td><input id="bridge-settings-next-mqtt-name"
|
||||
class="form-control" type="text" ng-model="mqtt.name"
|
||||
placeholder="A MQTT Client ID"></td>
|
||||
<td><input id="bridge-settings-next-mqtt-ip"
|
||||
class="form-control" type="text" ng-model="mqtt.ip"
|
||||
placeholder="MQTT Broker IP and port"></td>
|
||||
<td><input id="bridge-settings-next-mqtt-username"
|
||||
class="form-control" type="text" ng-model="mqtt.username"
|
||||
placeholder="MQTT Broker username (optional)"></td>
|
||||
<td><input id="bridge-settings-next-mqtt-password"
|
||||
class="form-control" type="password" ng-model="mqtt.password"
|
||||
placeholder="MQTT Broker password (opt)"></td>
|
||||
<td><button class="btn btn-danger" type="submit"
|
||||
ng-click="removeMQTTtoSettings(mqtt.name, mqtt.ip)">Del</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="bridge-settings-next-mqtt-name"
|
||||
<td><input id="bridge-settings-new-mqtt-name"
|
||||
class="form-control" type="text" ng-model="newmqttname"
|
||||
placeholder="A MQTT Client ID"></td>
|
||||
<td><input id="bridge-settings-next-mqtt-ip"
|
||||
<td><input id="bridge-settings-new-mqtt-ip"
|
||||
class="form-control" type="text" ng-model="newmqttip"
|
||||
placeholder="MQTT Broker IP and port"></td>
|
||||
<td><input id="bridge-settings-next-mqtt-username"
|
||||
<td><input id="bridge-settings-new-mqtt-username"
|
||||
class="form-control" type="text" ng-model="newmqttusername"
|
||||
placeholder="MQTT Broker username (optional)"></td>
|
||||
<td><input id="bridge-settings-next-mqtt-password"
|
||||
<td><input id="bridge-settings-new-mqtt-password"
|
||||
class="form-control" type="password" ng-model="newmqttpassword"
|
||||
placeholder="MQTT Broker password (opt)"></td>
|
||||
<td><button class="btn btn-success" type="submit"
|
||||
@@ -284,26 +328,35 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tr ng-repeat="hass in bridge.settings.hassaddress.devices">
|
||||
<td>{{hass.name}}</td>
|
||||
<td>{{hass.ip}}</td>
|
||||
<td>{{hass.port}}</td>
|
||||
<td ng-if="hass.password">*******</td>
|
||||
<td ng-if="!hass.password"> </td>
|
||||
<td>{{hass.secure}}</td>
|
||||
<td><input id="bridge-settings-next-hass-name"
|
||||
class="form-control" type="text" ng-model="hass.name"
|
||||
placeholder="A HomeAssistant"></td>
|
||||
<td><input id="bridge-settings-next-hass-ip"
|
||||
class="form-control" type="text" ng-model="hass.ip"
|
||||
placeholder="192.168.1.3"></td>
|
||||
<td><input id="bridge-settings-next-hass-port"
|
||||
class="form-control" type="text" ng-model="hass.port"
|
||||
placeholder="8123"></td>
|
||||
<td><input id="bridge-settings-next-hass-password"
|
||||
class="form-control" type="password" ng-model="hass.password"
|
||||
placeholder="Home Assistant password (opt)"></td>
|
||||
<td><input type="checkbox"
|
||||
ng-model="hass.secure" ng-true-value=true
|
||||
ng-false-value=false></td>
|
||||
<td><button class="btn btn-danger" type="submit"
|
||||
ng-click="removeHasstoSettings(hass.name, hass.ip)">Del</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="bridge-settings-next-hass-name"
|
||||
<td><input id="bridge-settings-new-hass-name"
|
||||
class="form-control" type="text" ng-model="newhassname"
|
||||
placeholder="A HomeAssistant"></td>
|
||||
<td><input id="bridge-settings-next-hass-ip"
|
||||
<td><input id="bridge-settings-new-hass-ip"
|
||||
class="form-control" type="text" ng-model="newhassip"
|
||||
placeholder="192.168.1.3"></td>
|
||||
<td><input id="bridge-settings-next-hass-port"
|
||||
<td><input id="bridge-settings-new-hass-port"
|
||||
class="form-control" type="text" ng-model="newhassport"
|
||||
placeholder="8123"></td>
|
||||
<td><input id="bridge-settings-next-hass-password"
|
||||
<td><input id="bridge-settings-new-hass-password"
|
||||
class="form-control" type="password" ng-model="newhasspassword"
|
||||
placeholder="Home Assistant password (opt)"></td>
|
||||
<td><input type="checkbox"
|
||||
@@ -329,29 +382,38 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tr ng-repeat="domoticz in bridge.settings.domoticzaddress.devices">
|
||||
<td>{{domoticz.name}}</td>
|
||||
<td>{{domoticz.ip}}</td>
|
||||
<td>{{domoticz.port}}</td>
|
||||
<td>{{domoticz.username}}</td>
|
||||
<td ng-if="domoticz.password">*******</td>
|
||||
<td ng-if="!domoticz.password"> </td>
|
||||
<td><input id="bridge-settings-next-domoticz-name"
|
||||
class="form-control" type="text" ng-model="domoticz.name"
|
||||
placeholder="A Domoticz"></td>
|
||||
<td><input id="bridge-settings-next-domoticz-ip"
|
||||
class="form-control" type="text" ng-model="domoticz.ip"
|
||||
placeholder="192.168.1.3"></td>
|
||||
<td><input id="bridge-settings-next-domoticz-port"
|
||||
class="form-control" type="text" ng-model="domoticz.port"
|
||||
placeholder="8080"></td>
|
||||
<td><input id="bridge-settings-next-domoticz-username"
|
||||
class="form-control" type="text" ng-model="domoticz.username"
|
||||
placeholder="Domoticz username"></td>
|
||||
<td><input id="bridge-settings-next-domoticz-password"
|
||||
class="form-control" type="password" ng-model="domoticz.password"
|
||||
placeholder="Domoticz password (opt)"></td>
|
||||
<td><button class="btn btn-danger" type="submit"
|
||||
ng-click="removeDomoticztoSettings(domoticz.name, domoticz.ip)">Del</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="bridge-settings-next-domoticz-name"
|
||||
<td><input id="bridge-settings-new-domoticz-name"
|
||||
class="form-control" type="text" ng-model="newdomoticzname"
|
||||
placeholder="A Domoticz"></td>
|
||||
<td><input id="bridge-settings-next-domoticz-ip"
|
||||
<td><input id="bridge-settings-new-domoticz-ip"
|
||||
class="form-control" type="text" ng-model="newdomoticzip"
|
||||
placeholder="192.168.1.3"></td>
|
||||
<td><input id="bridge-settings-next-domoticz-port"
|
||||
<td><input id="bridge-settings-new-domoticz-port"
|
||||
class="form-control" type="text" ng-model="newdomoticzport"
|
||||
placeholder="8080"></td>
|
||||
<td><input id="bridge-settings-next-domoticz-username"
|
||||
<td><input id="bridge-settings-new-domoticz-username"
|
||||
class="form-control" type="text" ng-model="newdomoticzusername"
|
||||
placeholder="Domoticz username"></td>
|
||||
<td><input id="bridge-settings-next-domoticz-password"
|
||||
<td><input id="bridge-settings-new-domoticz-password"
|
||||
class="form-control" type="password" ng-model="newdomoticzpassword"
|
||||
placeholder="Domoticz password (opt)"></td>
|
||||
<td><button class="btn btn-success" type="submit"
|
||||
@@ -373,25 +435,32 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tr ng-repeat="somfy in bridge.settings.somfyaddress.devices">
|
||||
<td>{{somfy.name}}</td>
|
||||
<td>{{somfy.ip}}</td>
|
||||
<td>{{somfy.username}}</td>
|
||||
<td ng-if="somfy.password">*******</td>
|
||||
<td ng-if="!somfy.password"> </td>
|
||||
<td><input id="bridge-settings-next-somfy-name"
|
||||
class="form-control" type="text" ng-model="somfy.name"
|
||||
placeholder="A Somfy"></td>
|
||||
<td><input id="bridge-settings-next-somfy-ip"
|
||||
class="form-control" type="text" ng-model="somfy.ip"
|
||||
placeholder="https://www.tahomalink.com"></td>
|
||||
<td><input id="bridge-settings-next-somfy-username"
|
||||
class="form-control" type="text" ng-model="somfy.username"
|
||||
placeholder="Somfy username"></td>
|
||||
<td><input id="bridge-settings-next-somfy-password"
|
||||
class="form-control" type="password" ng-model="somfy.password"
|
||||
placeholder="Somfy password"></td>
|
||||
<td><button class="btn btn-danger" type="submit"
|
||||
ng-click="removeSomfytoSettings(somfy.name, somfy.ip)">Del</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="bridge-settings-next-somfy-name"
|
||||
<td><input id="bridge-settings-new-somfy-name"
|
||||
class="form-control" type="text" ng-model="newsomfyname"
|
||||
placeholder="A Somfy"></td>
|
||||
<td><input id="bridge-settings-next-somfy-ip"
|
||||
<td><input id="bridge-settings-new-somfy-ip"
|
||||
class="form-control" type="text" ng-model="newsomfyip"
|
||||
placeholder="https://www.tahomalink.com"></td>
|
||||
<td><input id="bridge-settings-next-somfy-username"
|
||||
<td><input id="bridge-settings-new-somfy-username"
|
||||
class="form-control" type="text" ng-model="newsomfyusername"
|
||||
placeholder="Somfy username"></td>
|
||||
<td><input id="bridge-settings-next-somfy-password"
|
||||
<td><input id="bridge-settings-new-somfy-password"
|
||||
class="form-control" type="password" ng-model="newsomfypassword"
|
||||
placeholder="Somfy password"></td>
|
||||
<td><button class="btn btn-success" type="submit"
|
||||
|
||||
Reference in New Issue
Block a user