Add pulse frequency counter sensors for Shelly like #110248

Like #110248 (Add pulse counter sensors for Shelly by bieniu · Pull Request #110248 · home-assistant/core · GitHub), Shelly Uni report frequency pulse counter

Actually, the implemented request add only the pulse counter, not the frequency counter

The red circle contains the requested data to be included as sensors in shelly integration.

For me, the sensor report a water flow in Liters/minutes and the theoric formula is
Q (L/min) = F (Hz) * 1
(Amazon.fr)

Thanks

Shelly.GetConfig : Look at “input:2” → xfreq

{
  "ble": {
    "enable": false,
    "rpc": {
      "enable": true
    },
    "observer": {
      "enable": false
    }
  },
  "cloud": {
    "enable": true,
    "server": "aaaaaaaaaa:6022/jrpc"
  },
  "input:0": {
    "id": 0,
    "name": null,
    "type": "switch",
    "enable": true,
    "invert": false
  },
  "input:1": {
    "id": 1,
    "name": null,
    "type": "switch",
    "enable": true,
    "invert": false
  },
  "input:2": {
    "id": 2,
    "name": "Flow",
    "type": "count",
    "enable": true,
    "count_rep_thr": 100,
    "freq_window": 1,
    "freq_rep_thr": 10,
    "xcounts": {
      "expr": "x*1",
      "unit": "L"
    },
    "xfreq": {
      "expr": "x*0.9",
      "unit": "L/min"
    }
  },
  "mqtt": {
    "enable": false,
    "server": null,
    "client_id": "shellyplusuni-aaaaaaaa",
    "user": null,
    "ssl_ca": null,
    "topic_prefix": "shellyplusuni-aaaaaaaa",
    "rpc_ntf": true,
    "status_ntf": false,
    "use_client_cert": false,
    "enable_rpc": true,
    "enable_control": true
  },
  "switch:0": {
    "id": 0,
    "name": null,
    "in_mode": "follow",
    "initial_state": "match_input",
    "auto_on": false,
    "auto_on_delay": 60,
    "auto_off": false,
    "auto_off_delay": 60
  },
  "switch:1": {
    "id": 1,
    "name": null,
    "in_mode": "follow",
    "initial_state": "match_input",
    "auto_on": false,
    "auto_on_delay": 60,
    "auto_off": false,
    "auto_off_delay": 60
  },
  "sys": {
    "device": {
      "name": null,
      "mac": "aaaaaa",
      "fw_id": "20240223-142029/1.2.2-g7c39781",
      "discoverable": true,
      "eco_mode": false
    },
    "location": {
      "tz": "Europe/Paris",
      "lat": 0,
      "lon": 0
    },
    "debug": {
      "level": 2,
      "file_level": null,
      "mqtt": {
        "enable": false
      },
      "websocket": {
        "enable": false
      },
      "udp": {
        "addr": null
      }
    },
    "ui_data": {

    },
    "rpc_udp": {
      "dst_addr": null,
      "listen_port": null
    },
    "sntp": {
      "server": "time.google.com"
    },
    "cfg_rev": 29
  },
  "voltmeter:100": {
    "id": 100,
    "name": null,
    "report_thr": 0.1,
    "range": 0,
    "xvoltage": {
      "expr": null,
      "unit": null
    }
  },
  "wifi": {
    "ap": {
      "ssid": "ShellyPlusUni-aaaaaa",
      "is_open": false,
      "enable": false,
      "range_extender": {
        "enable": false
      }
    },
    "sta": {
      "ssid": "aaaa",
      "is_open": false,
      "enable": true,
      "ipv4mode": "dhcp",
      "ip": null,
      "netmask": null,
      "gw": null,
      "nameserver": null
    },
    "sta1": {
      "ssid": null,
      "is_open": true,
      "enable": false,
      "ipv4mode": "dhcp",
      "ip": null,
      "netmask": null,
      "gw": null,
      "nameserver": null
    },
    "roam": {
      "rssi_thr": -80,
      "interval": 60
    }
  },
  "ws": {
    "enable": false,
    "server": null,
    "ssl_ca": "ca.pem"
  }
}

Shelly.GetStatus : look at input:2 → freq and xfreq
xfreq is the value computed by the expr configured in xfreq.expr (x*0.9 ine this example)

{
  "ble": {

  },
  "cloud": {
    "connected": true
  },
  "input:0": {
    "id": 0,
    "state": false
  },
  "input:1": {
    "id": 1,
    "state": false
  },
  "input:2": {
    "id": 2,
    "counts": {
      "total": 8641,
      "xtotal": 8641,
      "by_minute": [0, 0, 0],
      "xby_minute": [0, 0, 0],
      "minute_ts": 1713462840
    },
    "freq": 9,
    "xfreq": 8.1
  },
  "mqtt": {
    "connected": false
  },
  "switch:0": {
    "id": 0,
    "source": "init",
    "output": false
  },
  "switch:1": {
    "id": 1,
    "source": "init",
    "output": false
  },
  "sys": {
    "mac": "xxxxx",
    "restart_required": false,
    "time": "19:54",
    "unixtime": 1713462886,
    "uptime": 3741,
    "ram_size": 245020,
    "ram_free": 129652,
    "fs_size": 458752,
    "fs_free": 143360,
    "cfg_rev": 29,
    "kvs_rev": 0,
    "schedule_rev": 0,
    "webhook_rev": 0,
    "available_updates": {
      "beta": {
        "version": "1.3.0-beta1"
      }
    },
    "reset_reason": 1
  },
  "voltmeter:100": {
    "id": 100,
    "voltage": 0.02
  },
  "wifi": {
    "sta_ip": "192.168.1.57",
    "status": "got ip",
    "ssid": "xxx",
    "rssi": -71
  },
  "ws": {
    "connected": false
  }
}

Actual reported sensors is
input:2.counts total/xtotal
shelly 2