diff --git a/Documentation/README.md b/Documentation/README.md index 9ef436a..4c9e0fb 100644 --- a/Documentation/README.md +++ b/Documentation/README.md @@ -38,6 +38,16 @@ Utilize the provided Home Assistant automations to control and interact with the Time to remove the training wheels and learn to send commands to and from the panel via MQTT. +---- + +## Frequently Asked Questions + +* **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. +* **Can I use HASP with \**? 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. +* **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. + +---- + ## HASwitchPlate Architecture The complete HA SwitchPlate build consists of 4 physical components: diff --git a/Home_Assistant/deployhasp.sh b/Home_Assistant/deployhasp.sh index 7f8303e..23a747f 100644 --- a/Home_Assistant/deployhasp.sh +++ b/Home_Assistant/deployhasp.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash ############################################################################### -# deployhasp.sh - Configure Home Assistnat for HASP integration, then download +# deployhasp.sh - Configure Home Assistant for HASP integration, then download # the latest HASP automation package and modify for the provided device name ############################################################################### @@ -68,7 +68,20 @@ then echo " packages: !include_dir_named packages" echo "===========================================================================" else - sed -i 's/^homeassistant:.*/homeassistant:\n packages: !include_dir_named packages/' configuration.yaml + if grep "^homeassistant:" configuration.yaml > /dev/null + then + sed -i 's/^homeassistant:.*/homeassistant:\n packages: !include_dir_named packages/' configuration.yaml + elif grep "^default_config:" configuration.yaml > /dev/null + then + sed -i 's/^default_config:.*/default_config:\nhomeassistant:\n packages: !include_dir_named packages/' configuration.yaml + else + echo "===========================================================================" + echo "WARNING: Could not add package declaration to 'configuration.yaml'." + echo " Please add the following statement to your configuration:" + echo "default_config:" + echo " packages: !include_dir_named packages" + echo "===========================================================================" + fi fi fi @@ -76,36 +89,33 @@ fi if ! grep "^recorder:" configuration.yaml > /dev/null then echo "recorder:" >> configuration.yaml + echo " include:" >> configuration.yaml + echo " domains:" >> configuration.yaml + echo " - automation" >> configuration.yaml + echo " - binary_sensor" >> configuration.yaml + echo " - input_boolean" >> configuration.yaml + echo " - input_number" >> configuration.yaml + echo " - input_select" >> configuration.yaml + echo " - input_datetime" >> configuration.yaml + echo " - input_text" >> configuration.yaml + echo " - weather" >> configuration.yaml fi # Warn if MQTT is not enabled if ! grep "^mqtt:" configuration.yaml > /dev/null then - echo "===========================================================================" - echo "WARNING: Required MQTT broker configuration not setup in configuration.yaml" - echo "HASP WILL NOT FUNCTION UNTIL THIS HAS BEEN CONFIGURED! The embedded option" - echo "offered my Home Assistant is buggy, so deploying Mosquitto is recommended." - echo "" - echo "Home Assistant MQTT configuration: https://www.home-assistant.io/docs/mqtt/broker/#run-your-own" - echo "Install Mosquitto: sudo apt-get install mosquitto mosquitto-clients" - echo "===========================================================================" -fi - -# Hass has a bug where packaged automations don't work unless you have at least one -# automation manually created outside of the packages. Attempt to test for that and -# create a dummy automation if an empty automations.yaml file is found. -if grep "^automation: \!include automations.yaml" configuration.yaml > /dev/null -then - if [ -f automations.yaml ] + if ! grep '"domain": "mqtt"' .storage/core.config_entries > /dev/null then - if [[ $(< automations.yaml) == "[]" ]] - then - echo "WARNING: empty automations.yaml found, creating DUMMY automation for package compatibility" - echo "- action: []" > automations.yaml - echo " id: DUMMY" >> automations.yaml - echo " alias: DUMMY Can Be Deleted After First Automation Has Been Added" >> automations.yaml - echo " trigger: []" >> automations.yaml - fi + echo "===========================================================================" + echo "WARNING: Required MQTT broker configuration not setup in configuration.yaml" + echo " or added under Configuration > Integrations." + echo "" + echo "HASP WILL NOT FUNCTION UNTIL THIS HAS BEEN CONFIGURED! The embedded option" + echo "offered my Home Assistant is buggy, so deploying Mosquitto is recommended." + echo "" + echo "Home Assistant MQTT configuration: https://www.home-assistant.io/docs/mqtt/broker/#run-your-own" + echo "Install Mosquitto: sudo apt-get install mosquitto mosquitto-clients" + echo "===========================================================================" fi fi @@ -123,6 +133,7 @@ then # rename text in contents of files sed -i -- 's/plate01/'"$hasp_device"'/g' $hasp_temp_dir/packages/plate01/hasp_plate01_*.yaml sed -i -- 's/plate01/'"$hasp_device"'/g' $hasp_temp_dir/hasp-examples/plate01/hasp_plate01_*.yaml + sed -i -- 's/plate01/'"$hasp_device"'/g' $hasp_temp_dir/packages/hasp_plate01_lovelace.txt # rename files and folder - thanks to @cloggedDrain for this loop! mkdir $hasp_temp_dir/packages/$hasp_device @@ -156,6 +167,8 @@ then fi done rm -rf $hasp_temp_dir/hasp-examples/plate01 + # rename the lovelace UI file + mv $hasp_temp_dir/packages/hasp_plate01_lovelace.txt $hasp_temp_dir/packages/hasp_${hasp_device}_lovelace.txt fi # Check to see if the target directories already exist @@ -193,3 +206,6 @@ fi echo "===========================================================================" echo "SUCCESS! Restart Home Assistant to enable HASP device $hasp_device" +echo "Check the file packages/hasp_${hasp_device}_lovelace.txt for a set of" +echo "basic Lovelace UI elements you can include in your configuration to manage" +echo "the new device." diff --git a/Home_Assistant/hasp-examples/plate01/hasp_plate01_00_autofirmwareupdate.yaml b/Home_Assistant/hasp-examples/plate01/hasp_plate01_00_autofirmwareupdate.yaml index 5a7ca7b..0f4cf9d 100644 --- a/Home_Assistant/hasp-examples/plate01/hasp_plate01_00_autofirmwareupdate.yaml +++ b/Home_Assistant/hasp-examples/plate01/hasp_plate01_00_autofirmwareupdate.yaml @@ -15,4 +15,4 @@ automation: - service: mqtt.publish data_template: topic: 'hasp/plate01/command/espupdate' - payload: '' + payload: '' \ No newline at end of file diff --git a/Home_Assistant/hasp-examples/plate01/hasp_plate01_00_backlightbysun.yaml b/Home_Assistant/hasp-examples/plate01/hasp_plate01_00_backlightbysun.yaml index 56214ca..d385bf7 100644 --- a/Home_Assistant/hasp-examples/plate01/hasp_plate01_00_backlightbysun.yaml +++ b/Home_Assistant/hasp-examples/plate01/hasp_plate01_00_backlightbysun.yaml @@ -8,7 +8,7 @@ automation: trigger: - platform: time_pattern # Matches every minute - seconds: 00 + seconds: 0 condition: - condition: template value_template: '{{ states.sun.sun.attributes.elevation <= 10 }}' diff --git a/Home_Assistant/hasppackages.tar.gz b/Home_Assistant/hasppackages.tar.gz index b3c0ba2..7b94de7 100644 Binary files a/Home_Assistant/hasppackages.tar.gz and b/Home_Assistant/hasppackages.tar.gz differ diff --git a/Home_Assistant/migrate-hasp-107.sh b/Home_Assistant/migrate-hasp-107.sh new file mode 100644 index 0000000..a3124da --- /dev/null +++ b/Home_Assistant/migrate-hasp-107.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +############################################################################### +# migrate-hasp-107.sh - Modify an existing Home Assistant configuration +# with HASP deployed to accomodate breaking changes in v107 +############################################################################### + +# Confirm that we're working in the .homeassistant folder by checking for configuration.yaml +if [ ! -f configuration.yaml ] +then + echo "WARNING: 'configuration.yaml' not found in current directory." + echo "Searching for Home Assistant 'configuration.yaml'..." + configfile=$(find / -name configuration.yaml 2>/dev/null) + count=$(echo "$configfile" | wc -l) + if [ $count == 1 ] + then + configdir=$(dirname "${configfile}") + cd $configdir + echo "INFO: configuration.yaml found under: $configdir" + else + echo "ERROR: Failed to locate the active 'configuration.yaml'" + echo " Please run this script from the homeassistant" + echo " configuration folder for your environment." + exit 1 + fi +fi + +# If the user has already deployed HASP devices... +if [ -d packages ] +then + # Search through existing packages to see if we have any "view:" statements to remove as they have been deprecated + find packages -name "hasp_*.yaml" -exec sed -i '/[[:blank:]]view\:/d' {} + +fi \ No newline at end of file diff --git a/Home_Assistant/packages/hasp_demo.yaml b/Home_Assistant/packages/hasp_demo.yaml index f38ffe4..c6c0522 100644 --- a/Home_Assistant/packages/hasp_demo.yaml +++ b/Home_Assistant/packages/hasp_demo.yaml @@ -3,7 +3,9 @@ # these and/or replace with your own devices weather: - - platform: met + - platform: nws + api_key: haspuser@haswitchplate.com + name: nws alarm_control_panel: - platform: manual diff --git a/Home_Assistant/packages/hasp_plate01_lovelace.txt b/Home_Assistant/packages/hasp_plate01_lovelace.txt new file mode 100644 index 0000000..2329b2b --- /dev/null +++ b/Home_Assistant/packages/hasp_plate01_lovelace.txt @@ -0,0 +1,31 @@ + - path: plate01 + title: plate01 + badges: + - entity: binary_sensor.plate01_connected + - entity: sensor.plate01_status + cards: + - type: entities + title: plate01 Page Selection + entities: + - input_number.hasp_plate01_activepage + - input_number.hasp_plate01_pagebutton1page + - input_text.hasp_plate01_pagebutton1label + - input_number.hasp_plate01_pagebutton2page + - input_text.hasp_plate01_pagebutton2label + - input_number.hasp_plate01_pagebutton3page + - input_text.hasp_plate01_pagebutton3label + - type: entities + title: plate01 Colors + entities: + - input_number.hasp_plate01_selectedforegroundcolor + - input_number.hasp_plate01_selectedbackgroundcolor + - input_number.hasp_plate01_unselectedforegroundcolor + - input_number.hasp_plate01_unselectedbackgroundcolor + - type: entities + title: plate01 automations + entities: + - automation.hasp_plate01_00_firsttimesetup + - type: entities + title: Light + entities: + - light.plate01_backlight \ No newline at end of file diff --git a/Home_Assistant/packages/plate01/hasp_plate01_00_components.yaml b/Home_Assistant/packages/plate01/hasp_plate01_00_components.yaml index c79b6f2..6e22142 100755 --- a/Home_Assistant/packages/plate01/hasp_plate01_00_components.yaml +++ b/Home_Assistant/packages/plate01/hasp_plate01_00_components.yaml @@ -67,52 +67,52 @@ input_text: input_number: hasp_plate01_pagebutton1page: name: plate01 Page 1 Page - icon: mdi:format-list-numbered + icon: mdi:numeric min: 0 max: 9 step: 1 hasp_plate01_pagebutton2page: name: plate01 Page 2 Page - icon: mdi:format-list-numbered + icon: mdi:numeric min: 0 max: 9 step: 1 hasp_plate01_pagebutton3page: name: plate01 Page 3 Page - icon: mdi:format-list-numbered + icon: mdi:numeric min: 0 max: 9 step: 1 hasp_plate01_activepage: name: plate01 Active Page - icon: mdi:format-list-numbered + icon: mdi:numeric min: 0 max: 9 step: 1 hasp_plate01_alarmcode1: name: plate01 AlarmCode1 - icon: mdi:format-list-numbered + icon: mdi:numeric min: -1 max: 9 step: 1 initial: -1 hasp_plate01_alarmcode2: name: plate01 AlarmCode2 - icon: mdi:format-list-numbered + icon: mdi:numeric min: -1 max: 9 step: 1 initial: -1 hasp_plate01_alarmcode3: name: plate01 AlarmCode3 - icon: mdi:format-list-numbered + icon: mdi:numeric min: -1 max: 9 step: 1 initial: -1 hasp_plate01_alarmcode4: name: plate01 AlarmCode4 - icon: mdi:format-list-numbered + icon: mdi:numeric min: -1 max: 9 step: 1 diff --git a/Home_Assistant/packages/plate01/hasp_plate01_p2_clock.yaml b/Home_Assistant/packages/plate01/hasp_plate01_p2_clock.yaml index 39bb7a9..04c2694 100755 --- a/Home_Assistant/packages/plate01/hasp_plate01_p2_clock.yaml +++ b/Home_Assistant/packages/plate01/hasp_plate01_p2_clock.yaml @@ -33,7 +33,7 @@ automation: trigger: platform: time_pattern # Matches every minute - seconds: 00 + seconds: 0 condition: - condition: state entity_id: 'binary_sensor.plate01_connected' diff --git a/Home_Assistant/packages/plate01/hasp_plate01_p2_weather.yaml b/Home_Assistant/packages/plate01/hasp_plate01_p2_weather.yaml index b1ecb48..16410f0 100755 --- a/Home_Assistant/packages/plate01/hasp_plate01_p2_weather.yaml +++ b/Home_Assistant/packages/plate01/hasp_plate01_p2_weather.yaml @@ -6,7 +6,7 @@ automation: - alias: hasp_plate01_p2_Weather trigger: - platform: state - entity_id: weather.met_no + entity_id: weather.nws - platform: state entity_id: 'binary_sensor.plate01_connected' - platform: homeassistant @@ -23,12 +23,12 @@ automation: - service: mqtt.publish data: topic: 'hasp/plate01/command/p[2].b[6].txt' - payload_template: '"{{state_attr("weather.met_no","temperature")|int}}°F"' + payload_template: '"{{state_attr("weather.nws","temperature")|int}}°F"' - service: mqtt.publish data: topic: 'hasp/plate01/command/p[2].b[7].font' - 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 %}' + 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 %}' - service: mqtt.publish data: topic: 'hasp/plate01/command/p[2].b[7].txt' - payload_template: '"{{states.weather.met_no.state|wordwrap(20, wrapstring="\\r")|title}}"' \ No newline at end of file + payload_template: '"{{states.weather.nws.state|wordwrap(20, wrapstring="\\r")|title}}"' \ No newline at end of file