• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


[Fully Supported] CleverWatts
#1
Hi - It's my first time trying to give back to this community, please be gentle... I have managed to get "Clever Watts 240v wireless wall sockets" working.

[Image: Watts_Clever_AUS_Socket_Set_large.gif?v=1381702905]

I would happily make a "protocol" but I'm not sure how to do so, so instead i stuck to what I know well, bash scripting. I hope its OK. The script is called "cleverwatts" and must be made executable (chmod +x cleverwatts) and placed in the directory where the pilight compiled binaries are located.

Code:
#!/bin/sh

if [ "$#" -ne "2" ]; then
        echo "Missing paramaters."
        echo ""
        echo "Usage: $0 <id:1|2|3|all> <command:on|off>"
        echo ""
        echo "Example: $0 1 on"
        echo "Would turn device 1 on."
        echo ""
        echo "Example: $0 all off"
        echo "Would turn all devices off."
        echo ""
        exit 1
fi

ps -ef|grep -q pilight-daemon|grep -v grep
if [ "$?" -eq 0 ]; then
        echo "The pilight-daemon not running. Start daemon first."
        exit 1
fi

case $1 in
        1)
                case $2 in
                        ON|on)
                                pilight-send -p raw -c "271 813 813 271 813 271 271 813 813 271 813 271 813 271 271 813 813 271 271 813 813 271 271 1084 813 271 271 813 271 813 813 271 271 1084 271 813 271 813 271 813 813 271 813 271 813 271 271 1084 271 9214"
                        ;;
                        OFF|off)
                                pilight-send -p raw -c "270 810 810 270 810 270 270 1080 810 270 810 270 810 270 270 810 810 270 270 810 810 270 270 1080 810 270 270 810 270 1080 810 270 270 810 270 1080 270 1080 270 1080 270 1080 810 270 810 270 270 1080 270 9180"
                        ;;
                        *)
                                echo "Unknown command $2. Valid commands are ON|OFF"
                        ;;
                esac
        ;;
        2)
                case $2 in
                        ON|on)
                                pilight-send -p raw -c "271 813 813 271 813 271 271 813 813 271 813 271 813 271 271 813 813 271 271 1084 813 271 271 1084 813 271 271 1084 271 1084 813 271 271 1084 271 1084 271 1084 271 1084 813 271 813 271 271 1084 271 1084 271 9214"
                        ;;
                        OFF|off)
                                pilight-send -p raw -c "271 813 813 271 813 271 271 813 813 271 813 271 813 271 271 1084 813 271 271 1084 813 271 271 1084 813 271 271 1084 271 1084 813 271 271 1084 271 1084 271 1084 271 1084 271 1084 813 271 271 1084 271 1084 271 9214"
                        ;;
                        *)
                                echo "Unknown command $2. Valid commands are ON|OFF"
                        ;;
                esac

        ;;
        3)
                case $2 in
                        ON|on)
                                pilight-send -p raw -c "271 813 813 271 813 271 271 813 813 271 813 271 813 271 271 813 813 271 271 813 813 271 271 813 813 271 271 1084 271 1084 813 271 271 813 271 1084 271 813 271 813 813 271 271 813 813 271 271 813 271 9214"
                        ;;
                        OFF|off)
                                pilight-send -p raw -c "272 816 816 272 816 272 272 1088 816 272 816 272 816 272 272 1088 816 272 272 1088 816 272 272 1088 816 272 272 1088 272 1088 816 272 272 1088 272 1088 272 1088 272 1088 272 1088 272 1088 816 272 272 1088 272 9248"
                        ;;
                        *)
                                echo "Unknown command $2. Valid commands are ON|OFF"
                        ;;
                esac

        ;;
        ALL|all)
                case $2 in
                        ON|on)
                                pilight-send -p raw -c "273 819 819 273 819 273 273 1092 819 273 819 273 819 273 273 1092 819 273 273 1092 819 273 273 1092 819 273 273 1092 273 1092 819 273 273 1092 273 1092 273 1092 273 1092 819 273 273 1092 273 1092 819 273 273 9282"
                        ;;
                        OFF|off)
                                pilight-send -p raw -c "271 813 813 271 813 271 271 813 813 271 813 271 813 271 271 813 813 271 271 813 813 271 271 813 813 271 271 813 271 1084 813 271 271 1084 271 1084 271 1084 271 813 271 1084 271 813 271 1084 813 271 271 9214"
                        ;;
                        *)
                                echo "Unknown command $2. Valid commands are ON|OFF"
                        ;;
                esac

        ;;
        *)
                echo "Unknown device ID. Valid devices are 1,2,3,ALL."
        ;;
esac


All of these raw commands were observed with the pilight-debug command and then by pressing the appropriate button on the remote control. These commands are then called from my smart phone (Android) using an app that sends the command to my raspberry pi via SSH.

I hope this helps someone and saves them some time.
 
Reply
#2
Can you at least also provide a pilight-debug output for various buttons for the protocol characteristics
 
Reply
#3
Yes of course. I'm happy to help however I can despite your obvious assumption otherwise given your "can you at least" back handed request.

Your welcome by the way, for the bash control script.

I should have a "devices" configuration file for these sockets soon (will post below). Still trying to work out the JSON format and how it relates to the web page.

EDIT: ^ Cancel that. After troubles and research it looks like raw commands arn't supported in that file [Image: 1sm067roll.gif]

I did these a few times and they keep changing from "pulselen" 269 to 270 at random. So i'm not sure what that is about but that's no surprise because I dont understand any of the output - do you?

1-ON

Quote:--[RESULTS]--

pulse: 3
rawlen: 50
binlen: 12
pulselen: 270

Raw code:
270 810 810 270 810 270 270 810 810 270 810 270 810 270 270 810 810 270 270 810 810 270 270 810 810 270 270 810 270 810 810 270 270 810 270 810 270 810 270 810 810 270 810 270 810 270 270 810 270 9180
Binary code:
010111101101

1-OFF

Quote:--[RESULTS]--

pulse: 3
rawlen: 50
binlen: 12
pulselen: 269

Raw code:
269 807 807 269 807 269 269 807 807 269 807 269 807 269 269 807 807 269 269 807 807 269 269 807 807 269 269 807 269 807 807 269 269 807 269 807 269 807 269 807 269 807 807 269 807 269 269 807 269 9146
Binary code:
010111101101

2-ON

Quote:--[RESULTS]--

pulse: 3
rawlen: 50
binlen: 12
pulselen: 270

Raw code:
270 810 810 270 810 270 270 810 810 270 810 270 810 270 270 810 810 270 270 810 810 270 270 810 810 270 270 1080 270 810 810 270 270 810 270 810 270 810 270 810 810 270 810 270 270 810 270 810 270 9180
Binary code:
010111101101

2-OFF

Quote:--[RESULTS]--

pulse: 3
rawlen: 50
binlen: 12
pulselen: 269

Raw code:
269 807 807 269 807 269 269 807 807 269 807 269 807 269 269 807 807 269 269 807 807 269 269 807 807 269 269 807 269 807 807 269 269 807 269 807 269 807 269 807 269 807 807 538 269 1076 269 807 269 9146
Binary code:
010111101101

3-ON

Quote:--[RESULTS]--

pulse: 3
rawlen: 50
binlen: 12
pulselen: 269

Raw code:
269 807 807 269 807 269 269 807 807 269 807 269 807 269 269 807 807 269 269 807 807 269 269 807 807 269 269 807 269 807 807 269 269 807 269 807 269 807 269 807 807 269 269 807 807 269 269 807 269 9146
Binary code:
010111101111

3-OFF

Quote:--[RESULTS]--

pulse: 3
rawlen: 50
binlen: 12
pulselen: 270

Raw code:
270 810 810 270 810 270 270 810 810 270 810 270 810 270 270 810 810 270 270 810 810 270 270 810 810 270 270 810 270 810 810 270 270 810 270 810 270 810 270 810 270 810 270 810 810 270 270 810 270 9180
Binary code:
010111101111

ALL-ON

Quote:--[RESULTS]--

pulse: 3
rawlen: 50
binlen: 12
pulselen: 269

Raw code:
269 807 807 269 1076 269 269 807 807 269 807 269 807 269 269 807 1076 269 269 807 807 269 269 807 807 269 269 807 269 807 807 269 269 807 269 807 269 807 269 807 807 269 269 807 269 807 807 269 269 9146
Binary code:
010111101110


ALL-OFF

Quote:--[RESULTS]--

pulse: 3
rawlen: 50
binlen: 12
pulselen: 269

Raw code:
269 807 807 269 807 269 269 807 807 269 807 269 807 269 269 807 807 269 269 807 807 269 269 807 807 269 269 807 269 807 807 269 269 807 269 807 269 807 269 807 269 807 269 807 269 807 807 269 269 9146
Binary code:
010111101110




 
Reply
#4
Quote:Yes of course. I'm happy to help however I can despite your obvious assumption otherwise given your "can you at least" back handed request.

Your welcome by the way, for the bash control script.
Unsure

Can you create different threads for the other devices (and remove the output from your post).
 
Reply
#5
I have decoded it.

Step 1. (1-ON)
Code:
270 810 810 270 810 270 270 810 810 270 810 270 810 270 270 810 810 270 270 810 810 270 270 810 810 270 270 810 270 810 810 270 270 810 270 810 270 810 270 810 810 270 810 270 810 270 270 810 270 9180

Step 2.
Create groups of two.
Code:
270 810
810 270
810 270
270 810
810 270
810 270
810 270
270 810
810 270
270 810
810 270
270 810
810 270
270 810
270 810
810 270
270 810
270 810
270 810
270 810
810 270
810 270
810 270
270 810
270 9180

Step 3.
<= 500 = 0, > 500 = 1
Code:
0 1
1 0
1 0
0 1
1 0
1 0
1 0
0 1
1 0
0 1
1 0
0 1
1 0
0 1
0 1
1 0
0 1
0 1
0 1
0 1
1 0
1 0
1 0
0 1
0 1

Step 4.
Remove first column of numbers:
Code:
1
0
0
1
0
0
0
1
0
1
0
1
0
1
1
0
1
1
1
1
0
0
0
1
1

Step 5.
Rearrange numbers:
Code:
1001000101010110111100011

Step 6.
Assign functions to bit numbers:
1. Bit 0 till 19 = ID
2. Bit 20 = ON/OFF
3. Bit 21 till 22 = Unit
4. Bit 23 = ALL

Some evidence:

1001000101010110111100011 - 1-ON
1001000101010110111110111 - 2-OFF
1001000101010110111101101 - ALL-ON

I you want to create the protocol yourself, you can use the conrad protocol as a reference. It has quite the same structure.
 
Reply
#6
Cool how you can decode this stuff Wink Nice!
 
Reply
#7
Experience Cool or a modern 1000 pieces puzzle.
 
Reply
#8
Thanks for that work!

I have some questions though as some things do not add up for me yet:

Code:
Bit#   0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
1-ON = 1  0  0  1  0  0  0  1  0  1  0  1  0  1  1  0  1  1  1  1  0  0  0  1  1

Bit#   Function
00-19 = ID     = 00100010101011011110
   20 = ON/OFF = 0 (OFF - Wrong)
21-22 = Unit   = 00 (0 - Correct if units start from 0, so "socket 1" = 00)
   23 = ALL    = 1 (ON - Wrong)


Bit#    0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
2-OFF = 1  0  0  1  0  0  0  1  0  1  0  1  0  1  1  0  1  1  1  1  1  0  1  1  1

Bit#   Function
00-19 = ID     = 10010001010101101111
   20 = ON/OFF = 1 (ON - Wrong)
21-22 = Unit   = 01 (1 - Correct if units start from 0, so "socket 1" = 00)
   23 = ALL    = 1 (ON - Wrong)

Bit#     0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
ALL-ON = 1  0  0  1  0  0  0  1  0  1  0  1  0  1  1  0  1  1  1  1  0  1  1  0  1

Bit#  = Func   = Raw Data
00-19 = ID     =10010001010101101111
   20 = ON/OFF = 0 (OFF - Wrong)
21-22 = Unit   = 11 (3 - Correct if units start from 0, so "socket 1" = 00)
   23 = ALL    = 0 (OFF - Wrong)


1) The on/off function is always inverted, it's 0 when it should be 1 etc. Is this normal? Does 0 mean on and 1 mean off?

2) Does the unit number start from bit "00" / decimal "0" for unit 1?

3) Is the "All" function inverted as well (when a "All" button is pressed the all bit is 0 and when a specific number button is pressed the "All" bit is now 1?

4) What about the 24th bit?
 
Reply
#9
Quote:1) The on/off function is always inverted, it's 0 when it should be 1 etc. Is this normal? Does 0 mean on and 1 mean off?
Don't assume that a 1 should be on and a 0 should be off. It's just a variable that says something about a state, it doesn't say anything about what state. That's something the programmers did Wink

Quote:2) Does the unit number start from bit "00" / decimal "0" for unit 1?
In your case, yes.

Quote:3) Is the "All" function inverted as well (when a "All" button is pressed the all bit is 0 and when a specific number button is pressed the "All" bit is now 1?
Yes

Quote:4) What about the 24th bit?
That's the footer of about 9100 usec.
 
Reply
#10
Haha! Okay, thank you. Smile

So what is the next step from here, I need to create a philight/libs/protocol/*.c file for these?

Is there a program where I can enter all the bit positions and possible values etc and it creates the *.c file for me?

What would be the best *.c file to use as a template to start from?
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Partially Supported] TFA / Conrad Weather Yves 203 46,666 03-27-2020, 01:21 PM
Last Post: Ascenion
  [Fully Supported] KlikAanKlikUit Motion Sensor koen01 37 20,265 03-26-2020, 02:46 PM
Last Post: Gisto
Lightbulb [Fully Supported] Kaku Door sensor (AMST-606) geerttttt 53 34,710 10-19-2019, 06:26 PM
Last Post: curlymo
  [Fully Supported] DHT22 IcedEarth 86 46,205 11-18-2018, 09:33 AM
Last Post: curlymo
  [Fully Supported] Arctech Old Martin 111 54,235 03-27-2018, 04:43 PM
Last Post: genfersee
  [Fully Supported] Clarus Switches Marcin 69 37,724 01-30-2018, 07:10 PM
Last Post: Niek
  [Fully Supported] Remote Control Socket (RC101-U/RC201) Sean 18 15,627 01-04-2018, 06:18 AM
Last Post: ettman8
  [Fully Supported] LM75 and LM76 temperature sensor horst_dieter 64 35,356 11-19-2017, 08:54 PM
Last Post: edepi
  [Fully Supported] No-brand temp/humidity sensor (alecto_ws1700) meloen 57 47,234 12-25-2016, 09:53 PM
Last Post: creamers
  [Fully Supported] Impuls/SelectRemote Bram 113 66,907 05-28-2016, 02:53 PM
Last Post: Puuu

Forum Jump:


Browsing: 1 Guest(s)