Hauptmenü

Reboot MAxCube

Begonnen von doman75, 22 Februar 2019, 11:05:23

Vorheriges Thema - Nächstes Thema

doman75

Hallo,

bei openhab ist es ja möglich den Cube zu rebooten von der ferne (also mit orginal Firmware drauf) ist das bei FHEM auch irgendwie möglich?

Grüße
Swen

brain666

ich habe mal rumexperimentiert es muss ja eigentlich gehen das man den Cube rebooten kann.

leider komme ich aber auch nicht weiter :(


root@debian:~# curl -d '{"action-cubeReboot":1234}' -H "Content-Type: application/json"  http://192.168.188.70:62910/rest/things/max:bridge:OEQ1944526/config --http0.9 -verbose
*   Trying 192.168.188.70:62910...
* Connected to 192.168.188.70 (192.168.188.70) port 62910 (#0)
> POST /rest/things/max:bridge:OEQ1944526/config HTTP/1.1
> Host: 192.168.188.70:62910
> User-Agent: curl/7.82.0
> Accept: */*
> Referer: rbose
> Content-Type: application/json
> Content-Length: 26
>
H:OEQ1944526,1b521a,0113,00000000,2fd57510,01,32,16041b,0e2d,03,0000
M:
C:1b521a,7RtSGgATAf9PRVExOTQ0NTI2AAsABEAAAAAAAAAAAP///////////////////////////wsABEAAAAAAAAAAQf///////////////////////////2h0dHA6Ly9tYXgtcG9ydGFsLmVxLTMuZGU6ODAvbG9va3VwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAENFVAAACgADAAAOEENFU1QAAwACAAAcIA==
C:1be39f,0hvjnwEAEaFQRVExMDEyNjg4IyI9CQcYAzAM/wBEVEzwRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERUTPBFIEUgRSBFIEUgRSBFIEUgRSBFIEUgREhEukzwRSBFIEUgRSBFIEUgRSBFIEUgRSBESES6TPBFIEUgRSBFIEUgRSBFIEUgRSBFIERIRLpM8EUgRSBFIEUgRSBFIEUgRSBFIEUgREhEukzwRSBFIEUgRSBFIEUgRSBFIEUgRS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ommen

quelle https://github.com/Bouni/max-cube-protocol/blob/master/Cube_Discovery.md


"eQ3Max*\0" + serialnumber + "R"

brain666

müsste ich nicht eine msg zurück bekommen vom cube wenn ich ein udp paket sende?



echo -e '\x65 \x51 \x33 \x4D \x61 \x78 \x2A \x00 \x2A \x2A \x2A \x2A \x2A \x2A \x2A \x2A \x2A \x2A \x49' > /dev/udp/192.168.188.36/23272


eigentlich müsste doch so der reboot ausgelöst werden

Serial vom Cube ist IEW0006612


echo -e '\x65 \x51 \x33 \x4D \x61 \x78 \x49 \x45 \x57 \x30 \x30 \x30 \x36 \x36 \x31 \x32 \x52' > /dev/udp/192.168.188.36/23272



brain666

#4
neuer Versuch scheiterte auch :(


echo -en "\x65\x51\x33\x4D\x61\x78\x49\x45\x57\x30\x30\x30\x36\x36\x31\x32\x52" | nc -w1 -u -b 192.168.188.255 23272
echo -e "\x65\x51\x33\x4D\x61\x78\x49\x45\x57\x30\x30\x30\x36\x36\x31\x32\x52" | nc -w1 -u -b 192.168.188.255 23272


scheinbar liegt es an der art wie ich übermittle


17190 19405 6.256499676 192.168.188.21 → 192.168.188.36 A21 59 Unknown[Malformed Packet]
36614 37319 11.322551329 PCPartne_83:60:de → eQ-3Entw_01:ce:e8 ARP 42 Who has 192.168.188.36? Tell 192.168.188.21
37333 11.323580408 eQ-3Entw_01:ce:e8 → PCPartne_83:60:de ARP 60 192.168.188.36 is at 00:1a:22:01:ce:e8
42105 42770 13.099536058 192.168.188.21 → 192.168.188.36 A21 80 Unknown[Malformed Packet]
50460 51772 16.588121467 192.168.188.21 → 192.168.188.36 A21 80 Unknown[Malformed Packet]
63007 63062 21.882766600 192.168.188.21 → 192.168.188.36 A21 80 Unknown[Malformed Packet]
105955 106250 51.755861536 192.168.188.21 → 192.168.188.36 A21 61 Unknown[Malformed Packet]
106465 107172 52.738039620 192.168.188.36 → 192.168.188.21 A21 68 Unknown[Malformed Packet]
107173 52.738132074 192.168.188.21 → 192.168.188.36 ICMP 96 Destination unreachable (Port unreachable)
116344 116502 59.867411539 192.168.188.21 → 192.168.188.36 A21 61 Unknown[Malformed Packet]
116956 60.315246080 192.168.188.36 → 192.168.188.21 A21 68 Unknown[Malformed Packet]
116957 60.315327905 192.168.188.21 → 192.168.188.36 ICMP 96 Destination unreachable (Port unreachable)
121484 121644 63.851739049 192.168.188.21 → 192.168.188.36 A21 61 Unknown[Malformed Packet]
122254 122977 64.842116144 192.168.188.36 → 192.168.188.21 A21 68 Unknown[Malformed Packet]
122978 64.842163218 192.168.188.21 → 192.168.188.36 ICMP 96 Destination unreachable (Port unreachable)
123377 123407 65.078590551 PCPartne_83:60:de → eQ-3Entw_01:ce:e8 ARP 42 Who has 192.168.188.36? Tell 192.168.188.21
123408 65.078978056 eQ-3Entw_01:ce:e8 → PCPartne_83:60:de ARP 60 192.168.188.36 is at 00:1a:22:01:ce:e8
130196 130667 70.796529036 eQ-3Entw_01:ce:e8 → Broadcast    ARP 60 Who has 192.168.188.9? Tell 192.168.188.36
135089 135122 74.140690610 192.168.188.21 → 192.168.188.36 A21 61 Unknown[Malformed Packet]
136431 136411 75.125280098 192.168.188.36 → 192.168.188.21 A21 68 Unknown[Malformed Packet]
136412 75.125390248 192.168.188.21 → 192.168.188.36 ICMP 96 Destination unreachable (Port unreachable)
142203 142823 79.883046126 192.168.188.21 → 192.168.188.36 A21 61 Unknown[Malformed Packet]
143729 143922 80.866344196 192.168.188.36 → 192.168.188.21 A21 68 Unknown[Malformed Packet]
143923 80.866418508 192.168.188.21 → 192.168.188.36 ICMP 96 Destination unreachable (Port unreachable)
150958 151097 86.410653267 192.168.188.21 → 192.168.188.36 A21 61 Unknown[Malformed Packet]
151848 151941 86.856079877 192.168.188.36 → 192.168.188.21 A21 68 Unknown[Malformed Packet]
151942 86.856183346 192.168.188.21 → 192.168.188.36 ICMP 96 Destination unreachable (Port unreachable)
158788 159225 93.022746273 192.168.188.21 → 192.168.188.36 A21 61 Unknown[Malformed Packet]
159490 159670 93.475189360 192.168.188.36 → 192.168.188.21 A21 68 Unknown[Malformed Packet]
159671 93.475265796 192.168.188.21 → 192.168.188.36 ICMP 96 Destination unreachable (Port unreachable)
168365 169017 102.226781017 192.168.188.21 → 192.168.188.36 A21 59 Unknown[Malformed Packet]



brain666

next test

Python --> message base64 encoded

leider auch negativ :(


import socket

UDP_IP = "192.168.188.36"
UDP_PORT = 23272
MESSAGE = "ZVEzTWF4SUVXMDAwNjYxMlIK"

print("UDP target IP: %s" % UDP_IP)
print("UDP target port: %s" % UDP_PORT)
print("message: %s" % MESSAGE)

sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP
sock.sendto(MESSAGE.encode(), (UDP_IP, UDP_PORT))


brain666

Servus zusammen,

weiß jemand wieso ich bei convert nach hex eine 2e rausbekomme

laut https://github.com/Bouni/max-cube-protocol/blob/master/Cube_Discovery.md sollte dort eigentlich eine 00 sein

root@debian:~/test# echo eQ3Max*.**********I | hd
00000000  65 51 33 4d 61 78 2a 2e  2a 2a 2a 2a 2a 2a 2a 2a  |eQ3Max*.********|
00000010  2a 2a 49 0a                                       |**I.|
00000014


Hence to find a specific cube send a discovery packet with the content: "eQ3Max*\0" + serialnumber + "I"


root@debian:~/test# echo "eQ3Max*\0"IEW0006612"I" | hd
00000000  65 51 33 4d 61 78 2a 5c  30 49 45 57 30 30 30 36  |eQ3Max*\0IEW0006|
00000010  36 31 32 49 0a                                    |612I.|
00000015


brain666

#7
es hat geklappt ich konnte den Cube bzw. die Cubes jetzt zum reboot bewegen



in Python


import socket
import codecs

UDP_PORT = 23272

CUBE1_IP = "192.168.188.36"
CUBE2_IP = "192.168.188.70"

CUBE_SN1 = "IEW0006612"
CUBE_SN2 = "OEQ1944526"
CUBE_INIT = '\x65\x51\x33\x4D\x61\x78\x2A\x00'
CUBE_REBOOT = '\x52'

MESSAGE = '\x65\x51\x33\x4D\x61\x78\x2A\x00\x49\x45\x57\x30\x30\x30\x36\x36\x31\x32\x52'
MESSAGE2 = '\x65\x51\x33\x4D\x61\x78\x2A\x00\x4F\x45\x51\x31\x39\x34\x34\x35\x32\x36\x52'

message_bytes = MESSAGE.encode('ascii')
message2_bytes = MESSAGE2.encode('ascii')

print("Cube 1:")
print("UDP target IP: %s" % CUBE1_IP)
print("UDP target port: %s" % UDP_PORT)
print("message: %s" % MESSAGE)

print("Cube 2:")
print("UDP target IP: %s" % CUBE2_IP)
print("UDP target port: %s" % UDP_PORT)
print("message: %s" % MESSAGE2)

sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP
sock.sendto(MESSAGE.encode(), (CUBE1_IP, UDP_PORT))

sock.sendto(MESSAGE2.encode(), (CUBE2_IP, UDP_PORT))


in fhem habe ich es mir so eingebunden


define Cube_reboot DOIF ([Cube_neustarten:state] eq "reboot") { system("python3 /opt/fhem/cube_reboot &") }
setuuid Cube_reboot 6273a075-f33f-078c-02c4-b0908db49464755a
attr Cube_reboot do always
define Cube_neustarten dummy
setuuid Cube_neustarten 6273a083-f33f-078c-de14-322231ac64fc75f3
attr Cube_neustarten setList reboot
attr Cube_neustarten webCmd reboot

brain666

Shell Script für den Reboot
es muss nur die IP & die SN eingetragen werden


#!/bin/bash
tmp="/tmp/cube"
UDP_PORT="23272"
CUBE1_IP="192.168.188.36"
CUBE_SN1="IEW0006612"

CUBE_INIT='\x65\x51\x33\x4D\x61\x78\x2A\x00'
CUBE_REBOOT='\x52'

if [ -f "$tmp" ]; then
rm $tmp
fi
echo "Convert Serial nach hex"
echo -n $CUBE_SN1 | xxd -ps | sed -e ':a' -e 's/\([0-9]\{2\}\|^\)\([0-9]\{2\}\)/\1\\x\2/;ta' >> $tmp
file="$tmp"
lines=`cat $file`
for line in $lines; do
        echo "$line"
done
echo "Max-Cube Reboot"
echo "IP: $CUBE1_IP"
echo "Seriennummer: $CUBE_SN1"
echo -en $CUBE_INIT$lines$CUBE_REBOOT  | nc -w1 -u -b 192.168.188.36 23272
echo "Reboot dauert ca. 2 Minuten"
rm $tmp


Wzut

python , shell .... warum denn nicht gleich Perl ?
Hier meine beiden Vorschläge für die 99_myUtils mit ordenlichen Fehlermeldungen im Logfile
sub cube_reboot
{
    use IO::Socket;

    my $host   = shift // return;
    my $serial = shift // return;

    my $sock = IO::Socket::INET->new(
PeerPort => 23272,
PeerHost => $host,
Type => SOCK_DGRAM,
Proto => 'udp',
Blocking => 0,
Timeout => 5);

    if (!$sock) {
Log3 ('cube_reboot', 2, "Cannot create socket - $@");
return;
    }

    my $message = 'eQ3Max*'.0x00.$serial.'R';
    my $s = $sock->send($message, 0, $host);
    Log3 ('cube_reboot', 2, "Cannot send message $message to cube $host") if (!defined($s));

    $sock->close();
    return;
}


Aufruf z.B. (bei mir)
{cube_reboot('192.168.0.228', 'MKF0071736')}

oder man holt sich die IP und SerienNr direkt aus dem Device :

sub cube_reboot
{
    use IO::Socket;

    my $name = shift // return;

    my ($host,undef) = split(':',InternalVal($name ,'DeviceName', ': '));
    my $serial = InternalVal($name, 'serial', '');

    if (!$serial || !$host) {
Log3 ('cube_reboot', 2, "Cannot get cube IP") if (!$host);
Log3 ('cube_reboot', 2, "Cannot get cube serial") if (!$serial);
return;
    }

    my $sock = IO::Socket::INET->new(
PeerPort => 23272,
PeerHost => $host,
Type => SOCK_DGRAM,
Proto => 'udp',
Blocking => 0,
Timeout => 5);

    if (!$sock) {
Log3 ('cube_reboot', 2, "Cannot create socket - $@");
return;
    }

    my $message = 'eQ3Max*'.0x00.$serial.'R';
    my $s = $sock->send($message, 0, $host);
    Log3 ('cube_reboot', 2, "Cannot send message $message to cube $host") if (!defined($s));

    $sock->close();
    return;
}


der Aufruf ist dann auch etwas kürzer, da nur noch der Name übergeben werden muß
{cube_reboot('meinCube')}
Maintainer der Module: MAX, MPD, UbiquitiMP, UbiquitiOut, SIP, BEOK, readingsWatcher

brain666

Servus Wzut

in Perl habe ich es nicht hinbekommen :(

leider klappen deine beiden Beispiele auch nicht.


2022.05.17 09:24:28 2: Cannot send message eQ3Max*0OEQ1944526R to cube 192.168.188.70
2022.05.17 09:24:34 2: Cannot get cube serial
2022.05.17 09:26:24 2: Cannot send message eQ3Max*0OEQ1944526R to cube 192.168.188.70
2022.05.17 09:27:57 2: Cannot send message eQ3Max*0OEQ1944526R to cube 192.168.188.70
2022.05.17 09:28:08 2: Cannot send message eQ3Max*0OEQ1944526R to cube 192.168.188.70