several changes

master
openhabian configurator 2019-11-10 16:10:43 +01:00
parent c2bf6d60e4
commit 28ea7b8d90
12 changed files with 436 additions and 1 deletions

82
items/all.items.sample Normal file
View File

@ -0,0 +1,82 @@
// https://www.openhab.org/docs/configuration/iconsets/classic/
Group level2 "Level2"
Group ground_floor "Ground Floor" <groundfloor> (level2)
Group main_floor "Second Floor" <firstfloor> (level2)
Group engineering "Engineering" (main_floor)
Group lab "Lab" (main_floor)
Group chill_zone "Chill Zone" (main_floor)
Group entrance "Entrance" (main_floor)
//-------------------------------------------------------------------------------
// https://community.openhab.org/t/sonoff-tasmota-with-mqtt-binding-2-4-using-config-files/61494
Switch ground_floor_door "Door" <frontdoor> (ground_floor)
Switch engineering_table_lamps "Table Lamps" <lightbulb> (engineering) { channel="mqtt:topic:engineering_table_lamps_socket:power" }
Switch engineering_ceiling_lamps "Ceiling Lamps" <lightbulb> (engineering) { channel="mqtt:topic:engineering_ceiling_lamps_socket:power" }
Switch chill_zone_lamps
"Lamps"
<lightbulb>
(chill_zone)
{ channel="mqtt:topic:chill_zone_lamps_socket:power" }
Number chill_zone_lamps_socket_switch_vcc
"Switch Voltage [%.3f]"
(chill_zone)
{ channel="mqtt:topic:chill_zone_lamps_socket_switch:voltage" }
String chill_zone_lamps_socket_switch_uptime
"Uptime [%s]"
(chill_zone)
{ channel="mqtt:topic:chill_zone_lamps_socket_switch:uptime" }
Number chill_zone_lamps_socket_switch_rssi
"RSSI [%d]"
(chill_zone)
{ channel="mqtt:topic:chill_zone_lamps_socket_switch:rssi" }
// If ChromeCast doesn't work you have to link this item with the Chromecast channel manually
String chill_zone_chromecast_appid
"Chromecast AppId [%s]"
{ channel="chromecast:chromecast:b000d809ccb35a409a3dd3d14e0fbf08:appId" }
// If ChromeCast doesn't work you have to link this item with the Chromecast channel manually
String chill_zone_chromecast_status
"Chromecast Status [%s]"
{ channel="chromecast:chromecast:b000d809ccb35a409a3dd3d14e0fbf08:statustext" }
Switch chill_zone_beamer_switch
"Beamer"
(chill_zone)
Number chill_zone_beamer_input
"Beamer Input"
// Selection chill_zone_beamer_input
// "Beamer Input"
// (chill_zone)
// Selection chill_zone_beamer_input
// "Beamer Input"
// (chll_zone)
// mappings=[
// 0="DVI",
// 1="HDMI 1",
// 2="HDMI 2",
// 3="VGA 1",
// 4="VGA 2"
// ]
Switch chill_zone_lamps_switch
{ channel="mqtt:topic:chill_zone_lamps_socket_switch:power" }
// Item types: https://www.openhab.org/docs/configuration/items.html#type

9
openhab2.iml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

173
rules/all.rules.sample Normal file
View File

@ -0,0 +1,173 @@
// https://www.openhab.org/addons/bindings/http1/
// Command types: OnOffType, IncreaseDecreaseType, PercentType, HSBType, ...
// Events: changed, received update, received command
// Commands: postUpdate(), sendCommand(), ...
// The following two are equal:
// chill_zone_lamps_switch.sendCommand(chill_zone_lamps.state as OnOffType)
// sendCommand(chill_zone_lamps_switch, chill_zone_lamps.state as OnOffType)
// Variables available in the execution block:
// receivedCommand, previousState, triggeringItem, receivedEvent
import java.util.List
import java.util.ArrayList
rule "Open Door"
when
Item ground_floor_door changed
then
// the IP of the real relay is 10.0.101.6
//val host = '10.0.101.6'
// val host = 'localhost:9090'
// http://10.0.101.6/state.xml?relay1State=2&pulseTime1=5
//val String url = "http://" + host + "/state.xml"
//logInfo("RestApi", "URL: {}", url)
// val String state = sendHttpGetRequest(url)
// logInfo("RestApi", "Output: {}", state)
//val String longurl = "http://www.deutschlandfunk.de/podcast-nachrichten.1257.de.podcast.xml"
val String response = sendHttpGetRequest("http://10.0.101.6/state.xml?relay1State=2&pulseTime1=55", 1000)
if (response === null) {
logInfo("RelayState", "State: null")
} else {
val String relayState = transform("XPATH", "/datavalues/relay1state", response)
logInfo("RelayState", "State: " + relayState)
}
// 19:19:15.207 [ERROR] [e.smarthome.model.script.actions.HTTP] - Fatal transport error:
// java.util.concurrent.ExecutionException:
// org.eclipse.jetty.client.HttpResponseException:
// HTTP protocol violation: bad response on HttpConnectionOverHTTP@2c22f14b(l:/10.2.113.167:48056 <-> r:/10.0.101.6:80,closed=false)=>HttpChannelOverHTTP@24f1b504(exchange=HttpExchange@797f0a37 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@77bae95f(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@33643fd2{s=START}],recv=HttpReceiverOverHTTP@1a14f52f(rsp=IDLE,failure=null)[HttpParser{s=CLOSE,0 of -1}]]<-SocketChannelEndPoint@1bbb6ae8{/10.0.101.6:80<->/10.2.113.167:48056,OPEN,fill=-,flush=-,to=1/0}{io=0/0,kio=0,kro=1}->HttpConnectionOverHTTP@2c22f14b(l:/10.2.113.167:48056 <-> r:/10.0.101.6:80,closed=false)=>HttpChannelOverHTTP@24f1b504(exchange=HttpExchange@797f0a37 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@77bae95f(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@33643fd2{s=START}],recv=HttpReceiverOverHTTP@1a14f52f(rsp=IDLE,failure=null)[HttpParser{s=CLOSE,0 of -1}]]
end
rule "Beamer Power"
when
Item chill_zone_beamer_switch changed
then
val state = chill_zone_beamer_switch.state.toString
// logInfo("RestApi", "Command: {}", receivedCommand)
if (state == 'ON') {
state = sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3101fe0660")
} else {
state = sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3102fd0660")
}
logInfo("Beamer", "State: {}", state)
end
rule "Beamer Input"
when
Item chill_zone_beamer_input changed
then
val state = chill_zone_beamer_input.state
// val List<String> commands = newArrayList(
// "2a3109f6070566",
// "2a3109f6071475",
// "2a3109f6071576",
// "2a3109f6070162",
// "2a3109f6070263"
// )
// val url = "http://10.2.113.7/tgi/return.tgi?command=" + commands.get(state)
logInfo("Bamer_Input", "Beamer Input: {}", state)
switch (state) {
// DVI - hackerspace video
case 0: sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3109f6070566")
// HDMI1
case 1: sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3109f6071475")
// HDMI2 - chromecast
case 2: sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3109f6071576")
// VGA1
case 3: sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3109f6070162")
// VGA2
case 4: sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3109f6070263")
}
end
rule "Switch changed"
when
Item chill_zone_lamps_switch changed
then
logInfo("Rules", "Switch changed: {}", chill_zone_lamps_switch.state)
chill_zone_lamps.sendCommand(chill_zone_lamps_switch.state as OnOffType)
end
rule "Lamps changed"
when
Item chill_zone_lamps changed
then
logInfo("Rules", "Lamps changed: {}", chill_zone_lamps_switch.state)
chill_zone_lamps_switch.sendCommand(chill_zone_lamps.state as OnOffType)
end
rule "Switch voltage"
when
Item chill_zone_lamps_socket_switch received update or Item chill_zone_lamps_socket_switch changed
then
logInfo("Rules", "Voltage: {}", chill_zone_lamps_switch)
// chill_zone_lamps_socket_vcc.postUpdate()
end
rule "Chromecast changed"
when
Item chill_zone_chromecast_status changed //or Item chill_zone_chromecast_appid changed
// or Item chromecast_chromecast_b000d809ccb35a409a3dd3d14e0fbf08 changed or Item chromecast_chromecast_b000d809ccb35a409a3dd3d14e0fbf08 received update or Item chromecast_chromecast_b000d809ccb35a409a3dd3d14e0fbf08 received command
// or Item chromecast_chromecast_b000d809ccb35a409a3dd3d14e0fbf08_appId changed or Item chromecast_chromecast_b000d809ccb35a409a3dd3d14e0fbf08_appId received update or Item chromecast_chromecast_b000d809ccb35a409a3dd3d14e0fbf08_appId received command
// or Item chromecast_chromecast_b000d809ccb35a409a3dd3d14e0fbf08_CC1AD845 changed or Item chromecast_chromecast_b000d809ccb35a409a3dd3d14e0fbf08_CC1AD845 received update or Item chromecast_chromecast_b000d809ccb35a409a3dd3d14e0fbf08_CC1AD845 received command
// Item chill_zone_chromecast changed
then
sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3101fe0660")
// @todo: wait here until the beamer is online
//val app = chromecast_chromecast_b000d809ccb35a409a3dd3d14e0fbf08_CC1AD845.state.toString
val app = chill_zone_chromecast_status.state.toString
val input = null
if (app == null || app == UNDEF || app == 'UNDEF' || app == '' ) {
// if (app == null || app == 'UNDEF' ) {
input = 0 // hackerspace video
chill_zone_beamer_input.postUpdate(input)
// chill_zone_beamer_input.sendCommand(input)
} else {
input = 2 // chromecast
chill_zone_beamer_input.postUpdate(input)
// chill_zone_beamer_input.sendCommand(input)
}
logInfo("beamer", "Set beamer input: {}", input)
end
// rule "status received update"
// when
// Item status received update
// then
// relaySwitch.postUpdate(if(status.state.toString == "1") ON else OFF)
// end
// Persistence services and the Rule engine are started in parallel. Because of
// this, it is possible that, during an openHAB startup, Rules will execute before
// Item states used by those Rules have been restored. (In this case, those unrestored
// Items have an "undefined" state when the Rule is executed.) Therefore, Rules
// that rely on persisted Item states may not work correctly on a consistent basis.
// IPs:
//
// * ChromeCast: http://10.2.113.120:8008

8
services/dashboard.cfg Normal file

File diff suppressed because one or more lines are too long

18
services/http.cfg Normal file
View File

@ -0,0 +1,18 @@
# timeout in milliseconds for the http requests (optional, defaults to 5000)
#timeout=
# the interval in milliseconds when to find new refresh candidates
# (optional, defaults to 1000)
#granularity=
# whether to substitute the current time or state value into the URL
# (optional, defaults to true)
#format=
# configuration of the first cache item
#<id1>.url=
#<id1>.updateInterval=
# configuration of the second cache item
#<id2>.url=
#<id2>.updateInterval=

14
services/influxdb.cfg Normal file
View File

@ -0,0 +1,14 @@
# The database URL, e.g. http://127.0.0.1:8086 or https://127.0.0.1:8084 .
# Defaults to: http://127.0.0.1:8086
# url=http(s)://<host>:<port>
# The name of the database user, e.g. openhab.
# Defaults to: openhab
# user=<user>
# The password of the database user.
# password=
# The name of the database, e.g. openhab.
# Defaults to: openhab
# db=<database>

30
services/mail.cfg Normal file
View File

@ -0,0 +1,30 @@
# The SMTP server hostname, e.g. "smtp.gmail.com"
#hostname=
# the SMTP port to use (optional, defaults to 25 (resp. 587 for TLS/SSL))
#port=
# the username and password if the SMTP server requires authentication
#username=
#password=
# The email address to use for sending mails
#from=
# set to "true", if STARTTLS is enabled (not required) for the connection
# (optional, defaults to false)
#tls=
# set to "true", if SSL negotiation should occur on connection
# do not use both tls=true and ssl=true
# (optional, defaults to false)
#ssl=
# set to "true", if POP before SMTP (another authentication mechanism)
# should be enabled. Username and Password are taken from the above
# configuration (optional, default to false)
#popbeforesmtp=
# Character set used to encode message body
# (optional, if not provided platform default is used)
#charset=

0
services/mapdb.cfg Normal file
View File

40
services/mqtt.cfg Normal file
View File

@ -0,0 +1,40 @@
#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#
# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
#<broker>.url=tcp://<host>:1883
# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
#<broker>.clientId=<clientId>
# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false
# Optional. User id to authenticate with the broker.
#<broker>.user=<user>
# Optional. Password to authenticate with the broker.
#<broker>.pwd=<password>
# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>
# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>
# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>
# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>

1
services/twitter.cfg Normal file
View File

@ -0,0 +1 @@
enabled=true

60
things/all.things.sample Normal file
View File

@ -0,0 +1,60 @@
Bridge mqtt:broker:mosquitto "Mosquitto" [
host="localhost",
port=1883,
secure=false,
username="",
password="",
clientID="openHAB2"
]{
Thing topic chill_zone_lamps_socket "Power Socket" @ "Chill zone" {
Channels:
Type switch : power "Power" [
stateTopic="stat/chill_zone/lamp/Power",
commandTopic="cmnd/chill_zone/lamp/Power"
]
}
Thing topic engineering_table_lamps_socket "Table Power Socket" @ "Engineering" {
Channels:
Type switch : power "Power" [
stateTopic="stat/engineering/table_lamp/Power",
commandTopic="cmnd/engineering/table_lamp/Power"
]
}
Thing topic engineering_ceiling_lamps_socket "Ceiling Power Socket" @ "Engineering" {
Channels:
Type switch : power "Power" [
stateTopic="stat/engineering/ceiling_lamp/Power",
commandTopic="cmnd/engineering/ceiling_lamp/Power"
]
}
// Thing topic chill_zone_lamps_socket_switch "Power Socket Switch" @ "Chill zone" {
// Channels:
// Type switch : power "Power" [
// stateTopic="stat/sonoff2/POWER",
// commandTopic="cmnd/sonoff2/POWER"
// ]
// Type number : voltage "Voltage" [
// stateTopic="tele/sonoff2/STATE",
// transformationPattern="JSONPATH:$.Vcc"
// ]
// Type string : uptime "Uptime" [
// stateTopic="tele/sonoff2/STATE",
// transformationPattern="JSONPATH:$.Uptime"
// ]
// Type number : rssi "RSSI" [
// stateTopic="tele/sonoff2/STATE",
// transformationPattern="JSONPATH:$.Wifi.RSSI"
// ]
// }
}
// When the callback URL matters - https://github.com/openhab/openhab2-addons/issues/1984#issuecomment-285320106
// OpenHAB is not able to communicate with the chromecast => Remote host closed connection during handshake
// Thing chromecast:chromecast:b000d809ccb35a409a3dd3d14e0fbf08 [ipAddress="10.2.113.120", port=8008]
Thing chromecast:chromecast:b000d809ccb35a409a3dd3d14e0fbf08 [ipAddress="10.2.113.120", port=8009]

View File

@ -52,7 +52,7 @@ Bridge mqtt:broker:mosquitto "Mosquitto" [
commandTopic="cmnd/chill_zone/sonoffs/Power"
]
}
Thing exec:command:beamerpower [command="/sbin/apcaccess -u", interval=5, timeout=2, autorun=false]
// Thing exec:command:beamerpower [command="/sbin/apcaccess -u", interval=5, timeout=2, autorun=false]
// ----------------------------------------------------------------------------