Invalid Service Data, required key not provided (from action trigger in Python)

I’m getting the following error when trying to send a notification to my LG WebOS TV. It basically takes an image from my IP Camera, uses the free Sighthound API to get the make model and colour of the car, and then sends it through PushBullet, but I also wanted to add it to my LG TV through a notification.

From searching this looks like a formatting error but I can’t figure out why for the life of me.

INFO:homeassistant.components.http:Serving /api/services/notify/livingroom_tv to 192.168.1.48 (auth: True)
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: domain=notify, service=livingroom_tv, service_data=data=message=There is a black Honda Accord in your driveway., data=icon=E:\BlueIris\sighthound\driveway2.jpg, service_call_id=110457552-15>
ERROR:homeassistant.core:Invalid service data for notify.livingroom_tv: required key not provided @ data[‘message’]. Got None

Here is the portion from my python script:

url = "http://192.168.1.48:8123/api/services/notify/livingroom_tv"
payload = json.dumps({
 "data": {
  "message":"There is a {} {} {} in your driveway.".format(color, make, model),
  "data": {
   "icon":"E:\BlueIris\sighthound\driveway2.jpg"
  }}})
headers = {
  "content-type": "application/json",
  "x-ha-access": "*****"
  }

and from my config.yaml

notify:
 platform: webostv
 host: 192.168.1.64
 name: livingroom_tv

I think you need to remove the outermost “data”. I.e.,

payload = json.dumps({
 "message":"There is a {} {} {} in your driveway.".format(color, make, model),
 "data": {
  "icon":"E:\BlueIris\sighthound\driveway2.jpg"
  }})
1 Like