Compare commits
No commits in common. "master" and "robert-master-patch-22461" have entirely different histories.
master
...
robert-mas
@ -1,68 +0,0 @@
|
|||||||
# Homematic IP
|
|
||||||
import homematicip
|
|
||||||
from homematicip.home import Home
|
|
||||||
from homematicip.device import ShutterContact, WallMountedThermostatPro
|
|
||||||
# Import MQTT client.
|
|
||||||
import paho.mqtt.client as paho
|
|
||||||
|
|
||||||
# MQTT credentials
|
|
||||||
# mqtt_username = 'homeassistant' # MQTT client username
|
|
||||||
# mqtt_password = '3355' # MQTT client password
|
|
||||||
client_id = 'homematicip-pi' # unique client_id
|
|
||||||
mqtt_broker = "raspberrypi" # broker address, usually your HASS IP address
|
|
||||||
|
|
||||||
# create the MQTT client
|
|
||||||
client = paho.Client(client_id, protocol=paho.MQTTv31) # * set a random string (max 23 chars)
|
|
||||||
|
|
||||||
# client connection
|
|
||||||
# client.username_pw_set(mqtt_username, mqtt_password) # MQTT server credentials
|
|
||||||
client.connect(mqtt_broker, 1883, 60) # MQTT server address
|
|
||||||
|
|
||||||
# Homematic IP
|
|
||||||
config = homematicip.find_and_load_config_file()
|
|
||||||
|
|
||||||
home = Home()
|
|
||||||
home.set_auth_token(config.auth_token)
|
|
||||||
home.init(config.access_point)
|
|
||||||
|
|
||||||
topic = 'weathersensors/'
|
|
||||||
room = 'Leonie'
|
|
||||||
#client.subscribe(topic + room + "/setHeatingProfile")
|
|
||||||
client.subscribe(topic + room + "/activeProfile")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def on_message(client, userdata, msg): # The callback for when a PUBLISH message is received from the server.
|
|
||||||
global home
|
|
||||||
home.get_current_state()
|
|
||||||
for group in home.groups:
|
|
||||||
if group.label == room:
|
|
||||||
if group.groupType == "HEATING":
|
|
||||||
for profile in group.profiles:
|
|
||||||
if profile.name != "":
|
|
||||||
client.publish(topic + room + "/activeProfile", group.activeProfile.name)
|
|
||||||
client.publish(topic + room + "/heatingProfiles/" + profile.index, profile.name)
|
|
||||||
#print(profile.index + ": " + profile.name)
|
|
||||||
#print(profile.name)
|
|
||||||
#print(msg.payload.decode("utf-8"))
|
|
||||||
if profile.name == msg.payload.decode("utf-8"):
|
|
||||||
print("msg: " + msg.payload.decode("utf-8"))
|
|
||||||
print("Profile Index: " + profile.index)
|
|
||||||
#print(group)
|
|
||||||
group.set_active_profile(profile.index)
|
|
||||||
#print("%s %s" % (msg.topic, msg.payload.decode("utf-8")))
|
|
||||||
|
|
||||||
|
|
||||||
def heating_profile(group):
|
|
||||||
print("Active Heating Profile: " + group.activeProfile.name)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
client.on_message = on_message # Define callback function for receipt of a message
|
|
||||||
|
|
||||||
client.loop_forever() # Start networking daemon
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
@ -29,31 +29,31 @@ docker = docker.from_env()
|
|||||||
|
|
||||||
container = docker.containers.run("rtl_433:inkbird", "-R 42 -R 187 -F json -T 40 -M time:utc:usec", devices={'/dev/bus/usb/001/004:/dev/bus/usb/001/004:rwm'}, remove=True)
|
container = docker.containers.run("rtl_433:inkbird", "-R 42 -R 187 -F json -T 40 -M time:utc:usec", devices={'/dev/bus/usb/001/004:/dev/bus/usb/001/004:rwm'}, remove=True)
|
||||||
|
|
||||||
for line in container.logs(stream=True):
|
for line in container.split('\n'):
|
||||||
|
|
||||||
print("line: " + line)
|
print("line: " + line)
|
||||||
print("line length: " + str(len(line)))
|
print("line length: " + str(len(line)))
|
||||||
|
|
||||||
if len(line) > 0:
|
if len(line) > 0:
|
||||||
jsonData = (json.loads(line))
|
jsonData = (json.loads(line))
|
||||||
|
|
||||||
model = str(jsonData['model'])
|
model = str(jsonData['model'])
|
||||||
if model == "Hideki-TS04":
|
if model == "Hideki-TS04":
|
||||||
topic = 'weathersensors/garden'
|
topic = 'weathersensors/garden'
|
||||||
else:
|
else:
|
||||||
topic = 'weathersensors/pool'
|
topic = 'weathersensors/pool'
|
||||||
|
|
||||||
time = str(jsonData['time'])
|
time = str(jsonData['time'])
|
||||||
if model == "Inkbird ITH-20R":
|
if model == "Inkbird ITH-20R":
|
||||||
battery_json_key = "battery"
|
battery_json_key = "battery"
|
||||||
else:
|
else:
|
||||||
battery_json_key = "battery_ok"
|
battery_json_key = "battery_ok"
|
||||||
battery = str(jsonData[battery_json_key])
|
battery = str(jsonData[battery_json_key])
|
||||||
temperature = str(jsonData['temperature_C'])
|
temperature = str(jsonData['temperature_C'])
|
||||||
humidity = str(jsonData['humidity'])
|
humidity = str(jsonData['humidity'])
|
||||||
|
|
||||||
client.publish(topic + "/time", "" + time)
|
client.publish(topic + "/time", "" + time)
|
||||||
client.publish(topic + "/battery", "" + battery)
|
client.publish(topic + "/battery", "" + battery)
|
||||||
client.publish(topic + "/temperature", "" + temperature)
|
client.publish(topic + "/temperature", "" + temperature)
|
||||||
client.publish(topic + "/humidity", "" + humidity)
|
client.publish(topic + "/humidity", "" + humidity)
|
||||||
client.publish(topic + "/availability", "ON")
|
client.publish(topic + "/availability", "ON")
|
||||||
|
@ -1,61 +1,86 @@
|
|||||||
|
import json
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
# Homematic IP
|
# Homematic IP
|
||||||
import homematicip
|
import homematicip
|
||||||
from homematicip.home import Home
|
from homematicip.home import Home
|
||||||
from homematicip.device import ShutterContact, WallMountedThermostatPro
|
from homematicip.device import ShutterContact,HeatingThermostat,PlugableSwitchMeasuring,WallMountedThermostatPro
|
||||||
|
|
||||||
# Import MQTT client.
|
# Import MQTT client.
|
||||||
|
import paho.mqtt.publish as publish
|
||||||
import paho.mqtt.client as paho
|
import paho.mqtt.client as paho
|
||||||
|
|
||||||
# MQTT credentials
|
# MQTT credentials
|
||||||
# mqtt_username = 'homeassistant' # MQTT client username
|
# mqtt_username = 'homeassistant' # MQTT client username
|
||||||
# mqtt_password = '3355' # MQTT client password
|
# mqtt_password = '3355' # MQTT client password
|
||||||
client_id = 'homematicip-pi' # unique client_id
|
# client_id = 'temperature' # unique client_id
|
||||||
mqtt_broker = "raspberrypi" # broker address, usually your HASS IP address
|
mqtt_broker = "raspberrypi" # broker address, usually your HASS IP address
|
||||||
|
|
||||||
# create the MQTT client
|
# create the MQTT client
|
||||||
client = paho.Client(client_id, protocol=paho.MQTTv31) # * set a random string (max 23 chars)
|
global client
|
||||||
|
client = paho.Client(protocol=paho.MQTTv31) # * set a random string (max 23 chars)
|
||||||
|
|
||||||
# client connection
|
# client connection
|
||||||
# client.username_pw_set(mqtt_username, mqtt_password) # MQTT server credentials
|
# client.username_pw_set(mqtt_username, mqtt_password) # MQTT server credentials
|
||||||
client.connect(mqtt_broker, 1883, 60) # MQTT server address
|
client.connect(mqtt_broker, 1883, 60) # MQTT server address
|
||||||
|
|
||||||
# Homematic IP
|
# Homematic IP
|
||||||
config = homematicip.find_and_load_config_file()
|
config = homematicip.find_and_load_config_file()
|
||||||
|
|
||||||
home = Home()
|
home = Home()
|
||||||
home.set_auth_token(config.auth_token)
|
home.set_auth_token(config.auth_token)
|
||||||
home.init(config.access_point)
|
home.init(config.access_point)
|
||||||
|
|
||||||
|
def write_shutter(room,device):
|
||||||
|
print(room, " ", device.label, " ", device.lastStatusUpdate, " ", device.windowState)
|
||||||
|
#print(device)
|
||||||
|
|
||||||
def write_shutter(room, device):
|
def write_plugableswitchmeasuring(room,device):
|
||||||
print(room, " ", device.label, " ", device.lastStatusUpdate, " ", device.windowState)
|
print(room, " ", device.label, " ", device.lastStatusUpdate, " ", device.currentPowerConsumption, " ", device.energyCounter)
|
||||||
# print(device)
|
|
||||||
|
|
||||||
|
def write_heatingthermostat(room,device):
|
||||||
|
print(room, " ", device.label, " ", device.lastStatusUpdate)
|
||||||
|
|
||||||
def write_wallmountedthermostatpro(room, device):
|
def write_wallmountedthermostatpro(room,device):
|
||||||
topic = 'weathersensors/' + room
|
global time
|
||||||
|
global deviceName
|
||||||
|
global actualTemperature
|
||||||
|
global setPointTemperature
|
||||||
|
global humidity
|
||||||
|
|
||||||
client.publish(topic + "/time", "" + str(device.lastStatusUpdate))
|
time = device.lastStatusUpdate
|
||||||
client.publish(topic + "/actualTemperature", "" + str(device.actualTemperature))
|
deviceName = device.label
|
||||||
client.publish(topic + "/setPointTemperature", "" + str(device.setPointTemperature))
|
actualTemperature = device.actualTemperature
|
||||||
client.publish(topic + "/humidity", "" + str(device.humidity))
|
setPointTemperature = device.setPointTemperature
|
||||||
|
humidity = device.humidity
|
||||||
|
|
||||||
|
topic = 'weathersensors/'+room
|
||||||
|
|
||||||
|
#print(topic)
|
||||||
|
|
||||||
|
client.publish(topic + "/time", "" + str(time))
|
||||||
|
client.publish(topic + "/actualTemperature", "" + str(actualTemperature))
|
||||||
|
client.publish(topic + "/setPointTemperature", "" + str(setPointTemperature))
|
||||||
|
client.publish(topic + "/humidity", "" + str(humidity))
|
||||||
client.publish(topic + "/availability", "ON")
|
client.publish(topic + "/availability", "ON")
|
||||||
|
|
||||||
print({"Room": room, "Device Name": device.label, "Last Status Update": device.lastStatusUpdate,
|
print({"Room":room, "Device Name":device.label, "Last Status Update" : device.lastStatusUpdate, "Actual Temperature":device.actualTemperature, "Set Point Temperature":device.setPointTemperature,"Humidity":device.humidity})
|
||||||
"Actual Temperature": device.actualTemperature, "Set Point Temperature": device.setPointTemperature,
|
|
||||||
"Humidity": device.humidity})
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global home
|
global home
|
||||||
home.get_current_state()
|
home.get_current_state()
|
||||||
for group in home.groups:
|
for group in home.groups:
|
||||||
if group.groupType == "META":
|
if group.groupType=="META":
|
||||||
for device in group.devices:
|
for device in group.devices:
|
||||||
if isinstance(device, ShutterContact):
|
if isinstance(device,ShutterContact):
|
||||||
write_shutter(group.label, device)
|
write_shutter(group.label,device)
|
||||||
elif isinstance(device, WallMountedThermostatPro):
|
elif isinstance(device,HeatingThermostat):
|
||||||
write_wallmountedthermostatpro(group.label, device)
|
write_heatingthermostat(group.label,device)
|
||||||
|
elif isinstance(device,PlugableSwitchMeasuring):
|
||||||
|
write_plugableswitchmeasuring(group.label,device)
|
||||||
|
elif isinstance(device,WallMountedThermostatPro):
|
||||||
|
write_wallmountedthermostatpro(group.label,device)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user