home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.65k stars 30.79k forks source link

Ecowitt new device WFC01 unhandled by integration #97808

Open zipzagster opened 1 year ago

zipzagster commented 1 year ago

The problem

Ecowitt has a new device, a water valve, that when added to the GW2000 does not appear in the integration

What version of Home Assistant Core has the issue?

2023.8.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Ecowitt

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @pvizeli, mind taking a look at this issue as it has been labeled with an integration (ecowitt) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `ecowitt` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign ecowitt` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


ecowitt documentation ecowitt source (message by IssueLinks)

cloudbr34k84 commented 1 year ago

Following too see if this gets movement

stevekmoore commented 11 months ago

Also following as just purchased a WFC01 and wanting to control it from HomeAssistant via this Ecowitt integration.

mortenx commented 10 months ago

how is it?

CAT1210 commented 10 months ago

Following as well.

pauljatho commented 10 months ago

Would be great if this valve could be supported but I suspect it may not be possible

issue-triage-workflows[bot] commented 7 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

CAT1210 commented 7 months ago

I keep HA updated and haven't seen this valve in the implementation or heard anything about whether or not it's even possible, yet....

cokecan72 commented 7 months ago

As above, there has been no information I've seen to suggest this implementation has even been considered, let alone worked on. Still hopeful this can be added

mhors commented 6 months ago

Just purchased WFC01 + GW2000 + WH51 assuming it could integrate with HA. Read a post from Dec-23 stating a few months for this integration to be added to Ecowitt HA integration. Any update that Ecowitt could post here?

mhors commented 6 months ago

This link here suggests a development will be delivered by Feb-2924.

https://community.home-assistant.io/t/ecowitt-weatherstation-integration-for-home-assistant/194718/322

domhaas commented 5 months ago

As I've received my WFC01 recently I've spent some time on getting it to work with HA. The good thing: the local web-service of the Ecowitt Gateway (GW2000 in my case) gives access to the subdevices without any issue.

This works already with rest-command/rest in HA to get all information about the subdevice and control it:

rest_command:
  watering_turn_on:
    url: http://192.168.x.x/parse_quick_cmd_iot
    method: POST
    content_type: "application/json; charset=utf-8"
    payload: '{"command":[{"on_type":0,"off_type":0,"always_on":1,"on_time":0,"off_time":0,"val_type":1,"val":0,"cmd":"quick_run","id":123,"model":1}]}'

  watering_turn_off:
    url: http://192.168.x.x/parse_quick_cmd_iot
    method: POST
    content_type: "application/json; charset=utf-8"
    payload: '{"command":[{"cmd":"quick_stop","id":123,"model":1}]}'

rest:
  - resource: "http://192.168.x.x/parse_quick_cmd_iot"
    method: POST
    scan_interval: 10
    payload: '{"command":[{"cmd":"read_device","id":123,"model":1}]}'
    sensor:
      - name: "Water Temperature"
        value_template: "{{ value_json['command'][0]['water_temp'] }}"
        unit_of_measurement: "°C"
      - name: "Water Total"
        value_template: "{{ value_json['command'][0]['water_total'] }}"
        unit_of_measurement: "L"
    binary_sensor:
      - name: "Water On"
        value_template: "{{ value_json['command'][0]['water_running'] }}"

As this is just a test implementation: To Query all subdevices (iot-devices) there is also an endpoint for that: http://192.168.x.x/get_iot_device_list (device-id is not 123, I've changed it to that)

Response:

{"command":[{"cmd":"read_quick","model":1,"id":123,"ver":113,"rfnet_state":1,"battery":5,"signal":4}]}

I'm no python-dev. But I really think that thos ecowitt-subdevices could be easy integrated in the official HA-Integration. Currently it looks that on my Dashboard (Bewässerung = Watering):

image

Hope someone has skills & time to integrate it. Thanks!

bitlisz1 commented 5 months ago

Thanks! I also added like this.

There are plenty parameters:

http://192.168.x.x/get_iot_device_list

{"command":[{"cmd":"read_quick","model":1,"id":12345,"ver":113,"rfnet_state":1,"battery":4,"signal":2}]}

and

http://192.168.x.x/parse_quick_cmd_iot

{"command":[{"model":1,"id":12345,"nickname":"WFC01-0000123E","devicename":"h5PvBXKkzABC12rnTDMi","version":113,"water_status":0,"warning":0,"always_on":1,"val_type":1,"val":0,"run_time":12,"wfc01batt":5,"rssi":2,"gw_rssi":-75,"timeutc":1717279140,"publish_time":1717262636,"water_action":36,"water_running":0,"plan_status":0,"water_total":"70.795","happen_water":"70.673","flow_velocity":"0.00","water_temp":"17.0"}]}

Similar could be for other device (model 2) AC1100 WittSwitch Smart Plug 'ac_running','happen_elect', 'elect_total', 'realtime_power', 'ac_action', 'ac_voltage'

Montreal666 commented 5 months ago

As I've received my WFC01 recently I've spent some time on getting it to work with HA. The good thing: the local web-service of the Ecowitt Gateway (GW2000 in my case) gives access to the subdevices without any issue.

Thank you, implemented here as well. Also added a switch template but the value template has sync issues (flipping on/off continually ?) so had to comment it out :

- platform: template
  switches:
    ex_water_valve_ecowitt1:
      friendly_name: EX water valve ecowitt1
#     value_template: "{{ is_state('binary_sensor.ex_water_valve_ecowitt_wittflow1_water_running', 'on') }}"
      turn_on:
        - service: rest_command.ex_water_valve_ecowitt_wittflow1_turn_on
          data: {}
      turn_off:
        - service: rest_command.ex_water_valve_ecowitt_wittflow1_turn_off
          data: {}

BTW how/where did you find the commands/sensors data and usage?

Did you figure out a way to have a bidirectionnal switch (updating status) ?

maybe "water running" is not the correct parameter (valve not connected to water now). I there a "valve status" (on/off) which could be leveraged?

Thanks!

domhaas commented 5 months ago

As I've received my WFC01 recently I've spent some time on getting it to work with HA. The good thing: the local web-service of the Ecowitt Gateway (GW2000 in my case) gives access to the subdevices without any issue.

Thank you, implemented here as well. Also added a switch template but the value template has sync issues (flipping on/off continually ?) so had to comment it out :

- platform: template
  switches:
    ex_water_valve_ecowitt1:
      friendly_name: EX water valve ecowitt1
#     value_template: "{{ is_state('binary_sensor.ex_water_valve_ecowitt_wittflow1_water_running', 'on') }}"
      turn_on:
        - service: rest_command.ex_water_valve_ecowitt_wittflow1_turn_on
          data: {}
      turn_off:
        - service: rest_command.ex_water_valve_ecowitt_wittflow1_turn_off
          data: {}

BTW how/where did you find the commands/sensors data and usage?

I've just used the (local) webinterface of the GWA2000 und looked into the debug-tools of the browser what requests have been sent.

Did you figure out a way to have a bidirectionnal switch (updating status) ?

No. But I don't think there are any: the local webinterface have separated calls.

maybe "water running" is not the correct parameter (valve not connected to water now). I there a "valve status" (on/off) which could be leveraged?

I think we need to find that out. This is the response: image

Montreal666 commented 5 months ago

Maybe "water status" (or does this check for water presence in the valve?) . Will run some more tests and report back. Thx

bitlisz1 commented 5 months ago

My switch template looks like this and seems to work:

switch:
  - platform: template
    switches:
      wfc01_watering:
        friendly_name: "WFC01 Watering"
        value_template: "{{ is_state('binary_sensor.wfc01_water_on', 'on') }}"
        turn_on:
          service: rest_command.wfc01_watering_turn_on
          data:
            zoneid: 1
            turn_on: 1
        turn_off:
          service: rest_command.wfc01_watering_turn_off
          data:
            zoneid: 1
            turn_on: 0

Watering_off

Watering_on

Montreal666 commented 5 months ago

Can you provide your code for binary_sensor.wfc01_water_on ?

Thx

bitlisz1 commented 5 months ago

Here is all related to WFC01 from my config.yaml:


rest_command:
  wfc01_watering_turn_on:
    url: http://192.168.1.123/parse_quick_cmd_iot
    method: POST
    content_type: "application/json; charset=utf-8"
    payload: '{"command":[{"on_type":0,"off_type":0,"always_on":1,"on_time":0,"off_time":0,"val_type":1,"val":0,"cmd":"quick_run","id":12345,"model":1}]}'

  wfc01_watering_turn_off:
    url: http://192.168.1.123/parse_quick_cmd_iot
    method: POST
    content_type: "application/json; charset=utf-8"
    payload: '{"command":[{"cmd":"quick_stop","id":12345,"model":1}]}'

rest:
  - resource: "http://192.168.1.123/parse_quick_cmd_iot"
    method: POST
    scan_interval: 10
    payload: '{"command":[{"cmd":"read_device","id":12345,"model":1}]}'
    sensor:
      - name: "WFC01 Water Total"
        value_template: "{{ value_json['command'][0]['water_total'] }}"
        unit_of_measurement: "L"
      - name: "WFC01 Water Flow Velocity"
        value_template: "{{ value_json['command'][0]['flow_velocity'] }}"
        unit_of_measurement: "L/min"
      - name: "WFC01 Water Temperature"
        value_template: "{{ value_json['command'][0]['water_temp'] }}"
        unit_of_measurement: "°C"
      - name: "WFC01 Water Run Time"
        value_template: "{{ value_json['command'][0]['run_time'] }}"
        unit_of_measurement: "sec"
      - name: "WFC01 Battery"
        value_template: "{{ value_json['command'][0]['wfc01batt'] }}"
        unit_of_measurement: "level"
      - name: "WFC01 RSSI"
        value_template: "{{ value_json['command'][0]['rssi'] }}"
        unit_of_measurement: "level"
    binary_sensor:
      - name: "WFC01 Water On"
        value_template: "{{ value_json['command'][0]['water_running'] }}"
      - name: "WFC01 Water Plan Status"
        value_template: "{{ value_json['command'][0]['plan_status'] }}"
      - name: "WFC01 Water Status"
        value_template: "{{ value_json['command'][0]['water_status'] }}"
      - name: "WFC01 Water Warning"
        value_template: "{{ value_json['command'][0]['warning'] }}"
Montreal666 commented 5 months ago

Thanks! Is your valve connected to water? My status keeps toggling on/off on but I suspect it is related to the valve not being connected to water; The actual valve relay doesn't trigger, just the status toggling on/off on each scan interval.

image
bitlisz1 commented 5 months ago

Yes, mine is connected to water.

mhors commented 5 months ago

I have yet to try out the above access to my GW2000A, but for what it's worth, I have noticed spurious 'no water' notification at the start of a 'water on' event. This may be what @Montreal666 is experiencing also.

Screenshot_2024-06-03-07-27-26-44_aa17207b2fdd1d98a56b347e71d60713

cokecan72 commented 5 months ago

Thank you so much for this work around using REST! Just set it up and it's working great. I've had two of these devices since they were released in the UK but have largely been unable to use them the way wanted (via HA automations) till now. This looks like it'll work well until the official integration is updated.

pauljatho commented 5 months ago

This doesn't seem to be working for me, I've literally copied / pasted the code and then changed to my IP address which I know is correct as I can login to the web admin for the gateway, and all of the sensors come up as unavailable, any ideas what could be wrong?

Only thing possibly different is that I also have an Ecowitt weather station and the gateway picks up those sensors but can't imagine this to be an issue.

Model number on my unit is WFC01C

My code


#-----------------------------------------------------------
## Ecowitt Water valve
#-----------------------------------------------------------        
rest_command:
  wfc01_watering_turn_on:
    url: http://192.168.88.149/parse_quick_cmd_iot
    method: POST
    content_type: "application/json; charset=utf-8"
    payload: '{"command":[{"on_type":0,"off_type":0,"always_on":1,"on_time":0,"off_time":0,"val_type":1,"val":0,"cmd":"quick_run","id":12345,"model":1}]}'

  wfc01_watering_turn_off:
    url: http://192.168.88.149/parse_quick_cmd_iot
    method: POST
    content_type: "application/json; charset=utf-8"
    payload: '{"command":[{"cmd":"quick_stop","id":12345,"model":1}]}'

rest:
  - resource: "http://192.168.88.149/parse_quick_cmd_iot"
    method: POST
    scan_interval: 10
    payload: '{"command":[{"cmd":"read_device","id":12345,"model":1}]}'
    sensor:
      - name: "WFC01 Water Total"
        value_template: "{{ value_json['command'][0]['water_total'] }}"
        unit_of_measurement: "L"
      - name: "WFC01 Water Flow Velocity"
        value_template: "{{ value_json['command'][0]['flow_velocity'] }}"
        unit_of_measurement: "L/min"
      - name: "WFC01 Water Temperature"
        value_template: "{{ value_json['command'][0]['water_temp'] }}"
        unit_of_measurement: "°C"
      - name: "WFC01 Water Run Time"
        value_template: "{{ value_json['command'][0]['run_time'] }}"
        unit_of_measurement: "sec"
      - name: "WFC01 Battery"
        value_template: "{{ value_json['command'][0]['wfc01batt'] }}"
        unit_of_measurement: "level"
      - name: "WFC01 RSSI"
        value_template: "{{ value_json['command'][0]['rssi'] }}"
        unit_of_measurement: "level"
    binary_sensor:
      - name: "WFC01 Water On"
        value_template: "{{ value_json['command'][0]['water_running'] }}"
      - name: "WFC01 Water Plan Status"
        value_template: "{{ value_json['command'][0]['plan_status'] }}"
      - name: "WFC01 Water Status"
        value_template: "{{ value_json['command'][0]['water_status'] }}"
      - name: "WFC01 Water Warning"
        value_template: "{{ value_json['command'][0]['warning'] }}"

![WFC](https://github.com/home-assistant/core/assets/60437563/516ebda1-1567-48e6-96b6-fe4c020aeb9a)
cokecan72 commented 5 months ago

you need to change the 'id' in the payload as well as the IP address in the URL. This is unique to your device.

Following domhaas and bitlistz1's post earlier, you need to load http://192.168.x.x/get_iot_device_list (either in a web page or CURL or similar). This will list all the iot devices connected and also give you the unique ID's for each. Obviously change the IP address to match your gateway :) Worth just double checking the 'model' in the payload matches what's in this URL too

pauljatho commented 5 months ago

Following domhaas and bitlistz1's post earlier, you need to load http://192.168.x.x/get_iot_device_list (either in a web page or CURL or similar).

Ah thanks a million I somehow missed that, it's working now, appreciate the help.

domhaas commented 5 months ago

Here is all related to WFC01 from my config.yaml:


rest_command:
  wfc01_watering_turn_on:
    url: http://192.168.1.123/parse_quick_cmd_iot
    method: POST
    content_type: "application/json; charset=utf-8"
    payload: '{"command":[{"on_type":0,"off_type":0,"always_on":1,"on_time":0,"off_time":0,"val_type":1,"val":0,"cmd":"quick_run","id":12345,"model":1}]}'

  wfc01_watering_turn_off:
    url: http://192.168.1.123/parse_quick_cmd_iot
    method: POST
    content_type: "application/json; charset=utf-8"
    payload: '{"command":[{"cmd":"quick_stop","id":12345,"model":1}]}'

rest:
  - resource: "http://192.168.1.123/parse_quick_cmd_iot"
    method: POST
    scan_interval: 10
    payload: '{"command":[{"cmd":"read_device","id":12345,"model":1}]}'
    sensor:
      - name: "WFC01 Water Total"
        value_template: "{{ value_json['command'][0]['water_total'] }}"
        unit_of_measurement: "L"
      - name: "WFC01 Water Flow Velocity"
        value_template: "{{ value_json['command'][0]['flow_velocity'] }}"
        unit_of_measurement: "L/min"
      - name: "WFC01 Water Temperature"
        value_template: "{{ value_json['command'][0]['water_temp'] }}"
        unit_of_measurement: "°C"
      - name: "WFC01 Water Run Time"
        value_template: "{{ value_json['command'][0]['run_time'] }}"
        unit_of_measurement: "sec"
      - name: "WFC01 Battery"
        value_template: "{{ value_json['command'][0]['wfc01batt'] }}"
        unit_of_measurement: "level"
      - name: "WFC01 RSSI"
        value_template: "{{ value_json['command'][0]['rssi'] }}"
        unit_of_measurement: "level"
    binary_sensor:
      - name: "WFC01 Water On"
        value_template: "{{ value_json['command'][0]['water_running'] }}"
      - name: "WFC01 Water Plan Status"
        value_template: "{{ value_json['command'][0]['plan_status'] }}"
      - name: "WFC01 Water Status"
        value_template: "{{ value_json['command'][0]['water_status'] }}"
      - name: "WFC01 Water Warning"
        value_template: "{{ value_json['command'][0]['warning'] }}"

Hey @bitlisz1 In my case the sensors are getting the state "unknown" for some seconds after the rest-service updates the sensors, after that, the sensors are getting the right values. Same on your side? Haven't used the rest-service till now.

I think this is a design-issue of the rest-service in Home Assistant.

bitlisz1 commented 5 months ago

Yes, same behaviour here.

rondol1 commented 5 months ago

Thanks for all your combined efforts! Question 1: I have two device with (of course) different ID's. How to include the second device? I can't just copy the whole block. Question 2: And how did you get that nice switch card with all the sensors underneath?

Thanks!

bitlisz1 commented 5 months ago

rondol1:

Copy here reply for these (alter IP/ID):

(192.168.x.x HUB's address)

http://192.168.x.x/get_iot_device_list

and

http://192.168.x.x/parse_quick_cmd_iot

rondol1 commented 5 months ago

bitlisz1: To be precise, I have one hub with two WFC01 subdevices. With your YAML I managed to get data for one but how do I get the second one? The IP address for the hub is obviously the same. If I copy/paste the whole YAML part and alter the alter the ID, it give an error "duplicated mapping key". So the second WFC01 should be integrated in the existing YAML.

EDIT: Never mind, figured it out :) !

Montreal666 commented 5 months ago

Hey @bitlisz1 In my case the sensors are getting the state "unknown" for some seconds after the rest-service updates the sensors, after that, the sensors are getting the right values. Same on your side? Haven't used the rest-service till now.

I think this is a design-issue of the rest-service in Home Assistant.

For those who created a template switch, would you mind checking your switch behavior:

Once turned on, mine keeps flipping between on and off every scan_interval (10 seconds) see below. It doesn't affect the actual WFC01 state which remains "ON" I've tried using "water_running" and "water_status" as value template no such issues when the switch is OFF.

probably related to the "unknown" state when updating, as mentioned above? If you experience the same behavior, did you figure a workaround? Maybe a state template which ignores "unknown"?

Thanks!

Thank you!

image
rest.yaml

- resource: "http://192.168.0.xxx/parse_quick_cmd_iot"
  method: POST
  scan_interval: 10
  payload: '{"command":[{"cmd":"read_device","id":xxxxx,"model":1}]}'
  sensor:
    - name: "EX water valve ecowitt wittflow1 water temperature"
      unique_id: ex_water_valve_ecowitt_wittflow1_water_temperature
      value_template: "{{ value_json['command'][0]['water_temp'] }}"
      unit_of_measurement: "°C"
    - name: "EX water valve ecowitt wittflow1 water total"
      unique_id: ex_water_valve_ecowitt_wittflow1_water_total
      value_template: "{{ value_json['command'][0]['water_total'] }}"
      unit_of_measurement: "L"
    - name: "EX water valve ecowitt wittflow1 flow velocity"
      unique_id: ex_water_valve_ecowitt_wittflow1_flow_velocity
      value_template: "{{ value_json['command'][0]['flow_velocity'] }}"
      unit_of_measurement: "L/min"
    - name: "EX water valve ecowitt wittflow1 run time"
      unique_id: ex_water_valve_ecowitt_wittflow1_run_time
      value_template: "{{ value_json['command'][0]['run_time'] }}"
      unit_of_measurement: "sec"
    - name: "EX water valve ecowitt wittflow1 battery level"
      unique_id: ex_water_valve_ecowitt_wittflow1_battery_level
      value_template: "{{ value_json['command'][0]['wfc01batt'] }}"
      unit_of_measurement: "level"
    - name: "EX water valve ecowitt wittflow1 rssi"
      unique_id: ex_water_valve_ecowitt_wittflow1_rssi
      value_template: "{{ value_json['command'][0]['rssi'] }}"
      unit_of_measurement: "level"
  binary_sensor:
    - name: "EX water valve ecowitt wittflow1 water running"
      unique_id: ex_water_valve_ecowitt_wittflow1_water_running    
      value_template: "{{ value_json['command'][0]['water_running'] }}"
    - name: "EX water valve ecowitt wittflow1 plan status"
      unique_id: ex_water_valve_ecowitt_wittflow1_plan_status    
      value_template: "{{ value_json['command'][0]['plan_status'] }}"
    - name: "EX water valve ecowitt wittflow1 water status"
      unique_id: ex_water_valve_ecowitt_wittflow1_water_status    
      value_template: "{{ value_json['command'][0]['water_status'] }}"
    - name: "EX water valve ecowitt wittflow1 warning"
      unique_id: ex_water_valve_ecowitt_wittflow1_warning    
      value_template: "{{ value_json['command'][0]['warning'] }}"

rest_command.yaml

ex_water_valve_ecowitt_wittflow1_turn_on:
  url: http://192.168.0.xxx/parse_quick_cmd_iot
  method: POST
  content_type: "application/json; charset=utf-8"
  payload: '{"command":[{"on_type":0,"off_type":0,"always_on":1,"on_time":0,"off_time":0,"val_type":1,"val":0,"cmd":"quick_run","id":xxxxx,"model":1}]}'

ex_water_valve_ecowitt_wittflow1_turn_off:
  url: http://192.168.0.xxx/parse_quick_cmd_iot
  method: POST
  content_type: "application/json; charset=utf-8"
  payload: '{"command":[{"cmd":"quick_stop","id":xxxxx,"model":1}]}'

switch.yaml

- platform: template
  switches:
    ex_water_valve_ecowitt1:
      friendly_name: EX water valve ecowitt1
      value_template: "{{ is_state('binary_sensor.ex_water_valve_ecowitt_wittflow1_water_status', 'on') }}"
      turn_on:
        - service: rest_command.ex_water_valve_ecowitt_wittflow1_turn_on
          data: {}
      turn_off:
        - service: rest_command.ex_water_valve_ecowitt_wittflow1_turn_off
          data: {}
cokecan72 commented 5 months ago

When I turn mine on with the template sensor, the visible toggle flicks back to off but the valve remains on. it doesn't seem to ever update and show it as being "on" even though the other sensors show it's on and water is passing. I also don't get repeated log entries every 10 seconds like you do, though my switch is very slightly different to yours:

switch:
  - platform: template
    switches:
      wfc01__valve:
        friendly_name: "WFC01 Valve"
        unique_id: wfc01_valve
        value_template: "{{ is_state('binary_sensor.wfc01_water_on', 'on') }}"
        turn_on:
          service: rest_command.wfc01_valve_turn_on
          data:
            zoneid: 1
            turn_on: 1
        turn_off:
          service: rest_command.wfc01_valve_turn_off
          data:
            zoneid: 1
            turn_on: 0

I've been testing automations and they turn the valve on and off without issue using the template switch above but I'm just missing a visible indication that it's on at the minute

Montreal666 commented 5 months ago

Ok thanks, this seems to confirm something is still misconfigured in ordrer to correctly track the valve status. I had previously tried

            zoneid: 1
            turn_on: 0

with the same results... will have to dig deeper to figure it out. let me knolw if you find something. thx

werkstrom commented 3 months ago

Thanks everyone for all the research. I get the same issue with every second read the sensors turn "unknown". Looking in the log it appears the JSON data is "undefined" image Calling the APi rapidly from Postman works just fine, so I guess that is hardly the issue.

Edit: It appears on my RPi 4 the REST code in HA is so slow it cannot handle a call every 10 seconds. Upping the request intervall to 20 sek and I have no drop outs.

my rest.yaml now looks like this (added some icons if anyone is interested):

- resource: "http://192.168.xxx.xxx/parse_quick_cmd_iot"
  method: POST
  scan_interval: 20
  headers:
    Content-Type: application/json
  payload: '{"command":[{"cmd":"read_device","id":12345,"model":1}]}'
  sensor:
    - name: "Ecowitt WFC01 Terrace Bambu Volume"
      unique_id: "Ecowitt_WFC01_Terrace_Bambu_Volume_001"
      icon: "mdi:waves"
      value_template: "{{ value_json.command[0].water_total }}"
      unit_of_measurement: "L"

    - name: "Ecowitt WFC01 Terrace Bambu water temperature"
      unique_id: "Ecowitt_WFC01_Terrace_Bambu_Water_Temp_001"
      icon: "mdi:thermometer-water"
      value_template: "{{ value_json.command[0].water_temp }}"
      unit_of_measurement: "°C"

    - name: "Ecowitt WFC01 Terrace Bambu water flow velocity"
      unique_id: "Ecowitt_WFC01_Terrace_Bambu_Water_Flow_Velocity_001"
      icon: "mdi:speedometer"
      value_template: "{{ value_json.command[0].flow_velocity }}"
      unit_of_measurement: "L/min"

    - name: "Ecowitt WFC01 Terrace Bambu Run Time"
      unique_id: "Ecowitt_WFC01_Terrace_Bambu_Run_Time_001"
      icon: "mdi:timer-play-outline"
      value_template: "{{ value_json.command[0].run_time }}"
      unit_of_measurement: "s"

    - name: "Ecowitt WFC01 Terrace Bambu Battery Level"
      unique_id: "Ecowitt_WFC01_Terrace_Bambu_Battery_Level_001"
      icon: "mdi:battery-high"
      value_template: "{{ value_json.command[0].wfc01batt }}"
      unit_of_measurement: "level"

    - name: "Ecowitt WFC01 Terrace Bambu RF Signal"
      unique_id: "Ecowitt_WFC01_Terrace_Bambu_RF_Signal_001"
      icon: "mdi:radio-tower"
      value_template: "{{ value_json.command[0].rssi }}"
      unit_of_measurement: "level"

  binary_sensor:
    - name: "Ecowitt WFC01 Terrace Bambu Water Running"
      unique_id: "Ecowitt_WFC01_Terrace_Bambu_water_running_001"
      icon: "mdi:water-pump"
      value_template: "{{ value_json.command[0].water_running }}"

    - name: "Ecowitt WFC01 Terrace Bambu Plan Status"
      unique_id: "Ecowitt_WFC01_Terrace_Bambu_Plan_Status_001"
      icon: "mdi:water-outline"
      value_template: "{{ value_json.command[0].plan_status }}"

    - name: "Ecowitt WFC01 Terrace Bambu Water Status"
      unique_id: "Ecowitt_WFC01_Terrace_Bambu_Water_Status_001"
      icon: "mdi:water-outline"
      value_template: "{{ value_json.command[0].water_status }}"

    - name: "Ecowitt WFC01 Terrace Bambu Warning"
      unique_id: "Ecowitt_WFC01_Terrace_Bambu_Warning_001"
      icon: "mdi:water-alert-outline"
      value_template: "{{ value_json.command[0].warning }}"

Also added a rest commands for watering with 1L and 40L of water (volume in DL i.e. 1/10 L). If you need a template for that call. rest_command.yaml is like this:

ecowitt_wfc01_terrace_bambu_turn_on:
  url: "http://192.168.xxx.xxx/parse_quick_cmd_iot"
  method: POST
  headers:
    Content-Type: application/json
  payload: '{"command":[{"on_type":0,"off_type":0,"always_on":1,"on_time":0,"off_time":0,"val_type":1,"val":0,"cmd":"quick_run","id":12345,"model":1}]}'

ecowitt_wfc01_terrace_bambu_turn_off:
  url: "http://192.168.xxx.xxx/parse_quick_cmd_iot"
  method: POST
  headers:
    Content-Type: application/json
  payload: '{"command":[{"cmd":"quick_stop","id":12345,"model":1}]}'

ecowitt_wfc01_terrace_bambu_1_l:
  url: "http://192.168.xxx.xxx/parse_quick_cmd_iot"
  method: POST
  headers:
    Content-Type: application/json
  payload: '{"command":[{"on_type":0,"off_type":0,"always_on":0,"on_time":0,"off_time":0,"val_type":3,"val":10,"cmd":"quick_run","id":12345,"model":1}]}'

ecowitt_wfc01_terrace_bambu_40_l:
  url: "http://192.168.xxx.xxx/parse_quick_cmd_iot"
  method: POST
  headers:
    Content-Type: application/json
  payload: '{"command":[{"on_type":0,"off_type":0,"always_on":0,"on_time":0,"off_time":0,"val_type":3,"val":400,"cmd":"quick_run","id":12345,"model":1}]}'
domhaas commented 3 months ago

Edit: It appears on my RPi 4 the REST code in HA is so slow it cannot handle a call every 10 seconds. Upping the request intervall to 20 sek and I have no drop outs.

Thanks @werkstrom for the hint. Sensor are not getting unknown since i've changed it from 10s -> 20s. But it obviously has nothing to do with performance - I use a current (fast) Intel CPU and had the same problem with the 10s. It's probably due to a timing-issue of Home Assistant.

Montreal666 commented 3 months ago

If anyone is interested, I have an extra valve (WFC01C 433Mhz) + Gateway (GW2000 433Mhz). Make me a reasonnable offer via PM. Thanks.

murch1 commented 3 months ago

Thanks for everyone's help. I have refined the code a little and thought I would share here.

  1. Added helper input_number.tap_timer field to set a variable tap timer (in minutes). This way, I am not relying on Home Assistant to keep track of valve open timing and hand that power back to the valve. Can be adjusted to set a volume limit but you need to change the "val_type" from 1 to 3 in the valve API REST call and use the units Litres x10 (as mentioned above).
  2. Added extra sequence steps in the switch template to force a RESTful reload after the valve is opened (turn_on) or closed (turn_off). This way, the status of the valve is seen to act straight away, instead of waiting for the periodic refresh of the RESTful data. I have my refresh set to 60sec, so this was more important for me. Might not be an issue if your refresh is set to 10-20sec. Two second delay is to allow the valve status to update on the GW2000 gateway. Normal refresh rate applies if the valve is actuated outside of this switch (e.g. when the valve times out).

configuration.yaml

# Water valves                                                                                   
switch:                         
  - platform: template                                                                           
    switches:                                                                                    
      wfc01_valve:                                                                               
        friendly_name: "Ecowitt WFC01 Test Valve"
        unique_id: ecowitt_wfc01_test_valve                                                      
        value_template: "{{ is_state('binary_sensor.ecowitt_wfc01_test_water_status', 'on') }}"
        turn_on:                                                                                 
          - sequence:                                                                            
            - service: rest_command.ecowitt_wfc01_test_turn_on                                 
              data:                                                                              
                zoneid: 1                                                                        
                turn_on: 1                                                                     
                time: '{{ states.input_number.tap_timer.state | int }}'                        
            - delay:                                                                           
                hours: 0                                                                       
                minutes: 0                                                                     
                seconds: 2                                                                     
                milliseconds: 0                                                                
            - service: rest.reload                                                             
        turn_off:                                                                              
          - sequence:                                                                          
            - service: rest_command.ecowitt_wfc01_test_turn_off                                
              data:                                                    
                zoneid: 1                                                                      
                turn_on: 0                                                                     
            - delay:                                                                           
                hours: 0                                                                       
                minutes: 0                                                                     
                seconds: 2                                                                     
                milliseconds: 0                                
            - service: rest.reload 

rest_command.yaml

ecowitt_wfc01_test_turn_on:                                                                                                                                     
  url: "http://192.168.x.x/parse_quick_cmd_iot"                                                                                                                  
  method: POST                                                                                                                                                  
  headers:                                                                                                                                                      
    Content-Type: application/json                                                                                                                              
  payload: '{"command":[{"on_type":0,"off_type":0,"always_on":0,"on_time":0,"off_time":0,"val_type":1,"val":{{ time }},"cmd":"quick_run","id":12345,"model":1}]}

ecowitt_wfc01_test_turn_off:                                                                                                                                    
  url: "http://192.168.x.x/parse_quick_cmd_iot"                                                                                                                  
  method: POST                                                                                                                                                  
  headers:                                                                                                                                                      
    Content-Type: application/json                                                                                                                              
  payload: '{"command":[{"cmd":"quick_stop","id":12345,"model":1}]}'

rest.yaml

- resource: "http://192.168.x.x/parse_quick_cmd_iot"                                                                                                             
  method: POST                                                                                                                                                  
  scan_interval: 60                                                                                                                                             
  headers:                                                                                                                                                      
    Content-Type: application/json                                                                                                                              
  payload: '{"command":[{"cmd":"read_device","id":12345,"model":1}]}'                                                                                           
  sensor:                                                                                                                                                       
    - name: "Ecowitt WFC01 Test Volume"                                                                                                                         
      unique_id: "Ecowitt_WFC01_test_volume"                                                                                                                    
      icon: "mdi:waves"                                                                                                                                         
      value_template: "{{ value_json.command[0].water_total }}"                                                                                                 
      unit_of_measurement: "L"                                                                                                                                  

    - name: "Ecowitt WFC01 Test Temperature"                                                                                                                    
      unique_id: "Ecowitt_WFC01_test_temperature"                                                                                                               
      icon: "mdi:thermometer-water"                                                                                                                             
      value_template: "{{ value_json.command[0].water_temp }}"                                                                                                  
      unit_of_measurement: "C"                                                                                                                                  

    - name: "Ecowitt WFC01 Test Flowrate"                                                                                                               
      unique_id: "Ecowitt_WFC01_test_flowrate"                                                                                                                  
      icon: "mdi:speedometer"                                                                                                                                   
      value_template: "{{ value_json.command[0].flow_velocity }}"                                                                                               
      unit_of_measurement: "L/min"                                                                                                                              

    - name: "Ecowitt WFC01 Test Run Time"                                                                                                                       
      unique_id: "Ecowitt_WFC01_test_runtime"                                                                                                                   
      icon: "mdi:timer-play-outline"                                                                                                                            
      value_template: "{{ value_json.command[0].run_time }}"                                                                                                    
      unit_of_measurement: "s"                                                                                                                                  

    - name: "Ecowitt WFC01 Test Battery Level"                                                                                                                  
      unique_id: "Ecowitt_WFC01_test_batt_lvl"                                                                                                                  
      icon: "mdi:battery-high"                                                                                                                                  
      value_template: "{{ value_json.command[0].wfc01batt }}"                                                                                                   
      unit_of_measurement: "level"                                                                                                                              

    - name: "Ecowitt WFC01 Test RF Signal"                                                                                                                      
      unique_id: "Ecowitt_WFC01_test_rf_sig"                                                                                                                    
      icon: "mdi:radio-tower"                                                                                                                                   
      value_template: "{{ value_json.command[0].rssi }}"                                                                                                        
      unit_of_measurement: "level"                                                                                                                              

  binary_sensor:                                                                                                                                                
    - name: "Ecowitt WFC01 Test Water Running"                                                                                                                  
      unique_id: "Ecowitt_WFC01_test_water_running"                                                                                                             
      icon: "mdi:water-pump"                                                                                                                                    
      value_template: "{{ value_json.command[0].water_running }}"                                                                                               

    - name: "Ecowitt WFC01 Test Plan Status"                                                                                                                    
      unique_id: "Ecowitt_WFC01_test_plan_status"                                                                                                               
      icon: "mdi:water-outline"                                                                                                                                 
      value_template: "{{ value_json.command[0].plan_status }}"                                                                                                 

    - name: "Ecowitt WFC01 Test Water Status"                                                                                                                   
      unique_id: "Ecowitt_WFC01_test_water_status"                                                                                                              
      icon: "mdi:water-outline"                                                                                                                                 
      value_template: "{{ value_json.command[0].water_status }}"                                                                                                

    - name: "Ecowitt WFC01 Test Warning"                                                                                                                        
      unique_id: "Ecowitt_WFC01_test_warning"                                                                                                                   
      icon: "mdi:water-alert-outline"                                                                                                                           
      value_template: "{{ value_json.command[0].warning }}" 
image
werkstrom commented 3 months ago

Cool @murch1 😁☀️👍 For anyone interested, my payload in REST-yaml looks like this for setting a specific volume.

#Reads value of helper (in liters), multiply with 10 (for deciliters which the valve uses), removes any decimals from the deciliter value and calls the service.

  payload: >
    {% set watering_volume = states('input_number.wateringvolume_bamboo') | float %}
    {% set adjusted_volume = (watering_volume * 10) | int %}
    {"command":[{"on_type":0,"off_type":0,"always_on":0,"on_time":0,"off_time":0,"val_type":3,"val":{{ adjusted_volume }},"cmd":"quick_run","id":12345,"model":1}]}
domhaas commented 3 months ago
2. Added extra sequence steps in the switch template to force a RESTful reload after the valve is opened (turn_on) or closed (turn_off). This way, the status of the valve is seen to act straight away, instead of waiting for the periodic refresh of the RESTful data. I have my refresh set to 60sec, so this was more important for me. Might not be an issue if your refresh is set to 10-20sec. Two second delay is to allow the valve status to update on the GW2000 gateway. Normal refresh rate applies if the valve is actuated outside of this switch (e.g. when the valve times out).

@murch1 Restarting the rest service completely is problematic, at least for me, as I still use various other rest endpoints. In addition, the status briefly changes back to "unknown" after reloading the sensors.

With the update of the sensors, however, it seems to work quite well. Strangely enough, it does take longer from time to time, or the status changes to "unknown" - not really reproducible when.

The rest-servic a home assistant probably has a few problems.

Translated with DeepL.com (free version)

          - sequence:
            - service: rest_command.wfc01_watering_turn_on
              data:
                zoneid: 1
                turn_on: 1
            - delay:
                hours: 0
                minutes: 0
                seconds: 2
                milliseconds: 0
            #- service: rest.reload
            - service: homeassistant.update_entity
              entity_id: binary_sensor.Ecowitt_WFC01_water_status
rondol1 commented 3 months ago

Somehow I'm overlooking something.

I copied the yaml code. I'm pretty sure I replaced the IP and device ID correctly, but when I hit the switch I get an error: Error rendering data template: UndefinedError: 'None' has no attribute 'state'

werkstrom commented 3 months ago

@rondol1: Hard to tell since you don't attach your code 😉 But a shot in the dark. If you're trying to use the Liters or Seconds... Did you set the helper up?

rondol1 commented 3 months ago

That's exactly the cause, when I comment out the template, It works like it used to. I'm quite a noob with this. Should I've created a helper manually myself, our is that part of the code as published here? I presumed the last (for most new lines I have no clue what they are about :))

And about my code, I'd already changed it trying to get it solved. So it wasn't very helpful anymore.

werkstrom commented 3 months ago

@rondol1

Should I've created a helper manually myself

Yes. 👍

CharlBest commented 2 months ago

I'm sharing it if anyone is interested in a NodeRed/Home Assistant solution. Works 100%

image image

On/off node

image

Setting ID

image

Build command:

image

Node code:

if (msg.shouldTurnOn) {
    msg.payload = `{"command":[{"on_type":0,"off_type":0,"always_on":1,"on_time":0,"off_time":0,"val_type":1,"val":0,"cmd":"quick_run","id":${msg.payload},"model":1}]}`
} else {
    msg.payload = `{"command":[{"cmd":"quick_stop","id":${msg.payload},"model":1}]}`
}

return msg

HTTP request node

image
marcoace84 commented 2 days ago

As I've received my WFC01 recently I've spent some time on getting it to work with HA. The good thing: the local web-service of the Ecowitt Gateway (GW2000 in my case) gives access to the subdevices without any issue.

This works already with rest-command/rest in HA to get all information about the subdevice and control it:


rest_command:
  watering_turn_on:
    url: http://192.168.x.x/parse_quick_cmd_iot
    method: POST
    content_type: "application/json; charset=utf-8"
    payload: '{"command":[{"on_type":0,"off_type":0,"always_on":1,"on_time":0,"off_time":0,"val_type":1,"val":0,"cmd":"quick_run","id":123,"model":1}]}'

  watering_turn_off:
    url: http://192.168.x.x/parse_quick_cmd_iot
    method: POST
    content_type: "application/json; charset=utf-8"
    payload: '{"command":[{"cmd":"quick_stop","id":123,"model":1}]}'

Hi I copied the piece of code for the switch but it doesn't come out in the entities... how is it possible? here is my code where I changed the ip and id

rest_command: watering_turn_on: url: http://192.168.178.108/parse_quick_cmd_iot method: POST content_type: "application/json; charset=utf-8" payload: '{"command":[{"on_type":0,"off_type":0,"always_on":1,"on_time":0,"off_time":0,"val_type":1,"val":0,"cmd":"quick_run","id":13929,"model":1}]}'

watering_turn_off: url: http://192.168.178.108/parse_quick_cmd_iot method: POST content_type: "application/json; charset=utf-8" payload: '{"command":[{"cmd":"quick_stop","id":13929,"model":1}]}'

marcoace84 commented 2 days ago

if I send this from the browser

http://192.168.178.108/parse_quick_cmd_iot

I receive this message Request method for this URI is not handled by server