h4de5 / home-assistant-vimar

VIMAR by-me integration into home-assistant.io
GNU General Public License v3.0
42 stars 6 forks source link

Delay state #12

Closed lupinve closed 3 years ago

lupinve commented 4 years ago

Hi,

I recently purchased a Vimar 01946 web server and easily managed to use your project with home assistant version 0.112.3 on Raspberry 4. Lights and thermostats were detected. For thermostats I have yet to try to test them. For the lights I have a lag problem when I turn the light on or off from the Vimar device. The state on HA has a delay of approximately 30 seconds. Is it a known problem or a configuration problem of my system?

Thanks for your help Matteo

h4de5 commented 4 years ago

Yes unfortunately this is known. I have to delay the update requests from home-assistant to the webserver, otherwise the webserver goes into an unresponsive state and requires a cold restart.

lupinve commented 3 years ago

I currently have version 2.3 of the webserver. I'd like to try to change the delay of update requests. I can try testing if you tell me where I can change the delay. Thanks Matteo

h4de5 commented 3 years ago

in each platform (light.py, cover.py, switch.py, climate.py) you will find two consts:

SCAN_INTERVAL = timedelta(seconds=20)
PARALLEL_UPDATES = 2

see: https://github.com/h4de5/home-assistant-vimar/blob/957b4bf4e1ebbc780382034884290eb330b813f1/light.py#L20

the first one is the time for how long each entity waits until it polls the webserver for new data. the second defines how may parallel requests can run at the same time.

you can play around with those numbers - but be informed, that the webserver may become unresponsive. i havn't got time to test out the limits as I am trying to fix this issue using a different approach.

lupinve commented 3 years ago

Hi,

I'm still testing the delay and for now it seems to work well with this setting, only for light.py:

SCAN_INTERVAL = timedelta(seconds=6) PARALLEL_UPDATES = 3

I also wanted to ask you if Vimar's IR sensor integration is already possible. In my xml it is detected but in HA it is considered light and does not work properly.

index index="120" label="SENSORE IR SALOTTO " number="0" room="SALOTTO" type="SENSORE IR" zone=""> datapointtypes channel="CH_Main_Automation"> datapointtype mode="rw" name="DPTSwitch">  groupobject address="0EF9"/> /datapointtype> /datapointtypes> device address="1108" manufacturer="002C" name="ConvimarSAISensoreIR" type="0001" version="8"> properties/> functionalblock channel="CH_Main_Automation" classification="sensor" index="2" main="True" name="ConvimarSensoreIR"> groupobjects> datapointtype mode="rw" name="DPTSwitch"/> /groupobjects> properties/> /functionalblock> /device>

Do I have to change any data? Thanks so much !!!!!

h4de5 commented 3 years ago

I see. An IR sensor would be like a switch or like a sensor (without the possibility to change its state from ha?)

lupinve commented 3 years ago

like a switch https://www.vimar.com/en/int/catalog/product/index/code/20485 i can use it for turn on the light when people show up

at the moment it is detected as a light that once activated does not turn off anymore

h4de5 commented 3 years ago

Ah i see. Maybe setting its state simply to 1 is wrong for that device. Can you have a look at contributing.md (the second part about setting a value) ?

lupinve commented 3 years ago

i try it, there seems to be no movement variation i find this value

NO-PAYLOADNO-HASCHODENO-OPTIONALWEB-DOMUSPAD_SOAP5f1328dbf1e3e5DML-SQLSELECTSELECT ID,NAME,STATUS_ID,CURRENT_VALUE FROM DPADD_OBJECT WHERE ID IN (229,265,598);83 ns:service-databasesocketoperationResponse > Response payload length: 303 DPCM-0000 303 Response: DBMG-000 NextRows: 4 Row000001: 'ID','NAME','STATUS_ID','CURRENT_VALUE' Row000002: '229','_DPAD_DBCONSTANT_VIMAR_BYME_TRIGGEROBJECT_VIDEOMESSAGE_UNHANDLED','-1','0' Row000003: '265','_DPAD_DBCONSTANT_VIMAR_BYME_TRIGGEROBJECT_SENSORS_HUMIDITY_ALARM','-1','0' Row000004: '598','on/off','-1','1'
h4de5 commented 3 years ago

this seems to be the read state - no the set state. I would need to request/payload that is sent to the webserver- not the answer. but I guess - as this still does only have a normal on/off state, the timer is somehow realized differently. You could have those timers within ha automations like this:

"some_uniqe_name":
  alias: büro rollos öffnen
  sequence:
    - data: {}
      entity_id:
        - light.id_of_light1
        - light.id_of_light2
      service: light.turn_on
    - delay: 0:00:15
    - data: {}
      entity_id:
        - light.id_of_light1
        - light.id_of_light2
      service: light.turn_off

this is just a script (for script.yaml) that will turn off those given lights after 15sec. you could play around with automations.

h4de5 commented 3 years ago

@lupinve with the latest code push, the updates should be comming in much faster. the entity states will be updated once every 6 seconds.

I am closing this issue as the original issue seems to be working already. Please let me know if that's not the case.

switching lights off after a given time, needs to be added through hass automations, i guess. also let me know if you made progress there.