therealwaldo / thermal Goto Github PK
View Code? Open in Web Editor NEWThermal Vision Sensor and Camera for Home Assistant
License: Apache License 2.0
Thermal Vision Sensor and Camera for Home Assistant
License: Apache License 2.0
As the title says
The domain in use, thermal
, conflicts with the original project forcing people who have the old one installed to remove it. Renaming the domain will avoid this situation.
GitHub config currently does not include labels. It would be nice to have that part automated.
Firstly, thank you so much for making this. It’s awesome, and I’m currently running it. I want to make more of these, but I want to do it on an ESP32 so that I can connect them via ethernet. I’m new to esphome and coding - can I just use the same code with and ESP32?
Thanks again for making this. I hope it becomes an official integration. It’s really great, and I think it’s a way cooler and better solution to motion sensing compared to mmWave. I want to make one of these for every room in the house, but want to learn more before diving too deeply into it.
I used integration with ESPhome
I'm testing the component and everything is working fine so far.
After restarting HA, I have a warning in the log. Is it possible to remove it somehow?
Homeassistant core-2021.12.5
Logger: homeassistant.helpers.entity
Source: helpers/entity.py:549
First occurred: 17:17:06 (1 occurrences)
Last logged: 17:17:06
Entity camera.prototype_thermal_camera (<class 'custom_components.thermal_vision.camera.ThermalVisionCamera'>) implements device_state_attributes. Please report it to the custom component author.
Include as a default repository in HACS so that it is easier to install.
Is your feature request related to a problem? Please describe.
Currently only returns metric units.
Describe the solution you'd like
Ideally, we would determine units from the HA installation, and return them appropriately.
Currently does not have a unique ID so cannot customize entities via. the UI.
Allow configuration with bulk syntax to allow for unique IDs to be set easier.
i'm having a issue when i try to add the camera, in home assistant log it shows this error:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 88, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/camera/init.py", line 823, in get
return await self.handle(request, camera)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/camera/init.py", line 841, in handle
image = await _async_get_image(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/camera/init.py", line 192, in _async_get_image
else await camera.async_camera_image(width=width, height=height)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/thermal_vision/camera.py", line 264, in async_camera_image
self._update_pixel_sensor()
File "/config/custom_components/thermal_vision/camera.py", line 293, in _update_pixel_sensor
encoded_pixels = self.hass.states.get(self._pixel_sensor).state
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
At some point in the not too distant parts (2022.10 or 2022.9) after a HA update my camera entities became no longer available. Unfortunately I don't have much to go on in order to try and debug this problem myself.
In logs, I'm seeing some errors related to camera.py, 'extra_state_attributes':
2022-10-13 17:07:08.372 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration thermal_vision which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2022-10-13 17:07:21.531 ERROR (MainThread) [homeassistant.components.camera] Error adding entities for domain camera with platform thermal_vision
File "/config/custom_components/thermal_vision/camera.py", line 212, in extra_state_attributes
2022-10-13 17:07:21.582 ERROR (MainThread) [homeassistant.components.camera] Error while setting up thermal_vision platform for camera
File "/config/custom_components/thermal_vision/camera.py", line 212, in extra_state_attributes
2022-10-13 17:07:31.279 ERROR (MainThread) [homeassistant.components.homekit] HomeKit M4 Thermal Camera cannot startup: entity not available: {'include_domains': [], 'exclude_domains': [], 'include_entities': ['camera.m4_thermal_camera'], 'exclude_entities': [], 'include_entity_globs': [], 'exclude_entity_globs': []}
2022-10-13 17:07:31.408 ERROR (MainThread) [homeassistant.components.homekit] HomeKit Mini Cooper Thermal Camera cannot startup: entity not available: {'include_domains': [], 'exclude_domains': [], 'include_entities': ['camera.mini_cooper_thermal_camera'], 'exclude_entities': [], 'include_entity_globs': [], 'exclude_entity_globs': []}
File "/config/custom_components/thermal_vision/camera.py", line 212, in extra_state_attributes
File "/config/custom_components/thermal_vision/camera.py", line 212, in extra_state_attributes
File "/config/custom_components/thermal_vision/camera.py", line 212, in extra_state_attributes
File "/config/custom_components/thermal_vision/camera.py", line 212, in extra_state_attributes
File "/config/custom_components/thermal_vision/camera.py", line 212, in extra_state_attributes
configuration:
- platform: thermal_vision
name: Mini Cooper Thermal Camera
#overlay: true
pixel_sensor: sensor.mini_cooper_car_sensor_pixels
# # rotate: 180
#auto_range: true
interpolate:
method: disabled
I'm using ESPHome custom devices (ultrasonic/temp sensors in addition to the AMG8833 sensor) so I can't debug that ESPHome isn't the culprit using the ESP-only firmware, but all the sensor values/etc in HA seem to be working fine, so I doubt it's ESPHome's fault. If ESPHome is to blame the only thing I can think is that there is some change to the text-sensor sensor value that the thermal-vision parser isn't interpreting correctly.
esphome, FYi this is a packaged config, since I have multiple of these sensors:
esphome:
name: $devicename
platform: ESP32
board: tinypico
includes:
- custom/amg8833.h
- custom/amg8833_camera.h
libraries:
- "Wire"
- "SparkFun GridEYE AMG88 Library"
on_boot:
then:
- output.turn_on: gpio_led
- light.control:
id: ledneo
brightness: 0.25
state: on
green: 1
red: 0.5
packages:
base: !include base.yaml
i2c:
sda: 21
scl: 22
scan: true
frequency: 400kHz
bme680_bsec:
address: 0x77
output:
- platform: gpio
pin: 13
inverted: true
id: gpio_led
light:
- platform: fastled_spi
chipset: APA102
data_pin: 2
clock_pin: 12
num_leds: 1
rgb_order: BGR
id: ledneo
interval:
- interval: 2s
then:
if:
condition:
wifi.connected:
then:
- light.control:
id: ledneo
blue: 1
green: 0
else:
- light.control:
id: ledneo
blue: 0
green: 1
text_sensor:
- platform: bme680_bsec
iaq_accuracy:
name: "${friendly_name} BME680 IAQ Accuracy"
- platform: custom
lambda: |-
auto amg8833 = new AMG8833CameraComponent();
App.register_component(amg8833);
return {amg8833};
text_sensors:
- name: "${friendly_name} Pixels"
binary_sensor:
- platform: template
name: "${friendly_name} Present"
lambda: |-
if (id(ultradistance).state < ${vehicle_height}) {
//if sensor less than trigger height, car is present
return true;
} else {
//car is not present
return false;
}
sensor:
- platform: bme680_bsec
temperature:
name: "${friendly_name} BME680 Temperature"
id: bme680temperature
pressure:
name: "${friendly_name} BME680 Pressure"
humidity:
name: "${friendly_name} BME680 Humidity"
id: bme680humidity
iaq:
name: "${friendly_name} BME680 IAQ"
co2_equivalent:
name: "${friendly_name} BME680 eCO2"
breath_voc_equivalent:
name: "${friendly_name} BME680 Breath eVOC"
- platform: ultrasonic
trigger_pin: 33
echo_pin: 32
name: "${friendly_name} Ultrasonic Sensor"
id: ultradistance
update_interval: 5s
timeout: 3m
filters:
- median:
window_size: 11
send_every: 6
send_first_at: 5
- platform: custom
lambda: |-
auto amg8833 = new AMG8833Component();
App.register_component(amg8833);
return {amg8833->sensor_temperature, amg8833->max_temperature, amg8833->min_temperature, amg8833->avg_temperature, amg8833->min_index, amg8833->max_index};
sensors:
- name: "${friendly_name} Thermal Sensor Temperature"
unit_of_measurement: °C
device_class: temperature
accuracy_decimals: 2
- name: "${friendly_name} Thermal Sensor Max"
id: tmax
unit_of_measurement: °C
device_class: temperature
accuracy_decimals: 2
- name: "${friendly_name} Thermal Sensor Min"
id: tmin
unit_of_measurement: °C
device_class: temperature
accuracy_decimals: 2
- name: "${friendly_name} Thermal Sensor Avg"
id: tavg
unit_of_measurement: °C
device_class: temperature
accuracy_decimals: 2
- name: "${friendly_name} Thermal Sensor Min Index"
accuracy_decimals: 0
- name: "${friendly_name} Thermal Sensor Max Index"
accuracy_decimals: 0
v3.0.0
logger:
default: warn
logs:
custom_components.thermal_vision: debug
camera:
- platform: thermal_vision
name: "Joshua's Room Thermal Camera"
host: http://192.168.2.228
min_temp: 20
max_temp: 40
auto_range: false
preserve_aspect_ratio: false
overlay: false
sensor:
rows: 24
cols: 32
interpolate:
method: linear
rows: 48
cols: 64
I am trying to get the MLX90640 sensor to work with this project.
I have made a custom PlatformIO project to interface with the camera and return similar data to the AMG8833 one.
All I am getting is a purple image.
I am not 100% sure if I am doing something wrong or it is an issue with the project.
Any help would be appreciated.
the result of "http://192.168.2.228/raw"
raw.json.txt
The only logs I got were with Interpolation method set to bicubic otherwise I don't see any logs
2021-11-01 10:52:36 ERROR (MainThread) [homeassistant.components.camera] Error while setting up thermal_vision platform for camera
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/thermal_vision/camera.py", line 131, in async_setup_platform
async_add_entities([ThermalVisionCamera(config, hass)])
File "/config/custom_components/thermal_vision/camera.py", line 193, in __init__
self._setup_default_image()
File "/config/custom_components/thermal_vision/camera.py", line 320, in _setup_default_image
self._default_image = self._camera_image(
File "/config/custom_components/thermal_vision/camera.py", line 351, in _camera_image
interpolation = interpolate(xi, yi, pixels, xo, yo, self._method)
File "/config/custom_components/thermal_vision/interpolate.py", line 140, in interpolate
return bicubic(xi, yi, values, xo, yo)
File "/config/custom_components/thermal_vision/interpolate.py", line 46, in bicubic
f30 = values[i + 2, j - 1] # row3 col0 >> x0,y3
IndexError: index 24 is out of bounds for axis 0 with size 24
Latest version installed using HACS
camera:
sensor:
I do not get any state attributes out of the sensor entity since the home assistant 2022.4 update.
Do I have any config error which was somehow accepted earlier, or is the integration and the latest OS version not working together any more?
The camera just works fine.
Thanks in advance!
Latest version installed using HACS
camera:
- platform: thermal_vision
name: Thermal Kabinet Camera
host: http://10.0.107.25
sensor:
rows: 24
cols: 32
interpolate:
method: disabled
sensor:
- platform: thermal_vision
name: Thermal Kabinet Sensor
host: http://10.0.107.25
sensor:
rows: 24
cols: 32
binary_sensor:
- platform: thermal_vision
name: Thermal Kabinet Occupancy
host: http://10.0.107.25
A clear and concise description of what the bug is.
I am trying to implement this inside the HA. Using the Pimoroni MLX90640 and ESP32 and this project:
https://github.com/pixelsquared/thermal_vision-ESP32-MLX90640
Camera is working. But with very low fps. By my guess with only 1fps. It is also rotate by 90 degrees.
Binary sensor is most of the time true. Even if I leave the room. Also the sensor values newer changes. I tried to set scan_interval to 5 seconds but again I do not get any values only, the first one on HA start.
How to debug this? My goal is to have reliable room presence detection.
Thank you.
I'm interested in using the MLX90640 for occupancy detection but I'm looking for some recommendations for mounting it on a ceiling in a way that allows it to be adjusted to point in the desired direction and maintains a reasonably discrete, non-ugly appearance.
I am using the latest version compiled with Arduino IDE (PIO Home gives me compatibility problems with 64 bit libraries), with the latest version of the component for Home Assistant and also the latest version of Home Assistant.
I'm able to get the camera image and the presence occupancy, but not the temperature.
This is my components status:
GitHub TheRealWaldo/thermal 072bb1f on 27 Aug 2021
Thermal Vision 3.1.2
Home Assistant 2022.10.5
Supervisor 2022.10.0
Operating System 9.3
This is my config on HA:
- platform: thermal_vision
unique_id: thermal_vision_camera
host: http://192.168.4.81
auto_range: yes
min_diff: 8
rotate: 180
width: 320
height: 320
mirror: true
overlay: true
- platform: thermal_vision
unique_id: thermal_vision_binary_sensor
host: http://192.168.4.81
- platform: thermal_vision
unique_id: thermal_vision_sensor
host: http://192.168.4.81
All
n/a
This custom integration uses deprecated DEVICE_CLASS_*
constants in its codebase.
The DEVICE_CLASS_*
constants have been deprecated and replaced in Home Assistant Core 2021.12 (over a year ago). I would highly suggest updating/migrating this integration to the new enums.
For example, for the device classes supported by the sensor
platform, there is now a SensorDeviceClass
enum. So if a sensor previously used the DEVICE_CLASS_ENERGY
constant, it should now use SensorDeviceClass.ENERGY
. Other platforms (like binary_sensor
, and number
) provide similar enumerations for their supported device classes.
The migration thus only consists of replacing constants with an enumeration member and is, therefore, very low impact and should be fairly straightforward.
If I can help resolve any questions regarding this change or migration, feel free to ask or respond to this issue. I'm happy to help!
Kindest regards,
../Frenck
n/a
It would be helpful to identify visually which pixels are max and/or min spots.
Both updating the sensor to record 2d co-ordinates and drawing an optional 'target' on the max/min locations.
With auto_range
it can be hard to imagine what the difference between pixels actually is. Something like a distance indicator superimposed over the image might suffice.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.