Projet de remplacement du "RPiPasserelle" d'Otec.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lib.py 646B

12345678910111213141516171819202122232425262728
  1. def shift_response(d):
  2. def shift_dict(d_):
  3. d_k = list(map(int, d_.keys()))
  4. if not len(d_k):
  5. return d_
  6. d_k.sort()
  7. offset = d_k[0]-1
  8. d_res = {
  9. str(k - offset): d_[k]
  10. for k in d_k
  11. if (k in d_)
  12. }
  13. return d_res
  14. d_shifted = { 'macAddress': d['macAddress'] }
  15. if 'Analog' in d.keys():
  16. d_shifted['Analog'] = shift_dict(d['Analog'])
  17. if 'Integer' in d.keys():
  18. d_shifted['Integer'] = shift_dict(d['Integer'])
  19. if 'Digital' in d.keys():
  20. d_shifted['Digital'] = shift_dict(d['Digital'])
  21. return d_shifted