Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aneisch committed Sep 23, 2023
1 parent f04c0c7 commit 6e98ad8
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 70 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ Also using Grafana/Influx for graphing, both running in Docker containers on NUC
Description | value
-- | --
Lines of ESPHome YAML | 2467
Lines of Home Assistant YAML | 7942
Lines of Home Assistant YAML | 7953
[Integrations](https://www.home-assistant.io/integrations/) in use | 52
Zigbee devices in [`zha`](https://www.home-assistant.io/integrations/zha/) | 26
Z-Wave devices in [`zwave_js`](https://www.home-assistant.io/integrations/zwave_js/) | 37

Description | value
-- | --
Entities in the [`alarm_control_panel`](https://www.home-assistant.io/components/alarm_control_panel) domain | 1
Entities in the [`automation`](https://www.home-assistant.io/components/automation) domain | 102
Entities in the [`binary_sensor`](https://www.home-assistant.io/components/binary_sensor) domain | 128
Entities in the [`automation`](https://www.home-assistant.io/components/automation) domain | 104
Entities in the [`binary_sensor`](https://www.home-assistant.io/components/binary_sensor) domain | 131
Entities in the [`button`](https://www.home-assistant.io/components/button) domain | 12
Entities in the [`calendar`](https://www.home-assistant.io/components/calendar) domain | 1
Entities in the [`camera`](https://www.home-assistant.io/components/camera) domain | 18
Expand All @@ -79,8 +79,8 @@ Entities in the [`input_boolean`](https://www.home-assistant.io/components/input
Entities in the [`input_datetime`](https://www.home-assistant.io/components/input_datetime) domain | 34
Entities in the [`input_number`](https://www.home-assistant.io/components/input_number) domain | 4
Entities in the [`input_select`](https://www.home-assistant.io/components/input_select) domain | 19
Entities in the [`input_text`](https://www.home-assistant.io/components/input_text) domain | 7
Entities in the [`light`](https://www.home-assistant.io/components/light) domain | 37
Entities in the [`input_text`](https://www.home-assistant.io/components/input_text) domain | 8
Entities in the [`light`](https://www.home-assistant.io/components/light) domain | 38
Entities in the [`lock`](https://www.home-assistant.io/components/lock) domain | 3
Entities in the [`media_player`](https://www.home-assistant.io/components/media_player) domain | 12
Entities in the [`number`](https://www.home-assistant.io/components/number) domain | 5
Expand All @@ -90,7 +90,7 @@ Entities in the [`remote`](https://www.home-assistant.io/components/remote) doma
Entities in the [`scene`](https://www.home-assistant.io/components/scene) domain | 2
Entities in the [`script`](https://www.home-assistant.io/components/script) domain | 39
Entities in the [`select`](https://www.home-assistant.io/components/select) domain | 2
Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 376
Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 379
Entities in the [`siren`](https://www.home-assistant.io/components/siren) domain | 1
Entities in the [`sun`](https://www.home-assistant.io/components/sun) domain | 1
Entities in the [`switch`](https://www.home-assistant.io/components/switch) domain | 152
Expand All @@ -100,7 +100,7 @@ Entities in the [`update`](https://www.home-assistant.io/components/update) doma
Entities in the [`vacuum`](https://www.home-assistant.io/components/vacuum) domain | 1
Entities in the [`weather`](https://www.home-assistant.io/components/weather) domain | 2
Entities in the [`zone`](https://www.home-assistant.io/components/zone) domain | 6
**Total state objects** | **1031**
**Total state objects** | **1041**
## The HACS integrations/plugins that I use:
**Appdaemon**:<br>
[aneisch/follow_me_appdaemon](https://github.com/aneisch/follow_me_appdaemon)<br>
Expand Down
37 changes: 33 additions & 4 deletions automations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@
- service: homeassistant.turn_on
entity_id: switch.docker_watchtower


- alias: "Update Water Utilities"
id: "update_water_utilities"
trigger:
Expand All @@ -647,9 +648,40 @@
then:
- service: python_script.utility_meter_reset
data:
meter_entity: sensor.electric_usage
meter_entity: sensor.electricity_usage
cycle_reset_entity_id: sensor.electric_utilities_summary

- alias: "Update Utility Costs"
id: "update_utility_costs"
mode: single
trigger:
- platform: time_pattern
hours: "/1"
action:
- service: python_script.add_elecrtric_cost_attribute
data:
entity_id: sensor.electricity_usage
- service: python_script.add_water_cost_attribute
data:
meter_entity: sensor.water_usage

- alias: "Reset Utility Meters"
id: "reset_utility_meters"
trigger:
- platform: time
id: midnight
at: "00:00:00"
action:
- service: python_script.utility_meter_reset
data:
meter_entity: sensor.water_usage
cycle_reset_entity_id: sensor.electric_utilities_summary
- service: python_script.utility_meter_reset
data:
meter_entity: sensor.electricity_usage
cycle_reset_entity_id: sensor.electric_utilities_summary

# Legacy, remove later
- alias: "Update Electric Utilities Cost"
id: "update_electric_utilities_cost"
mode: parallel
Expand All @@ -667,9 +699,6 @@
- service: python_script.add_elecrtric_cost_attribute
data:
entity_id: sensor.electric_utilities_daily
- service: python_script.add_elecrtric_cost_attribute
data:
entity_id: sensor.electricity_usage

- alias: "Update USPS Mail Camera Path on Hass Restart"
id: "usps_mail_path_update"
Expand Down
2 changes: 1 addition & 1 deletion extras/Node-RED/flows.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions extras/appdaemon/apps/apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@ Backyard Flood Lights with Person Detection:
# Seconds to turn entity on when triggered
time_on: "30"

Doorbell Ring Light:
module: entity_timer
class: Timer
entities: light.front_door_ring_light
time_on: sunrise - 00:30:00
# Off is handled by NodeRed with Porch Lights

Office Light at Night With Door:
module: door_open
class: DoorLight
Expand Down
1 change: 1 addition & 0 deletions extras/docker-compose/other/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ services:
- "127.0.0.1:1984:1984"
environment:
- PLUS_API_KEY=secret
- TZ=America/Chicago
codeproject:
container_name: codeproject
restart: 'always'
Expand Down
1 change: 1 addition & 0 deletions extras/docker-compose/unified/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ services:
- "127.0.0.1:1984:1984"
environment:
- PLUS_API_KEY=secret
- TZ=America/Chicago
codeproject:
container_name: codeproject
restart: 'always'
Expand Down
Binary file modified images/nodered_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/nodered_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions input_text.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ electricity_cost_monthly_emporia:

water_cost_monthly:
name: "Water Cost"

sewer_cost_monthly:
name: "Sewer Cost"
34 changes: 18 additions & 16 deletions packages/frigate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,25 @@ automation:
topic: frigate/events
payload: end
value_template: "{{ value_json.type }}"
condition: "{{ 'usps' in trigger.payload_json['after']['sub_label'] }}" # Frigate 13 beta
condition: "{{ trigger.payload_json['after']['sub_label'] != 'Undefined' }}"
action:
- service: input_datetime.set_datetime
data:
entity_id: "input_datetime.usps_last"
time: "{{ ((as_timestamp(now())) | timestamp_custom('%H:%M:%S', true)) }}"
date: "{{ (as_timestamp(now()) | timestamp_custom('%Y-%m-%d', true)) }}"
- service: notify.signal_self
data:
message: "USPS detected"
data:
attachments:
- /config/images/logo.jpg
# No need for container to run after detection made, appdaemon will turn on in the morning
# - service: switch.turn_off
# entity_id: switch.docker_codeproject
- delay: "00:02:00"
- if: "{{ 'usps' in trigger.payload_json['after']['sub_label'] }}"
then:
- service: input_datetime.set_datetime
data:
entity_id: "input_datetime.usps_last"
time: "{{ ((as_timestamp(now())) | timestamp_custom('%H:%M:%S', true)) }}"
date: "{{ (as_timestamp(now()) | timestamp_custom('%Y-%m-%d', true)) }}"
- service: notify.signal_self
data:
message: "USPS detected"
data:
attachments:
- /config/images/logo.jpg
# No need for container to run after detection made, appdaemon will turn on in the morning
# - service: switch.turn_off
# entity_id: switch.docker_codeproject
- delay: "00:02:00"

- alias: Doorbell Ring
id: "frigate_doorbell_ring"
Expand Down
6 changes: 3 additions & 3 deletions python_scripts/add_elecrtric_cost_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Utilities API fed sensor
if inputEntity == 'sensor.electric_utilities_summary':
# Add $7 monthly charge to summary total
inputAttributesObject['cost'] = '{:.2f}'.format(7 + (float(inputState) * current_cost))
inputAttributesObject['cost'] = round(7 + (float(inputState) * current_cost), 2)

# Set custom sensor for tracking
# service_data = {"entity_id": "sensor.electricity_cost_monthly", "state": inputAttributesObject['cost'], "attributes": {"friendly_name": "Utilities Cost", "unit_of_measurement": "$", "icon":"mdi:currency-usd"}}
Expand All @@ -36,12 +36,12 @@
# Emporia vue fed sensor
elif inputEntity == 'sensor.electricity_usage':
# Add $7 monthly charge to summary total
inputAttributesObject['cost'] = '{:.2f}'.format(7 + ((float(inputState)) * current_cost))
inputAttributesObject['cost'] = round(7 + ((float(inputState)) * current_cost), 2)
service_data = {"entity_id": "input_text.electricity_cost_monthly_emporia", "value": inputAttributesObject['cost']}
hass.services.call("input_text", "set_value", service_data)

else:
inputAttributesObject['cost'] = '{:.2f}'.format((float(inputState) * current_cost))
inputAttributesObject['cost'] = round((float(inputState) * current_cost), 2)

#hass.bus.fire("debug", {"wow": ""})

Expand Down
66 changes: 51 additions & 15 deletions python_scripts/add_water_cost_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,60 @@
inputState = inputStateObject.state
inputAttributesObject = inputStateObject.attributes.copy()

usage = inputState
usage = 5000
unaccountedusage = int(float(inputState))
computed_water_cost = 12.40 # meter charge
computed_sewer_cost = 21.29 # base sewer up 4k gallons water usage

# 0 < usage < 10,000 = 2.40/1000gal
# 11,000 < usage < 15,000 = 3.12/1000gal
# 16,000 < usage < 20,000 = 3.83/1000gal
computed_cost = 0
# Sewer based on water consumption
tier2sewer = 4.26

if usage <= 11000:
computed_cost = (usage / 1000) * 2.40
if unaccountedusage >= 10000:
computed_sewer_cost = 46.87
elif unaccountedusage <= 4000:
pass
else:
tier2sewerusage = min(6000, unaccountedusage - 4000)
computed_sewer_cost = computed_sewer_cost + (tier2sewerusage / 1000) * tier2sewer

debug = computed_cost
# Water consumption
tier1rate = 2.75
tier2rate = 3.60
tier3rate = 4.40
tier4rate = 5.20
tier5rate = 6.05

# Add $10.80 monthly meter charge to summary total
inputAttributesObject['cost'] = '{:.2f}'.format(10.80 + computed_cost)
tier1usage = min(10000, unaccountedusage)
unaccountedusage = unaccountedusage - tier1usage

hass.bus.fire("debug", {"debug": debug, "result": '{:.2f}'.format(10.80 + computed_cost)})
tier2usage = min(5000, unaccountedusage)
unaccountedusage = unaccountedusage - tier2usage

# hass.states.set(MeterEntity, inputState, inputAttributesObject)
# service_data = {"entity_id": "input_text.water_cost_monthly", "value": inputAttributesObject['cost']}
# hass.services.call("input_text", "set_value", service_data)
tier3usage = min(5000, unaccountedusage)
unaccountedusage = unaccountedusage - tier3usage

tier4usage = min(5000, unaccountedusage)
unaccountedusage = unaccountedusage - tier4usage

tier5usage = unaccountedusage

computed_water_cost = computed_water_cost \
+ (tier1usage / 1000) * tier1rate \
+ (tier2usage / 1000) * tier2rate \
+ (tier3usage / 1000) * tier3rate \
+ (tier4usage / 1000) * tier4rate \
+ (tier5usage / 1000) * tier5rate


# Add water and sewer
computed_water_cost = round(computed_water_cost, 2)
computed_sewer_cost = round(computed_sewer_cost, 2)

# Set states
inputAttributesObject['cost'] = computed_water_cost
hass.states.set(MeterEntity, inputState, inputAttributesObject)

service_data = {"entity_id": "input_text.water_cost_monthly", "value": computed_water_cost}
hass.services.call("input_text", "set_value", service_data)

service_data = {"entity_id": "input_text.sewer_cost_monthly", "value": computed_sewer_cost}
hass.services.call("input_text", "set_value", service_data)
23 changes: 0 additions & 23 deletions sensors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,6 @@
monitored_gateway_interfaces:
- wan

# - platform: command_line
# name: Electric Utilities Daily
# scan_interval: 3600
# command: !secret utilities_curl_daily
# value_template: "{{ value_json.Kwh | float }}"
# unit_of_measurement: "kWh"
# json_attributes:
# - ReadDate

# - platform: command_line
# name: Electric Utilities Summary
# scan_interval: 3600
# command: !secret utilities_curl_summary
# value_template: "{{ value_json.TotalUsage | float }}"
# unit_of_measurement: "kWh"
# json_attributes:
# - TotalCost
# - MinUsage
# - MaxUsage
# - AvgUsage
# - StartDate
# - EndDate

- platform: history_stats
name: ac_runtime_today_cool
entity_id: sensor.thermostat_state
Expand Down
1 change: 1 addition & 0 deletions ui-lovelace/02-heads_up.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cards:
- entity_id: "group.under_cabinet_lights"
state: "on"
exclude:
- entity_id: light.front_door_ring_light
- entity_id: light.plant_light_corner
- entity_id: switch.nfc_reader
- entity_id: switch.sonoff_usb_1
Expand Down
6 changes: 5 additions & 1 deletion ui-lovelace/05-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,17 @@ cards:
hours_to_show: 730
icon: mdi:flash
- type: markdown
# Monthly Electric Cost: ${{ states('input_text.electricity_cost_monthly') }}
content: >
Monthly Electric Cost: ${{ states('input_text.electricity_cost_monthly') }}
Monthly Electric Cost Emporia: ${{ states('input_text.electricity_cost_monthly_emporia') }}
Monthly Water Cost: ${{ states('input_text.water_cost_monthly') }}
Monthly Sewer Cost: ${{ states('input_text.sewer_cost_monthly') }}
Monthly Water + Sewer + Electric: ${{ ((states('input_text.water_cost_monthly') | float) + (states('input_text.sewer_cost_monthly') | float) + (states('input_text.electricity_cost_monthly_emporia') | float)) | round(2) }}
Cycle Ends: {{ state_attr('sensor.electric_utilities_summary', 'EndDate')[4:-6] }}
- type: entities
Expand Down

0 comments on commit 6e98ad8

Please sign in to comment.