hi, I can’t seem to find a simple answer to this.
I have an existing table in a secondary database in MariaDB, that I would like to insert sensor data into on a 5 minutely basis.
I have searched and found appdaemon, nodered, or command line solutions. They seem like an outdated way to achieve this.
I feel like I should be able to insert the data directly via a script or restful command or SQL integration even directly via the recorder. I can’t find an example of that being done however.
Is there a mysql insert documented somewhere for HA?
Also can you reset a restful command from yaml configuration reloading?
It is core-mariadb install and not_homeassistant_database. port is 3306
If someone could point me to an example that would be great!
The url’s ive tried are the same as what would similar as from the recorder
mysql://user:password@SERVER_IP:{tried with and without port here}/DB_NAME?charset=utf8mb4
Logger: homeassistant.components.rest_command
Source: components/rest_command/__init__.py:148
Integration: RESTful Command (documentation, issues)
First occurred: 14:21:16 (1 occurrences)
Last logged: 14:21:16
Client error mysql://user:passwd@core-mariadb:3306/DB_name?charset=utf8mb4
Source: components/rest_command/__init__.py:121
Integration: Automation (documentation, issues)
First occurred: 14:07:12 (2 occurrences)
Last logged: 14:07:12
insert sbfspot: Error executing script. Unexpected error for call_service at pos 1:
While executing automation automation.insert_sbfspot
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 367, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 570, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1636, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1673, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/components/rest_command/__init__.py", line 121, in async_service_handler
async with getattr(websession, method)(
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 1138, in __aenter__
self._resp = await self._coro
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 535, in _request
conn = await self._connector.connect(
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 542, in connect
proto = await self._create_connection(req, traces, timeout)
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 907, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1146, in _create_direct_connection
assert port is not None
AssertionError
I have also tried the insert link from the tables page in myPHPadmin, which gives the 401 Unauthorised below
rest_command:
powerpal_insert_sbfspot:
url: 'http://url_sanitised/index.php?route=/table/change&db=DB_name&table=Consumption'
headers:
accept: "application/json, text/html"
method: post
payload: "{{now() | as_timestamp | int }},{{states('sensor.power_total_consumption')| float * 1000 }},{{states('sensor.power_live_consumption')| float * 1000 }},"
Logger: homeassistant.components.rest_command
Source: components/rest_command/__init__.py:137
Integration: RESTful Command (documentation, issues)
First occurred: 13:50:00 (1 occurrences)
Last logged: 13:50:00
Error. Url: http://url_sanitised/index.php?route=/table/change&db=DB_name&table=Consumption. Status code 401. Payload: b'1648608600,4870547.0,0.0,'