azogue / eventsensor

HomeAssistant custom sensor to track specific events
MIT License
89 stars 14 forks source link

Help for filter #70

Closed mircob85 closed 8 months ago

mircob85 commented 8 months ago

Hi, I need to create multiple sensors based to a specific text from event: sms.incoming_sms (4R-150 or 4R-160 or other name) Or filter by phone number, but the best choice for me is extract data from the "text".

This is the event:

event_type: sms.incoming_sms data: phone: "+39123456789" date: "2024-03-11 19:17:54" text: "4R-150:\r\nV 35\r\nIRRIGAZIONE\r\nrI 14'\r\nm 622\r\nh 18:43\r\nm/h ___\r\nS1 m 622, m/h 35\r\nPress:SI,\r\nGsm 18\r\nBatt 14V" origin: LOCAL time_fired: "2024-03-11T18:18:11.130286+00:00" context: id: 01HRQBS1ST28HTVR5ZA57MK47R parent_id: null user_id: null event

sensor

But I need to split, something like this: .... .split("\r\n")[1].split(" ")[1]

but only if the text contain "4R-150"

azogue commented 8 months ago

Hi @mircob85,

The kind of filtering you're looking for is not possible with this integration, sorry.

I suppose you could use another extra sensor (a 'template' sensor, for example), to try to extract the data you need from the event-sensor attributes. It's probably the best option to have the work done 👍