How to add scan_interval of sensor to script or automation?

Iam using xiaomi flora, scan_interval was set to 5 min. But sometime I want it update the value instantly, is there any way to add scan_interval to the script so I can create the button in HA dashboard ?
My idea is:
_Press the button, scan_interval will set to 1 sec.
_Delay 2 sec
_Then set scan_interval back to 5 min

There’s a homeassistant.update_entity service that you can use.

I tried, but it didnt work with BLE device

How did you set up the 5min interval ?
So what does your current config look like to update the entity ?

Your pic seems to have a lot of dandruff :rofl:

In configuration.yaml, sensor will look like this:

sensor:
  - platform: miflora
    mac: C4:7C:8D:64:F9:58
    monitored_conditions:
      - moisture
      - temperature
      - conductivity
      - light
      - battery
    name: SoilSensor1
    force_update: true
    scan_interval: 300

I just dont know how to transfer it to the script yet :frowning:

So as VDR says and you replied … you tried : -

  - alias: 'au_miflora_update'
    trigger:
      - platform: time_pattern
        minutes: '/1'
    action:
      - service: homeassistant.update_entity
        entity_id: sensor.soil_sensor1

Does nothing ?
Not sure that your sensor name should not be all in lower case

Having said that …
Your sensor set up looks weird
I would have thought it should look like this : -

sensor:
  - platform: miflora
    sensors:
      soil_sensor1:
        friendly_name: Soil Sensor 1
        mac: C4:7C:8D:64:F9:58
        monitored_conditions:
          - moisture
          - temperature
          - conductivity
          - light
          - battery
        force_update: true
        scan_interval: 300
      soil_sensor2:
        friendly_name: Soil Sensor 2
        mac: C4:7C:8D:64:F9:59
        monitored_conditions:
          - moisture
          - temperature
          - conductivity
          - light
          - battery
        force_update: true
        scan_interval: 300
      soil_sensor3:
        friendly_name: Soil Sensor 3
        mac: C4:7C:8D:64:F9:60
        monitored_conditions:
          - moisture
          - temperature
          - conductivity
          - light
          - battery
        force_update: true
        scan_interval: 300
etc.

I fix the name and add automation as you said, still nothing :(.

Okay, we may have to wait till someone more experienced with bluetooth comes to the thread.
Just to be sure though - the above ‘fix’ didn’t break your sensor did it ? (I was not 100% sure of the formatting, just going off ALL the other sensors I’ve ever configured)
Please feed back to provide the next guy with more info
Cheers

1 Like

Thank you, I had to match the name in dashboard to make it display again, not a big problem :).

As long as it still works, you at least haven’t taken a step back. :crazy_face:
I’m kind of intregued though, you obviously set the scan interval to give you decent battery lifetime - why do you need a plant sensor to update imediately ?
Surely the plant is not going anywhere ??? :man_shrugging:

Bcause my garden is using hydroponic, and the pump is pretty strong, a minutes can make it over water, so I want when the pump is running, the sensor will update in second to cut off the pump in right time.

Okay, if you don’t get a answer to this we can still fix your problem.
What we could do is run the pump for a minimum amount of time.
Wait 5 mins, check if value still below required moisture level
Run the pump again for the mininum amout of time.
Wait 5 mins …

In fact you could run that 24 hours a day if you need moisture level to be at a minimum
This should save you water and the risk of flooding if the sensor is in a dry spot, though if it’s proper hydroponics the plants are just in a nutrient rich solution ??? (dunnoe, I’m guessing)

A possible issue with this is your pump may have a maximum number of starts an hour or similar.

Edit : though thinking about this, you ‘may’ want to turn off such an automation during certain hours (“HEY ! I’m trying to sleep here !”) :rofl:

1 Like

These devices broadcast their state when it changes (at least that is how it works with esphome, I assume the direct home-assistant integration works the same.)

OK I assume wrong. I would highly recommend getting an esp32 device and use esphome:

  1. It can access more than one miflora
  2. It updates when the miflora broadcasts data, which is whenever data changes, so your sensor should always be up to date.

I dont think miflora auto send broadcasts data, bcause when I change scan_interval to 1 sec, it update instantly, or when I use an app on android phone name flower care, the data update in real time. Bcause of that, I think the master device should send request to make miflora update data (there is the light on miflora flashing in time with scan_inerval), and for battery save of course.

I heared about esp32 before, it pretty cool with greater range, but in my case, I dont actually need it