Skip to content

Commit 0014cf5

Browse files
authoredFeb 11, 2020
Merge pull request #84 from aderusha/dev
HASP v0.39
2 parents 8618c55 + 516aee3 commit 0014cf5

11 files changed

+133
-42
lines changed
 

‎Documentation/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ Utilize the provided Home Assistant automations to control and interact with the
3838

3939
Time to remove the training wheels and learn to send commands to and from the panel via MQTT.
4040

41+
----
42+
43+
## Frequently Asked Questions
44+
45+
* **Can I install HASP outside of North America?** While the various power supply options for the HASP electronics should offer a solution which can handle line voltage in most countries, the physical installation of the device probably won't work outside of North America. There is no international standard for the size and shape of workboxes, so things like screw hole locations and overall mounting dimensions used for the HASP are unlikely to work in any workbox outside of North America.
46+
* **Can I use HASP with \<Some Home Automation System\>**? If your home automation system can send Nextion commands as MQTT payloads, then yes. Getting it all to work is going to take a lot of work, but it's possible.
47+
* **Can I run HASP without a neutral wire?** Like most smart devices, a HASP installation will require a neutral wire available in the box you're mounting into.
48+
49+
----
50+
4151
## HASwitchPlate Architecture
4252

4353
The complete HA SwitchPlate build consists of 4 physical components:

‎Home_Assistant/deployhasp.sh

+42-26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
###############################################################################
3-
# deployhasp.sh - Configure Home Assistnat for HASP integration, then download
3+
# deployhasp.sh - Configure Home Assistant for HASP integration, then download
44
# the latest HASP automation package and modify for the provided device name
55
###############################################################################
66

@@ -68,44 +68,54 @@ then
6868
echo " packages: !include_dir_named packages"
6969
echo "==========================================================================="
7070
else
71-
sed -i 's/^homeassistant:.*/homeassistant:\n packages: !include_dir_named packages/' configuration.yaml
71+
if grep "^homeassistant:" configuration.yaml > /dev/null
72+
then
73+
sed -i 's/^homeassistant:.*/homeassistant:\n packages: !include_dir_named packages/' configuration.yaml
74+
elif grep "^default_config:" configuration.yaml > /dev/null
75+
then
76+
sed -i 's/^default_config:.*/default_config:\nhomeassistant:\n packages: !include_dir_named packages/' configuration.yaml
77+
else
78+
echo "==========================================================================="
79+
echo "WARNING: Could not add package declaration to 'configuration.yaml'."
80+
echo " Please add the following statement to your configuration:"
81+
echo "default_config:"
82+
echo " packages: !include_dir_named packages"
83+
echo "==========================================================================="
84+
fi
7285
fi
7386
fi
7487

7588
# Enable recorder if not enabled to persist relevant values
7689
if ! grep "^recorder:" configuration.yaml > /dev/null
7790
then
7891
echo "recorder:" >> configuration.yaml
92+
echo " include:" >> configuration.yaml
93+
echo " domains:" >> configuration.yaml
94+
echo " - automation" >> configuration.yaml
95+
echo " - binary_sensor" >> configuration.yaml
96+
echo " - input_boolean" >> configuration.yaml
97+
echo " - input_number" >> configuration.yaml
98+
echo " - input_select" >> configuration.yaml
99+
echo " - input_datetime" >> configuration.yaml
100+
echo " - input_text" >> configuration.yaml
101+
echo " - weather" >> configuration.yaml
79102
fi
80103

81104
# Warn if MQTT is not enabled
82105
if ! grep "^mqtt:" configuration.yaml > /dev/null
83106
then
84-
echo "==========================================================================="
85-
echo "WARNING: Required MQTT broker configuration not setup in configuration.yaml"
86-
echo "HASP WILL NOT FUNCTION UNTIL THIS HAS BEEN CONFIGURED! The embedded option"
87-
echo "offered my Home Assistant is buggy, so deploying Mosquitto is recommended."
88-
echo ""
89-
echo "Home Assistant MQTT configuration: https://www.home-assistant.io/docs/mqtt/broker/#run-your-own"
90-
echo "Install Mosquitto: sudo apt-get install mosquitto mosquitto-clients"
91-
echo "==========================================================================="
92-
fi
93-
94-
# Hass has a bug where packaged automations don't work unless you have at least one
95-
# automation manually created outside of the packages. Attempt to test for that and
96-
# create a dummy automation if an empty automations.yaml file is found.
97-
if grep "^automation: \!include automations.yaml" configuration.yaml > /dev/null
98-
then
99-
if [ -f automations.yaml ]
107+
if ! grep '"domain": "mqtt"' .storage/core.config_entries > /dev/null
100108
then
101-
if [[ $(< automations.yaml) == "[]" ]]
102-
then
103-
echo "WARNING: empty automations.yaml found, creating DUMMY automation for package compatibility"
104-
echo "- action: []" > automations.yaml
105-
echo " id: DUMMY" >> automations.yaml
106-
echo " alias: DUMMY Can Be Deleted After First Automation Has Been Added" >> automations.yaml
107-
echo " trigger: []" >> automations.yaml
108-
fi
109+
echo "==========================================================================="
110+
echo "WARNING: Required MQTT broker configuration not setup in configuration.yaml"
111+
echo " or added under Configuration > Integrations."
112+
echo ""
113+
echo "HASP WILL NOT FUNCTION UNTIL THIS HAS BEEN CONFIGURED! The embedded option"
114+
echo "offered my Home Assistant is buggy, so deploying Mosquitto is recommended."
115+
echo ""
116+
echo "Home Assistant MQTT configuration: https://www.home-assistant.io/docs/mqtt/broker/#run-your-own"
117+
echo "Install Mosquitto: sudo apt-get install mosquitto mosquitto-clients"
118+
echo "==========================================================================="
109119
fi
110120
fi
111121

@@ -123,6 +133,7 @@ then
123133
# rename text in contents of files
124134
sed -i -- 's/plate01/'"$hasp_device"'/g' $hasp_temp_dir/packages/plate01/hasp_plate01_*.yaml
125135
sed -i -- 's/plate01/'"$hasp_device"'/g' $hasp_temp_dir/hasp-examples/plate01/hasp_plate01_*.yaml
136+
sed -i -- 's/plate01/'"$hasp_device"'/g' $hasp_temp_dir/packages/hasp_plate01_lovelace.txt
126137

127138
# rename files and folder - thanks to @cloggedDrain for this loop!
128139
mkdir $hasp_temp_dir/packages/$hasp_device
@@ -156,6 +167,8 @@ then
156167
fi
157168
done
158169
rm -rf $hasp_temp_dir/hasp-examples/plate01
170+
# rename the lovelace UI file
171+
mv $hasp_temp_dir/packages/hasp_plate01_lovelace.txt $hasp_temp_dir/packages/hasp_${hasp_device}_lovelace.txt
159172
fi
160173

161174
# Check to see if the target directories already exist
@@ -193,3 +206,6 @@ fi
193206

194207
echo "==========================================================================="
195208
echo "SUCCESS! Restart Home Assistant to enable HASP device $hasp_device"
209+
echo "Check the file packages/hasp_${hasp_device}_lovelace.txt for a set of"
210+
echo "basic Lovelace UI elements you can include in your configuration to manage"
211+
echo "the new device."

‎Home_Assistant/hasp-examples/plate01/hasp_plate01_00_autofirmwareupdate.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ automation:
1515
- service: mqtt.publish
1616
data_template:
1717
topic: 'hasp/plate01/command/espupdate'
18-
payload: ''
18+
payload: ''

‎Home_Assistant/hasp-examples/plate01/hasp_plate01_00_backlightbysun.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ automation:
88
trigger:
99
- platform: time_pattern
1010
# Matches every minute
11-
seconds: 00
11+
seconds: 0
1212
condition:
1313
- condition: template
1414
value_template: '{{ states.sun.sun.attributes.elevation <= 10 }}'

‎Home_Assistant/hasppackages.tar.gz

696 Bytes
Binary file not shown.

‎Home_Assistant/migrate-hasp-107.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
###############################################################################
3+
# migrate-hasp-107.sh - Modify an existing Home Assistant configuration
4+
# with HASP deployed to accomodate breaking changes in v107
5+
###############################################################################
6+
7+
# Confirm that we're working in the .homeassistant folder by checking for configuration.yaml
8+
if [ ! -f configuration.yaml ]
9+
then
10+
echo "WARNING: 'configuration.yaml' not found in current directory."
11+
echo "Searching for Home Assistant 'configuration.yaml'..."
12+
configfile=$(find / -name configuration.yaml 2>/dev/null)
13+
count=$(echo "$configfile" | wc -l)
14+
if [ $count == 1 ]
15+
then
16+
configdir=$(dirname "${configfile}")
17+
cd $configdir
18+
echo "INFO: configuration.yaml found under: $configdir"
19+
else
20+
echo "ERROR: Failed to locate the active 'configuration.yaml'"
21+
echo " Please run this script from the homeassistant"
22+
echo " configuration folder for your environment."
23+
exit 1
24+
fi
25+
fi
26+
27+
# If the user has already deployed HASP devices...
28+
if [ -d packages ]
29+
then
30+
# Search through existing packages to see if we have any "view:" statements to remove as they have been deprecated
31+
find packages -name "hasp_*.yaml" -exec sed -i '/[[:blank:]]view\:/d' {} +
32+
fi

‎Home_Assistant/packages/hasp_demo.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
# these and/or replace with your own devices
44

55
weather:
6-
- platform: met
6+
- platform: nws
7+
api_key: haspuser@haswitchplate.com
8+
name: nws
79

810
alarm_control_panel:
911
- platform: manual
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
- path: plate01
2+
title: plate01
3+
badges:
4+
- entity: binary_sensor.plate01_connected
5+
- entity: sensor.plate01_status
6+
cards:
7+
- type: entities
8+
title: plate01 Page Selection
9+
entities:
10+
- input_number.hasp_plate01_activepage
11+
- input_number.hasp_plate01_pagebutton1page
12+
- input_text.hasp_plate01_pagebutton1label
13+
- input_number.hasp_plate01_pagebutton2page
14+
- input_text.hasp_plate01_pagebutton2label
15+
- input_number.hasp_plate01_pagebutton3page
16+
- input_text.hasp_plate01_pagebutton3label
17+
- type: entities
18+
title: plate01 Colors
19+
entities:
20+
- input_number.hasp_plate01_selectedforegroundcolor
21+
- input_number.hasp_plate01_selectedbackgroundcolor
22+
- input_number.hasp_plate01_unselectedforegroundcolor
23+
- input_number.hasp_plate01_unselectedbackgroundcolor
24+
- type: entities
25+
title: plate01 automations
26+
entities:
27+
- automation.hasp_plate01_00_firsttimesetup
28+
- type: entities
29+
title: Light
30+
entities:
31+
- light.plate01_backlight

‎Home_Assistant/packages/plate01/hasp_plate01_00_components.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -67,52 +67,52 @@ input_text:
6767
input_number:
6868
hasp_plate01_pagebutton1page:
6969
name: plate01 Page 1 Page
70-
icon: mdi:format-list-numbered
70+
icon: mdi:numeric
7171
min: 0
7272
max: 9
7373
step: 1
7474
hasp_plate01_pagebutton2page:
7575
name: plate01 Page 2 Page
76-
icon: mdi:format-list-numbered
76+
icon: mdi:numeric
7777
min: 0
7878
max: 9
7979
step: 1
8080
hasp_plate01_pagebutton3page:
8181
name: plate01 Page 3 Page
82-
icon: mdi:format-list-numbered
82+
icon: mdi:numeric
8383
min: 0
8484
max: 9
8585
step: 1
8686
hasp_plate01_activepage:
8787
name: plate01 Active Page
88-
icon: mdi:format-list-numbered
88+
icon: mdi:numeric
8989
min: 0
9090
max: 9
9191
step: 1
9292
hasp_plate01_alarmcode1:
9393
name: plate01 AlarmCode1
94-
icon: mdi:format-list-numbered
94+
icon: mdi:numeric
9595
min: -1
9696
max: 9
9797
step: 1
9898
initial: -1
9999
hasp_plate01_alarmcode2:
100100
name: plate01 AlarmCode2
101-
icon: mdi:format-list-numbered
101+
icon: mdi:numeric
102102
min: -1
103103
max: 9
104104
step: 1
105105
initial: -1
106106
hasp_plate01_alarmcode3:
107107
name: plate01 AlarmCode3
108-
icon: mdi:format-list-numbered
108+
icon: mdi:numeric
109109
min: -1
110110
max: 9
111111
step: 1
112112
initial: -1
113113
hasp_plate01_alarmcode4:
114114
name: plate01 AlarmCode4
115-
icon: mdi:format-list-numbered
115+
icon: mdi:numeric
116116
min: -1
117117
max: 9
118118
step: 1

‎Home_Assistant/packages/plate01/hasp_plate01_p2_clock.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ automation:
3333
trigger:
3434
platform: time_pattern
3535
# Matches every minute
36-
seconds: 00
36+
seconds: 0
3737
condition:
3838
- condition: state
3939
entity_id: 'binary_sensor.plate01_connected'

‎Home_Assistant/packages/plate01/hasp_plate01_p2_weather.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ automation:
66
- alias: hasp_plate01_p2_Weather
77
trigger:
88
- platform: state
9-
entity_id: weather.met_no
9+
entity_id: weather.nws
1010
- platform: state
1111
entity_id: 'binary_sensor.plate01_connected'
1212
- platform: homeassistant
@@ -23,12 +23,12 @@ automation:
2323
- service: mqtt.publish
2424
data:
2525
topic: 'hasp/plate01/command/p[2].b[6].txt'
26-
payload_template: '"{{state_attr("weather.met_no","temperature")|int}}°F"'
26+
payload_template: '"{{state_attr("weather.nws","temperature")|int}}°F"'
2727
- service: mqtt.publish
2828
data:
2929
topic: 'hasp/plate01/command/p[2].b[7].font'
30-
payload_template: '{% if states.weather.met_no.state|length <= 6 -%}3{% elif (states.weather.met_no.state|length > 6) and (states.weather.met_no.state|length <= 10) %}2{% elif (states.weather.met_no.state|length > 10) and (states.weather.met_no.state|length <= 15) %}1{% else %}0{%- endif %}'
30+
payload_template: '{% if states.weather.nws.state|length <= 6 -%}3{% elif (states.weather.nws.state|length > 6) and (states.weather.nws.state|length <= 10) %}2{% elif (states.weather.nws.state|length > 10) and (states.weather.nws.state|length <= 15) %}1{% else %}0{%- endif %}'
3131
- service: mqtt.publish
3232
data:
3333
topic: 'hasp/plate01/command/p[2].b[7].txt'
34-
payload_template: '"{{states.weather.met_no.state|wordwrap(20, wrapstring="\\r")|title}}"'
34+
payload_template: '"{{states.weather.nws.state|wordwrap(20, wrapstring="\\r")|title}}"'

0 commit comments

Comments
 (0)