Allow setting of binary_sensor's STATE via API without destroying attributes

Not sure I understand. Is this a LUA issue, or do you just not know how to format JSON for service calls? Use the service dev tool to test service data. It’ll be something like:

ha_api("services/input_select/select_option", '{"entity_id":"input_select.testvera","option":"Text of option to select"}')

Sorry, was not clear; How would I use below Vera Variable value to be formatted in the LUA to be parsed to HASS

So the Vera variable value I want passed to the input select is “sl_UserCode” from device 409 (see below).

I’m assuming below is not correct;
ha_api("services/input_select/select_option", '{"entity_id":"input_select.testvera","option":sl_Usercode}')

p.s. Current restful sensor:
http://192.168.1.5:3480/data_request?id=variableget&DeviceNum=409&serviceId=urn:micasaverde-com:serviceId:DoorLock1&Variable=sl_UserCode

Yeah - been too long since I’ve used LUA. Don’t know. LUA’s concatenator is ..

So something like
ha_api(“services/input_select/select_option”, ‘{“entity_id”:“input_select.testvera”,“option”:"’ … sl_Usercode … ‘"}’)

You’ll need to figure out where to execute it and where you have access to that variable.

I’m coming to the party 5 years late. I too would like to be able to optionally merge attributes in the API call to set state. At the moment I’m resending “friendly_name” every time so it doesn’t get lost. I’m aware that I can use customize: in the config as an alternative, but that’s clunky compared to setting it via the UI.