hi, ok i mod as you told me i hope i did right
import sqlite3
import requests
from homeassistant.const import EVENT_CALL_SERVICE
@service(supports_response="only")
def get_sensor_web(search_term, return_response=True):
taxiamigo_db_path = '/config/testwebdb.db' # Replace with the actual path
connection = sqlite3.connect(taxiamigo_db_path)
cursor = connection.cursor()
cursor.execute("SELECT (location || ' y ' || sensor_value ) as searchTerm FROM websensor WHERE location LIKE ? LIMIT 1", ('%' + search_term + '%',))
results = cursor.fetchall()
cursor.close()
connection.close()
hass.bus.fire("get_sensor_web_event", {"wow": results})
response = requests.post(url, headers=headers, json=data)
return { "get_sensor_web": get_data_address}
this is what i receive in my event listener
event_type: get_sensor_web_event
data:
wow:
- - VIA A VALENCIA Y FUNCIONA
origin: LOCAL
time_fired: "2024-05-25T23:43:12.833534+00:00"
context:
id: 01HYS263E1A86E1KATJVJ8XPPF
parent_id: null
user_id: null
and this is what it showme in the chrome console
index.html:34 The response is: Response {type: 'basic', url: 'https://xxxxxxxxxxxxxxxxxxxx/api/services/pyscript/get_sensor_web', redirected: false, status: 200, ok: true, …}
body: (…)
bodyUsed: true
headers: Headers
[[Prototype]]: Headersappend: ƒ append()delete: ƒ delete()entries: ƒ entries()forEach: ƒ forEach()get: ƒ ()getSetCookie: ƒ getSetCookie()has: ƒ has()keys: ƒ keys()set: ƒ ()values: ƒ values()constructor: ƒ Headers()Symbol(Symbol.iterator): ƒ entries()Symbol(Symbol.toStringTag): "Headers"
[[Prototype]]: Object
ok: true
redirected: false
status: 200
statusText: "OK"
type: "basic"url: "https://xxxxxxxxxxxxxxxxxxx/api/services/pyscript/get_sensor_web"[[Prototype]]: Response
index.html:47 []length: 0[[Prototype]]: Array(0)at: ƒ at()concat: ƒ concat()constructor: ƒ Array()copyWithin: ƒ copyWithin()entries: ƒ entries()every: ƒ every()fill: ƒ fill()filter: ƒ filter()find: ƒ find()findIndex: ƒ findIndex()findLast: ƒ findLast()findLastIndex: ƒ findLastIndex()flat: ƒ flat()flatMap: ƒ flatMap()forEach: ƒ forEach()includes: ƒ includes()indexOf: ƒ indexOf()join: ƒ join()keys: ƒ keys()lastIndexOf: ƒ lastIndexOf()length: 0map: ƒ map()pop: ƒ pop()push: ƒ push()reduce: ƒ reduce()reduceRight: ƒ reduceRight()reverse: ƒ reverse()shift: ƒ shift()slice: ƒ slice()some: ƒ some()sort: ƒ sort()splice: ƒ splice()toLocaleString: ƒ toLocaleString()toReversed: ƒ toReversed()toSorted: ƒ toSorted()toSpliced: ƒ toSpliced()toString: ƒ toString()unshift: ƒ unshift()values: ƒ values()with: ƒ with()Symbol(Symbol.iterator): ƒ values()Symbol(Symbol.unscopables): {at: true, copyWithin: true, entries: true, fill: true, find: true, …}
[[Prototype]]: Object