itchannel / apex-ha

Local Neptune Apex HA Integration (Aquarium Controller)
GNU General Public License v3.0
19 stars 3 forks source link

Combining Sensors #33

Open behold81 opened 1 year ago

behold81 commented 1 year ago

Is it possible to combine sensors by name to there main item?

E.G. where you have an power monitored outlet. The main outlet has sub entities of Watts, voltage, amps. Instead of being separate entities.

Would fix some integrations with energy dashboard.

brettonw commented 1 year ago

I understand the conceptual organization you want, but it’s not really consistent with the way HA works. Each one of these things is a sensor, and that value is its state.

I created a helper for the energy dashboard that is a sum of all the W sensors, and then the integration (summation) helper to create a kwh entity, so I have a single energy line item that is my aquarium.I wonder if the apex integration could create these helpers for you.

behold81 commented 1 year ago

I have done this. Created them as helpers. But I think it's moaning that amps or voltage are missing to complete the calculations. Maybe it's something else.

I could be wrong.

Either way you are right they are entities but should they not be a sub of a device which is the outlet. Apex mor at the integration level?

Just thinking out loud.

BTW. Loving having this integration.

brettonw commented 1 year ago

For reference, here is my yaml (rename according to your entities):

template:
  sensor:
    - name: "Aquarium Power"
      unique_id: "aquarium_power_w"
      unit_of_measurement: "W"
      device_class: "power"
      state: >
        {% set w1 = (states('sensor.apex_light1_2_1w') | float) %}
        {% set w2 = (states('sensor.apex_light2_2_2w') | float) %}
        {% set w3 = (states('sensor.apex_retpump_2_3w') | float) %}
        {% set w4 = (states('sensor.apex_reflight_2_4w') | float) %}
        {% set w5 = (states('sensor.apex_skimmer_2_5w') | float) %}
        {% set w6 = (states('sensor.apex_dos_2_6w') | float) %}
        {% set w7 = (states('sensor.apex_heater_2_7w') | float) %}
        {% set w8 = (states('sensor.apex_pwrhead_2_8w') | float) %}
        {{ w1 + w2 + w3 + w4 + w5 + w6 + w7 + w8 }}

Just to answer your question from the HA perspective, the entire Apex is the device.