Affichage des articles dont le libellé est automation. Afficher tous les articles
Affichage des articles dont le libellé est automation. Afficher tous les articles

mercredi 1 avril 2026

Reverse-engineering Ropvacnic S1 vacuum for homeassistant integration

Integrating the Ropvacnic S1 into Home Assistant via LocalTuya

The Ropvacnic S1 is a Tuya-based robot vacuum. Getting it to work locally in Home Assistant requires some digging — the DP numbers aren't documented anywhere, and LocalTuya has a bug in its locate function. This guide documents everything I found.

Why local control? Faster response, no cloud dependency, works if Tuya servers go down. The device still sends data to Tuya's cloud, but Home Assistant commands go directly over your LAN.

Setup: Home Assistant OS 2026.3.4 · LocalTuya 5.2.3 · Protocol 3.4 · Region: Western America


Step 1 — Tuya IoT Platform Setup

Create an account at iot.tuya.com (not tuya.com — click "Developer Platform" at the bottom). Create a Cloud Project with these settings:

  • Industry: Smart Home
  • Development Method: Smart Home
  • Data Center: Western America (for Canada/USA accounts)

Important: The Data Center must match your Tuya Smart app region. A mismatch causes a "Data center inconsistency" error when scanning the QR code.

Under Devices → Link Tuya App Account, scan the QR code with your Tuya Smart app. Then note:

  • Access ID — from the Overview tab
  • Access Secret — from the Overview tab
  • UID — from the linked account (starts with az...)

Step 2 — Discover DPs with tinytuya

A DP (Data Point) is a numbered channel that controls one specific function of the device. Install tinytuya on your computer to identify them all:

pip3 install tinytuya
python3 -m tinytuya wizard
# Enter your Access ID, Secret, UID and region (us)
 
python3 -m tinytuya snapshot
# Poll: Y → shows all live DP values

Complete DP Map — Ropvacnic S1

DP Code Type Values
1switchBooleantrue / false
2switch_goBooleantrue / false
3modeEnumstandby, random, wall_follow, spiral, chargego
4direction_controlEnumforward, backward, turn_left, turn_right, stop
5statusEnumstandby, smart_clean, goto_charge, charging, charge_done, paused
6residual_electricityInteger0–100 (%)
7clean_timeIntegerminutes
9clean_areaInteger
13seek (locate)Booleantrue / false
14suctionEnumgentle, normal, strong
17edge_brushInteger0–100 (%)
18filterInteger0–100 (%)
20water_controlEnumclosed, low, middle, high

Note: DP 13 (seek/locate) is not visible in the standard tinytuya output. It was found by brute-force testing DPs 10–16 using d.set_value(dp, True) and listening for the vacuum's beep.


Step 3 — LocalTuya Entity Configuration

Install LocalTuya via HACS, restart HA, then go to Settings → Devices & Services → Add Integration → LocalTuya.

Set Manual DPS to: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25

Configure the entity with these values:

FieldValue
ID (status DP)5
Power DP (powergo_dp)1
Mode DP3
Battery DP6
Fan Speed DP14
Clean Time DP7
Clean Area DP9
Locate DP13
Fault DP(leave empty)
Idle Statusstandby,sleep
Docked Statuscharging,chargecompleted,charge_done
Returning Statusgoto_charge
Modes liststandby,random,wall_follow,spiral,chargego
Return home modechargego
Fan speeds listgentle,normal,strong
Pause statepaused
Stop statusstandby

Step 4 — Fix vacuum.py (LocalTuya bug)

LocalTuya 5.2.3 has a bug in async_locate — it sends an empty string "" instead of True, so the locate button does nothing. Fix it via the Terminal add-on:

sed -i 's/set_dp("", self._config\[CONF_LOCATE_DP\])/set_dp(True, self._config[CONF_LOCATE_DP])/g' \
  /config/custom_components/localtuya/vacuum.py
 
# Verify
grep -A3 "async_locate" /config/custom_components/localtuya/vacuum.py

Step 5 — Fix config via Terminal (if GUI doesn't save)

The LocalTuya GUI sometimes doesn't persist certain changes (notably mode_dp and id). Edit the config file directly:

# Backup first!
cp /config/.storage/core.config_entries \
   /config/.storage/core.config_entries.backup
 
# Status DP = 5 (reads DP 5 for state)
sed -i 's/"id":1,"idle_status_value":"standby,sleep"/"id":5,"idle_status_value":"standby,sleep"/g' \
  /config/.storage/core.config_entries
 
# powergo_dp must be 1 (start/pause)
sed -i 's/"powergo_dp":5/"powergo_dp":1/g' \
  /config/.storage/core.config_entries
 
# mode_dp = 3 (stop + return to base)
sed -i 's/"mode_dp":0/"mode_dp":3/g' \
  /config/.storage/core.config_entries
 
# locate_dp = 13
sed -i 's/"locate_dp":0/"locate_dp":13/g' \
  /config/.storage/core.config_entries
 
# Remove fault_dp entirely (causes false errors)
sed -i 's/,"fault_dp":[0-9]*//g' \
  /config/.storage/core.config_entries

After edits, reload LocalTuya: Settings → Devices & Services → LocalTuya → 3 dots → Reload — no full restart needed.


Final Result

After completing all steps, the Ropvacnic S1 is fully controllable from Home Assistant with local-only communication:

  • State correctly shows Docked, Cleaning, Returning, and Paused
  • Start, Pause, Stop, and Return to Base all work
  • Locate (beep) works after the vacuum.py fix
  • Battery percentage displayed in real time
  • Fan speed (gentle / normal / strong) selectable from HA
  • Clean time and area tracked per session

vendredi 26 mai 2017

GMAIL - Google Script - auto delete old (junk) mail

Today I discovered the "google scripts" that allow you to run some sophisticated actions on the various "google apps"/"cloud apps". This includes Gmail, Google drive, etc.

Let's start with gmail since I have some needs I could not fit into the pretty basic filters that can be defined directly from the UI.


Context :
* I am able to identify labels are "search" (defined at the time the mail arrives) on my mailbox, that I want to delete after a certain period of time.

For instance, I might be interested in some promotions sent by some companies I have reductions cards with, but after X days, it's of no use and it's only taking precious space in my inbox.

* I do not wish to delete them directly, the "usual" trash with 30 days retention period is fine enought.

* I want to have this run every night.

1. Go to  https://script.google.com

2. Enter this script :

  • set the variable delayDays
  • set the variable mySearch accordingly to your needs.
Version 2017 (old)

function cleanUp() {
  /**
  * @var    delayDays int   : Enter # of days before messages are moved to trash
  * @var    mySearch string : Enter the search as tested in Gmail search bar.
  */
  var delayDays = 30 ;
  var mySearch =  'label:online_store-totoStore OR from:bonsplans@newsletter.travel.com .com OR label:paris-freecycle';
  
  //-- code
  var maxDate = new Date();
  maxDate.setDate(maxDate.getDate()-delayDays);
  var tmp_threads = GmailApp.search(mySearch);
  var threads = [];
  var threads = threads.concat(tmp_threads);

  for (var i = 0; i < threads.length; i++) {
    if (threads[i].getLastMessageDate()
      {
        threads[i].moveToTrash();
      }
  }
}



EDIT 2020 : https://github.com/copolycube/GmailPurgeEmailsMatchingQuery
new version with same features plus :
  • array of simplier queries to find
  • does multiple search instead of 1 massive one
  • concatenates a "avoid deletion", for example to keep "starred" e-mail (by default)


3. Set it up to run every night :
 3.1 : select the 'clock/trigger'.
 3.2 : add the desired triggers on the popup window that will appear.




Other solution (easier)

Use regular Gmail filters triggering deletions, but with search keys like :
older_than:6m

example :  find all promotions older than 1y that haven't been starred

category:promotions older_than:1y -label:starred 



vendredi 19 juin 2015

Ansible vs. Chef vs. Puppet vs. Salt

There are currently various tools to maintain automatically an infrastructure. The four listed below seem to be the main ones.


Ansible is an IT automation tool. It can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates.


·         Chef https://www.chef.io/
“Chef turns infrastructure into code. With Chef, you can automate how you build, deploy, and manage your infrastructure. Your infrastructure becomes as versionable, testable, and repeatable as application code."


·         Puppet https://puppetlabs.com
“Puppet is a configuration management solution that allows you to define the state of your IT infrastructure, and then automatically enforces the desired state. Puppet automates every step of the software delivery process, from provisioning of physical and virtual machines to orchestration and reporting; from early-stage code development through testing, production release and updates.”


·         Salt : http://saltstack.com
“SaltStack takes a new approach to infrastructure management by developing software that is easy enough to get running in seconds, scalable enough to manage tens of thousands of servers, and fast enough to control and communicate with them in milliseconds. SaltStack delivers a dynamic infrastructure communication bus used for orchestration, remote execution, configuration management and much more. The Salt project was launched in 2011 and today is the fastest-growing, most-active infrastructure orchestration and configuration management open source project in the world. The SaltStack community is committed to keeping the Salt project focused, friendly, healthy and open.”




And some comparisions :