allangood / rtlamr2mqtt

Docker container to send rtlamr readings to a mqtt broker
MIT License
326 stars 51 forks source link

Allow Meter ID to be stored in secrets.yaml #178

Open ayourk opened 1 year ago

ayourk commented 1 year ago

It would be great to be able to do something like the following in secrets,yaml and then use that in the config to hide the meter IDs in the main config.

--- secrets.yaml --- meter_elec: 10528282 meter_gas: 52212210 meter_water: 3223125100


The numbers above are random numbers I created in the moment and are not reflective of an exact meter ID; they are used as examples only.

- id: !secret meter_elec 
  protocol: scm
  name: meter_electricity
  format: "#####.##"
  unit_of_measurement: kWh
  icon: mdi:lightning-bolt
  device_class: energy
  state_class: total_increasing
  filters:
    - multiply: 0.01
- id: !secret meter_gas
  protocol: scm
  name: meter_gas
  format: "####.###"
  unit_of_measurement: ft³
  icon: mdi:gas-meter
  device_class: gas
  state_class: total_increasing
  filters:
    - multiply: 0.001
- id: !secret meter_water
  protocol: r900
  name: meter_water
  format: "#######.#"
  unit_of_measurement: gal
  icon: mdi:water
  device_class: water
  state_class: total_increasing
  filters:
    - multiply: 0.1

Please note: If you want to add Gas or Water to the Energy Dashboard, you MUST change the units to m³. Once added to the energy dashboard, the units can be changed back.

onedr0p commented 9 months ago

Another improvement to this would to also be able to support injecting env like home assistant supports. e.g.

- id: !env_var METER_ID
  protocol: r900
  name: meter_water
  format: "#######.#"
  unit_of_measurement: gal
  icon: mdi:water
  device_class: water
  state_class: total_increasing
  filters:
    - multiply: 0.1
PrplHaz4 commented 9 months ago

Either of these methods for pulling Meter IDs out of the primary config would work for me.

Please note: If you want to add Gas or Water to the Energy Dashboard, you MUST change the units to m³. Once added to the energy dashboard, the units can be changed back.

Can you elaborate on this one? I've been wondering why my water units aren't showing up in the Energy Dashboard - they are currently in ft³. Something like this?

  1. Change the units to m³ in rtlamr2mqtt, restart rtlamr2mqtt
  2. Restart homeassistant, see them on the dashboard
  3. Reset units back to ft³ in rtlamr2mqtt, restart rtlamr2mqtt
  4. Restart homeassistant, see them on the dashboard
ayourk commented 9 months ago

Here is a link to the start of the conversation where I started getting the Gas section nailed down in the Home Assistant Discord, #energy channel: https://discord.com/channels/330944238910963714/872496321574088765/1041881869958004837