Python script to check Neato status every night

Python and python framework

Moderator: leecollings

Post Reply
quack3d
Posts: 86
Joined: Sunday 26 March 2017 17:03
Target OS: -
Domoticz version:
Contact:

Python script to check Neato status every night

Post by quack3d »

I have a python script (based on https://github.com/stianaske/pybotvac) that checks dock status of my Neato Botvac Connected and returns True if docked. At the moment I have created a custom sensor in Domoticz that gets updated with True or False when script has been run. So I'm thinking the script needs to run at 9 pm, then Domoticz needs to check the custom sensor and send a push if it's set to False. What's the best way to do this?
User avatar
bbqkees
Posts: 407
Joined: Sunday 17 August 2014 21:01
Target OS: Linux
Domoticz version: 4.1x
Location: The Netherlands
Contact:

Re: Python script to check Neato status every night

Post by bbqkees »

If you only want to run the check once a day, you can use a cron job to execute the script at the time you need.

Other option would be to put the script in the domoticz events editor.
Thenn it will run every minute.

make sure to you set a user variable when the message is sent once, because otherwise you get a message every minute when undocked.
The user value should be reset when docked.
Bosch / Nefit / Buderus / Junkers / Worcester / Sieger EMS bus Wi-Fi MQTT Gateway and interface boards: https://bbqkees-electronics.nl/
quack3d
Posts: 86
Joined: Sunday 26 March 2017 17:03
Target OS: -
Domoticz version:
Contact:

Re: Python script to check Neato status every night

Post by quack3d »

Forgot to say I'm using Windows, so no cron available. And running it every minute seems excessive when I really just need a check in the evening.
User avatar
bbqkees
Posts: 407
Joined: Sunday 17 August 2014 21:01
Target OS: Linux
Domoticz version: 4.1x
Location: The Netherlands
Contact:

Re: Python script to check Neato status every night

Post by bbqkees »

That a script is called every minute does not mean you have to actually check the status of the robot every minute.
You can just do a check once a day.
Bosch / Nefit / Buderus / Junkers / Worcester / Sieger EMS bus Wi-Fi MQTT Gateway and interface boards: https://bbqkees-electronics.nl/
quack3d
Posts: 86
Joined: Sunday 26 March 2017 17:03
Target OS: -
Domoticz version:
Contact:

Re: Python script to check Neato status every night

Post by quack3d »

I made this script in LUA that runs the python script that updates the value of a dummy info device in Domoticz. Then the LUA script sends out a Pushbullet notification with the value of the dummy device.

But what's a good way of making the LUA script wait for the result of robotdock.pyw?

Code: Select all

local switch_1 = 'Robot - check dock'
local text_sensor = 'Is robot in dock??'
local title = 'Robot dock status'
local robot_path = 'C:\\Program Files (x86)\\Domoticz\\scripts\\python\\robotdock.pyw'
local push_path = 'C:\\Program Files (x86)\\Domoticz\\scripts\\batch\\pushbullet.bat'

 commandArray = {}
  if (otherdevices[switch_1] == 'On')
  then
    commandArray[switch_1] = 'Off'
    print('"'..robot_path..'"')
    os.execute('"'..robot_path..'"')
    local message = otherdevices[text_sensor]
    local tit_msg = title..'"' .. ' "' ..message
    local combined = '""'..push_path..'" "'..tit_msg..'""'
    print(combined)
    os.execute(combined)
  end
return commandArray
Post Reply

Who is online

Users browsing this forum: domja and 1 guest