Closed hamwong closed 7 years ago
can it be set second device in mqtt.conf and run both device?
sp1 is supported and could be used with host/mac specified mp1 is not supported by the https://github.com/mjg59/python-broadlink library and broadlink-mqtt as well
now it works with single device only but I'm working on multi-mode supporting several devices at same time
Hi, I found your code got another bug when load in other directory,
Traceback (most recent call last): File "/home/pi/broadlink-mqtt/mqtt.py", line 61, in on_message replay(device, file) File "/home/pi/broadlink-mqtt/mqtt.py", line 112, in replay with open(file, 'rb') as f: IOError: [Errno 2] No such file or directory: 'commands/tv/Contex/power'
by the way, do you mind tell me how to do command SP1 on mqtt? as the code I am using https://github.com/johado/python-broadlink/tree/master/broadlink Johado Branch work with MP1, I may command it by simple python command but I really don't know how to write code, I may do a little modify on your coding.
currently I am using a bash script to check any multi instance, do you think you may add code to ignore double lock same devices?
while true; do
Checksum=$(ps -ef | grep mqtt -c) Checkid=$(ps -ef | grep mqtt | awk 'NR==1{print $2 }') if [ "$Checksum" == 2 ]; then echo "MQTT Already Loaded" break elif [ "$Checksum" == 1 ]; then python /home/pi/broadlink-mqtt/mqtt.py & echo "MQTT Loading" sleep 2 else sudo kill $Checkid echo "$Checksum \n" echo "Killed multi mqtt instane" fi done
Thanks for reporting issues! I've fixed bug with directories and also added support for mp1 device
To ignore double lock you can start two instances of mqtt.py with different config files used and both of them should use non-lookup device type with exact IP and MAC addresses specified
What do you mean by "do command SP1" ?
you said code is able to control SP1, than how should I turn SP1 on/off on mqtt?
for Infra-Red: eg: mosquitto_pub -h localhost -p 1883 -q qos -t broadlink/purfier/Sharp/IONoff -m replay
than how does SP1 control on MQTT?
I tried to run the code with openhab start by openhab rules, but I found with unknown reason, code run twice on background on openhab rules, I add log msg and it only have once, so it is very oddly.
please try "broadlink/power" topic now with on/off payload to switch on and off device
Thanks, confirm directory issue have been fixed on stored ir
hi, I am looking at your code, and also review the code on https://github.com/mjg59/python-broadlink , I think MP1 is supported by original, just not complected,
anyway, I think the command you use in your code only for SP1, SP2 got little difference before support multi device, will it be difficult to add check power state in code? I mean as I found the code should locking the device, should it be able to know the power status changed and revert back on MQTT?
PS, on SP2 or MP1, command changed to 1 turns socket and on/off comand change to True/False
Again, Thanks for your hard work, below for your reference
Set power state on a SmartPlug SP2/SP3:
devices[0].set_power(True) Check power state on a SmartPlug:
state = devices[0].check_power() Set power state for S1 on a SmartPowerStrip MP1:
devices[0].set_power(1, True) Check power state on a SmartPowerStrip:
state = devices[0].check_power()
hi,
I suggest on code line 202 if broadlink_rm_temperature_interval > 0: it should also add device_type ='RM', otherwise if user forgot to add # on temp timer, code will crash when timer on time,
sp1 command works, I made mistake while modify code,
Hi, FYI when I use simple python command state = devices[0].check_power() print devices[0].check_power() I got result as {'s3': True, 's2': True, 's1': True, 's4': True} for set socket 4 off, devices.set_power(4, False)
HI, I guess you need to set exception on time out, code will stop when there is time out
Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/home/pi/broadlink-mqtt/mqtt.py", line 178, in run self.s.run() File "/usr/lib/python2.7/sched.py", line 117, in run action(*argument) File "/home/pi/broadlink-mqtt/mqtt.py", line 166, in broadlink_rm_temperature_timer temperature = str(device.check_temperature()) File "/usr/local/lib/python2.7/dist-packages/broadlink-0.3-py2.7.egg/broadlink/init.py", line 569, in check_temperature response = self.send_packet(0x6a, packet) File "/usr/local/lib/python2.7/dist-packages/broadlink-0.3-py2.7.egg/broadlink/init.py", line 342, in send_packet response = self.cs.recvfrom(1024) timeout: timed out
I've changed several things and added support of messages like 1/on for MP1 device Please check
Hi, so excited, Thanks for your hard work, currently in office, will do it once I back home
hi, I can't figure out how to command mp1 with your new code, do you mind give a hand on it, I take several wild guess but all fail. Thanks and regards
[2017-02-25 01:45:21,386] DEBUG Received MQTT message broadlink2/power off [2017-02-25 01:45:21,387] DEBUG Unrecognized MQTT message off [2017-02-25 01:46:12,934] DEBUG Received MQTT message broadlink2/1/power off [2017-02-25 01:46:12,935] DEBUG Unrecognized MQTT message off [2017-02-25 01:46:24,026] DEBUG Received MQTT message broadlink2/1 off [2017-02-25 01:46:24,027] DEBUG Unrecognized MQTT message off [2017-02-25 01:47:27,987] DEBUG Received MQTT message broadlink2/power on [2017-02-25 01:47:27,988] DEBUG Unrecognized MQTT message on [2017-02-25 01:47:41,613] DEBUG Received MQTT message broadlink2/power 1 [2017-02-25 01:47:41,614] DEBUG Unrecognized MQTT message 1 [2017-02-25 01:48:11,591] DEBUG Received MQTT message broadlink2/power 1 on [2017-02-25 01:48:11,591] DEBUG Unrecognized MQTT message 1 on [2017-02-25 01:49:03,081] DEBUG Received MQTT message broadlink2/power on 1 [2017-02-25 01:49:03,082] DEBUG Unrecognized MQTT message on 1 [2017-02-25 01:49:06,136] DEBUG Received MQTT message broadlink2/power 1 1 [2017-02-25 01:49:06,137] DEBUG Unrecognized MQTT message 1 1 [2017-02-25 01:49:26,320] DEBUG Received MQTT message broadlink2/1/power on [2017-02-25 01:49:26,321] DEBUG Unrecognized MQTT message on
use SOCKET/STATE format for message on broadlink/power topic like 3/on or 2/off
It works.~~ it's great thank you for your hard work~~~ really appreciate what you have done, looking forward that MQTT can also revert power status ~
in fact I can't found which part in your code convert on > True off > False Thanks for your code~
I found SP1, in your code, and some code looks unfinished yet, may I know can I use your code control socket? thanks