It took me a while to get to this, but it seems like I need some help.
I added the following to my configuration.yaml
sensor: !include sensors.yaml
template: !include template.yaml
Then I created those files. They look like the following:
- sensor:
- name: Water Projected Bill
state: '{{ state_attr("sensor.aquahawk_water", "billAmount")["projected"]["billing period"]["total"] }}'
unit_of_measurement: "$"
- name: Water Prior Billing Period
state: '{{ state_attr("sensor.aquahawk_water", "waterUse")["prior"]["billing period"]["gallons"] }}'
unit_of_measurement: "gal"
- name: Water Current Billing Period
state: '{{ state_attr("sensor.aquahawk_water", "waterUse")["current"]["billing period"]["gallons"] }}'
unit_of_measurement: "gal"
- name: Water Yesterday
state: '{{ state_attr("sensor.aquahawk_water", "waterUse")["prior"]["1 day"]["gallons"] }}'
unit_of_measurement: "gal"
- name: Water Today
state: '{{ state_attr("sensor.aquahawk_water", "waterUse")["current"]["1 day"]["gallons"] }}'
unit_of_measurement: "gal"
- platform: command_line
name: AquaHawk Water
command: "/config/aqua.sh"
scan_interval: 30 # probably don't ping too frequent to be kind to AquaHawk
unique_id: aquahawk_water_meter
json_attributes:
- waterUse
- billAmount
command_timeout: 30
value_template: '{{ value_json["waterUse"]["prior"]["1 day"]["gallons"] }}'
I also created aqua.sh as instructed and changed my username/password/district.
I am getting the following errors in the logs:
render_info._result = self.async_render(variables, strict=strict, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 411, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'None' has no attribute 'prior'
2022-09-13 12:28:43 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'None' has no attribute 'prior'') while processing template 'Template("{{ state_attr("sensor.aquahawk_water", "waterUse")["prior"]["billing period"]["gallons"] }}")' for attribute '_attr_native_value' in entity 'sensor.water_prior_billing_period'
2022-09-13 12:28:43 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{ state_attr("sensor.aquahawk_water", "waterUse")["current"]["billing period"]["gallons"] }}")
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 409, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1859, in _render_with_context
return template.render(**kwargs)
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1291, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 926, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.9/site-packages/jinja2/sandbox.py", line 303, in getitem
return obj[argument]
jinja2.exceptions.UndefinedError: 'None' has no attribute 'current'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 525, in async_render_to_info
render_info._result = self.async_render(variables, strict=strict, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 411, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'None' has no attribute 'current'
2022-09-13 12:28:43 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'None' has no attribute 'current'') while processing template 'Template("{{ state_attr("sensor.aquahawk_water", "waterUse")["current"]["billing period"]["gallons"] }}")' for attribute '_attr_native_value' in entity 'sensor.water_current_billing_period'
2022-09-13 12:28:43 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{ state_attr("sensor.aquahawk_water", "waterUse")["prior"]["1 day"]["gallons"] }}")
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 409, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1859, in _render_with_context
return template.render(**kwargs)
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1291, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 926, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.9/site-packages/jinja2/sandbox.py", line 303, in getitem
return obj[argument]
jinja2.exceptions.UndefinedError: 'None' has no attribute 'prior'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 525, in async_render_to_info
render_info._result = self.async_render(variables, strict=strict, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 411, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'None' has no attribute 'prior'
2022-09-13 12:28:43 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'None' has no attribute 'prior'') while processing template 'Template("{{ state_attr("sensor.aquahawk_water", "waterUse")["prior"]["1 day"]["gallons"] }}")' for attribute '_attr_native_value' in entity 'sensor.water_yesterday'
2022-09-13 12:28:43 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{ state_attr("sensor.aquahawk_water", "waterUse")["current"]["1 day"]["gallons"] }}")
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 409, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1859, in _render_with_context
return template.render(**kwargs)
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1291, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 926, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.9/site-packages/jinja2/sandbox.py", line 303, in getitem
return obj[argument]
jinja2.exceptions.UndefinedError: 'None' has no attribute 'current'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 525, in async_render_to_info
render_info._result = self.async_render(variables, strict=strict, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 411, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'None' has no attribute 'current'
2022-09-13 12:28:43 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'None' has no attribute 'current'') while processing template 'Template("{{ state_attr("sensor.aquahawk_water", "waterUse")["current"]["1 day"]["gallons"] }}")' for attribute '_attr_native_value' in entity 'sensor.water_today'
2022-09-13 12:28:44 ERROR (SyncWorker_0) [root] Uncaught exception
RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
2022-09-13 12:28:45 WARNING (MainThread) [custom_components.hacs] You have 'maykar/kiosk-mode' installed with HACS this repository has been removed from HACS, please consider removing it. Removal reason (Repository is archived)
2022-09-13 12:28:50 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connection
/bin/sh: /config/aqua.sh: not found
2022-09-13 12:29:07 ERROR (SyncWorker_1) [homeassistant.components.command_line] Command failed: /config/aqua.sh
2022-09-13 12:29:07 WARNING (SyncWorker_1) [homeassistant.components.command_line.sensor] Empty reply found when expecting JSON data
/bin/sh: /config/aqua.sh: not found
2022-09-13 12:29:37 ERROR (SyncWorker_3) [homeassistant.components.command_line] Command failed: /config/aqua.sh
2022-09-13 12:29:37 WARNING (SyncWorker_3) [homeassistant.components.command_line.sensor] Empty reply found when expecting JSON data
/bin/sh: /config/aqua.sh: not found
2022-09-13 12:30:07 ERROR (SyncWorker_0) [homeassistant.components.command_line] Command failed: /config/aqua.sh
2022-09-13 12:30:07 WARNING (SyncWorker_0) [homeassistant.components.command_line.sensor] Empty reply found when expecting JSON data
2022-09-13 12:30:10 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.energy_usage has unit W which is unsupported for device_class energy
/bin/sh: /config/aqua.sh: not found
2022-09-13 12:30:37 ERROR (SyncWorker_5) [homeassistant.components.command_line] Command failed: /config/aqua.sh
2022-09-13 12:30:37 WARNING (SyncWorker_5) [homeassistant.components.command_line.sensor] Empty reply found when expecting JSON data
/bin/sh: /config/aqua.sh: not found
2022-09-13 12:31:07 ERROR (SyncWorker_1) [homeassistant.components.command_line] Command failed: /config/aqua.sh
2022-09-13 12:31:07 WARNING (SyncWorker_1) [homeassistant.components.command_line.sensor] Empty reply found when expecting JSON data
/bin/sh: /config/aqua.sh: not found
2022-09-13 12:31:37 ERROR (SyncWorker_5) [homeassistant.components.command_line] Command failed: /config/aqua.sh
2022-09-13 12:31:37 WARNING (SyncWorker_5) [homeassistant.components.command_line.sensor] Empty reply found when expecting JSON data
Any help would be appreciated!