Seven Segments OCR
The seven_segments
image processing integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [Learn more] allows you to read physical seven segments displays through Home Assistant. ssocr
Notes for Home Assistant Core Installations
ssocr
needs to be available on your system. Check the installation instruction below:
sudo dnf -y install imlib2-devel # Fedora
sudo apt install libimlib2-dev # Ubuntu
brew install imlib2 # macOS
git clone https://github.com/auerswal/ssocr.git
cd ssocr
make
sudo make PREFIX=/usr install # On most systems
make deb # (Optional) This allows you to make a deb so that you apt is aware of ssocr
Configuration
To enable the OCR of a seven segment display in your installation, add the following to your configuration.yaml
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file.
在更改了configuration.yaml
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] 文件后,重启 Home Assistant 以应用更改。
# Example configuration.yaml entry
image_processing:
- platform: seven_segments
source:
- entity_id: camera.seven_segments
Configuration Variables
The command line tool ssocr
. Set it if you use a different name for the executable.
X coordinate of the upper left corner of the area to crop.
Y coordinate of the upper left corner of the area to crop.
Threshold for the difference between the digits and the background.
Other arguments to use. Like -D
, dilation
, erosion
, greyscale
, make_mono
, etc.
Setup process
It’s suggested that the first attempt to determine the needed parameters is using ssocr
directly. This may require a couple of iterations to get the result
ssocr -D erosion crop 390 250 490 280 -t 20 -d 4 seven-seg.png
This would lead to the following entry for the configuration.yaml
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file:
camera:
- platform: local_file
file_path: /home/homeassistant/.homeassistant/seven-seg.png
name: seven_segments
image_processing:
- platform: seven_segments
x_position: 390
y_position: 250
height: 280
width: 490
threshold: 20
digits: 4
source:
- entity_id: camera.seven_segments
With the help of a template sensor, the value can be shown as badge.
sensor:
- platform: template
sensors:
power_meter:
value_template: "{{ states('image_processing.sevensegment_ocr_seven_segments') }}"
friendly_name: "Ampere"
unit_of_measurement: "A"