Skip to content

Instantly share code, notes, and snippets.

@georgeh
Last active May 22, 2022 02:07
Show Gist options
  • Save georgeh/0c4d27f30c2c04cbbc81f9d193f6cfc8 to your computer and use it in GitHub Desktop.
Save georgeh/0c4d27f30c2c04cbbc81f9d193f6cfc8 to your computer and use it in GitHub Desktop.
DTE Insight Home Assistant configuration
sensor:
# Read in DTE Insight via MQTT. You can add an MQTT integration in Home Assistant with the DTE Insight's IP address on port 2883
- platform: mqtt # this is my DTE Insight, if you have multiple MQTT servers this might be different
name: Instant Energy Usage
state_topic: "event/metering/instantaneous_demand"
unit_of_measurement: W
value_template: "{{ value_json.demand }}"
state_class: measurement
device_class: energy
# These convert the template sensors below from Watts to Kilowatt-hours using the power of calculus
- platform: integration
source: sensor.grid_electric_usage
name: DTE Energy Usage
unit_prefix: k
- platform: integration
source: sensor.grid_electric_return
name: DTE Energy Return
unit_prefix: k
template:
- sensor:
# Calculate the household electric usage by adding the DTE Insight measurement with the solar measurement
- name: "Grid Electric Usage"
unit_of_measurement: W
state_class: measurement
device_class: power
state: >
{% set dte_watts = states('sensor.instant_energy_usage' ) | int %}
{% set solar_watts = states('sensor.envoy_202119015431_current_power_production' ) | int %}
{{ dte_watts + solar_watts }}
# Calculate the electricity that is returned to the grid by only using the DTE Insight value when it is negative
- name: "Grid Electric Return"
unit_of_measurement: W
state_class: measurement
device_class: power
state: >
{% set dte_watts = states('sensor.instant_energy_usage' ) | int %}
{% if dte_watts < 0 %}
{{ 0 - dte_watts }}
{% else %}
0
{% endif %}
@georgeh
Copy link
Author

georgeh commented May 10, 2022

@bdimcheff Try that out and let me know how it goes. I'm starting to doubt my numbers after comparing them to my bill

@bdimcheff
Copy link

@georgeh have you made entities that return the current rate for DTE import/export for the energy dashboard to do pricing stuff?

@georgeh
Copy link
Author

georgeh commented May 17, 2022

No, I'm on a fixed plan right now. If I move to D1.2 I'll probably just use an Automation to switch the value at 11am and 7pm.

@bdimcheff
Copy link

well I have this if you need it at some point:

  - sensor:
    - name: "DTE Rate"
      state: >
        {% set season = "summer" if now().month >= 6 or now().month <= 1 else "winter" %}
        {% set weekday = now().weekday() < 5 %}
        {% set rate = "peak" if now().hour >= 11 and now().hour < 19 and weekday else "offpeak" %}
        
        {{ season }}_{{rate}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment