Neato BotVac Connected binding?

Hi NCO,

here a short description …

Requirement/preparation

1.install pybotvac python library from GitHub - stianaske/pybotvac: Python module for interacting with Neato Botvac Connected vacuum robots.
2. register your neato with a mobile app, remember mail and password
3. get serial from your neato

Create/modify openhab2 config files

items: demo.items

Switch neatoSwitchGetLastMap			"Letzte Reinigungskarte ..."																	
String neatoGetLastMapRunning			"Download ... [%s]"

sitemaps: demo.sitemap (extract)

    Frame {
        Text item=neatoGetLastMapRunning  visibility=[neatoGetLastMapRunning != "-"] 			
        Switch item=neatoSwitchGetLastMap mappings=[ON="Laden"] visibility=[neatoGetLastMapRunning == "-"]
 //   	Webview url="/static/neato-botvac/botvac-last-map.html" 
        Image url="http://localhost:8080/static/neato-botvac/botvac-last-map.png" refresh=2000
    }

rules: neato-botvac.rules

val String filename = "neato-botvac.rules"

rule "system start: initialize Switch neatoSwitchGetLastMap"
    when
        System started
    then
    createTimer(now.plusSeconds(60)) [|

        if (neatoSwitchGetLastMap.state == NULL) neatoSwitchGetLastMap.postUpdate(OFF)

        if (neatoGetLastMapRunning.state == NULL) neatoGetLastMapRunning.postUpdate("-")
    ]
    end

rule "Getting last map for neato botvac connected"
    when
       Item neatoSwitchGetLastMap received command ON
    then
        neatoGetLastMapRunning.postUpdate("Download ...")
        executeCommandLine("/etc/openhab2/scripts/neato-botvac-getlastmap.py")
        neatoGetLastMapRunning.postUpdate("-")
        neatoSwitchGetLastMap.postUpdate(OFF)
    end

scripts: neato-botvac-getlastmap.py

#!/usr/bin/python
from pybotvac import Account
from os       import system

email    = 'your mail'
password = 'your password'
serial   = 'your neato serial'
path_tmp = '/etc/openhab2/html/tmp/'
path_dst = '/etc/openhab2/html/neato-botvac/'
map_file = 'botvac-last-map.png'

account  = Account(email, password)
link     = account.maps[serial]['maps'][0]['url']

account.get_map_image(link, path_tmp)

system('mv ' + path_tmp + '*-user-map.png ' + path_dst + map_file)

system: create some folder (as openhab user or member of openhab group)

mkdir /etc/openhab2/html/neato-botvac
mkdir /etc/openhab2/html/tmp

html page: botvac-last-map.html in /etc/openhab2/html/neato-botvac/

<!DOCTYPE html>
<html>
<head>
    <title>Neato Botvac Connected - last map</title>
    <style type="text/css" media="screen">
        img {
            background: white;
            border: 1px solid black;
            width: 500px;
            height: 500px;
        }

    </style>
    <script type="text/javascript" src="/extensions/Selfhtml/js/jquery/jquery-1.11.1.min.js"></script>
    <script type="text/javascript">
		//<![CDATA[
		//]]>
    </script>
</head>
<body>
    <main>
        <img src="botvac-last-map.png" alt="Uups! Bitte letzte Reinigungskarte laden..."> 
    </main>
</body>
</html>
2 Likes