This commit is contained in:
joBr99
2022-03-11 18:55:05 +01:00
3 changed files with 60 additions and 12 deletions

View File

@@ -13,7 +13,7 @@ NsPanel Lovelace UI is a Firmware for the nextion screen inside of NSPanel in th
- Detail Pages for Lights (Brightness and Temperature of the Light) and for Covers (Position)
- Thermostat Page
- Media Player Card
- Screensaver Page with Time and Date
- Screensaver Page with Time, Date and Weather Information
It works with [Tasmota](https://tasmota.github.io/docs/) and MQTT.
To control the panel and update it with content from HomeAssistant there is an [AppDaemon](https://github.com/AppDaemon/appdaemon) App.
@@ -53,7 +53,7 @@ For more detailed Instructions see the following Sections:
- [Configuration](#configuration)
- [Configuring the MQTT integration in AppDaemon](#configuring-the-mqtt-integration-in-appdaemon)
- [Configure your NSPanel in AppDaemon](#configure-your-nspanel-in-appdaemon)
- [FAQ](#faq---frequently-asked-questions)
## How It Works
@@ -142,7 +142,7 @@ This section describes how to free your nspanel from stock firmware and get it r
### Flash Tasmota to your NSPanel
You need to connect to your nspanel via serial and flash the `tasmota32-nspanel.bin` to your NSPanel.
You need to connect to your nspanel via serial and flash the [tasmota32-nspanel.bin](https://github.com/tasmota/install/raw/main/firmware/unofficial/tasmota32-nspanel.bin) to your NSPanel.
Make sure to come back to this guide, before uploading the nspanel.be/autoexec.be files.
For more deatils see the [NSPanel Page of the Tasmota Template Repository](https://templates.blakadder.com/sonoff_NSPanel.html).
@@ -163,6 +163,8 @@ After a reboot of tasmota your screen will light up with the stock display firmw
Configure your MQTT Server in Tasmota.
See Tasmota [MQTT Documentation](https://tasmota.github.io/docs/MQTT/) for more details.
![tasmota-mqtt-config](doc-pics/tasmota-mqtt-config.png)
### Upload Berry Driver to Tasmota
1. Download the [Berry Driver from this Repository](tasmota/autoexec.be).
@@ -176,20 +178,27 @@ See Tasmota [MQTT Documentation](https://tasmota.github.io/docs/MQTT/) for more
#### Use your own Webserver
Upload the [tft file from HMI folder](HMI/nspanel.tft) to a Webserver (for example www folder of Home Assistant) and execute the following command in Tasmota Console.
**Webserver needs to support HTTP Range Header Requests, python2/3 http server doesn't work**
**Webserver must be HTTP, HTTPS is not supported, due to limitations of berry lang on tasmota**
`FlashNextion http://ip-address-of-your-homeassistant:8123/local/nspanel.tft`
## Configuration
### Configuring the MQTT integration in AppDaemon
For the app to work you need a working MQTT Configuration in AppDaemon. Please configure mqtt server, user and password in `appdaemon.yaml`
For the app to work you need a working MQTT Configuration in AppDaemon. Please add the configuration of your mqtt server, user and password to your existing `appdaemon.yaml`
```yaml
.
.
.
---
secrets: /config/secrets.yaml
appdaemon:
latitude: 52.0
longitude: 4.0
elevation: 2
time_zone: Europe/Berlin
plugins:
HASS:
type: hass
@@ -202,10 +211,13 @@ For the app to work you need a working MQTT Configuration in AppDaemon. Please c
client_user: "mqttuser"
client_password: "mqttpassword"
client_topics: NONE
.
.
.
http:
url: http://127.0.0.1:5050
admin:
api:
hadashboard:
```
Please see [appdaemon.yaml](appdaemon/appdaemon.yaml) as an exmaple.
### Configure your NSPanel in AppDaemon
@@ -265,3 +277,26 @@ key | optional | type | default | description
`module` | False | string | | The module name of the app.
`class` | False | string | | The name of the Class.
`config` | False | complex | | Config/Mapping between Homeassistant and your NsPanel
## FAQ - Frequently Asked Questions
### Flashing of the Display Firmware with FlashNextion doesn't work
1. Make sure to use the [tasmota32-nspanel.bin](https://github.com/tasmota/install/raw/main/firmware/unofficial/tasmota32-nspanel.bin) Tasmota build.
2. Make sure to use an WebServer which supports http range requests like HomeAssistant, apache2 or nginx for exmaple.
3. Make sure to use HTTP and **not HTTPS**
### My flashing doesn't start at all
Try to send the FlashNextion command a second time.
### My flashing got interrupted and the loading bar does not longer change.
Reboot Tasmota and try to flash it a second time.
### Waiting for content - This is taking longer than usual on the screen
Please check your MQTT Topics in your apps.yaml and your mqtt configuration on tasmota.

View File

@@ -23,6 +23,10 @@ class NsPanelLovelanceUI:
self.mqtt.mqtt_subscribe(topic=self.config["panelRecvTopic"])
self.mqtt.listen_event(self.handle_mqtt_incoming_message, "MQTT_MESSAGE", topic=self.config["panelRecvTopic"], namespace='mqtt')
# send panel back to startup page on restart of this script
self.send_mqtt_msg("pageType,pageStartup")
# Setup time callback
time = datetime.time(0, 0, 0)
self.api.run_minutely(self.update_time, time)
@@ -48,7 +52,7 @@ class NsPanelLovelanceUI:
if self.api.parse_time(timeset["time"]) > self.api.get_now().time() and not found_current_dim_value:
# first time after current time, set dim value
self.current_screensaver_brightness = sorted_timesets[index-1]["value"]
self.api.log("Setting dim value to %s", sorted_timesets[index-1], level="DEBUG")
self.api.log("Setting dim value to %s", sorted_timesets[index-1]) #level="DEBUG"
found_current_dim_value = True
# send screensaver brightness in case config has changed
self.update_screensaver_brightness(kwargs={"value": self.current_screensaver_brightness})
@@ -272,7 +276,6 @@ class NsPanelLovelanceUI:
self.api.log("Found configured item in Home Assistant %s", item, level="DEBUG")
else:
self.api.error("The following item does not exist in Home Assistant, configuration error: %s", item)
raise Exception('Entity not found')
def register_callbacks(self):
items = []
@@ -283,6 +286,8 @@ class NsPanelLovelanceUI:
items.extend(page["items"])
for item in items:
if not self.api.entity_exists(item):
continue
self.api.log("Enable state callback for %s", item, level="DEBUG")
self.api.handle = self.api.listen_state(self.state_change_callback, entity_id=item, attribute="all")
@@ -370,6 +375,10 @@ class NsPanelLovelanceUI:
return "entityUpd,{0},{1},{2},{3},{4},{5}".format(item_nr, "button", item, 10, name, "ACTIVATE")
def generate_thermo_page(self, item):
if not self.api.entity_exists(item):
return
entity = self.api.get_entity(item)
heading = entity.attributes.friendly_name
current_temp = int(entity.attributes.current_temperature*10)
@@ -382,6 +391,10 @@ class NsPanelLovelanceUI:
return "entityUpd,{0},{1},{2},{3},{4},{5},{6},{7}".format(item, heading, current_temp, dest_temp, status, min_temp, max_temp, step_temp)
def generate_media_page(self, item):
if not self.api.entity_exists(item):
return
entity = self.api.get_entity(item)
heading = entity.attributes.friendly_name
icon = 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB