I have some DI-O/Cacon cover managed via MQTT Cover. I only have 2 buttons : UP/DOWN.
When I press UP, I can press UP again to STOP. Same thing for DOWN.
I want to add function this to STOP button. This idea is to get the STOP action in MQTT, get the last action/position of the cover and send to mqtt the action UP or DOWN and stop the cover.
I’m looking at appdameon but it seems i can’t use paho lib for mqtt.??
I can make an external python script if appdaemon can’t but I would prefer use appdaemon.
Do you have an other solution. to implement STOP action ?
I have checked this thread before writing here : https://community.home-assistant.io/t/appdaemon-mqtt/8118.
Maybe i misunderstood, but i see : [quote=“aimc, post:2, topic:8118”]
AppDaemon currently does not have the code to integrate directly with MQTT,
[/quote]
Yes, correct. My comment above was saying that there is no explicit support for MQTT in AppDaemon, but it’s just Python code so you can use any libraries that you like in AppDaemon Apps.
Hi, i m still using a small Python script without appdaemon. I didn’t get time to migrate to appdaemon but i can share it of course, maybe tomorrow.
I am using mqtt to get and set status of my cover so it just a mqtt call linked with last action. I run this script at startup with systemctl.
Edit : add script parts :
#!/usr/bin/python
import paho.mqtt.client as mqtt
import redis
import time
import re
import json
def init_db():
db = redis.Redis(host='127.0.0.1', port=6379, db=0)
return db
def on_connect(client, userdata, rc):
print("Connected with result code "+str(rc))
client.subscribe( [
("RF/command",0),
] )
def on_message(client, userdata, msg):
db = init_db()
if str(msg.topic) == "RF/command":
print "Topic: ", msg.topic+'\nMessage: '+str(msg.payload)
if str(msg.payload) == "10;NewKaku;123456;1;ON":
db.setex('window_currentPosition',"ON",2592000)
elif str(msg.payload) == "10;NewKaku;123456;1;OFF":
db.setex('window_currentPosition',"OFF",2592000)
elif str(msg.payload) == "10;NewKaku;123456;1;STOP":
cover('window',client)
elif str(msg.payload) == "10;NewKaku;654321;2;ON":
db.setex('door_currentPosition',"ON",2592000)
elif str(msg.payload) == "10;NewKaku;654321;2;OFF":
db.setex('door_currentPosition',"OFF",2592000)
elif str(msg.payload) == "10;NewKaku;654321;2;STOP":
cover('door',client)
def cover(name,client):
db = init_db()
if name == 'window':
time_to_100 = 14 // later
payload_on = "10;NewKaku;123456;1;ON"
payload_off = "10;NewKaku;123456;1;OFF"
elif name == 'door':
time_to_100 = 22 // later
payload_on = "10;NewKaku;654321;2;ON"
payload_off = "10;NewKaku;654321;2;OFF"
if db.get(str(name)+'_currentPosition') == 'OFF':
print("OFF")
client.publish("RF/command",payload_off,qos=0,retain=False)
elif db.get(str(name)+'_currentPosition') == 'ON':
print("ON")
client.publish("RF/command",payload_on,qos=0,retain=False)
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect("192.168.1.10", 1883, 60)
client.loop_forever()