kvj / hass_openwrt

Home Assistant integration with OpenWrt devices
MIT License
114 stars 20 forks source link

Adding new Sensors / entities - How To #30

Open demlak opened 4 months ago

demlak commented 4 months ago

Since this issue was going in a complete different direction, i start a new one here:

I want to add new Sensors/Entities to the integration. for example ubus call dsl metrics

For sure i have to add this to the ACL File.. like this and restart rpcd.

{
  "hass": {
    "description": "Home Assistant OpenWrt integration permissions",
    "read": {
      "ubus": {
        "network.wireless": ["status"],
        "network.device": ["status"],
        "iwinfo": ["info", "assoclist"],
        "hostapd.*": ["get_clients", "wps_status"],
        "system": ["board"],
        "dsl": ["metrics"]
      },
    },
    "write": {
      "ubus": {
        "system": ["reboot"],
        "hostapd.*": ["wps_start", "wps_cancel"],
        "file": ["exec"]
      },
      "file": {
        "/usr/bin/uptime": ["exec"]
      }
    }
  }
}

but since i did not find anything new to the integrations-tab in hassio.. i was trying to understand the code of this addon.. i am not a coder =) So.. do i understand it correctly, that adding new sensors/entities - for example as an ubus-call - there is no automatism to integrate it? Are all Sensors hard-coded? Do i need to clone the repo and change code for myself to add?

If i am wrong.. what is the correct way to add new sensors/entities?