Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I have done the Following.
- 1. Flashed the Sonoff itead Switch
- 2. Configured the Mosquitto broker
- 3. Configured the mqtt.cfg for openhab
- Now I checked if everything is working.
- I can access the Sonoff Switch via. Firefox
- I check and configure the MQTT for the Sonoff Switch.
- Sonoff Console Log
- ```csv
- 00:00:00 APP: Project sonoff Sonoff (Topic cmnd/sonoff-977686, Fallback DVES_977686, GroupTopic sonoffs) Version 4.0.8
- 00:00:00 Wifi: Connecting to AP1 wonderland in mode 11N as cmnd/sonoff-977686-5766...
- 00:00:05 Wifi: Connected
- 00:00:05 mDNS: Initialized
- 00:00:05 HTTP: Webserver active on cmnd/sonoff-977686-5766.local with IP address ***.***.***.***
- 11:01:51 MQTT: Attempting connection...
- 11:01:53 mDNS: Query done with 0 mqtt services found
- 11:01:53 MQTT: Connected
- 11:01:53 MQTT: tele/cmnd/sonoff-977686/LWT = Online (retained)
- 11:01:53 MQTT: cmnd/cmnd/sonoff-977686/POWER =
- 11:01:53 MQTT: tele/cmnd/sonoff-977686/INFO1 = {"Module":"Sonoff Basic", "Version":"4.0.8", "FallbackTopic":"DVES_977686", "GroupTopic":"sonoffs"}
- 11:01:53 MQTT: tele/cmnd/sonoff-977686/INFO2 = {"WebserverMode":"Admin", "Hostname":"cmnd/sonoff-977686-5766", "IPaddress":"***.***.***.***"}
- 11:01:53 MQTT: tele/cmnd/sonoff-977686/INFO3 = {"Started":"Software/System restart"}
- 11:01:54 MQTT: stat/cmnd/sonoff-977686/RESULT = {"POWER":"ON"}
- 11:01:54 MQTT: stat/cmnd/sonoff-977686/POWER = ON
- ```
- Switching from On to Off Mosquitto Log
- ```csv
- 1492682688: Received PUBLISH from DVES_977686 (d0, q0, r0, m0, 'stat/cmnd/sonoff-977686/RESULT', ... (15 bytes))
- 1492682688: Received PUBLISH from DVES_977686 (d0, q0, r0, m0, 'stat/cmnd/sonoff-977686/POWER', ... (3 bytes))
- ```
- Feels good.
- Now I tested an simple MQTT openHAB item.
- ```csv
- Switch LivingRoom_Light "Living Room Light" <light> (ALL, Office_Workstation, Office_First_Floor) { mqtt=">[mosquitto:cmnd/sonoff-977686/POWER:command:*:default], <[mosquitto:stat/cmnd/sonoff-977686/POWER:state:default]" }
- ```
- Verbose Mosquitto Log when saving the openHAB item
- ```csv
- 1492682948: Received PINGREQ from DVES_977686
- 1492682948: Sending PINGRESP to DVES_977686
- 1492682948: Received UNSUBSCRIBE from openhabian.1492677563242
- 1492682948: stat/cmnd/sonoff-977686/POWER
- 1492682948: openhabian.1492677563242 stat/cmnd/sonoff-977686/POWER
- 1492682948: Received SUBSCRIBE from openhabian.1492677563242
- 1492682948: stat/cmnd/sonoff-977686/POWER (QoS 1)
- 1492682948: openhabian.1492677563242 1 stat/cmnd/sonoff-977686/POWER
- 1492682948: Sending SUBACK to openhabian.1492677563242
- ```
- When I press the button on my sitemap Mosquitto Log
- ```csv
- 1492683090: Received PUBLISH from openhabian.1492677563242 (d0, q1, r1, m25, 'cmnd/sonoff-977686/POWER', ... (2 bytes))
- 1492683090: Sending PUBACK to openhabian.1492677563242 (Mid: 25)
- 1492683090: Sending PUBLISH to mosqsub/26728-openHABia (d0, q0, r0, m0, 'cmnd/sonoff-977686/POWER', ... (2 bytes))
- ```
- This did not switch the Sonoff switch so I thought hm okay I should start with a MQTT state read item so I did.
- ```csv
- Switch LivingRoom_Light_State "Give me this state" (All, Office_Workstation, Office_First_Floor) { mqtt="<[mosquitto:stat/cmnd/sonoff-977686/POWER:state:default]" }
- ```
- Was really good the Item on the Sitemap displayed me if the Sonoff itead is on/off.
- But how the DUCK can I switch the Sonoff Switch via openHAB?
- My first Item should do that or not?
- ```csv
- Switch LivingRoom_Light "Living Room Light" <light> (ALL, Office_Workstation, Office_First_Floor) { mqtt=">[mosquitto:cmnd/sonoff-977686/POWER:command:*:default], <[mosquitto:stat/cmnd/sonoff-977686/POWER:state:default]" }
- ```
- Am I missing something?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement