I successfully switched from @syssi custom_components to @critical2104 python script (i got the hardware mod on my sensors), now it works again!
A quick recap for anyone interested:
-
Enable python script component adding the string “python_script:” in your configuration.yaml
-
Create a folder named “python_scripts” in your home assistant folder
-
Get the python script file “set_state.py” linked in the quote @MiSSHeaDShoT reply and put it in the python_scripts folder
-
Create an automation like mine and adapt it to your needs:
- alias: Xiaomi Sensor Fix
trigger:
- platform: state
entity_id:
- binary_sensor.bodysensor_cucina
- binary_sensor.bodysensor_doccia
- binary_sensor.bodysensor_entrata
- binary_sensor.bodysensor_lavandino
from: 'off'
to: 'on'
for: 00:00:05
condition: []
action:
- service: python_script.set_state
data_template:
entity_id: "{{ trigger.entity_id }}"
state: 'off'
Thank you guys for your help <3
edit: there’s a problem though: once the sensor correctly goes off after the custom time (like 5 or 10 seconds) it won’t turn on if triggered shortly after.
Did some tests and the sensor states are triggered correctly (checked in the xiaomi home app) but something is off with the python script, it works only the first time