How to add coinmotion API to home assistant

Hi all,

I’m trying to get coinmotion to share my wallet ballance to home assistant via API integration, but due to my very limited knowledge on these things (trying to learn for the first time) I am strugling even though I’ve read instructions for rest api configuration (just too stupid to understand most likely).

  1. I’ve created API on coinmotion side, and trying to follow this guide over here:

I have started with something like this in configuration.yaml

 - platform: rest
    name: coinmotion
    method: POST
    payload: '{ "nonce" : "1463731543" : "eur_bal": "195.83000000" }'
        Content-Type: application/json
        X-COINMOTION-APIKEY: "my api key"
        X-COINMOTION-SIGNATURE: "my signature"

Would someone be able to guide me what exactly I should do for being able to view in home assistant the balance of my wallet?

Does your config load without errors?
If yes, go to Developer Tools -> States and search for sensor.coinmotion - you’ll see what’s available.
Then read some docs and try to figure out how to display it or ask here

Thanks, config loads without errors, but in states it gives error with authentication.

The part I am strugling now for hours is the below part. I know that the signature is to be created based of the two points mentioned below, but I am not able to understand how to set this up. I’ve tried to search the HA forums, and google but I do not find anything which would help me out.

  • X-COINMOTION-SIGNATURE - Request signature computed as detailed in the Authentication section


Authentication is done using an API key and a secret. All requests must be signed with a signature, which is computed as follows:

  • the payload is the nonce and the parameters object JSON encoded

payload = nonce, parameters object -> JSON encode

  • the signature is an HMAC-SHA512 hash of the payload and your API secret

signature = HMAC-SHA512 ($payload, $api_secret)

The signature is encoded as the HTTP header named X-COINMOTION-SIGNATURE .

So basically you’re asking for help in configuring that coin motion API?
Maybe it’s better to use their website/forum?
Where did you get all the info above from?

Yes, I’ve requested them to help as well but have not heard anything back…

Basically my issue is how to do the coding in home assistant:

  • I know that for signature they want a HMAC hash of combinated “nonce” value and parameters object.
  • Nonce I can get for example using " {{ utcnow().timestamp() }}".
  • parameters object I can figure out

But what I do not know is that how can define a payload as combination of two inputs:

  • payload = " {{ utcnow().timestamp() }}". + parameters object

And how I can define

  • X-COINMOTION-SIGNATURE = " payload + api_secret.

So I am lacking the understanding to define in configuration.yaml two attributes (payload and x-coinmotion signature) built from two different data inputs.

From what I can see you cannot use templates in headers so no go for
Don’t know what else you can try… maybe have another look at available integrations?

Yeah, I’m starting to think of actually moving my bitcoin wallet to one of the HA supported solutions, instead of trying to hit my head to the wall with this one. I’ve tried to search from the forums and from google other examples, even tried to reverse engineer the existing HA integrations, but still after multiple hours (days) of researching I am basically at the very start of setting this up.

And it does not help that the documentation by coinmotion is very poor (or at least hard for beginners to understand).

Thanks anyways for trying to help!

but why do you need home automation for checking your bitcoin wallet? is it the key factor when you choose? :wink:

I want to have an easy way to view my bitcoin wallet ballance in a dashboard which show other information relevant for me.

Plus I would be able to create notifications of when bitcoin rates are below or above specific tresholds.

Currently I have bitcoin integration added, which shows the current bitcoin rates, but I need to manually do the conversion to euros. One option could be also to create a script in HA, which does convert the rate to euros, and then uses the known amount of bitcoins I have, and this way knowing my wallet state in euros. Not optimal, but I guess it would work well enough.

Check out the BitFetch custom component. You should be able to use the BTCEUR pair for what you want to do. Reach out if you have any feedback or need any help!

Im also working with the api, did you ever get any answer from Coinmotion?

Not really directly answering the original question, but I Managed to get this working with bash. This is the way you need to create the signature with openssl. Just set APIKEY and APISECRET from coinmotion and you are good to go.
Works with bash (and Mac)

time=$(date +%s)
signature=$(echo -n $body | openssl dgst -sha512 -hmac $APISECRET)
curl -X POST -H "Content-Type: application/json" \
             -H "X-COINMOTION-APIKEY: $APIKEY" \
             -H "X-COINMOTION-SIGNATURE: $signature" \
       -d "$body" \