Deebot Ozmo 950 [MQTT][CLOUDFREE][CLOUD][bumper][non-bumper]

Begonnen von schwatter, 15 Juni 2020, 21:42:30

Vorheriges Thema - Nächstes Thema

schwatter

#135
Nabend,

damit wir schnell den Redirect per Fhem an und aus schalten können, habe ich mir 2 Scripte
und ein DOIF gebastelt.

Da wir im Moment nur Telnet anstatt SSH haben, benutze ich TCL. Dafür brauchen wir "expect".
# we use https://www.tcl.tk/ to login in telnet
apt install expect

Dann einen Ordner in Fhem erstellen.
mkdir /opt/fhem/deebot

Nun 2 Scripte im Ordner anlegen. Wichtig, Password von euerem Bot einfügen. Direkt unter expect "Password: " im send.
vi /opt/fhem/deebot/deebotswitch_on.sh
#!/usr/bin/expect
# if you get "Escape character is '^]'" as the output it means got connected otherwise it has failed

# change to the ip of your bot
spawn telnet 192.168.178.81 23
expect "'^]'."

expect "deboot login: "
send "root\n"
sleep 1
expect "Password: "
send "HierKommtEuerPasswordHin\n"
sleep 2
send "echo 1 > /data/freebot/spoofswitch\n"
puts "switched to on, now reboot"
sleep 1
send "reboot\n"
expect eof
exit

vi /opt/fhem/deebot/deebotswitch_off.sh
#!/usr/bin/expect
# if you get "Escape character is '^]'" as the output it means got connected otherwise it has failed

# change to the ip of your bot
spawn telnet 192.168.178.81 23
expect "'^]'."

expect "deboot login: "
send "root\n"
sleep 1
expect "Password: "
send "HierKommtEuerPasswordHin\n"
sleep 2
send "echo 0 > /data/freebot/spoofswitch\n"
send "/etc/rc.d/medusa.sh stop\n"
puts "switched to off, now reboot"
sleep 1
send "reboot\n"
expect eof
exit

Jetzt die Scripte ausführbar machen, fhem als Eigentümer und dialout als Gruppe setzen.
chmod +x -R /opt/fhem/deebot
chown -R fhem /opt/fhem/deebot
chgrp -R dialout /opt/fhem/deebot

Zum Abschluss das DOIF.
defmod Deebot950.Redirectcontrol DOIF (["$SELF:command: Aus"])\
    ( {system("/opt/fhem/deebot/deebotswitch_off.sh")} )\
DOELSEIF (["$SELF:command: An"])\
    ( {system("/opt/fhem/deebot/deebotswitch_on.sh &")} )
attr Deebot950.Redirectcontrol cmdState AUS|AN
attr Deebot950.Redirectcontrol group Saugroboter
attr Deebot950.Redirectcontrol icon audio_shuffle
attr Deebot950.Redirectcontrol readingList command
attr Deebot950.Redirectcontrol setList command:uzsuSelectRadio,An,Aus
attr Deebot950.Redirectcontrol stateFormat Redirectstatus: (command)
attr Deebot950.Redirectcontrol webCmd command

edit:
Ahhh, ganz vergessen. Damit das funktioniert, muss auch das Script auf dem Bot angepasst werden.
Ist damit erledigt.
Siehe https://forum.fhem.de/index.php?topic=112149.msg1300870#msg1300870 unter Punkt 3.


Gruß schwatter