Page 1 of 1
help for telegram silent with python
Posted: Wednesday 25 May 2022 14:40
by david31
Hello
I would like to send a silent message with python.
With LUA on domoticz, it's working fine.
but not in python ...
Code: Select all
def send_mqtt_publish(topic, data):
data_mqtt = json.dumps(data)
mqttc.publish(topic, data)
def on_connect(client, userdata, flags, rc):
mqttc.connected_flag=True
mqttc.subscribe(MQTT_TOPIC_IN)
mqttc.subscribe(MQTT_TOPIC_OUT)
mqttc = mqtt.Client()
mqttc.on_connect = on_connect
mqttc.connected_flag=False
mqttc.connect("127.0.0.1", 1883, 60)
mqttc.loop_start()
send_mqtt_publish(MQTT_TOPIC_IN, '{\"command\": \"sendnotification\", \"subject\": \"Alarme\", \"body\": \"Probleme arrosage, intervention immediate\", \"Priority\": -1}')
time.sleep(time_disconnect_mqtt)
mqttc.disconnect()
sys.exit(0)
The flag priority not work ... message have always a sound ...
Sorry for my bad english
Re: help for telegram silent with python
Posted: Wednesday 25 May 2022 15:58
by waltervl
what does the log file say? Can it read -1 ? Perhaps try
\"Priority\": \"-1\"}
Re: help for telegram silent with python
Posted: Wednesday 25 May 2022 16:02
by david31
On log file, none error
I have tested, not working ...
Re: help for telegram silent with python
Posted: Wednesday 25 May 2022 16:35
by waltervl
According wiki:
"priority": 0 }
So not: Priority (case sensitive)
Re: help for telegram silent with python
Posted: Wednesday 25 May 2022 16:38
by jvdz
Try using lowercase for priority:
Code: Select all
send_mqtt_publish(MQTT_TOPIC_IN, '{\"command\": \"sendnotification\", \"subject\": \"Alarme\", \"body\": \"Probleme arrosage, intervention immediate\", \"priority\": -1}')
ps: Which version are you running?
Re: help for telegram silent with python
Posted: Wednesday 25 May 2022 16:42
by david31
Los case, same problem
Version: 2022.1
Build Hash: c9526851b
Compile Date: 2022-01-31 09:34:32
dzVents Version: 3.1.8
Python Version: 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
Re: help for telegram silent with python
Posted: Wednesday 25 May 2022 16:46
by jvdz
Ok ... Show me the LUA script that is working so I understand what you are doing.
(but the parameters in MQTT need to be lowercase!)
Code: Select all
{"command": "sendnotification",
"idx": idx,
"name": "Some name",
"subsystem": "target subsystems"
"subject": "Message Subject",
"body": "Message Body",
"extradata": "extradata"
"priority": priority,
"sound": "mysound",
"brfromnotification": "brfromnotificationdata" }
Re: help for telegram silent with python
Posted: Wednesday 25 May 2022 16:49
by david31
It's working
Code: Select all
send_mqtt_publish(MQTT_TOPIC_IN, '{\"command\": \"sendnotification\", \"subject\": \"Alarme\", \"priority\": -1, \"body\": \"Probleme arrosage, intervention immediate\"}')
low case priority and after subject only
Thanks for all
Re: help for telegram silent with python
Posted: Wednesday 25 May 2022 17:22
by jvdz
Do you mean you need to define the priority After the subject field?
This is also working fine for me:
Code: Select all
{"command": "sendnotification", "subsystems": "telegram" ,"priority": -1, "subject": "Alarm", "body": "Test, message2"}
Re: help for telegram silent with python
Posted: Wednesday 25 May 2022 17:40
by david31
If priority is lastest, not work for me ...
Work somewhere
The message is receive all cases
Re: help for telegram silent with python
Posted: Wednesday 25 May 2022 18:16
by jvdz
Works for me anywhere I place "priority" and that is what is expected as the JSON is translated into an Object with and you address them through their keywords. SO as long as the JSON is coded correctly things should work irrelevant the sequence of these keywords.
